diff --git a/src/bun_core/string/mod.rs b/src/bun_core/string/mod.rs index a01cfced60ee..5a2a9cdcad1e 100644 --- a/src/bun_core/string/mod.rs +++ b/src/bun_core/string/mod.rs @@ -754,15 +754,6 @@ impl String { bytes.len() == lit.len() && strings::eql_comptime_ignore_len(bytes, lit) } - /// `bun.String.githubAction` — returns a `Display` - /// formatter that escapes the string for GitHub Actions annotation output - /// (`%0A` for newlines, ANSI stripped). Encoding-aware: materialises a - /// UTF-8 view inside `fmt` so 16-bit / WTF-backed strings are handled. - #[inline] - pub fn github_action(&self) -> StringGithubActionFormatter<'_> { - StringGithubActionFormatter { text: self } - } - /// `bun.String.hasPrefixComptime` — ASCII prefix check. Dispatches on /// encoding so only `prefix.len()` units are touched; never scans or /// transcodes `self`. @@ -1266,19 +1257,6 @@ impl core::fmt::Display for String { } } -/// `Display` adapter for [`String::github_action`]. Converts to UTF-8 on the -/// fly (handles 16-bit / WTF-backed strings) and delegates to -/// `crate::fmt::github_action_writer`. -pub struct StringGithubActionFormatter<'a> { - text: &'a String, -} -impl core::fmt::Display for StringGithubActionFormatter<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - let utf8 = self.text.to_utf8_without_ref(); - crate::fmt::github_action_writer(f, utf8.slice()) - } -} - /// `Display` adapter for [`ZigString::github_action`]. Converts to UTF-8 on /// the fly (handles 16-bit / latin-1 encodings) and delegates to /// `crate::fmt::github_action_writer`. diff --git a/src/jsc/Errorable.rs b/src/jsc/Errorable.rs index 79b125d65b85..4bedea4943bc 100644 --- a/src/jsc/Errorable.rs +++ b/src/jsc/Errorable.rs @@ -25,13 +25,6 @@ impl Errorable { } } - pub fn value(val: T) -> Self { - Self { - result: Result { value: val }, - success: true, - } - } - pub fn ok(val: T) -> Self { Self { result: Result { value: val }, diff --git a/src/jsc/JSUint8Array.rs b/src/jsc/JSUint8Array.rs index 90cd298ec4da..a2a87fba92bd 100644 --- a/src/jsc/JSUint8Array.rs +++ b/src/jsc/JSUint8Array.rs @@ -1,6 +1,5 @@ use core::ffi::c_void; -use crate::sizes; use crate::{JSGlobalObject, JSValue}; bun_opaque::opaque_ffi! { @@ -9,18 +8,6 @@ bun_opaque::opaque_ffi! { } impl JSUint8Array { - pub fn ptr(&self) -> *mut u8 { - // SAFETY: `self` points at a live JSUint8Array cell; the typed-array vector - // pointer lives at a fixed byte offset computed by the C++ codegen - // (`crate::sizes`). `byte_add` preserves pointer provenance. - unsafe { - std::ptr::from_ref::(self) - .byte_add(sizes::BUN_FFI_POINTER_OFFSET_TO_TYPED_ARRAY_VECTOR) - .cast::<*mut u8>() - .read() - } - } - /// `bytes` must come from `bun.default_allocator` (the global mimalloc allocator); /// ownership is transferred to the returned JS Uint8Array. // The global allocator IS mimalloc, so `Box<[u8]>` encodes that ownership. diff --git a/src/jsc/RefString.rs b/src/jsc/RefString.rs index 811f9ca0442b..e5f7e90d9d1f 100644 --- a/src/jsc/RefString.rs +++ b/src/jsc/RefString.rs @@ -6,10 +6,8 @@ use core::ffi::c_void; use core::ptr::NonNull; -use bun_jsc::{JSGlobalObject, JSValue, JsResult}; // `bun_core::WTFStringImpl` is the *pointer* type (= `*mut WTFStringImplStruct`). use bun_core::WTFStringImpl; -use bun_jsc::StringJsc as _; // extension trait providing `.to_js()` on `bun_core::String` pub(crate) type Hash = u32; @@ -36,13 +34,6 @@ pub struct RefString { } impl RefString { - pub fn to_js(&self, global: &JSGlobalObject) -> JsResult { - // Wrap the raw - // `WTFStringImpl` pointer without bumping the refcount (`String` has - // no `Drop`, so this is adopt-then-forget). - bun_core::String::adopt_wtf_impl(self.impl_).to_js(global) - } - pub(crate) fn compute_hash(input: &[u8]) -> u32 { bun_hash::XxHash32::hash(0, input) } diff --git a/src/jsc/bindings/BunClientData.cpp b/src/jsc/bindings/BunClientData.cpp index e654e3ed1e0d..5750e03c3d85 100644 --- a/src/jsc/bindings/BunClientData.cpp +++ b/src/jsc/bindings/BunClientData.cpp @@ -96,11 +96,6 @@ void JSVMClientData::JSHeapDataDeleter::operator()(JSHeapData* heapData) const JSVMClientData::~JSVMClientData() { - m_clients.forEach([](auto& client) { - client.willDestroyVM(); - }); - m_clients.clear(); - m_normalWorld = nullptr; } void JSVMClientData::create(VM* vm, void* bunVM) diff --git a/src/jsc/bindings/BunClientData.h b/src/jsc/bindings/BunClientData.h index f16367fd9059..8130d1862ff2 100644 --- a/src/jsc/bindings/BunClientData.h +++ b/src/jsc/bindings/BunClientData.h @@ -19,9 +19,7 @@ class DOMWrapperWorld; // #include "WorkerThreadType.h" #include #include -#include #include -#include "JSVMClientDataClient.h" #include #include #include "JSCTaskScheduler.h" @@ -151,8 +149,6 @@ class JSVMClientData : public JSC::VM::ClientData { // after every swap. WTF::UncheckedKeyHashMap> isolationSourceProviderCache; - void addClient(JSVMClientDataClient& client) { m_clients.add(client); } - private: bool isWebCoreJSClientData() const final { return true; } @@ -185,7 +181,6 @@ class JSVMClientData : public JSC::VM::ClientData { Vector m_outputConstraintSpaces; WebCore::HTTPHeaderIdentifiers m_httpHeaderIdentifiers; - WeakHashSet m_clients; }; } // namespace WebCore diff --git a/src/jsc/bindings/IDLTypes.h b/src/jsc/bindings/IDLTypes.h index ae6def884888..5b52f43f52c1 100644 --- a/src/jsc/bindings/IDLTypes.h +++ b/src/jsc/bindings/IDLTypes.h @@ -365,18 +365,6 @@ struct IDLDate : IDLType { static WallTime extractValueFromNullable(WallTime value) { return value; } }; -struct IDLJSON : IDLType { - using ConversionResultType = String; - using NullableConversionResultType = String; - using ParameterType = const String&; - using NullableParameterType = const String&; - - using NullableType = String; - static String nullValue() { return String(); } - static bool isNullValue(const String& value) { return value.isNull(); } - template static U&& extractValueFromNullable(U&& value) { return std::forward(value); } -}; - struct IDLScheduledAction : IDLType> { }; template struct IDLSerializedScriptValue : IDLWrapper { diff --git a/src/jsc/bindings/JSDOMWrapper.h b/src/jsc/bindings/JSDOMWrapper.h index 395b4df3ff32..db5044a4af7a 100644 --- a/src/jsc/bindings/JSDOMWrapper.h +++ b/src/jsc/bindings/JSDOMWrapper.h @@ -49,14 +49,6 @@ inline constexpr uint8_t JSDOMWrapperType = 0b11101110; inline constexpr uint8_t JSEventType = 0b11101111; inline constexpr uint8_t JSNodeType = 0b11110000; inline constexpr uint8_t JSNodeTypeMask = 0b00001111; -inline constexpr uint8_t JSTextNodeType = JSNodeType | NodeConstants::TEXT_NODE; -inline constexpr uint8_t JSProcessingInstructionNodeType = JSNodeType | NodeConstants::PROCESSING_INSTRUCTION_NODE; -inline constexpr uint8_t JSDocumentTypeNodeType = JSNodeType | NodeConstants::DOCUMENT_TYPE_NODE; -inline constexpr uint8_t JSDocumentFragmentNodeType = JSNodeType | NodeConstants::DOCUMENT_FRAGMENT_NODE; -inline constexpr uint8_t JSDocumentWrapperType = JSNodeType | NodeConstants::DOCUMENT_NODE; -inline constexpr uint8_t JSCommentNodeType = JSNodeType | NodeConstants::COMMENT_NODE; -inline constexpr uint8_t JSCDATASectionNodeType = JSNodeType | NodeConstants::CDATA_SECTION_NODE; -inline constexpr uint8_t JSAttrNodeType = JSNodeType | NodeConstants::ATTRIBUTE_NODE; inline constexpr uint8_t JSElementType = 0b11110000 | NodeConstants::ELEMENT_NODE; inline constexpr uint8_t JSAsJSONType = JSElementType; diff --git a/src/jsc/bindings/JSVMClientDataClient.h b/src/jsc/bindings/JSVMClientDataClient.h deleted file mode 100644 index cc7c6c326e96..000000000000 --- a/src/jsc/bindings/JSVMClientDataClient.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include - -namespace WebCore { - -class JSVMClientDataClient : public AbstractRefCountedAndCanMakeWeakPtr { -public: - virtual ~JSVMClientDataClient() = default; - virtual void willDestroyVM() = 0; -}; - -} // namespace WebCore diff --git a/src/jsc/bindings/ares_build.h b/src/jsc/bindings/ares_build.h deleted file mode 100644 index 2c4927ba5d60..000000000000 --- a/src/jsc/bindings/ares_build.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef __CARES_BUILD_H -#define __CARES_BUILD_H - -#define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t -#define CARES_TYPEOF_ARES_SSIZE_T ssize_t - -/* Prefix names with CARES_ to make sure they don't conflict with other config.h - * files. We need to include some dependent headers that may be system specific - * for C-Ares */ -#define CARES_HAVE_SYS_TYPES_H -#define CARES_HAVE_SYS_SOCKET_H -/* #undef CARES_HAVE_WINDOWS_H */ -/* #undef CARES_HAVE_WS2TCPIP_H */ -/* #undef CARES_HAVE_WINSOCK2_H */ -/* #undef CARES_HAVE_WINDOWS_H */ -#define CARES_HAVE_ARPA_NAMESER_H -#define CARES_HAVE_ARPA_NAMESER_COMPAT_H - -#ifdef CARES_HAVE_SYS_TYPES_H -#include -#endif - -#ifdef CARES_HAVE_SYS_SOCKET_H -#include -#endif - -#ifdef CARES_HAVE_WINSOCK2_H -#include -#endif - -#ifdef CARES_HAVE_WS2TCPIP_H -#include -#endif - -#ifdef CARES_HAVE_WINDOWS_H -#include -#endif - -typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; -typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t; - -#endif /* __CARES_BUILD_H */ diff --git a/src/jsc/bindings/headers-cpp.h b/src/jsc/bindings/headers-cpp.h deleted file mode 100644 index 1453b0a0fb1b..000000000000 --- a/src/jsc/bindings/headers-cpp.h +++ /dev/null @@ -1,190 +0,0 @@ -// clang-format off -//-- GENERATED FILE. Do not edit -- -// -// To regenerate this file, run: -// -// make headers -// -//-- GENERATED FILE. Do not edit -- -#pragma once - -#include -#include -#include - -#include "root.h" - -#ifndef INCLUDED_JavaScriptCore_JSObject_h -#define INCLUDED_JavaScriptCore_JSObject_h -#include -#endif - -extern "C" const size_t JSC__JSObject_object_size_ = sizeof(JSC::JSObject); -extern "C" const size_t JSC__JSObject_object_align_ = alignof(JSC::JSObject); - -#ifndef INCLUDED_DOMFormData_h -#define INCLUDED_DOMFormData_h -#include "DOMFormData.h" -#endif - -extern "C" const size_t WebCore__DOMFormData_object_size_ = sizeof(WebCore::DOMFormData); -extern "C" const size_t WebCore__DOMFormData_object_align_ = alignof(WebCore::DOMFormData); - -#ifndef INCLUDED_FetchHeaders_h -#define INCLUDED_FetchHeaders_h -#include "FetchHeaders.h" -#endif - -extern "C" const size_t WebCore__FetchHeaders_object_size_ = sizeof(WebCore::FetchHeaders); -extern "C" const size_t WebCore__FetchHeaders_object_align_ = alignof(WebCore::FetchHeaders); - -#ifndef INCLUDED_JavaScriptCore_JSCell_h -#define INCLUDED_JavaScriptCore_JSCell_h -#include -#endif - -extern "C" const size_t JSC__JSCell_object_size_ = sizeof(JSC::JSCell); -extern "C" const size_t JSC__JSCell_object_align_ = alignof(JSC::JSCell); - -#ifndef INCLUDED_JavaScriptCore_JSString_h -#define INCLUDED_JavaScriptCore_JSString_h -#include -#endif - -extern "C" const size_t JSC__JSString_object_size_ = sizeof(JSC::JSString); -extern "C" const size_t JSC__JSString_object_align_ = alignof(JSC::JSString); - -#ifndef INCLUDED_JavaScriptCore_JSModuleLoader_h -#define INCLUDED_JavaScriptCore_JSModuleLoader_h -#include -#endif - -extern "C" const size_t JSC__JSModuleLoader_object_size_ = sizeof(JSC::JSModuleLoader); -extern "C" const size_t JSC__JSModuleLoader_object_align_ = alignof(JSC::JSModuleLoader); - -#ifndef INCLUDED_webcore_AbortSignal_h -#define INCLUDED_webcore_AbortSignal_h -#include "webcore/AbortSignal.h" -#endif - -extern "C" const size_t WebCore__AbortSignal_object_size_ = sizeof(WebCore::AbortSignal); -extern "C" const size_t WebCore__AbortSignal_object_align_ = alignof(WebCore::AbortSignal); - -#ifndef INCLUDED_JavaScriptCore_JSPromise_h -#define INCLUDED_JavaScriptCore_JSPromise_h -#include -#endif - -extern "C" const size_t JSC__JSPromise_object_size_ = sizeof(JSC::JSPromise); -extern "C" const size_t JSC__JSPromise_object_align_ = alignof(JSC::JSPromise); - -extern "C" const size_t JSC__JSInternalPromise_object_size_ = sizeof(JSC::JSPromise); -extern "C" const size_t JSC__JSInternalPromise_object_align_ = alignof(JSC::JSPromise); - -#ifndef INCLUDED_JavaScriptCore_JSFunction_h -#define INCLUDED_JavaScriptCore_JSFunction_h -#include -#endif - -extern "C" const size_t JSC__JSFunction_object_size_ = sizeof(JSC::JSFunction); -extern "C" const size_t JSC__JSFunction_object_align_ = alignof(JSC::JSFunction); - -#ifndef INCLUDED_JavaScriptCore_JSGlobalObject_h -#define INCLUDED_JavaScriptCore_JSGlobalObject_h -#include -#endif - -extern "C" const size_t JSC__JSGlobalObject_object_size_ = sizeof(JSC::JSGlobalObject); -extern "C" const size_t JSC__JSGlobalObject_object_align_ = alignof(JSC::JSGlobalObject); - -#ifndef INCLUDED_JavaScriptCore_JSMap_h -#define INCLUDED_JavaScriptCore_JSMap_h -#include -#endif - -extern "C" const size_t JSC__JSMap_object_size_ = sizeof(JSC::JSMap); -extern "C" const size_t JSC__JSMap_object_align_ = alignof(JSC::JSMap); - -#ifndef INCLUDED_JavaScriptCore_JSValue_h -#define INCLUDED_JavaScriptCore_JSValue_h -#include -#endif - -extern "C" const size_t JSC__JSValue_object_size_ = sizeof(JSC::JSValue); -extern "C" const size_t JSC__JSValue_object_align_ = alignof(JSC::JSValue); - -#ifndef INCLUDED_JavaScriptCore_Exception_h -#define INCLUDED_JavaScriptCore_Exception_h -#include -#endif - -extern "C" const size_t JSC__Exception_object_size_ = sizeof(JSC::Exception); -extern "C" const size_t JSC__Exception_object_align_ = alignof(JSC::Exception); - -#ifndef INCLUDED_JavaScriptCore_VM_h -#define INCLUDED_JavaScriptCore_VM_h -#include -#endif - -extern "C" const size_t JSC__VM_object_size_ = sizeof(JSC::VM); -extern "C" const size_t JSC__VM_object_align_ = alignof(JSC::VM); - -#ifndef INCLUDED_JavaScriptCore_ThrowScope_h -#define INCLUDED_JavaScriptCore_ThrowScope_h -#include -#endif - -extern "C" const size_t JSC__ThrowScope_object_size_ = sizeof(JSC::ThrowScope); -extern "C" const size_t JSC__ThrowScope_object_align_ = alignof(JSC::ThrowScope); - -#ifndef INCLUDED_JavaScriptCore_TopExceptionScope_h -#define INCLUDED_JavaScriptCore_TopExceptionScope_h -#include -#endif - -extern "C" const size_t JSC__TopExceptionScope_object_size_ = sizeof(JSC::TopExceptionScope); -extern "C" const size_t JSC__TopExceptionScope_object_align_ = alignof(JSC::TopExceptionScope); - -#ifndef INCLUDED__ZigGlobalObject_h_ -#define INCLUDED__ZigGlobalObject_h_ -#include ""ZigGlobalObject.h"" -#endif - -extern "C" const size_t Zig__GlobalObject_object_size_ = sizeof(Zig::GlobalObject); -extern "C" const size_t Zig__GlobalObject_object_align_ = alignof(Zig::GlobalObject); - -#ifndef INCLUDED_Path_h -#define INCLUDED_Path_h -#include "Path.h" -#endif - -extern "C" const size_t Bun__Path_object_size_ = sizeof(Bun__Path); -extern "C" const size_t Bun__Path_object_align_ = alignof(Bun__Path); - -#ifndef INCLUDED__ConsoleObject_h_ -#define INCLUDED__ConsoleObject_h_ -#include ""ConsoleObject.h"" -#endif - -extern "C" const size_t Bun__ConsoleObject_object_size_ = sizeof(Zig::ConsoleClient); -extern "C" const size_t Bun__ConsoleObject_object_align_ = alignof(Zig::ConsoleClient); - -#ifndef INCLUDED_ -#define INCLUDED_ -#include "" -#endif - -extern "C" const size_t Bun__Timer_object_size_ = sizeof(Bun__Timer); -extern "C" const size_t Bun__Timer_object_align_ = alignof(Bun__Timer); - -#ifndef INCLUDED_ -#define INCLUDED_ -#include "" -#endif - -extern "C" const size_t Bun__BodyValueBufferer_object_size_ = sizeof(Bun__BodyValueBufferer); -extern "C" const size_t Bun__BodyValueBufferer_object_align_ = alignof(Bun__BodyValueBufferer); - -const size_t sizes[39] = {sizeof(JSC::JSObject), sizeof(WebCore::DOMURL), sizeof(WebCore::DOMFormData), sizeof(WebCore::FetchHeaders), sizeof(SystemError), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(JSC::JSModuleLoader), sizeof(WebCore::AbortSignal), sizeof(JSC::JSPromise), sizeof(JSC::JSPromise), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(JSC::JSMap), sizeof(JSC::JSValue), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::TopExceptionScope), sizeof(FFI__ptr), sizeof(Reader__u8), sizeof(Reader__u16), sizeof(Reader__u32), sizeof(Reader__ptr), sizeof(Reader__i8), sizeof(Reader__i16), sizeof(Reader__i32), sizeof(Reader__f32), sizeof(Reader__f64), sizeof(Reader__i64), sizeof(Reader__u64), sizeof(Reader__intptr), sizeof(Zig::GlobalObject), sizeof(Bun__Path), sizeof(ArrayBufferSink), sizeof(HTTPSResponseSink), sizeof(HTTPResponseSink), sizeof(FileSink), sizeof(FileSink)}; - -const size_t aligns[39] = {alignof(JSC::JSObject), alignof(WebCore::DOMURL), alignof(WebCore::DOMFormData), alignof(WebCore::FetchHeaders), alignof(SystemError), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(JSC::JSModuleLoader), alignof(WebCore::AbortSignal), alignof(JSC::JSPromise), alignof(JSC::JSPromise), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(JSC::JSMap), alignof(JSC::JSValue), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::TopExceptionScope), alignof(FFI__ptr), alignof(Reader__u8), alignof(Reader__u16), alignof(Reader__u32), alignof(Reader__ptr), alignof(Reader__i8), alignof(Reader__i16), alignof(Reader__i32), alignof(Reader__f32), alignof(Reader__f64), alignof(Reader__i64), alignof(Reader__u64), alignof(Reader__intptr), alignof(Zig::GlobalObject), alignof(Bun__Path), alignof(ArrayBufferSink), alignof(HTTPSResponseSink), alignof(HTTPResponseSink), alignof(FileSink), alignof(FileSink)}; diff --git a/src/jsc/bindings/headers-handwritten.h b/src/jsc/bindings/headers-handwritten.h index d765bfb946ad..801e4b08022d 100644 --- a/src/jsc/bindings/headers-handwritten.h +++ b/src/jsc/bindings/headers-handwritten.h @@ -282,28 +282,6 @@ inline constexpr Encoding Encoding__base64url = 6; inline constexpr Encoding Encoding__hex = 7; inline constexpr Encoding Encoding__buffer = 8; -typedef uint8_t WritableEvent; -inline constexpr WritableEvent WritableEvent__Close = 0; -inline constexpr WritableEvent WritableEvent__Drain = 1; -inline constexpr WritableEvent WritableEvent__Error = 2; -inline constexpr WritableEvent WritableEvent__Finish = 3; -inline constexpr WritableEvent WritableEvent__Pipe = 4; -inline constexpr WritableEvent WritableEvent__Unpipe = 5; -inline constexpr WritableEvent WritableEvent__Open = 6; -inline constexpr WritableEvent WritableEventUser = 254; - -typedef uint8_t ReadableEvent; - -inline constexpr ReadableEvent ReadableEvent__Close = 0; -inline constexpr ReadableEvent ReadableEvent__Data = 1; -inline constexpr ReadableEvent ReadableEvent__End = 2; -inline constexpr ReadableEvent ReadableEvent__Error = 3; -inline constexpr ReadableEvent ReadableEvent__Pause = 4; -inline constexpr ReadableEvent ReadableEvent__Readable = 5; -inline constexpr ReadableEvent ReadableEvent__Resume = 6; -inline constexpr ReadableEvent ReadableEvent__Open = 7; -inline constexpr ReadableEvent ReadableEventUser = 254; - #ifndef STRING_POINTER #define STRING_POINTER typedef struct StringPointer { diff --git a/src/jsc/bindings/helpers.h b/src/jsc/bindings/helpers.h index cb9bc987755c..ac788968f214 100644 --- a/src/jsc/bindings/helpers.h +++ b/src/jsc/bindings/helpers.h @@ -118,16 +118,6 @@ static const WTF::String toString(ZigString str) { reinterpret_cast(untag(str.ptr)), str.len })); } -static WTF::AtomString toAtomString(ZigString str) -{ - - if (!isTaggedUTF16Ptr(str.ptr)) { - return makeAtomString(std::span(untag(str.ptr), str.len)); - } else { - return makeAtomString(std::span(reinterpret_cast(untag(str.ptr)), str.len)); - } -} - static const WTF::String toString(ZigString str, StringPointer ptr) { if (str.len == 0 || str.ptr == nullptr || ptr.len == 0) { @@ -245,8 +235,6 @@ static void appendToBuilder(ZigString str, WTF::StringBuilder& builder) builder.append({ untag(str.ptr), str.len }); } -static WTF::String toStringNotConst(ZigString str) { return toString(str); } - static const JSC::JSString* toJSString(ZigString str, JSC::JSGlobalObject* global) { return JSC::jsOwnedString(global->vm(), toString(str)); @@ -258,9 +246,6 @@ static JSC::JSString* toJSStringGC(ZigString str, JSC::JSGlobalObject* global) } static const ZigString ZigStringEmpty = ZigString { (unsigned char*)"", 0 }; -static const unsigned char __dot_char = '.'; -static const ZigString ZigStringCwd = ZigString { &__dot_char, 1 }; -static const BunString BunStringCwd = BunString { BunStringTag::StaticZigString, ZigStringCwd }; static const BunString BunStringEmpty = BunString { BunStringTag::Empty, nullptr }; static const unsigned char* taggedUTF16Ptr(const char16_t* ptr) @@ -268,14 +253,6 @@ static const unsigned char* taggedUTF16Ptr(const char16_t* ptr) return reinterpret_cast(reinterpret_cast(ptr) | (static_cast(1) << 63)); } -static ZigString toZigString(WTF::String* str) -{ - return str->isEmpty() - ? ZigStringEmpty - : ZigString { str->is8Bit() ? str->span8().data() : taggedUTF16Ptr(str->span16().data()), - str->length() }; -} - static ZigString toZigString(WTF::StringImpl& str) { return str.isEmpty() @@ -328,21 +305,6 @@ static ZigString toZigString(JSC::JSString* str, JSC::JSGlobalObject* global) return toZigString(str->value(global)); } -static ZigString toZigString(JSC::Identifier& str, JSC::JSGlobalObject* global) -{ - return toZigString(str.string()); -} - -static ZigString toZigString(JSC::Identifier* str, JSC::JSGlobalObject* global) -{ - return toZigString(str->string()); -} - -static WTF::StringView toStringView(ZigString str) -{ - return WTF::StringView(std::span { untag(str.ptr), str.len }); -} - static void throwException(JSC::ThrowScope& scope, ZigErrorType err, JSC::JSGlobalObject* global) { scope.throwException(global, diff --git a/src/jsc/bindings/node/http/llhttp/api.h b/src/jsc/bindings/node/http/llhttp/api.h deleted file mode 100644 index c40478fbb4e5..000000000000 --- a/src/jsc/bindings/node/http/llhttp/api.h +++ /dev/null @@ -1,357 +0,0 @@ -#ifndef INCLUDE_LLHTTP_API_H_ -#define INCLUDE_LLHTTP_API_H_ -#ifdef __cplusplus -extern "C" { -#endif -#include - -#if defined(__wasm__) -#define LLHTTP_EXPORT __attribute__((visibility("default"))) -#elif defined(_WIN32) -#define LLHTTP_EXPORT __declspec(dllexport) -#else -#define LLHTTP_EXPORT -#endif - -typedef llhttp__internal_t llhttp_t; -typedef struct llhttp_settings_s llhttp_settings_t; - -typedef int (*llhttp_data_cb)(llhttp_t*, const char* at, size_t length); -typedef int (*llhttp_cb)(llhttp_t*); - -struct llhttp_settings_s { - /* Possible return values 0, -1, `HPE_PAUSED` */ - llhttp_cb on_message_begin; - - /* Possible return values 0, -1, HPE_USER */ - llhttp_data_cb on_protocol; - llhttp_data_cb on_url; - llhttp_data_cb on_status; - llhttp_data_cb on_method; - llhttp_data_cb on_version; - llhttp_data_cb on_header_field; - llhttp_data_cb on_header_value; - llhttp_data_cb on_chunk_extension_name; - llhttp_data_cb on_chunk_extension_value; - - /* Possible return values: - * 0 - Proceed normally - * 1 - Assume that request/response has no body, and proceed to parsing the - * next message - * 2 - Assume absence of body (as above) and make `llhttp_execute()` return - * `HPE_PAUSED_UPGRADE` - * -1 - Error - * `HPE_PAUSED` - */ - llhttp_cb on_headers_complete; - - /* Possible return values 0, -1, HPE_USER */ - llhttp_data_cb on_body; - - /* Possible return values 0, -1, `HPE_PAUSED` */ - llhttp_cb on_message_complete; - llhttp_cb on_protocol_complete; - llhttp_cb on_url_complete; - llhttp_cb on_status_complete; - llhttp_cb on_method_complete; - llhttp_cb on_version_complete; - llhttp_cb on_header_field_complete; - llhttp_cb on_header_value_complete; - llhttp_cb on_chunk_extension_name_complete; - llhttp_cb on_chunk_extension_value_complete; - - /* When on_chunk_header is called, the current chunk length is stored - * in parser->content_length. - * Possible return values 0, -1, `HPE_PAUSED` - */ - llhttp_cb on_chunk_header; - llhttp_cb on_chunk_complete; - llhttp_cb on_reset; -}; - -/* Initialize the parser with specific type and user settings. - * - * NOTE: lifetime of `settings` has to be at least the same as the lifetime of - * the `parser` here. In practice, `settings` has to be either a static - * variable or be allocated with `malloc`, `new`, etc. - */ -LLHTTP_EXPORT -void llhttp_init(llhttp_t* parser, llhttp_type_t type, - const llhttp_settings_t* settings); - -LLHTTP_EXPORT -llhttp_t* llhttp_alloc(llhttp_type_t type); - -LLHTTP_EXPORT -void llhttp_free(llhttp_t* parser); - -LLHTTP_EXPORT -uint8_t llhttp_get_type(llhttp_t* parser); - -LLHTTP_EXPORT -uint8_t llhttp_get_http_major(llhttp_t* parser); - -LLHTTP_EXPORT -uint8_t llhttp_get_http_minor(llhttp_t* parser); - -LLHTTP_EXPORT -uint8_t llhttp_get_method(llhttp_t* parser); - -LLHTTP_EXPORT -int llhttp_get_status_code(llhttp_t* parser); - -LLHTTP_EXPORT -uint8_t llhttp_get_upgrade(llhttp_t* parser); - -/* Reset an already initialized parser back to the start state, preserving the - * existing parser type, callback settings, user data, and lenient flags. - */ -LLHTTP_EXPORT -void llhttp_reset(llhttp_t* parser); - -/* Initialize the settings object */ -LLHTTP_EXPORT -void llhttp_settings_init(llhttp_settings_t* settings); - -/* Parse full or partial request/response, invoking user callbacks along the - * way. - * - * If any of `llhttp_data_cb` returns errno not equal to `HPE_OK` - the parsing - * interrupts, and such errno is returned from `llhttp_execute()`. If - * `HPE_PAUSED` was used as a errno, the execution can be resumed with - * `llhttp_resume()` call. - * - * In a special case of CONNECT/Upgrade request/response `HPE_PAUSED_UPGRADE` - * is returned after fully parsing the request/response. If the user wishes to - * continue parsing, they need to invoke `llhttp_resume_after_upgrade()`. - * - * NOTE: if this function ever returns a non-pause type error, it will continue - * to return the same error upon each successive call up until `llhttp_init()` - * is called. - */ -LLHTTP_EXPORT -llhttp_errno_t llhttp_execute(llhttp_t* parser, const char* data, size_t len); - -/* This method should be called when the other side has no further bytes to - * send (e.g. shutdown of readable side of the TCP connection.) - * - * Requests without `Content-Length` and other messages might require treating - * all incoming bytes as the part of the body, up to the last byte of the - * connection. This method will invoke `on_message_complete()` callback if the - * request was terminated safely. Otherwise a error code would be returned. - */ -LLHTTP_EXPORT -llhttp_errno_t llhttp_finish(llhttp_t* parser); - -/* Returns `1` if the incoming message is parsed until the last byte, and has - * to be completed by calling `llhttp_finish()` on EOF - */ -LLHTTP_EXPORT -int llhttp_message_needs_eof(const llhttp_t* parser); - -/* Returns `1` if there might be any other messages following the last that was - * successfully parsed. - */ -LLHTTP_EXPORT -int llhttp_should_keep_alive(const llhttp_t* parser); - -/* Make further calls of `llhttp_execute()` return `HPE_PAUSED` and set - * appropriate error reason. - * - * Important: do not call this from user callbacks! User callbacks must return - * `HPE_PAUSED` if pausing is required. - */ -LLHTTP_EXPORT -void llhttp_pause(llhttp_t* parser); - -/* Might be called to resume the execution after the pause in user's callback. - * See `llhttp_execute()` above for details. - * - * Call this only if `llhttp_execute()` returns `HPE_PAUSED`. - */ -LLHTTP_EXPORT -void llhttp_resume(llhttp_t* parser); - -/* Might be called to resume the execution after the pause in user's callback. - * See `llhttp_execute()` above for details. - * - * Call this only if `llhttp_execute()` returns `HPE_PAUSED_UPGRADE` - */ -LLHTTP_EXPORT -void llhttp_resume_after_upgrade(llhttp_t* parser); - -/* Returns the latest return error */ -LLHTTP_EXPORT -llhttp_errno_t llhttp_get_errno(const llhttp_t* parser); - -/* Returns the verbal explanation of the latest returned error. - * - * Note: User callback should set error reason when returning the error. See - * `llhttp_set_error_reason()` for details. - */ -LLHTTP_EXPORT -const char* llhttp_get_error_reason(const llhttp_t* parser); - -/* Assign verbal description to the returned error. Must be called in user - * callbacks right before returning the errno. - * - * Note: `HPE_USER` error code might be useful in user callbacks. - */ -LLHTTP_EXPORT -void llhttp_set_error_reason(llhttp_t* parser, const char* reason); - -/* Returns the pointer to the last parsed byte before the returned error. The - * pointer is relative to the `data` argument of `llhttp_execute()`. - * - * Note: this method might be useful for counting the number of parsed bytes. - */ -LLHTTP_EXPORT -const char* llhttp_get_error_pos(const llhttp_t* parser); - -/* Returns textual name of error code */ -LLHTTP_EXPORT -const char* llhttp_errno_name(llhttp_errno_t err); - -/* Returns textual name of HTTP method */ -LLHTTP_EXPORT -const char* llhttp_method_name(llhttp_method_t method); - -/* Returns textual name of HTTP status */ -LLHTTP_EXPORT -const char* llhttp_status_name(llhttp_status_t status); - -/* Enables/disables lenient header value parsing (disabled by default). - * - * Lenient parsing disables header value token checks, extending llhttp's - * protocol support to highly non-compliant clients/server. No - * `HPE_INVALID_HEADER_TOKEN` will be raised for incorrect header values when - * lenient parsing is "on". - * - * **Enabling this flag can pose a security issue since you will be exposed to - * request smuggling attacks. USE WITH CAUTION!** - */ -LLHTTP_EXPORT -void llhttp_set_lenient_headers(llhttp_t* parser, int enabled); - -/* Enables/disables lenient handling of conflicting `Transfer-Encoding` and - * `Content-Length` headers (disabled by default). - * - * Normally `llhttp` would error when `Transfer-Encoding` is present in - * conjunction with `Content-Length`. This error is important to prevent HTTP - * request smuggling, but may be less desirable for small number of cases - * involving legacy servers. - * - * **Enabling this flag can pose a security issue since you will be exposed to - * request smuggling attacks. USE WITH CAUTION!** - */ -LLHTTP_EXPORT -void llhttp_set_lenient_chunked_length(llhttp_t* parser, int enabled); - -/* Enables/disables lenient handling of `Connection: close` and HTTP/1.0 - * requests responses. - * - * Normally `llhttp` would error on (in strict mode) or discard (in loose mode) - * the HTTP request/response after the request/response with `Connection: close` - * and `Content-Length`. This is important to prevent cache poisoning attacks, - * but might interact badly with outdated and insecure clients. With this flag - * the extra request/response will be parsed normally. - * - * **Enabling this flag can pose a security issue since you will be exposed to - * poisoning attacks. USE WITH CAUTION!** - */ -LLHTTP_EXPORT -void llhttp_set_lenient_keep_alive(llhttp_t* parser, int enabled); - -/* Enables/disables lenient handling of `Transfer-Encoding` header. - * - * Normally `llhttp` would error when a `Transfer-Encoding` has `chunked` value - * and another value after it (either in a single header or in multiple - * headers whose value are internally joined using `, `). - * This is mandated by the spec to reliably determine request body size and thus - * avoid request smuggling. - * With this flag the extra value will be parsed normally. - * - * **Enabling this flag can pose a security issue since you will be exposed to - * request smuggling attacks. USE WITH CAUTION!** - */ -LLHTTP_EXPORT -void llhttp_set_lenient_transfer_encoding(llhttp_t* parser, int enabled); - -/* Enables/disables lenient handling of HTTP version. - * - * Normally `llhttp` would error when the HTTP version in the request or status line - * is not `0.9`, `1.0`, `1.1` or `2.0`. - * With this flag the invalid value will be parsed normally. - * - * **Enabling this flag can pose a security issue since you will allow unsupported - * HTTP versions. USE WITH CAUTION!** - */ -LLHTTP_EXPORT -void llhttp_set_lenient_version(llhttp_t* parser, int enabled); - -/* Enables/disables lenient handling of additional data received after a message ends - * and keep-alive is disabled. - * - * Normally `llhttp` would error when additional unexpected data is received if the message - * contains the `Connection` header with `close` value. - * With this flag the extra data will discarded without throwing an error. - * - * **Enabling this flag can pose a security issue since you will be exposed to - * poisoning attacks. USE WITH CAUTION!** - */ -LLHTTP_EXPORT -void llhttp_set_lenient_data_after_close(llhttp_t* parser, int enabled); - -/* Enables/disables lenient handling of incomplete CRLF sequences. - * - * Normally `llhttp` would error when a CR is not followed by LF when terminating the - * request line, the status line, the headers or a chunk header. - * With this flag only a CR is required to terminate such sections. - * - * **Enabling this flag can pose a security issue since you will be exposed to - * request smuggling attacks. USE WITH CAUTION!** - */ -LLHTTP_EXPORT -void llhttp_set_lenient_optional_lf_after_cr(llhttp_t* parser, int enabled); - -/* - * Enables/disables lenient handling of line separators. - * - * Normally `llhttp` would error when a LF is not preceded by CR when terminating the - * request line, the status line, the headers, a chunk header or a chunk data. - * With this flag only a LF is required to terminate such sections. - * - * **Enabling this flag can pose a security issue since you will be exposed to - * request smuggling attacks. USE WITH CAUTION!** - */ -LLHTTP_EXPORT -void llhttp_set_lenient_optional_cr_before_lf(llhttp_t* parser, int enabled); - -/* Enables/disables lenient handling of chunks not separated via CRLF. - * - * Normally `llhttp` would error when after a chunk data a CRLF is missing before - * starting a new chunk. - * With this flag the new chunk can start immediately after the previous one. - * - * **Enabling this flag can pose a security issue since you will be exposed to - * request smuggling attacks. USE WITH CAUTION!** - */ -LLHTTP_EXPORT -void llhttp_set_lenient_optional_crlf_after_chunk(llhttp_t* parser, int enabled); - -/* Enables/disables lenient handling of spaces after chunk size. - * - * Normally `llhttp` would error when after a chunk size is followed by one or more - * spaces are present instead of a CRLF or `;`. - * With this flag this check is disabled. - * - * **Enabling this flag can pose a security issue since you will be exposed to - * request smuggling attacks. USE WITH CAUTION!** - */ -LLHTTP_EXPORT -void llhttp_set_lenient_spaces_after_chunk_size(llhttp_t* parser, int enabled); - -#ifdef __cplusplus -} /* extern "C" */ -#endif -#endif /* INCLUDE_LLHTTP_API_H_ */ diff --git a/src/jsc/bindings/webcore/HTTPHeaderValues.cpp b/src/jsc/bindings/webcore/HTTPHeaderValues.cpp deleted file mode 100644 index b4869e846edf..000000000000 --- a/src/jsc/bindings/webcore/HTTPHeaderValues.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2016-2017 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "HTTPHeaderValues.h" - -#include -#include - -namespace WebCore { - -namespace HTTPHeaderValues { - -const String& textPlainContentType() -{ - static NeverDestroyed contentType(MAKE_STATIC_STRING_IMPL("text/plain;charset=UTF-8")); - return contentType; -} - -const String& formURLEncodedContentType() -{ - static NeverDestroyed contentType(MAKE_STATIC_STRING_IMPL("application/x-www-form-urlencoded;charset=UTF-8")); - return contentType; -} - -const String& applicationJSONContentType() -{ - // The default encoding is UTF-8: https://www.ietf.org/rfc/rfc4627.txt. - static NeverDestroyed contentType(MAKE_STATIC_STRING_IMPL("application/json")); - return contentType; -} - -const String& noCache() -{ - static NeverDestroyed value(MAKE_STATIC_STRING_IMPL("no-cache")); - return value; -} - -const String& maxAge0() -{ - static NeverDestroyed value(MAKE_STATIC_STRING_IMPL("max-age=0")); - return value; -} - -} - -} diff --git a/src/jsc/bindings/webcore/HTTPHeaderValues.h b/src/jsc/bindings/webcore/HTTPHeaderValues.h deleted file mode 100644 index 6345a9a8fca5..000000000000 --- a/src/jsc/bindings/webcore/HTTPHeaderValues.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2016 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include - -namespace WebCore { - -namespace HTTPHeaderValues { - -const String& textPlainContentType(); -const String& formURLEncodedContentType(); -WEBCORE_EXPORT const String& applicationJSONContentType(); -const String& noCache(); -WEBCORE_EXPORT const String& maxAge0(); -} - -} diff --git a/src/jsc/bindings/webcore/JSDOMConvert.h b/src/jsc/bindings/webcore/JSDOMConvert.h index c8ebcbac449c..afa2196d4770 100644 --- a/src/jsc/bindings/webcore/JSDOMConvert.h +++ b/src/jsc/bindings/webcore/JSDOMConvert.h @@ -34,7 +34,6 @@ #include "JSDOMConvertEnumeration.h" #include "JSDOMConvertEventListener.h" #include "JSDOMConvertInterface.h" -#include "JSDOMConvertJSON.h" #include "JSDOMConvertNull.h" #include "JSDOMConvertNullable.h" #include "JSDOMConvertNumbers.h" @@ -45,6 +44,5 @@ #include "JSDOMConvertSerializedScriptValue.h" #include "JSDOMConvertStrings.h" #include "JSDOMConvertUnion.h" -#include "JSDOMConvertWebGL.h" #include "JSDOMConvertBufferSource+JSBuffer.h" diff --git a/src/jsc/bindings/webcore/JSDOMConvertJSON.h b/src/jsc/bindings/webcore/JSDOMConvertJSON.h deleted file mode 100644 index 6a4716dee7a5..000000000000 --- a/src/jsc/bindings/webcore/JSDOMConvertJSON.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2016 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#include "IDLTypes.h" -#include "JSDOMConvertBase.h" -#include - -namespace WebCore { - -template<> struct Converter : DefaultConverter { - static String convert(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue value) - { - return JSC::JSONStringify(&lexicalGlobalObject, value, 0); - } -}; - -template<> struct JSConverter { - static constexpr bool needsState = true; - static constexpr bool needsGlobalObject = false; - - static JSC::JSValue convert(JSC::JSGlobalObject& lexicalGlobalObject, const String& value) - { - return JSC::JSONParse(&lexicalGlobalObject, value); - } -}; - -} // namespace WebCore diff --git a/src/jsc/bindings/webcore/JSDOMConvertWebGL.cpp b/src/jsc/bindings/webcore/JSDOMConvertWebGL.cpp deleted file mode 100644 index bfcf892fe696..000000000000 --- a/src/jsc/bindings/webcore/JSDOMConvertWebGL.cpp +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (C) 2017 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "JSDOMConvertWebGL.h" - -#if ENABLE(WEBGL) - -#include "JSANGLEInstancedArrays.h" -#include "JSDOMConvertBufferSource.h" -#include "JSEXTBlendMinMax.h" -#include "JSEXTColorBufferFloat.h" -#include "JSEXTColorBufferHalfFloat.h" -#include "JSEXTFloatBlend.h" -#include "JSEXTFragDepth.h" -#include "JSEXTShaderTextureLOD.h" -#include "JSEXTTextureCompressionRGTC.h" -#include "JSEXTTextureFilterAnisotropic.h" -#include "JSEXTsRGB.h" -#include "JSKHRParallelShaderCompile.h" -#include "JSOESElementIndexUint.h" -#include "JSOESFBORenderMipmap.h" -#include "JSOESStandardDerivatives.h" -#include "JSOESTextureFloat.h" -#include "JSOESTextureFloatLinear.h" -#include "JSOESTextureHalfFloat.h" -#include "JSOESTextureHalfFloatLinear.h" -#include "JSOESVertexArrayObject.h" -#include "JSWebGLBuffer.h" -#include "JSWebGLColorBufferFloat.h" -#include "JSWebGLCompressedTextureASTC.h" -#include "JSWebGLCompressedTextureATC.h" -#include "JSWebGLCompressedTextureETC.h" -#include "JSWebGLCompressedTextureETC1.h" -#include "JSWebGLCompressedTexturePVRTC.h" -#include "JSWebGLCompressedTextureS3TC.h" -#include "JSWebGLCompressedTextureS3TCsRGB.h" -#include "JSWebGLDebugRendererInfo.h" -#include "JSWebGLDebugShaders.h" -#include "JSWebGLDepthTexture.h" -#include "JSWebGLDrawBuffers.h" -#include "JSWebGLFramebuffer.h" -#include "JSWebGLLoseContext.h" -#include "JSWebGLMultiDraw.h" -#include "JSWebGLProgram.h" -#include "JSWebGLRenderbuffer.h" -#include "JSWebGLSampler.h" -#include "JSWebGLTexture.h" -#include "JSWebGLTransformFeedback.h" -#include "JSWebGLVertexArrayObject.h" -#include "JSWebGLVertexArrayObjectOES.h" - -namespace WebCore { -using namespace JSC; - -// FIXME: This should use the IDLUnion JSConverter. -JSValue convertToJSValue(JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject, const WebGLAny& any) -{ - return WTF::switchOn( - any, - [](std::nullptr_t) -> JSValue { - return jsNull(); - }, - [](bool value) -> JSValue { - return jsBoolean(value); - }, - [](int value) -> JSValue { - return jsNumber(value); - }, - [](unsigned value) -> JSValue { - return jsNumber(value); - }, - [](long long value) -> JSValue { - return jsNumber(value); - }, - [](float value) -> JSValue { - return jsNumber(value); - }, - [&](const String& value) -> JSValue { - return jsStringWithCache(lexicalGlobalObject.vm(), value); - }, - [&](const Vector& values) -> JSValue { - MarkedArgumentBuffer list; - for (auto& value : values) - list.append(jsBoolean(value)); - RELEASE_ASSERT(!list.hasOverflowed()); - return constructArray(&globalObject, static_cast(nullptr), list); - }, - [&](const Vector& values) -> JSValue { - MarkedArgumentBuffer list; - for (auto& value : values) - list.append(jsNumber(value)); - RELEASE_ASSERT(!list.hasOverflowed()); - return constructArray(&globalObject, static_cast(nullptr), list); - }, - [&](const Vector& values) -> JSValue { - MarkedArgumentBuffer list; - for (auto& value : values) - list.append(jsNumber(value)); - RELEASE_ASSERT(!list.hasOverflowed()); - return constructArray(&globalObject, static_cast(nullptr), list); - }, - [&](const RefPtr& array) { - return toJS(&lexicalGlobalObject, &globalObject, array.get()); - }, - [&](const RefPtr& array) { - return toJS(&lexicalGlobalObject, &globalObject, array.get()); - }, - [&](const RefPtr& array) { - return toJS(&lexicalGlobalObject, &globalObject, array.get()); - }, - [&](const RefPtr& array) { - return toJS(&lexicalGlobalObject, &globalObject, array.get()); - }, - [&](const RefPtr& array) { - return toJS(&lexicalGlobalObject, &globalObject, array.get()); - }, - [&](const RefPtr& buffer) { - return toJS(&lexicalGlobalObject, &globalObject, buffer.get()); - }, - [&](const RefPtr& buffer) { - return toJS(&lexicalGlobalObject, &globalObject, buffer.get()); - }, - [&](const RefPtr& program) { - return toJS(&lexicalGlobalObject, &globalObject, program.get()); - }, - [&](const RefPtr& buffer) { - return toJS(&lexicalGlobalObject, &globalObject, buffer.get()); - }, - [&](const RefPtr& texture) { - return toJS(&lexicalGlobalObject, &globalObject, texture.get()); - }, - [&](const RefPtr& array) { - return toJS(&lexicalGlobalObject, &globalObject, array.get()); - } -#if ENABLE(WEBGL2) - , - [&](const RefPtr& sampler) { - return toJS(&lexicalGlobalObject, &globalObject, sampler.get()); - }, - [&](const RefPtr& transformFeedback) { - return toJS(&lexicalGlobalObject, &globalObject, transformFeedback.get()); - }, - [&](const RefPtr& array) { - return toJS(&lexicalGlobalObject, &globalObject, array.get()); - } -#endif - ); -} - -JSValue convertToJSValue(JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject, WebGLExtension& extension) -{ - switch (extension.getName()) { - case WebGLExtension::WebGLLoseContextName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::EXTShaderTextureLODName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::EXTTextureCompressionRGTCName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::EXTTextureFilterAnisotropicName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::EXTsRGBName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::EXTFragDepthName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::EXTBlendMinMaxName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::KHRParallelShaderCompileName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::OESStandardDerivativesName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::OESTextureFloatName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::OESTextureFloatLinearName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::OESTextureHalfFloatName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::OESTextureHalfFloatLinearName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::OESVertexArrayObjectName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::OESElementIndexUintName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::OESFBORenderMipmapName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLDebugRendererInfoName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLDebugShadersName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLCompressedTextureATCName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLCompressedTextureETCName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLCompressedTextureETC1Name: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLCompressedTexturePVRTCName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLCompressedTextureS3TCName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLCompressedTextureS3TCsRGBName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLCompressedTextureASTCName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLDepthTextureName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLDrawBuffersName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::ANGLEInstancedArraysName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::EXTColorBufferHalfFloatName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::EXTFloatBlendName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLColorBufferFloatName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::EXTColorBufferFloatName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - case WebGLExtension::WebGLMultiDrawName: - return toJS(&lexicalGlobalObject, &globalObject, static_cast(extension)); - } - ASSERT_NOT_REACHED(); - return jsNull(); -} - -} - -#endif diff --git a/src/jsc/bindings/webcore/JSDOMConvertWebGL.h b/src/jsc/bindings/webcore/JSDOMConvertWebGL.h deleted file mode 100644 index 0f899215ac72..000000000000 --- a/src/jsc/bindings/webcore/JSDOMConvertWebGL.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2016 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#pragma once - -#if ENABLE(WEBGL) - -#include "IDLTypes.h" -#include "JSDOMConvertBase.h" - -namespace WebCore { - -JSC::JSValue convertToJSValue(JSC::JSGlobalObject&, JSDOMGlobalObject&, const WebGLAny&); -JSC::JSValue convertToJSValue(JSC::JSGlobalObject&, JSDOMGlobalObject&, WebGLExtension&); - -inline JSC::JSValue convertToJSValue(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject, WebGLExtension* extension) -{ - if (!extension) - return JSC::jsNull(); - return convertToJSValue(lexicalGlobalObject, globalObject, *extension); -} - -template<> struct JSConverter { - static constexpr bool needsState = true; - static constexpr bool needsGlobalObject = true; - - static JSC::JSValue convert(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject, const WebGLAny& value) - { - return convertToJSValue(lexicalGlobalObject, globalObject, value); - } -}; - -template<> struct JSConverter { - static constexpr bool needsState = true; - static constexpr bool needsGlobalObject = true; - - template - static JSC::JSValue convert(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject, const T& value) - { - return convertToJSValue(lexicalGlobalObject, globalObject, Detail::getPtrOrRef(value)); - } -}; - -} // namespace WebCore - -#endif diff --git a/src/jsc/bindings/webcore/TaskSource.h b/src/jsc/bindings/webcore/TaskSource.h deleted file mode 100644 index 2c0a128e8b67..000000000000 --- a/src/jsc/bindings/webcore/TaskSource.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -namespace WebCore { - -enum class TaskSource : uint8_t { - DOMManipulation, - DatabaseAccess, - FileReading, - FontLoading, - Geolocation, - IdleTask, - IndexedDB, - MediaElement, - Microtask, - Networking, - PerformanceTimeline, - Permission, - PostedMessageQueue, - Speech, - UserInteraction, - WebGL, - WebXR, - WebSocket, - - // Internal to WebCore - InternalAsyncTask, // Safe to re-order or delay. -}; - -} // namespace WebCore diff --git a/src/jsc/headergen/sizegen.cpp b/src/jsc/headergen/sizegen.cpp index 890bac5fc0af..ba47274e95b2 100644 --- a/src/jsc/headergen/sizegen.cpp +++ b/src/jsc/headergen/sizegen.cpp @@ -11,8 +11,6 @@ using namespace std; #include "DOMURL.h" -#include "headers-cpp.h" - #include #include diff --git a/src/jsc/sizes.rs b/src/jsc/sizes.rs index 2c296b83238d..d5b83de50d55 100644 --- a/src/jsc/sizes.rs +++ b/src/jsc/sizes.rs @@ -6,4 +6,3 @@ //! memory layout is not guaranteed by the compiler. pub const BUN_FFI_POINTER_OFFSET_TO_ARGUMENTS_LIST: usize = 6; -pub(crate) const BUN_FFI_POINTER_OFFSET_TO_TYPED_ARRAY_VECTOR: usize = 16; diff --git a/test/internal/source-lints/dead-symbols-llhttp-helpers-install.test.ts b/test/internal/source-lints/dead-symbols-llhttp-helpers-install.test.ts new file mode 100644 index 000000000000..2097ed913c52 --- /dev/null +++ b/test/internal/source-lints/dead-symbols-llhttp-helpers-install.test.ts @@ -0,0 +1,68 @@ +// Guards against reintroduction of symbols and files removed as dead code from +// the C++ bindings (llhttp/api.h, helpers.h, headers-handwritten.h, +// HTTPHeaderValues, JSDOMConvertJSON/WebGL, TaskSource, JSVMClientDataClient, +// ares_build.h, headers-cpp.h) and a handful of uncalled Rust helpers in +// bun_core::String / bun_jsc. Each entry was verified to have zero callers +// across src/ and build/debug/codegen/ before deletion. +// +// This is a source-tree lint: it reads files from src/ and does not touch the +// built binary. + +import { expect, test } from "bun:test"; +import { readFileSync } from "node:fs"; +import path from "node:path"; + +const repoRoot = path.resolve(import.meta.dir, "..", "..", ".."); + +function src(p: string): string { + return readFileSync(path.join(repoRoot, p), "utf8"); +} + +// Whole-file deletions (llhttp/api.h, headers-cpp.h, ares_build.h, TaskSource.h, +// HTTPHeaderValues.{h,cpp}, JSDOMConvertJSON.h, JSDOMConvertWebGL.{h,cpp}, +// JSVMClientDataClient.h) are asserted indirectly below via the surviving +// files that used to reference them: if any of those deleted headers were +// referenced anywhere, the build would fail. The headers that were never +// `#include`d at all (api.h, ares_build.h, TaskSource.h, HTTPHeaderValues.h) +// have no surviving-file witness to check here. + +test("dead C++ symbols in helpers.h / headers-handwritten.h / JSDOMWrapper.h / BunClientData do not reappear", () => { + const checks: Array<[string, RegExp]> = [ + ["src/jsc/bindings/helpers.h", /static WTF::AtomString toAtomString\(ZigString/], + ["src/jsc/bindings/helpers.h", /\btoStringNotConst\b/], + ["src/jsc/bindings/helpers.h", /\b__dot_char\b/], + ["src/jsc/bindings/helpers.h", /\bZigStringCwd\b/], + ["src/jsc/bindings/helpers.h", /\bBunStringCwd\b/], + ["src/jsc/bindings/helpers.h", /toZigString\(WTF::String\*/], + ["src/jsc/bindings/helpers.h", /toZigString\(JSC::Identifier&/], + ["src/jsc/bindings/helpers.h", /toZigString\(JSC::Identifier\*/], + ["src/jsc/bindings/helpers.h", /static WTF::StringView toStringView\(ZigString/], + ["src/jsc/bindings/headers-handwritten.h", /\bWritableEvent__Close\b/], + ["src/jsc/bindings/headers-handwritten.h", /\bReadableEvent__Close\b/], + ["src/jsc/bindings/JSDOMWrapper.h", /\bJSTextNodeType\b/], + ["src/jsc/bindings/JSDOMWrapper.h", /\bJSDocumentWrapperType\b/], + ["src/jsc/bindings/BunClientData.h", /\baddClient\b/], + ["src/jsc/bindings/BunClientData.h", /\bm_clients\b/], + ["src/jsc/bindings/BunClientData.h", /JSVMClientDataClient\.h/], + ["src/jsc/bindings/BunClientData.h", /WeakHashSet\.h/], + ["src/jsc/bindings/BunClientData.cpp", /\bm_clients\b/], + ["src/jsc/bindings/webcore/JSDOMConvert.h", /JSDOMConvertJSON\.h/], + ["src/jsc/bindings/webcore/JSDOMConvert.h", /JSDOMConvertWebGL\.h/], + ["src/jsc/bindings/IDLTypes.h", /\bIDLJSON\b/], + ["src/jsc/headergen/sizegen.cpp", /headers-cpp\.h/], + ]; + const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`); + expect(resurrected).toEqual([]); +}); + +test("dead Rust symbols in bun_core / jsc do not reappear", () => { + const checks: Array<[string, RegExp]> = [ + ["src/bun_core/string/mod.rs", /\bStringGithubActionFormatter\b/], + ["src/jsc/JSUint8Array.rs", /pub fn ptr\(&self\) -> \*mut u8/], + ["src/jsc/sizes.rs", /\bBUN_FFI_POINTER_OFFSET_TO_TYPED_ARRAY_VECTOR\b/], + ["src/jsc/RefString.rs", /pub fn to_js\(&self,/], + ["src/jsc/Errorable.rs", /pub fn value\(val: T\)/], + ]; + const resurrected = checks.filter(([file, re]) => re.test(src(file))).map(([file, re]) => `${file}: ${re.source}`); + expect(resurrected).toEqual([]); +});