diff options
-rw-r--r-- | .github/workflows/bun-linux-build.yml | 6 | ||||
-rw-r--r-- | .github/workflows/bun-mac-aarch64.yml | 16 | ||||
-rw-r--r-- | .github/workflows/bun-mac-x64-baseline.yml | 16 | ||||
-rw-r--r-- | .github/workflows/bun-mac-x64.yml | 16 | ||||
-rw-r--r-- | Dockerfile.devcontainer | 2 | ||||
-rw-r--r-- | Makefile | 4 | ||||
m--------- | src/bun.js/WebKit | 0 | ||||
-rw-r--r-- | src/bun.js/base.zig | 11 | ||||
-rw-r--r-- | src/bun.js/bindings/ZigGeneratedCode.cpp | 346 | ||||
-rw-r--r-- | src/bun.js/bindings/bindings.zig | 24 | ||||
-rw-r--r-- | src/bun.js/bindings/headers-cpp.h | 8 | ||||
-rw-r--r-- | src/bun.js/bindings/headers.h | 66 | ||||
-rw-r--r-- | src/bun.js/bindings/headers.zig | 8 | ||||
-rw-r--r-- | src/bun.js/event_loop.zig | 2 | ||||
-rw-r--r-- | src/bun.js/ffi.exports.js | 2 | ||||
-rw-r--r-- | test/bun.js/ffi.test.js | 23 |
16 files changed, 502 insertions, 48 deletions
diff --git a/.github/workflows/bun-linux-build.yml b/.github/workflows/bun-linux-build.yml index 6ab3c2d3d..595451a68 100644 --- a/.github/workflows/bun-linux-build.yml +++ b/.github/workflows/bun-linux-build.yml @@ -37,21 +37,21 @@ jobs: arch: x86_64 build_arch: amd64 runner: linux-amd64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-linux-amd64-lto.tar.gz" webkit_basename: "bun-webkit-linux-amd64-lto" - cpu: westmere tag: linux-x64-baseline arch: x86_64 build_arch: amd64 runner: linux-amd64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-linux-amd64-lto.tar.gz" webkit_basename: "bun-webkit-linux-amd64-lto" - cpu: native tag: linux-aarch64 arch: aarch64 build_arch: arm64 runner: linux-arm64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-linux-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-linux-arm64-lto.tar.gz" webkit_basename: "bun-webkit-linux-arm64-lto" steps: diff --git a/.github/workflows/bun-mac-aarch64.yml b/.github/workflows/bun-mac-aarch64.yml index 45a2e6955..8cd614033 100644 --- a/.github/workflows/bun-mac-aarch64.yml +++ b/.github/workflows/bun-mac-aarch64.yml @@ -91,7 +91,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false # - cpu: haswell @@ -100,7 +100,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false # - cpu: westmere @@ -109,7 +109,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true # - cpu: haswell @@ -118,7 +118,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true - cpu: native @@ -126,7 +126,7 @@ jobs: tag: bun-darwin-aarch64 obj: bun-obj-darwin-aarch64 artifact: bun-obj-darwin-aarch64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-arm64-lto.tar.gz" runner: macos-arm64 dependencies: true compile_obj: true @@ -225,7 +225,7 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: haswell # arch: x86_64 # tag: bun-darwin-x64 @@ -233,14 +233,14 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" - cpu: native arch: aarch64 tag: bun-darwin-aarch64 obj: bun-obj-darwin-aarch64 package: bun-darwin-aarch64 artifact: bun-obj-darwin-aarch64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-arm64-lto.tar.gz" runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/bun-mac-x64-baseline.yml b/.github/workflows/bun-mac-x64-baseline.yml index 9cd84e19f..5850790c1 100644 --- a/.github/workflows/bun-mac-x64-baseline.yml +++ b/.github/workflows/bun-mac-x64-baseline.yml @@ -91,7 +91,7 @@ jobs: obj: bun-obj-darwin-x64-baseline runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" dependencies: true compile_obj: false # - cpu: haswell @@ -100,7 +100,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false - cpu: westmere @@ -109,7 +109,7 @@ jobs: obj: bun-obj-darwin-x64-baseline runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" dependencies: false compile_obj: true # - cpu: haswell @@ -118,7 +118,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true # - cpu: native @@ -126,7 +126,7 @@ jobs: # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # runner: macos-arm64 # dependencies: true # compile_obj: true @@ -219,7 +219,7 @@ jobs: package: bun-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: haswell # arch: x86_64 # tag: bun-darwin-x64 @@ -227,14 +227,14 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: native # arch: aarch64 # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # package: bun-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/bun-mac-x64.yml b/.github/workflows/bun-mac-x64.yml index 54c96a9da..f622d6b6f 100644 --- a/.github/workflows/bun-mac-x64.yml +++ b/.github/workflows/bun-mac-x64.yml @@ -91,7 +91,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false - cpu: haswell @@ -100,7 +100,7 @@ jobs: obj: bun-obj-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" dependencies: true compile_obj: false # - cpu: westmere @@ -109,7 +109,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true - cpu: haswell @@ -118,7 +118,7 @@ jobs: obj: bun-obj-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" dependencies: false compile_obj: true # - cpu: native @@ -126,7 +126,7 @@ jobs: # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-arm64-lto.tar.gz" # runner: macos-arm64 # dependencies: true # compile_obj: true @@ -221,7 +221,7 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" - cpu: haswell arch: x86_64 tag: bun-darwin-x64 @@ -229,14 +229,14 @@ jobs: package: bun-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: native # arch: aarch64 # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # package: bun-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-macos-arm64-lto.tar.gz" # runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/Dockerfile.devcontainer b/Dockerfile.devcontainer index c73d60a2f..7d5f01c3a 100644 --- a/Dockerfile.devcontainer +++ b/Dockerfile.devcontainer @@ -88,7 +88,7 @@ RUN cd $GITHUB_WORKSPACE && \ rm zig-linux-$BUILDARCH.zip; RUN cd $GITHUB_WORKSPACE && \ - curl -o bun-webkit-linux-$BUILDARCH.tar.gz -L https://github.com/oven-sh/WebKit/releases/download/aug27/bun-webkit-linux-$BUILDARCH.tar.gz && \ + curl -o bun-webkit-linux-$BUILDARCH.tar.gz -L https://github.com/oven-sh/WebKit/releases/download/aug27-1/bun-webkit-linux-$BUILDARCH.tar.gz && \ tar -xzf bun-webkit-linux-$BUILDARCH.tar.gz && \ rm bun-webkit-linux-$BUILDARCH.tar.gz && \ cat $WEBKIT_OUT_DIR/include/cmakeconfig.h > /dev/null @@ -440,7 +440,7 @@ BUN_LLD_FLAGS_WITHOUT_JSC = $(ARCHIVE_FILES) \ BUN_LLD_FLAGS = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES) $(BINDINGS_OBJ) BUN_LLD_FLAGS_DEBUG = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES_DEBUG) $(DEBUG_BINDINGS_OBJ) -BUN_LLD_FLAGS_FAST = $(BUN_LLD_FLAGS_DEBUG) +BUN_LLD_FLAGS_FAST = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES_DEBUG) $(BINDINGS_OBJ) CLANG_VERSION = $(shell $(CC) --version | awk '/version/ {for(i=1; i<=NF; i++){if($$i=="version"){split($$(i+1),v,".");print v[1]}}}') @@ -855,7 +855,7 @@ headers: rm -f /tmp/build-jsc-headers src/bun.js/bindings/headers.zig touch src/bun.js/bindings/headers.zig $(ZIG) build headers-obj - $(CXX) $(PLATFORM_LINKER_FLAGS) $(JSC_FILES_DEBUG) ${ICU_FLAGS} $(BUN_LLD_FLAGS_WITHOUT_JSC) -g $(DEBUG_BIN)/headers.o -W -o /tmp/build-jsc-headers -lc; + $(CXX) $(PLATFORM_LINKER_FLAGS) $(JSC_FILES_DEBUG) ${ICU_FLAGS} $(DEBUG_IO_FILES) $(BUN_LLD_FLAGS_WITHOUT_JSC) -g $(DEBUG_BIN)/headers.o -W -o /tmp/build-jsc-headers -lc; /tmp/build-jsc-headers $(ZIG) translate-c src/bun.js/bindings/headers.h > src/bun.js/bindings/headers.zig $(BUN_OR_NODE) misctools/headers-cleaner.js diff --git a/src/bun.js/WebKit b/src/bun.js/WebKit -Subproject c1ba87b24e59723afe32853863c3e649e3fdc8e +Subproject 2e9e9203ef0561f08919285f32d81b25ad96608 diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig index c1bfbf544..732f5ed97 100644 --- a/src/bun.js/base.zig +++ b/src/bun.js/base.zig @@ -3029,7 +3029,9 @@ pub const DOMEffect = struct { fn DOMCallArgumentType(comptime Type: type) []const u8 { const ChildType = if (@typeInfo(Type) == .Pointer) std.meta.Child(Type) else Type; return switch (ChildType) { - i32 => "JSC::SpecInt32Only", + i8, u8, i16, u16, i32 => "JSC::SpecInt32Only", + u32, i64, u64 => "JSC::SpecInt52Any", + f64 => "JSC::SpecDoubleReal", bool => "JSC::SpecBoolean", JSC.JSString => "JSC::SpecString", JSC.JSUint8Array => "JSC::SpecUint8Array", @@ -3041,6 +3043,9 @@ fn DOMCallArgumentTypeWrapper(comptime Type: type) []const u8 { const ChildType = if (@typeInfo(Type) == .Pointer) std.meta.Child(Type) else Type; return switch (ChildType) { i32 => "int32_t", + f64 => "double", + u64 => "uint64_t", + i64 => "int64_t", bool => "bool", JSC.JSString => "JSC::JSString*", JSC.JSUint8Array => "JSC::JSUint8Array*", @@ -3056,7 +3061,7 @@ fn DOMCallResultType(comptime Type: type) []const u8 { JSC.JSString => "JSC::SpecString", JSC.JSUint8Array => "JSC::SpecUint8Array", JSC.JSCell => "JSC::SpecCell", - f64 => "JSC::SpecNonIntAsDouble", + f64 => "JSC::SpecDoubleReal", else => "JSC::SpecHeapTop", }; } @@ -3165,7 +3170,7 @@ pub fn DOMCall( 2 => { try writer.writeAll(", "); try writer.writeAll(DOMCallArgumentTypeWrapper(Fields[2].field_type)); - try writer.writeAll("arg1, "); + try writer.writeAll(" arg1, "); try writer.writeAll(DOMCallArgumentTypeWrapper(Fields[3].field_type)); try writer.writeAll(" arg2)) {\n"); }, diff --git a/src/bun.js/bindings/ZigGeneratedCode.cpp b/src/bun.js/bindings/ZigGeneratedCode.cpp index c563597b8..1e2ff7dbf 100644 --- a/src/bun.js/bindings/ZigGeneratedCode.cpp +++ b/src/bun.js/bindings/ZigGeneratedCode.cpp @@ -37,7 +37,7 @@ extern "C" void FFI__ptr__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSV FFI__ptr__fastpathWrapper, thisObject->classInfo(), JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecNonIntAsDouble, + JSC::SpecDoubleReal, JSC::SpecUint8Array ); JSFunction* function = JSFunction::create( @@ -57,5 +57,349 @@ extern "C" void FFI__ptr__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSV } + +extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__u8__slowpathWrapper); +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__u8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { +VM& vm = JSC::getVM(lexicalGlobalObject); +IGNORE_WARNINGS_BEGIN("frame-address") +CallFrame* callFrame = DECLARE_CALL_FRAME(vm); +IGNORE_WARNINGS_END +JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); +return Reader__u8__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__u8__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { + return Reader__u8__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); +} + +extern "C" void Reader__u8__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { + JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_u8_signature( + Reader__u8__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt32Only, + JSC::SpecInt52Any, + JSC::SpecInt32Only + ); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("u8"_s), + Reader__u8__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u8__slowpathWrapper, + &DOMJIT_u8_signature + ); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "u8"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 + ); +} + + + +extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__u16__slowpathWrapper); +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__u16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { +VM& vm = JSC::getVM(lexicalGlobalObject); +IGNORE_WARNINGS_BEGIN("frame-address") +CallFrame* callFrame = DECLARE_CALL_FRAME(vm); +IGNORE_WARNINGS_END +JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); +return Reader__u16__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__u16__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { + return Reader__u16__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); +} + +extern "C" void Reader__u16__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { + JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_u16_signature( + Reader__u16__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt32Only, + JSC::SpecInt52Any, + JSC::SpecInt32Only + ); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("u16"_s), + Reader__u16__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u16__slowpathWrapper, + &DOMJIT_u16_signature + ); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "u16"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 + ); +} + + + +extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__u32__slowpathWrapper); +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__u32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { +VM& vm = JSC::getVM(lexicalGlobalObject); +IGNORE_WARNINGS_BEGIN("frame-address") +CallFrame* callFrame = DECLARE_CALL_FRAME(vm); +IGNORE_WARNINGS_END +JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); +return Reader__u32__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__u32__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { + return Reader__u32__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); +} + +extern "C" void Reader__u32__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { + JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_u32_signature( + Reader__u32__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt32Only, + JSC::SpecInt52Any, + JSC::SpecInt32Only + ); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("u32"_s), + Reader__u32__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u32__slowpathWrapper, + &DOMJIT_u32_signature + ); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "u32"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 + ); +} + + + +extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__ptr__slowpathWrapper); +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { +VM& vm = JSC::getVM(lexicalGlobalObject); +IGNORE_WARNINGS_BEGIN("frame-address") +CallFrame* callFrame = DECLARE_CALL_FRAME(vm); +IGNORE_WARNINGS_END +JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); +return Reader__ptr__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__ptr__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { + return Reader__ptr__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); +} + +extern "C" void Reader__ptr__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { + JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_ptr_signature( + Reader__ptr__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecHeapTop, + JSC::SpecInt52Any, + JSC::SpecInt32Only + ); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("ptr"_s), + Reader__ptr__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__ptr__slowpathWrapper, + &DOMJIT_ptr_signature + ); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "ptr"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 + ); +} + + + +extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__i8__slowpathWrapper); +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__i8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { +VM& vm = JSC::getVM(lexicalGlobalObject); +IGNORE_WARNINGS_BEGIN("frame-address") +CallFrame* callFrame = DECLARE_CALL_FRAME(vm); +IGNORE_WARNINGS_END +JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); +return Reader__i8__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__i8__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { + return Reader__i8__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); +} + +extern "C" void Reader__i8__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { + JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_i8_signature( + Reader__i8__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt32Only, + JSC::SpecInt52Any, + JSC::SpecInt32Only + ); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("i8"_s), + Reader__i8__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i8__slowpathWrapper, + &DOMJIT_i8_signature + ); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "i8"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 + ); +} + + + +extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__i16__slowpathWrapper); +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__i16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { +VM& vm = JSC::getVM(lexicalGlobalObject); +IGNORE_WARNINGS_BEGIN("frame-address") +CallFrame* callFrame = DECLARE_CALL_FRAME(vm); +IGNORE_WARNINGS_END +JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); +return Reader__i16__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__i16__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { + return Reader__i16__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); +} + +extern "C" void Reader__i16__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { + JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_i16_signature( + Reader__i16__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt32Only, + JSC::SpecInt52Any, + JSC::SpecInt32Only + ); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("i16"_s), + Reader__i16__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i16__slowpathWrapper, + &DOMJIT_i16_signature + ); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "i16"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 + ); +} + + + +extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__i32__slowpathWrapper); +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__i32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { +VM& vm = JSC::getVM(lexicalGlobalObject); +IGNORE_WARNINGS_BEGIN("frame-address") +CallFrame* callFrame = DECLARE_CALL_FRAME(vm); +IGNORE_WARNINGS_END +JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); +return Reader__i32__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__i32__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { + return Reader__i32__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); +} + +extern "C" void Reader__i32__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { + JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_i32_signature( + Reader__i32__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt32Only, + JSC::SpecInt52Any, + JSC::SpecInt32Only + ); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("i32"_s), + Reader__i32__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i32__slowpathWrapper, + &DOMJIT_i32_signature + ); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "i32"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 + ); +} + + + +extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__intptr__slowpathWrapper); +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__intptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__intptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { +VM& vm = JSC::getVM(lexicalGlobalObject); +IGNORE_WARNINGS_BEGIN("frame-address") +CallFrame* callFrame = DECLARE_CALL_FRAME(vm); +IGNORE_WARNINGS_END +JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); +return Reader__intptr__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__intptr__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { + return Reader__intptr__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); +} + +extern "C" void Reader__intptr__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { + JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_intptr_signature( + Reader__intptr__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecHeapTop, + JSC::SpecInt52Any, + JSC::SpecInt32Only + ); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("intptr"_s), + Reader__intptr__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__intptr__slowpathWrapper, + &DOMJIT_intptr_signature + ); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "intptr"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 + ); +} + + /* -- END DOMCall DEFINITIONS-- */ diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index a8faef56c..84d3c2bc2 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -2581,16 +2581,12 @@ pub const JSValue = enum(JSValueReprInt) { ?*JSPromise => asPromise(this), u52 => @truncate(u52, @intCast(u64, @maximum(this.toInt64(), 0))), - u64 => toUInt64NoTruncate(this), - u8 => @truncate(u8, toU32(this)), i16 => @truncate(i16, toInt32(this)), i8 => @truncate(i8, toInt32(this)), i32 => @truncate(i32, toInt32(this)), - i64 => this.toInt64(), - bool => this.toBoolean(), else => @compileError("Not implemented yet"), }; @@ -2735,9 +2731,7 @@ pub const JSValue = enum(JSValueReprInt) { JSValue => number, f64 => jsNumberFromDouble(number), u8 => jsNumberFromChar(number), - u16 => jsNumberFromInt32(@intCast(i32, number)), - i32 => jsNumberFromInt32(@intCast(i32, number)), - c_int => jsNumberFromInt32(@intCast(i32, number)), + i16, i32, c_int, i8, u16 => jsNumberFromInt32(@intCast(i32, number)), i64 => jsNumberFromInt64(@intCast(i64, number)), c_uint => jsNumberFromUint64(@intCast(u64, number)), u64 => jsNumberFromUint64(@intCast(u64, number)), @@ -3216,13 +3210,17 @@ pub const JSValue = enum(JSValueReprInt) { } pub fn asPtr(this: JSValue, comptime Pointer: type) *Pointer { - return @intToPtr(*Pointer, @bitCast(usize, this.asDouble())); + return @intToPtr(*Pointer, this.asPtrAddress()); } pub fn fromPtrAddress(addr: anytype) JSValue { return jsNumber(@bitCast(f64, @as(usize, addr))); } + pub fn asPtrAddress(this: JSValue) usize { + return @bitCast(usize, this.asDouble()); + } + pub fn fromPtr(addr: anytype) JSValue { return fromPtrAddress(@ptrToInt(addr)); } @@ -4215,7 +4213,15 @@ pub fn JSPropertyIterator(comptime options: JSPropertyIteratorOptions) type { // DOMCall Fields pub const __DOMCall_ptr = @import("../api/bun.zig").FFI.Class.functionDefinitions.ptr; - +pub const __DOMCall__reader_u8 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.@"u8"; +pub const __DOMCall__reader_u16 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.@"u16"; +pub const __DOMCall__reader_u32 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.@"u32"; +pub const __DOMCall__reader_ptr = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.@"ptr"; +pub const __DOMCall__reader_i8 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.@"i8"; +pub const __DOMCall__reader_i16 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.@"i16"; +pub const __DOMCall__reader_i32 = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.@"i32"; +pub const __DOMCall__reader_intptr = @import("../api/bun.zig").FFI.Reader.Class.functionDefinitions.@"intptr"; pub const DOMCalls = .{ @import("../api/bun.zig").FFI, + @import("../api/bun.zig").FFI.Reader, }; diff --git a/src/bun.js/bindings/headers-cpp.h b/src/bun.js/bindings/headers-cpp.h index 310c64eef..fa856aeb1 100644 --- a/src/bun.js/bindings/headers-cpp.h +++ b/src/bun.js/bindings/headers-cpp.h @@ -1,4 +1,4 @@ -//-- AUTOGENERATED FILE -- 1661660599 +//-- AUTOGENERATED FILE -- 1662704581 // clang-format off #pragma once @@ -240,8 +240,8 @@ extern "C" const size_t Zig__ConsoleClient_object_align_ = alignof(Zig::ConsoleC extern "C" const size_t Bun__Timer_object_size_ = sizeof(Bun__Timer); extern "C" const size_t Bun__Timer_object_align_ = alignof(Bun__Timer); -const size_t sizes[33] = {sizeof(JSC::JSObject), sizeof(WebCore::DOMURL), sizeof(WebCore::FetchHeaders), sizeof(SystemError), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(Inspector::ScriptArguments), sizeof(JSC::JSModuleLoader), sizeof(JSC::JSModuleRecord), sizeof(JSC::JSPromise), sizeof(JSC::JSInternalPromise), sizeof(JSC::SourceOrigin), sizeof(JSC::SourceCode), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(WTF::URL), sizeof(WTF::String), sizeof(JSC::JSValue), sizeof(JSC::PropertyName), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::CatchScope), sizeof(JSC::Identifier), sizeof(WTF::StringImpl), sizeof(WTF::ExternalStringImpl), sizeof(WTF::StringView), sizeof(FFI__ptr), sizeof(Zig::GlobalObject), sizeof(Bun__Path), sizeof(ArrayBufferSink), sizeof(HTTPSResponseSink), sizeof(HTTPResponseSink)}; +const size_t sizes[41] = {sizeof(JSC::JSObject), sizeof(WebCore::DOMURL), sizeof(WebCore::FetchHeaders), sizeof(SystemError), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(Inspector::ScriptArguments), sizeof(JSC::JSModuleLoader), sizeof(JSC::JSModuleRecord), sizeof(JSC::JSPromise), sizeof(JSC::JSInternalPromise), sizeof(JSC::SourceOrigin), sizeof(JSC::SourceCode), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(WTF::URL), sizeof(WTF::String), sizeof(JSC::JSValue), sizeof(JSC::PropertyName), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::CatchScope), sizeof(JSC::Identifier), sizeof(WTF::StringImpl), sizeof(WTF::ExternalStringImpl), sizeof(WTF::StringView), 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__intptr), sizeof(Zig::GlobalObject), sizeof(Bun__Path), sizeof(ArrayBufferSink), sizeof(HTTPSResponseSink), sizeof(HTTPResponseSink)}; -const char* names[33] = {"JSC__JSObject", "WebCore__DOMURL", "WebCore__FetchHeaders", "SystemError", "JSC__JSCell", "JSC__JSString", "Inspector__ScriptArguments", "JSC__JSModuleLoader", "JSC__JSModuleRecord", "JSC__JSPromise", "JSC__JSInternalPromise", "JSC__SourceOrigin", "JSC__SourceCode", "JSC__JSFunction", "JSC__JSGlobalObject", "WTF__URL", "WTF__String", "JSC__JSValue", "JSC__PropertyName", "JSC__Exception", "JSC__VM", "JSC__ThrowScope", "JSC__CatchScope", "JSC__Identifier", "WTF__StringImpl", "WTF__ExternalStringImpl", "WTF__StringView", "FFI__ptr", "Zig__GlobalObject", "Bun__Path", "ArrayBufferSink", "HTTPSResponseSink", "HTTPResponseSink"}; +const char* names[41] = {"JSC__JSObject", "WebCore__DOMURL", "WebCore__FetchHeaders", "SystemError", "JSC__JSCell", "JSC__JSString", "Inspector__ScriptArguments", "JSC__JSModuleLoader", "JSC__JSModuleRecord", "JSC__JSPromise", "JSC__JSInternalPromise", "JSC__SourceOrigin", "JSC__SourceCode", "JSC__JSFunction", "JSC__JSGlobalObject", "WTF__URL", "WTF__String", "JSC__JSValue", "JSC__PropertyName", "JSC__Exception", "JSC__VM", "JSC__ThrowScope", "JSC__CatchScope", "JSC__Identifier", "WTF__StringImpl", "WTF__ExternalStringImpl", "WTF__StringView", "FFI__ptr", "Reader__u8", "Reader__u16", "Reader__u32", "Reader__ptr", "Reader__i8", "Reader__i16", "Reader__i32", "Reader__intptr", "Zig__GlobalObject", "Bun__Path", "ArrayBufferSink", "HTTPSResponseSink", "HTTPResponseSink"}; -const size_t aligns[33] = {alignof(JSC::JSObject), alignof(WebCore::DOMURL), alignof(WebCore::FetchHeaders), alignof(SystemError), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(Inspector::ScriptArguments), alignof(JSC::JSModuleLoader), alignof(JSC::JSModuleRecord), alignof(JSC::JSPromise), alignof(JSC::JSInternalPromise), alignof(JSC::SourceOrigin), alignof(JSC::SourceCode), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(WTF::URL), alignof(WTF::String), alignof(JSC::JSValue), alignof(JSC::PropertyName), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::CatchScope), alignof(JSC::Identifier), alignof(WTF::StringImpl), alignof(WTF::ExternalStringImpl), alignof(WTF::StringView), alignof(FFI__ptr), alignof(Zig::GlobalObject), alignof(Bun__Path), alignof(ArrayBufferSink), alignof(HTTPSResponseSink), alignof(HTTPResponseSink)}; +const size_t aligns[41] = {alignof(JSC::JSObject), alignof(WebCore::DOMURL), alignof(WebCore::FetchHeaders), alignof(SystemError), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(Inspector::ScriptArguments), alignof(JSC::JSModuleLoader), alignof(JSC::JSModuleRecord), alignof(JSC::JSPromise), alignof(JSC::JSInternalPromise), alignof(JSC::SourceOrigin), alignof(JSC::SourceCode), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(WTF::URL), alignof(WTF::String), alignof(JSC::JSValue), alignof(JSC::PropertyName), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::CatchScope), alignof(JSC::Identifier), alignof(WTF::StringImpl), alignof(WTF::ExternalStringImpl), alignof(WTF::StringView), 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__intptr), alignof(Zig::GlobalObject), alignof(Bun__Path), alignof(ArrayBufferSink), alignof(HTTPSResponseSink), alignof(HTTPResponseSink)}; diff --git a/src/bun.js/bindings/headers.h b/src/bun.js/bindings/headers.h index 6d32dacdf..d5011fc76 100644 --- a/src/bun.js/bindings/headers.h +++ b/src/bun.js/bindings/headers.h @@ -1,5 +1,5 @@ // clang-format off -//-- AUTOGENERATED FILE -- 1661660599 +//-- AUTOGENERATED FILE -- 1662704581 #pragma once #include <stddef.h> @@ -654,6 +654,70 @@ ZIG_DECL JSC__JSValue FFI__ptr__fastpath(JSC__JSGlobalObject* arg0, void* arg1, ZIG_DECL JSC__JSValue FFI__ptr__slowpath(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue* arg2, size_t arg3); #endif +CPP_DECL void Reader__u8__put(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); + +#ifdef __cplusplus + +ZIG_DECL JSC__JSValue Reader__u8__fastpath(JSC__JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); +ZIG_DECL JSC__JSValue Reader__u8__slowpath(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue* arg2, size_t arg3); + +#endif +CPP_DECL void Reader__u16__put(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); + +#ifdef __cplusplus + +ZIG_DECL JSC__JSValue Reader__u16__fastpath(JSC__JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); +ZIG_DECL JSC__JSValue Reader__u16__slowpath(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue* arg2, size_t arg3); + +#endif +CPP_DECL void Reader__u32__put(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); + +#ifdef __cplusplus + +ZIG_DECL JSC__JSValue Reader__u32__fastpath(JSC__JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); +ZIG_DECL JSC__JSValue Reader__u32__slowpath(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue* arg2, size_t arg3); + +#endif +CPP_DECL void Reader__ptr__put(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); + +#ifdef __cplusplus + +ZIG_DECL JSC__JSValue Reader__ptr__fastpath(JSC__JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); +ZIG_DECL JSC__JSValue Reader__ptr__slowpath(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue* arg2, size_t arg3); + +#endif +CPP_DECL void Reader__i8__put(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); + +#ifdef __cplusplus + +ZIG_DECL JSC__JSValue Reader__i8__fastpath(JSC__JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); +ZIG_DECL JSC__JSValue Reader__i8__slowpath(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue* arg2, size_t arg3); + +#endif +CPP_DECL void Reader__i16__put(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); + +#ifdef __cplusplus + +ZIG_DECL JSC__JSValue Reader__i16__fastpath(JSC__JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); +ZIG_DECL JSC__JSValue Reader__i16__slowpath(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue* arg2, size_t arg3); + +#endif +CPP_DECL void Reader__i32__put(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); + +#ifdef __cplusplus + +ZIG_DECL JSC__JSValue Reader__i32__fastpath(JSC__JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); +ZIG_DECL JSC__JSValue Reader__i32__slowpath(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue* arg2, size_t arg3); + +#endif +CPP_DECL void Reader__intptr__put(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); + +#ifdef __cplusplus + +ZIG_DECL JSC__JSValue Reader__intptr__fastpath(JSC__JSGlobalObject* arg0, void* arg1, int64_t arg2, int32_t arg3); +ZIG_DECL JSC__JSValue Reader__intptr__slowpath(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue* arg2, size_t arg3); + +#endif #pragma mark - Zig::GlobalObject diff --git a/src/bun.js/bindings/headers.zig b/src/bun.js/bindings/headers.zig index 7aedef63f..4c2172404 100644 --- a/src/bun.js/bindings/headers.zig +++ b/src/bun.js/bindings/headers.zig @@ -411,6 +411,14 @@ pub extern fn WTF__StringView__is8Bit(arg0: [*c]const WTF__StringView) bool; pub extern fn WTF__StringView__isEmpty(arg0: [*c]const WTF__StringView) bool; pub extern fn WTF__StringView__length(arg0: [*c]const WTF__StringView) usize; pub extern fn FFI__ptr__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__u8__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__u16__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__u32__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__ptr__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__i8__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__i16__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__i32__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; +pub extern fn Reader__intptr__put(arg0: ?*JSC__JSGlobalObject, JSValue1: JSC__JSValue) void; pub extern fn Zig__GlobalObject__create(arg0: [*c]JSClassRef, arg1: i32, arg2: ?*anyopaque) ?*JSC__JSGlobalObject; pub extern fn Zig__GlobalObject__getModuleRegistryMap(arg0: ?*JSC__JSGlobalObject) ?*anyopaque; pub extern fn Zig__GlobalObject__resetModuleRegistryMap(arg0: ?*JSC__JSGlobalObject, arg1: ?*anyopaque) bool; diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig index 9e60a7539..54a5af1a8 100644 --- a/src/bun.js/event_loop.zig +++ b/src/bun.js/event_loop.zig @@ -470,12 +470,14 @@ pub const EventLoop = struct { } pub fn ensureWaker(this: *EventLoop) void { + JSC.markBinding(); if (this.waker == null) { this.waker = AsyncIO.Waker.init(this.virtual_machine.allocator) catch unreachable; } } pub fn enqueueTaskConcurrent(this: *EventLoop, task: Task) void { + JSC.markBinding(); this.concurrent_lock.lock(); defer this.concurrent_lock.unlock(); this.concurrent_tasks.writeItem(task) catch unreachable; diff --git a/src/bun.js/ffi.exports.js b/src/bun.js/ffi.exports.js index 52dd6d0d4..e537ee4d7 100644 --- a/src/bun.js/ffi.exports.js +++ b/src/bun.js/ffi.exports.js @@ -385,3 +385,5 @@ export function CFunction(options) { export function callback(options, cb) { return nativeCallback(options, cb); } + +export const read = ffi.read; diff --git a/test/bun.js/ffi.test.js b/test/bun.js/ffi.test.js index 778719910..72847788d 100644 --- a/test/bun.js/ffi.test.js +++ b/test/bun.js/ffi.test.js @@ -12,6 +12,7 @@ import { FFIType, callback, CFunction, + read, } from "bun:ffi"; const dlopen = (...args) => { @@ -613,6 +614,28 @@ function ffiRunner(fast) { // ffiRunner(true); // }); +it("FFI.read", () => { + const buffer = new BigInt64Array(64); + const view = new DataView(buffer.buffer); + const ptr_ = ptr(buffer); + + for (let i = 0; i < 64; i++) { + buffer[i] = BigInt(i); + expect(read.intptr(ptr_, i * 8)).toBe( + Number(view.getBigInt64(i * 8, true)) + ); + expect(read.ptr(ptr_, i * 8)).toBe(Number(view.getBigUint64(i * 8, true))); + } + for (let i = 0; i < buffer.byteLength / 4; i++) { + expect(read.i8(ptr_, i)).toBe(view.getInt8(i, true)); + expect(read.i16(ptr_, i)).toBe(view.getInt16(i, true)); + expect(read.i32(ptr_, i)).toBe(view.getInt32(i, true)); + expect(read.u8(ptr_, i)).toBe(view.getUint8(i, true)); + expect(read.u16(ptr_, i)).toBe(view.getUint16(i, true)); + expect(read.u32(ptr_, i)).toBe(view.getUint32(i, true)); + } +}); + it("run ffi", () => { ffiRunner(false); }); |