diff --git a/.gitattributes b/.gitattributes
index 842c0220db..ef212175fd 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -4,3 +4,4 @@ src/api/schema.js linguist-generated
src/javascript/jsc/bindings/sqlite/sqlite3.c linguist-vendored
src/javascript/jsc/bindings/sqlite/sqlite3_local.h linguist-vendored
*.lockb binary diff=lockb
+*.zig text eol=lf
diff --git a/.gitignore b/.gitignore
index 57069591ff..e8b5f0f8d1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -99,3 +99,6 @@ packages/bun-wasm/*.d.ts
src/fallback.version
src/runtime.version
+*.sqlite
+*.database
+*.db
diff --git a/Makefile b/Makefile
index 8494a10a0b..751fc55a93 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ endif
AR=
-
+CXX_VERSION=c++2a
TRIPLET = $(OS_NAME)-$(ARCH_NAME)
PACKAGE_NAME = bun-$(TRIPLET)
PACKAGES_REALPATH = $(realpath packages)
@@ -49,6 +49,7 @@ PRETTIER ?= $(shell which prettier || echo "./node_modules/.bin/prettier")
DSYMUTIL ?= $(shell which dsymutil || which dsymutil-13)
WEBKIT_DIR ?= $(realpath src/javascript/jsc/WebKit)
WEBKIT_RELEASE_DIR ?= $(WEBKIT_DIR)/WebKitBuild/Release
+WEBKIT_RELEASE_DIR_LTO ?= $(WEBKIT_DIR)/WebKitBuild/ReleaseLTO
NPM_CLIENT ?= $(shell which bun || which npm)
ZIG ?= $(shell which zig || echo -e "error: Missing zig. Please make sure zig is in PATH. Or set ZIG=/path/to-zig-executable")
@@ -97,7 +98,7 @@ LIBTOOL=libtoolize
ifeq ($(OS_NAME),darwin)
LIBTOOL=glibtoolize
AR=$(LLVM_PREFIX)/bin/llvm-ar
-BITCODE_OR_SECTIONS=
+BITCODE_OR_SECTIONS=-fembed-bitcode
endif
ifeq ($(OS_NAME),linux)
@@ -120,22 +121,28 @@ USE_BMALLOC ?= DEFAULT_USE_BMALLOC
JSC_BASE_DIR ?= ${HOME}/webkit-build
DEFAULT_JSC_LIB :=
+DEFAULT_JSC_LIB_DEBUG :=
ifeq ($(OS_NAME),linux)
DEFAULT_JSC_LIB = $(JSC_BASE_DIR)/lib
+DEFAULT_JSC_LIB_DEBUG = $(DEFAULT_JSC_LIB)
endif
ifeq ($(OS_NAME),darwin)
-DEFAULT_JSC_LIB = $(BUN_DEPS_DIR)
+DEFAULT_JSC_LIB = $(WEBKIT_RELEASE_DIR_LTO)/lib
+DEFAULT_JSC_LIB_DEBUG = $(WEBKIT_RELEASE_DIR)/lib
endif
JSC_LIB ?= $(DEFAULT_JSC_LIB)
+JSC_LIB_DEBUG ?= $(DEFAULT_JSC_LIB_DEBUG)
JSC_INCLUDE_DIR ?= $(JSC_BASE_DIR)/include
ZLIB_INCLUDE_DIR ?= $(BUN_DEPS_DIR)/zlib
ZLIB_LIB_DIR ?= $(BUN_DEPS_DIR)/zlib
-JSC_FILES := $(JSC_LIB)/libJavaScriptCore.a $(JSC_LIB)/libWTF.a $(JSC_LIB)/libbmalloc.a
+JSC_FILES := $(JSC_LIB)/libJavaScriptCore.a $(JSC_LIB)/libWTF.a $(JSC_LIB)/libbmalloc.a $(JSC_LIB)/libLowLevelInterpreterLib.a
+JSC_FILES_DEBUG := $(JSC_LIB_DEBUG)/libJavaScriptCore.a $(JSC_LIB_DEBUG)/libWTF.a $(JSC_LIB_DEBUG)/libbmalloc.a $(JSC_LIB_DEBUG)/libLowLevelInterpreterLib.a
+
ENABLE_MIMALLOC ?= 1
@@ -260,11 +267,12 @@ endif
BORINGSSL_PACKAGE = --pkg-begin boringssl $(BUN_DEPS_DIR)/boringssl.zig --pkg-end
CLANG_FLAGS = $(INCLUDE_DIRS) \
- -std=gnu++17 \
+ -std=$(CXX_VERSION) \
-DSTATICALLY_LINKED_WITH_JavaScriptCore=1 \
-DSTATICALLY_LINKED_WITH_WTF=1 \
-DSTATICALLY_LINKED_WITH_BMALLOC=1 \
-DBUILDING_WITH_CMAKE=1 \
+ -DBUN_SINGLE_THREADED_PER_VM_ENTRY_SCOPE=1 \
-DNDEBUG=1 \
-DNOMINMAX \
-DIS_BUILD \
@@ -293,7 +301,8 @@ endif
SHARED_LIB_EXTENSION = .so
-JSC_BINDINGS = $(JSC_FILES) $(BINDINGS_OBJ)
+JSC_BINDINGS = $(BINDINGS_OBJ) $(JSC_FILES)
+JSC_BINDINGS_DEBUG = $(BINDINGS_OBJ) $(JSC_FILES_DEBUG)
RELEASE_FLAGS=
DEBUG_FLAGS=
@@ -350,11 +359,14 @@ BUN_LLD_FLAGS_WITHOUT_JSC = $(ARCHIVE_FILES) \
$(LIBICONV_PATH) \
$(CLANG_FLAGS) \
$(DEFAULT_LINKER_FLAGS) \
- $(PLATFORM_LINKER_FLAGS)
+ $(PLATFORM_LINKER_FLAGS) \
+ $(SQLITE_OBJECT) ${ICU_FLAGS}
-BUN_LLD_FLAGS = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_BINDINGS) $(SQLITE_OBJECT) ${ICU_FLAGS}
+BUN_LLD_FLAGS = $(BUN_LLD_FLAGS_WITHOUT_JSC) $(JSC_FILES) $(BINDINGS_OBJ)
+
+BUN_LLD_FLAGS_DEBUG = $(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]}}}')
@@ -364,8 +376,8 @@ bun:
base64:
cd src/base64 && \
rm -rf src/base64/*.{o,ll,bc} && \
- $(CC) $(CFLAGS) $(OPTIMIZATION_LEVEL) -g -fPIC -c *.c -I$(SRC_DIR)/base64 -emit-llvm && \
- $(CXX) $(CXXFLAGS) $(CFLAGS) -c neonbase64.cc -g -fPIC -emit-llvm && \
+ $(CC) $(CFLAGS) $(OPTIMIZATION_LEVEL) -g -fPIC -c *.c -I$(SRC_DIR)/base64 $(BITCODE_OR_SECTIONS) && \
+ $(CXX) $(CXXFLAGS) $(CFLAGS) -c neonbase64.cc -g -fPIC $(BITCODE_OR_SECTIONS) && \
$(AR) rcvs $(BUN_DEPS_OUT_DIR)/libbase64.a ./*.bc
# Prevent dependency on libtcc1 so it doesn't do filesystem lookups
@@ -379,7 +391,7 @@ tinycc:
cp $(TINYCC_DIR)/*.a $(BUN_DEPS_OUT_DIR)
generate-builtins:
- rm -f src/javascript/jsc/bindings/WebCoreBuiltins.cpp src/javascript/jsc/bindings/WebCoreBuiltins.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp src/javascript/jsc/bindings/WebCore*Builtins* || echo ""
+ rm -f src/javascript/jsc/bindings/WebCoreBuiltins.cpp src/javascript/jsc/bindings/WebCoreBuiltins.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp src/javascript/jsc/bindings/*Strategy*Builtins* src/javascript/jsc/bindings/*Stream*Builtins* src/javascript/jsc/bindings/WebCore*Builtins* || echo ""
$(shell which python || which python2) $(realpath $(WEBKIT_DIR)/Source/JavaScriptCore/Scripts/generate-js-builtins.py) -i $(realpath src/javascript/jsc/bindings/builtins/js) -o $(realpath src/javascript/jsc/bindings) --framework WebCore --force
$(shell which python || which python2) $(realpath $(WEBKIT_DIR)/Source/JavaScriptCore/Scripts/generate-js-builtins.py) -i $(realpath src/javascript/jsc/bindings/builtins/js) -o $(realpath src/javascript/jsc/bindings) --framework WebCore --wrappers-only
echo '//clang-format off' > /tmp/1.h
@@ -393,9 +405,6 @@ generate-builtins:
cat /tmp/1.h src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h > src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h.1
mv src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h.1 src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h
$(SED) -i -e 's/class JSDOMGlobalObject/using JSDOMGlobalObject = Zig::GlobalObject/' src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h
-# Since we don't currently support web streams, we don't need this line
-# so we comment it out
- $(SED) -i -e 's/globalObject.addStaticGlobals/\/\/globalObject.addStaticGlobals/' src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp
# We delete this file because our script already builds all .cpp files
# We will get duplicate symbols if we don't delete it
rm src/javascript/jsc/bindings/WebCoreJSBuiltins.cpp
@@ -551,7 +560,7 @@ build-obj-safe:
$(ZIG) build obj -Drelease-safe
UWS_CC_FLAGS = -pthread -DLIBUS_USE_OPENSSL=1 -DUWS_HTTPRESPONSE_NO_WRITEMARK=1 -DLIBUS_USE_BORINGSSL=1 -DWITH_BORINGSSL=1 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion $(UWS_INCLUDE) -DUWS_WITH_PROXY
-UWS_CXX_FLAGS = $(UWS_CC_FLAGS) -std=gnu++17 -fno-exceptions
+UWS_CXX_FLAGS = $(UWS_CC_FLAGS) -std=$(CXX_VERSION) -fno-exceptions
UWS_LDFLAGS = -I$(BUN_DEPS_DIR)/boringssl/include -I$(ZLIB_INCLUDE_DIR)
USOCKETS_DIR = $(BUN_DEPS_DIR)/uws/uSockets/
USOCKETS_SRC_DIR = $(BUN_DEPS_DIR)/uws/uSockets/src/
@@ -562,7 +571,7 @@ usockets:
cd $(USOCKETS_DIR) && $(CXX) $(MACOS_MIN_FLAG) -fPIC $(CXXFLAGS) $(UWS_CXX_FLAGS) -save-temps -flto -I$(BUN_DEPS_DIR)/uws/uSockets/src $(UWS_LDFLAGS) -g $(DEFAULT_LINKER_FLAGS) $(PLATFORM_LINKER_FLAGS) $(OPTIMIZATION_LEVEL) -g -c $(wildcard $(USOCKETS_SRC_DIR)/*.cpp) $(wildcard $(USOCKETS_SRC_DIR)/**/*.cpp)
cd $(USOCKETS_DIR) && $(AR) rcvs $(BUN_DEPS_OUT_DIR)/libusockets.a *.o *.ii *.bc *.i
uws: usockets
- $(CXX) -emit-llvm -fPIC -I$(BUN_DEPS_DIR)/uws/uSockets/src $(CLANG_FLAGS) $(CFLAGS) $(UWS_CXX_FLAGS) $(UWS_LDFLAGS) $(PLATFORM_LINKER_FLAGS) -c -I$(BUN_DEPS_DIR) $(BUN_DEPS_OUT_DIR)/libusockets.a $(BUN_DEPS_DIR)/libuwsockets.cpp -o $(BUN_DEPS_OUT_DIR)/libuwsockets.o
+ $(CXX) $(BITCODE_OR_SECTIONS) -fPIC -I$(BUN_DEPS_DIR)/uws/uSockets/src $(CLANG_FLAGS) $(CFLAGS) $(UWS_CXX_FLAGS) $(UWS_LDFLAGS) $(PLATFORM_LINKER_FLAGS) -c -I$(BUN_DEPS_DIR) $(BUN_DEPS_OUT_DIR)/libusockets.a $(BUN_DEPS_DIR)/libuwsockets.cpp -o $(BUN_DEPS_OUT_DIR)/libuwsockets.o
@@ -698,7 +707,7 @@ jsc-bindings-headers:
touch src/javascript/jsc/bindings/headers.zig
mkdir -p src/javascript/jsc/bindings-obj/
$(ZIG) build headers-obj
- $(CXX) $(PLATFORM_LINKER_FLAGS) $(JSC_FILES) ${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} $(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/javascript/jsc/bindings/headers.h > src/javascript/jsc/bindings/headers.zig
$(ZIG) run misctools/headers-cleaner.zig -lc
@@ -926,6 +935,36 @@ jsc-copy-headers:
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/LazyPropertyInlines.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/LazyPropertyInlines.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/JSTypedArrayViewPrototype.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JSTypedArrayViewPrototype.h
cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JSTypedArrayPrototypes.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JIT.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JIT.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/StructureStubInfo.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/StructureStubInfo.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/PolymorphicAccess.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/PolymorphicAccess.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/AccessCase.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/AccessCase.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/ObjectPropertyConditionSet.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/ObjectPropertyConditionSet.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/PolyProtoAccessChain.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/PolyProtoAccessChain.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/PutKind.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/PutKind.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/StructureStubClearingWatchpoint.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/StructureStubClearingWatchpoint.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/AdaptiveInferredPropertyValueWatchpointBase.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/AdaptiveInferredPropertyValueWatchpointBase.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/StubInfoSummary.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/StubInfoSummary.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/CommonSlowPaths.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/CommonSlowPaths.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/DirectArguments.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/DirectArguments.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/GenericArguments.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/GenericArguments.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/ScopedArguments.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/ScopedArguments.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/runtime/JSLexicalEnvironment.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JSLexicalEnvironment.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITDisassembler.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITDisassembler.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITInlineCacheGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITInlineCacheGenerator.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITMathIC.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITMathIC.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITAddGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITAddGenerator.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITMathICInlineResult.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITMathICInlineResult.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/SnippetOperand.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/SnippetOperand.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITMulGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITMulGenerator.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITNegGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITNegGenerator.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITSubGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITSubGenerator.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/Repatch.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/Repatch.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITRightShiftGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITRightShiftGenerator.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JITBitBinaryOpGenerator.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JITBitBinaryOpGenerator.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/jit/JSInterfaceJIT.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/JSInterfaceJIT.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/llint/LLIntData.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/LLIntData.h
+ cp $(WEBKIT_DIR)/Source/JavaScriptCore/bytecode/FunctionCodeBlock.h $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/FunctionCodeBlock.h
find $(WEBKIT_RELEASE_DIR)/JavaScriptCore/Headers/JavaScriptCore/ -name "*.h" -exec cp {} $(WEBKIT_RELEASE_DIR)/JavaScriptCore/PrivateHeaders/JavaScriptCore/ \;
# This is a workaround for a JSC bug that impacts aarch64
@@ -934,7 +973,6 @@ jsc-force-fastjit:
$(SED) -i "s/USE(PTHREAD_JIT_PERMISSIONS_API)/CPU(ARM64)/g" $(WEBKIT_DIR)/Source/JavaScriptCore/jit/ExecutableAllocator.h
$(SED) -i "s/USE(PTHREAD_JIT_PERMISSIONS_API)/CPU(ARM64)/g" $(WEBKIT_DIR)/Source/JavaScriptCore/assembler/FastJITPermissions.h
$(SED) -i "s/USE(PTHREAD_JIT_PERMISSIONS_API)/CPU(ARM64)/g" $(WEBKIT_DIR)/Source/JavaScriptCore/jit/ExecutableAllocator.cpp
- $(SED) -i "s/GIGACAGE_ENABLED/0/g" $(WEBKIT_DIR)/Source/WTF/wtf/Gigacage.h
jsc-build-mac-compile:
mkdir -p $(WEBKIT_RELEASE_DIR) $(WEBKIT_DIR);
@@ -943,21 +981,43 @@ jsc-build-mac-compile:
cmake \
-DPORT="JSCOnly" \
-DENABLE_STATIC_JSC=ON \
+ -DENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE=ON \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_THIN_ARCHIVES=OFF \
-DENABLE_FTL_JIT=ON \
- -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-G Ninja \
$(CMAKE_FLAGS_WITHOUT_RELEASE) \
-DPTHREAD_JIT_PERMISSIONS_API=1 \
-DUSE_PTHREAD_JIT_PERMISSIONS_API=ON \
-DENABLE_REMOTE_INSPECTOR=ON \
- -DUSE_VISIBILITY_ATTRIBUTE=1 \
$(WEBKIT_DIR) \
$(WEBKIT_RELEASE_DIR) && \
- CFLAGS="$(CFLAGS) -emit-llvm -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -emit-llvm -ffat-lto-objects" \
+ CFLAGS="$(CFLAGS) $(BITCODE_OR_SECTIONS) -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) $(BITCODE_OR_SECTIONS) -ffat-lto-objects" \
cmake --build $(WEBKIT_RELEASE_DIR) --config Release --target jsc
+jsc-build-mac-compile-lto:
+ mkdir -p $(WEBKIT_RELEASE_DIR_LTO) $(WEBKIT_DIR);
+ cd $(WEBKIT_RELEASE_DIR_LTO) && \
+ ICU_INCLUDE_DIRS="$(HOMEBREW_PREFIX)opt/icu4c/include" \
+ cmake \
+ -DPORT="JSCOnly" \
+ -DENABLE_STATIC_JSC=ON \
+ -DENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE=ON \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DUSE_THIN_ARCHIVES=OFF \
+ -DCMAKE_C_FLAGS="-flto=full" \
+ -DCMAKE_CXX_FLAGS="-flto=full" \
+ -DENABLE_FTL_JIT=ON \
+ -G Ninja \
+ $(CMAKE_FLAGS_WITHOUT_RELEASE) \
+ -DPTHREAD_JIT_PERMISSIONS_API=1 \
+ -DUSE_PTHREAD_JIT_PERMISSIONS_API=ON \
+ -DENABLE_REMOTE_INSPECTOR=ON \
+ $(WEBKIT_DIR) \
+ $(WEBKIT_RELEASE_DIR_LTO) && \
+ CFLAGS="$(CFLAGS) -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -ffat-lto-objects" \
+ cmake --build $(WEBKIT_RELEASE_DIR_LTO) --config Release --target jsc
+
jsc-build-mac-compile-debug:
mkdir -p $(WEBKIT_RELEASE_DIR) $(WEBKIT_DIR);
cd $(WEBKIT_RELEASE_DIR) && \
@@ -977,7 +1037,7 @@ jsc-build-mac-compile-debug:
-DUSE_VISIBILITY_ATTRIBUTE=1 \
$(WEBKIT_DIR) \
$(WEBKIT_RELEASE_DIR) && \
- CFLAGS="$(CFLAGS) -emit-llvm -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -ffat-lto-objects" \
+ CFLAGS="$(CFLAGS) -ffat-lto-objects" CXXFLAGS="$(CXXFLAGS) -ffat-lto-objects" \
cmake --build $(WEBKIT_RELEASE_DIR) --config Debug --target jsc
jsc-build-linux-compile-config:
@@ -1014,6 +1074,7 @@ jsc-build-linux: jsc-build-linux-compile-config jsc-build-linux-compile-build js
jsc-build-mac-copy:
cp $(WEBKIT_RELEASE_DIR)/lib/libJavaScriptCore.a $(BUN_DEPS_OUT_DIR)/libJavaScriptCore.a
+ cp $(WEBKIT_RELEASE_DIR)/lib/libLowLevelInterpreterLib.a $(BUN_DEPS_OUT_DIR)/libLowLevelInterpreterLib.a
cp $(WEBKIT_RELEASE_DIR)/lib/libWTF.a $(BUN_DEPS_OUT_DIR)/libWTF.a
cp $(WEBKIT_RELEASE_DIR)/lib/libbmalloc.a $(BUN_DEPS_OUT_DIR)/libbmalloc.a
@@ -1073,7 +1134,7 @@ mimalloc:
-DMI_USE_CXX=ON \
-DMI_OVERRIDE=ON \
-DCMAKE_C_FLAGS="$(CFLAGS)" \
- -DCMAKE_CXX_FLAGS="$(CFLAGS)" \
+ -DCMAKE_CXX_FLAGS="$(CFLAGS) -fno-exceptions -fno-rtti" \
${MIMALLOC_OVERRIDE_FLAG} \
.\
&& make -j $(CPUS);
@@ -1085,7 +1146,7 @@ mimalloc-wasm:
cp $(BUN_DEPS_DIR)/mimalloc/$(MIMALLOC_INPUT_PATH) $(BUN_DEPS_OUT_DIR)/$(MIMALLOC_FILE).wasm
bun-link-lld-debug:
- $(CXX) $(BUN_LLD_FLAGS) $(DEBUG_FLAGS) $(SYMBOLS) \
+ $(CXX) $(BUN_LLD_FLAGS_DEBUG) $(DEBUG_FLAGS) $(SYMBOLS) \
-g \
$(DEBUG_BIN)/bun-debug.o \
-W \
@@ -1124,7 +1185,7 @@ ifeq ($(OS_NAME),darwin)
bun-link-lld-release-dsym:
$(DSYMUTIL) -o $(BUN_RELEASE_BIN).dSYM $(BUN_RELEASE_BIN)
-$(STRIP) $(BUN_RELEASE_BIN)
- mv $(BUN_RELEASE_BIN).o /tmp/bun-$(PACKAGE_JSON_VERSION).o
+ cp $(BUN_RELEASE_BIN).o /tmp/bun-$(PACKAGE_JSON_VERSION).o
copy-to-bun-release-dir-dsym:
gzip --keep -c $(PACKAGE_DIR)/bun.dSYM > $(BUN_RELEASE_DIR)/bun.dSYM.gz
@@ -1145,7 +1206,7 @@ wasm-return1:
-EMIT_LLVM_FOR_RELEASE= -emit-llvm
+EMIT_LLVM_FOR_RELEASE=-emit-llvm -flto="full"
EMIT_LLVM_FOR_DEBUG=
EMIT_LLVM=$(EMIT_LLVM_FOR_RELEASE)
@@ -1156,6 +1217,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
+ -fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM) \
-g3 -c -o $@ $<
@@ -1165,6 +1227,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/webcore/%.cpp
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
+ -fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM) \
-g3 -c -o $@ $<
@@ -1174,6 +1237,7 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/sqlite/%.cpp
$(MACOS_MIN_FLAG) \
$(OPTIMIZATION_LEVEL) \
-fno-exceptions \
+ -fno-rtti \
-ferror-limit=1000 \
$(EMIT_LLVM) \
-g3 -c -o $@ $<
diff --git a/bench/ffi/plus100/plus100-napi b/bench/ffi/plus100/plus100-napi
new file mode 160000
index 0000000000..485de94d06
--- /dev/null
+++ b/bench/ffi/plus100/plus100-napi
@@ -0,0 +1 @@
+Subproject commit 485de94d066493823a62483f7d2d092a29a307d4
diff --git a/bench/snippets/concat.js b/bench/snippets/concat.js
new file mode 100644
index 0000000000..46c6e0f7d5
--- /dev/null
+++ b/bench/snippets/concat.js
@@ -0,0 +1,66 @@
+import { bench, group, run } from "mitata";
+import { readFileSync } from "fs";
+import { allocUnsafe } from "bun";
+
+function polyfill(chunks) {
+ var size = 0;
+ for (const chunk of chunks) {
+ size += chunk.byteLength;
+ }
+ var buffer = new ArrayBuffer(size);
+ var view = new Uint8Array(buffer);
+ var offset = 0;
+ for (const chunk of chunks) {
+ view.set(chunk, offset);
+ offset += chunk.byteLength;
+ }
+ return buffer;
+}
+
+function polyfillUninitialized(chunks) {
+ var size = 0;
+ for (const chunk of chunks) {
+ size += chunk.byteLength;
+ }
+ var view = allocUnsafe(size);
+
+ var offset = 0;
+ for (const chunk of chunks) {
+ view.set(chunk, offset);
+ offset += chunk.byteLength;
+ }
+ return view.buffer;
+}
+
+const chunkGroups = [
+ [Uint8Array.from([123]), Uint8Array.from([456]), Uint8Array.from([789])],
+ Array.from(readFileSync(import.meta.path)).map((a) => Uint8Array.from([a])),
+ [readFileSync(import.meta.path)],
+ Array.from({ length: 42 }, () => readFileSync(import.meta.path)),
+ Array.from({ length: 2 }, () =>
+ new TextEncoder().encode(readFileSync(import.meta.path, "utf8").repeat(100))
+ ),
+];
+
+for (const chunks of chunkGroups) {
+ group(
+ `${chunks.reduce(
+ (prev, curr, i, a) => prev + curr.byteLength,
+ 0
+ )} bytes for ${chunks.length} chunks`,
+ () => {
+ bench("Bun.concatArrayBuffers", () => {
+ Bun.concatArrayBuffers(chunks);
+ });
+ bench("Uint8Array.set", () => {
+ polyfill(chunks);
+ });
+
+ bench("Uint8Array.set (uninitialized memory)", () => {
+ polyfillUninitialized(chunks);
+ });
+ }
+ );
+}
+
+await run();
diff --git a/bench/snippets/escapeHTML.js b/bench/snippets/escapeHTML.js
new file mode 100644
index 0000000000..f186b1d2f1
--- /dev/null
+++ b/bench/snippets/escapeHTML.js
@@ -0,0 +1,122 @@
+import { group } from "mitata";
+import { bench, run } from "mitata";
+import { encode as htmlEntityEncode } from "html-entities";
+import { escape as heEscape } from "he";
+
+var bunEscapeHTML = globalThis.escapeHTML || Bun.escapeHTML;
+
+const FIXTURE = require("fs")
+ .readFileSync(import.meta.dir + "/_fixture.txt", "utf8")
+ .split("")
+ .map((a) => {
+ if (a.charCodeAt(0) > 127) {
+ return "a";
+ }
+ return a;
+ })
+ .join("");
+
+const FIXTURE_WITH_UNICODE = require("fs").readFileSync(
+ import.meta.dir + "/_fixture.txt",
+ "utf8"
+);
+
+// from react-dom:
+const matchHtmlRegExp = /["'&<>]/;
+
+function reactEscapeHtml(string) {
+ const str = "" + string;
+ const match = matchHtmlRegExp.exec(str);
+
+ if (!match) {
+ return str;
+ }
+
+ let escape;
+ let html = "";
+ let index;
+ let lastIndex = 0;
+
+ for (index = match.index; index < str.length; index++) {
+ switch (str.charCodeAt(index)) {
+ case 34: // "
+ escape = """;
+ break;
+ case 38: // &
+ escape = "&";
+ break;
+ case 39: // '
+ escape = "'"; // modified from escape-html; used to be '''
+ break;
+ case 60: // <
+ escape = "<";
+ break;
+ case 62: // >
+ escape = ">";
+ break;
+ default:
+ continue;
+ }
+
+ if (lastIndex !== index) {
+ html += str.substring(lastIndex, index);
+ }
+
+ lastIndex = index + 1;
+ html += escape;
+ }
+
+ return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
+}
+
+// for (let input of [
+// "",
+// `long string, nothing to escape... `.repeat(9999),
+// `long utf16 string, no esc 🤔🤔🤔🤔🤔` + "tex".repeat(4000),
+// `smol`,
+// // `medium string with `,
+
+// FIXTURE,
+// // "[unicode]" + FIXTURE_WITH_UNICODE,
+// ]) {
+// group(
+// {
+// summary: true,
+// name:
+// `"` +
+// input.substring(0, Math.min(input.length, 32)) +
+// `"` +
+// ` (${input.length} chars)`,
+// },
+// () => {
+// bench(`ReactDOM.escapeHTML`, () => reactEscapeHtml(input));
+// bench(`html-entities.encode`, () => htmlEntityEncode(input));
+// bench(`he.escape`, () => heEscape(input));
+// bench(`Bun.escapeHTML`, () => bunEscapeHTML(input));
+// }
+// );
+// }
+
+for (let input of [
+ `long string, nothing to escape... `.repeat(9999999 * 3),
+ FIXTURE.repeat(8000),
+ // "[unicode]" + FIXTURE_WITH_UNICODE,
+]) {
+ group(
+ {
+ summary: true,
+ name:
+ `"` +
+ input.substring(0, Math.min(input.length, 32)) +
+ `"` +
+ ` (${new Intl.NumberFormat().format(input.length / 100_000_000_0)} GB)`,
+ },
+ () => {
+ // bench(`ReactDOM.escapeHTML`, () => reactEscapeHtml(input));
+ // bench(`html-entities.encode`, () => htmlEntityEncode(input));
+ // bench(`he.escape`, () => heEscape(input));
+ bench(`Bun.escapeHTML`, () => bunEscapeHTML(input));
+ }
+ );
+}
+await run();
diff --git a/bench/snippets/noop.js b/bench/snippets/noop.js
new file mode 100644
index 0000000000..789e6abbb1
--- /dev/null
+++ b/bench/snippets/noop.js
@@ -0,0 +1,17 @@
+import { bench, run } from "mitata";
+
+var noop = globalThis[Symbol.for("Bun.lazy")]("noop");
+
+bench("function", function () {
+ noop.function();
+});
+
+bench("setter", function () {
+ noop.getterSetter = 1;
+});
+
+bench("getter", function () {
+ noop.getterSetter;
+});
+
+run();
diff --git a/integration/bunjs-only-snippets/bun-jsc.test.js b/integration/bunjs-only-snippets/bun-jsc.test.js
new file mode 100644
index 0000000000..e329bc092c
--- /dev/null
+++ b/integration/bunjs-only-snippets/bun-jsc.test.js
@@ -0,0 +1,94 @@
+import { describe, expect, it } from "bun:test";
+import {
+ describe as jscDescribe,
+ describeArray,
+ gcAndSweep,
+ fullGC,
+ edenGC,
+ heapSize,
+ heapStats,
+ memoryUsage,
+ getRandomSeed,
+ setRandomSeed,
+ isRope,
+ callerSourceOrigin,
+ noFTL,
+ noOSRExitFuzzing,
+ optimizeNextInvocation,
+ numberOfDFGCompiles,
+ releaseWeakRefs,
+ totalCompileTime,
+ reoptimizationRetryCount,
+ drainMicrotasks,
+} from "bun:jsc";
+
+describe("bun:jsc", () => {
+ function count() {
+ var j = 0;
+ for (var i = 0; i < 999999; i++) {
+ j += i + 2;
+ }
+
+ return j;
+ }
+
+ it("describe", () => {
+ jscDescribe([]);
+ });
+ it("describeArray", () => {
+ describeArray([1, 2, 3]);
+ });
+ it("gcAndSweep", () => {
+ gcAndSweep();
+ });
+ it("fullGC", () => {
+ fullGC();
+ });
+ it("edenGC", () => {
+ edenGC();
+ });
+ it("heapSize", () => {
+ expect(heapSize() > 0).toBe(true);
+ });
+ it("heapStats", () => {
+ heapStats();
+ });
+ it("memoryUsage", () => {
+ memoryUsage();
+ });
+ it("getRandomSeed", () => {
+ getRandomSeed(2);
+ });
+ it("setRandomSeed", () => {
+ setRandomSeed(2);
+ });
+ it("isRope", () => {
+ expect(isRope("a" + 123 + "b")).toBe(true);
+ expect(isRope("abcdefgh")).toBe(false);
+ });
+ it("callerSourceOrigin", () => {
+ expect(callerSourceOrigin()).toBe(import.meta.url);
+ });
+ it("noFTL", () => {});
+ it("noOSRExitFuzzing", () => {});
+ it("optimizeNextInvocation", () => {
+ count();
+ optimizeNextInvocation(count);
+ count();
+ });
+ it("numberOfDFGCompiles", () => {
+ expect(numberOfDFGCompiles(count)).toBe(3);
+ });
+ it("releaseWeakRefs", () => {
+ releaseWeakRefs();
+ });
+ it("totalCompileTime", () => {
+ totalCompileTime(count);
+ });
+ it("reoptimizationRetryCount", () => {
+ reoptimizationRetryCount(count);
+ });
+ it("drainMicrotasks", () => {
+ drainMicrotasks();
+ });
+});
diff --git a/integration/bunjs-only-snippets/concat.test.js b/integration/bunjs-only-snippets/concat.test.js
new file mode 100644
index 0000000000..9f3e1f2575
--- /dev/null
+++ b/integration/bunjs-only-snippets/concat.test.js
@@ -0,0 +1,46 @@
+import { describe, it, expect } from "bun:test";
+import { gcTick } from "./gc";
+import { concat } from "bun";
+
+describe("concat", () => {
+ function polyfill(chunks) {
+ var size = 0;
+ for (const chunk of chunks) {
+ size += chunk.byteLength;
+ }
+ var buffer = new ArrayBuffer(size);
+ var view = new Uint8Array(buffer);
+ var offset = 0;
+ for (const chunk of chunks) {
+ view.set(chunk, offset);
+ offset += chunk.byteLength;
+ }
+ return buffer;
+ }
+
+ function concatToString(chunks) {
+ return Array.from(new Uint8Array(concat(chunks))).join("");
+ }
+
+ function polyfillToString(chunks) {
+ return Array.from(new Uint8Array(polyfill(chunks))).join("");
+ }
+
+ it("works with one element", () => {
+ expect(concatToString([new Uint8Array([123])])).toBe(
+ polyfillToString([new Uint8Array([123])])
+ );
+ });
+
+ it("works with two elements", () => {
+ expect(
+ concatToString([Uint8Array.from([123]), Uint8Array.from([456])])
+ ).toBe(polyfillToString([Uint8Array.from([123]), Uint8Array.from([456])]));
+ });
+
+ it("works with mix of ArrayBuffer and TypedArray elements", () => {
+ expect(
+ concatToString([Uint8Array.from([123]).buffer, Uint8Array.from([456])])
+ ).toBe(polyfillToString([Uint8Array.from([123]), Uint8Array.from([456])]));
+ });
+});
diff --git a/integration/bunjs-only-snippets/escapeHTML.test.js b/integration/bunjs-only-snippets/escapeHTML.test.js
new file mode 100644
index 0000000000..ecfcc5e7c1
--- /dev/null
+++ b/integration/bunjs-only-snippets/escapeHTML.test.js
@@ -0,0 +1,105 @@
+import { describe, it, expect } from "bun:test";
+import { gcTick } from "./gc";
+import { escapeHTML } from "bun";
+
+describe("escapeHTML", () => {
+ // The matrix of cases we need to test for:
+ // 1. Works with short strings
+ // 2. Works with long strings
+ // 3. Works with latin1 strings
+ // 4. Works with utf16 strings
+ // 5. Works when the text to escape is somewhere in the middle
+ // 6. Works when the text to escape is in the beginning
+ // 7. Works when the text to escape is in the end
+ // 8. Returns the same string when there's no need to escape
+ it("works", () => {
+ expect(escapeHTML("absolutely nothing to do here")).toBe(
+ "absolutely nothing to do here"
+ );
+ expect(escapeHTML("")).toBe(
+ "<script>alert(1)</script>"
+ );
+ expect(escapeHTML("<")).toBe("<");
+ expect(escapeHTML(">")).toBe(">");
+ expect(escapeHTML("&")).toBe("&");
+ expect(escapeHTML("'")).toBe("'");
+ expect(escapeHTML('"')).toBe(""");
+ expect(escapeHTML("\n")).toBe("\n");
+ expect(escapeHTML("\r")).toBe("\r");
+ expect(escapeHTML("\t")).toBe("\t");
+ expect(escapeHTML("\f")).toBe("\f");
+ expect(escapeHTML("\v")).toBe("\v");
+ expect(escapeHTML("\b")).toBe("\b");
+ expect(escapeHTML("\u00A0")).toBe("\u00A0");
+ expect(escapeHTML("" + "lalala")).toBe(
+ "lalala<script>alert(1)</script>lalala"
+ );
+
+ expect(escapeHTML("" + "lalala")).toBe(
+ "<script>alert(1)</script>lalala"
+ );
+ expect(escapeHTML("lalala" + "")).toBe(
+ "lalala" + "<script>alert(1)</script>"
+ );
+
+ expect(escapeHTML("What does 😊 mean?")).toBe("What does 😊 mean?");
+ const output = escapeHTML("What does 😊 mean in text?")).toBe(
+ "<div>What does 😊 mean in text?"
+ );
+
+ expect(
+ escapeHTML(
+ ("lalala" + "" + "lalala").repeat(900)
+ )
+ ).toBe("lalala<script>alert(1)</script>lalala".repeat(900));
+ expect(
+ escapeHTML(("" + "lalala").repeat(900))
+ ).toBe("<script>alert(1)</script>lalala".repeat(900));
+ expect(
+ escapeHTML(("lalala" + "").repeat(900))
+ ).toBe(("lalala" + "<script>alert(1)</script>").repeat(900));
+
+ // the positions of the unicode codepoint are important
+ // our simd code for U16 is at 8 bytes, so we need to especially check the boundaries
+ expect(
+ escapeHTML("😊lalala" + "" + "lalala")
+ ).toBe("😊lalala<script>alert(1)</script>lalala");
+ expect(escapeHTML("" + "lalala")).toBe(
+ "<script>😊alert(1)</script>lalala"
+ );
+ expect(escapeHTML("" + "lalala")).toBe(
+ "<script>alert(1)😊</script>lalala"
+ );
+ expect(escapeHTML("" + "😊lalala")).toBe(
+ "<script>alert(1)</script>😊lalala"
+ );
+ expect(escapeHTML("" + "lal😊ala")).toBe(
+ "<script>alert(1)</script>lal😊ala"
+ );
+ expect(
+ escapeHTML("" + "lal😊ala".repeat(10))
+ ).toBe("<script>alert(1)</script>" + "lal😊ala".repeat(10));
+
+ for (let i = 1; i < 10; i++)
+ expect(escapeHTML("" + "la😊".repeat(i))).toBe(
+ "<script>alert(1)</script>" + "la😊".repeat(i)
+ );
+
+ expect(escapeHTML("la😊" + "")).toBe(
+ "la😊" + "<script>alert(1)</script>"
+ );
+ expect(
+ escapeHTML(("lalala" + "😊").repeat(1))
+ ).toBe(("lalala" + "<script>alert(1)</script>😊").repeat(1));
+
+ expect(escapeHTML("😊".repeat(100))).toBe("😊".repeat(100));
+ expect(escapeHTML("😊<".repeat(100))).toBe("😊<".repeat(100));
+ expect(escapeHTML("<😊>".repeat(100))).toBe("<😊>".repeat(100));
+ });
+});
diff --git a/integration/bunjs-only-snippets/ffi.test.fixture.callback.c b/integration/bunjs-only-snippets/ffi.test.fixture.callback.c
index 36949e158f..3a557e7d5d 100644
--- a/integration/bunjs-only-snippets/ffi.test.fixture.callback.c
+++ b/integration/bunjs-only-snippets/ffi.test.fixture.callback.c
@@ -258,6 +258,9 @@ void* JSFunctionCall(void* globalObject, void* callFrame);
bool my_callback_function(void* arg0);
bool my_callback_function(void* arg0) {
+#ifdef INJECT_BEFORE
+INJECT_BEFORE;
+#endif
EncodedJSValue arguments[1] = {
PTR_TO_JSVALUE(arg0)
};
diff --git a/integration/bunjs-only-snippets/streams.test.js b/integration/bunjs-only-snippets/streams.test.js
new file mode 100644
index 0000000000..d694be1ba6
--- /dev/null
+++ b/integration/bunjs-only-snippets/streams.test.js
@@ -0,0 +1,186 @@
+import {
+ file,
+ gc,
+ readableStreamToArrayBuffer,
+ readableStreamToArray,
+} from "bun";
+import { expect, it } from "bun:test";
+import { writeFileSync } from "node:fs";
+
+it("exists globally", () => {
+ expect(typeof ReadableStream).toBe("function");
+ expect(typeof ReadableStreamBYOBReader).toBe("function");
+ expect(typeof ReadableStreamBYOBRequest).toBe("function");
+ expect(typeof ReadableStreamDefaultController).toBe("function");
+ expect(typeof ReadableStreamDefaultReader).toBe("function");
+ expect(typeof TransformStream).toBe("function");
+ expect(typeof TransformStreamDefaultController).toBe("function");
+ expect(typeof WritableStream).toBe("function");
+ expect(typeof WritableStreamDefaultController).toBe("function");
+ expect(typeof WritableStreamDefaultWriter).toBe("function");
+ expect(typeof ByteLengthQueuingStrategy).toBe("function");
+ expect(typeof CountQueuingStrategy).toBe("function");
+});
+
+it("ReadableStream (bytes)", async () => {
+ var stream = new ReadableStream({
+ start(controller) {
+ controller.enqueue(Buffer.from("abdefgh"));
+ },
+ pull(controller) {},
+ cancel() {},
+ type: "bytes",
+ });
+ const chunks = [];
+ const chunk = await stream.getReader().read();
+ chunks.push(chunk.value);
+ expect(chunks[0].join("")).toBe(Buffer.from("abdefgh").join(""));
+});
+
+it("ReadableStream (default)", async () => {
+ var stream = new ReadableStream({
+ start(controller) {
+ controller.enqueue(Buffer.from("abdefgh"));
+ controller.close();
+ },
+ pull(controller) {},
+ cancel() {},
+ });
+ const chunks = [];
+ const chunk = await stream.getReader().read();
+ chunks.push(chunk.value);
+ expect(chunks[0].join("")).toBe(Buffer.from("abdefgh").join(""));
+});
+
+it("readableStreamToArray", async () => {
+ var queue = [Buffer.from("abdefgh")];
+ var stream = new ReadableStream({
+ pull(controller) {
+ var chunk = queue.shift();
+ if (chunk) {
+ controller.enqueue(chunk);
+ } else {
+ controller.close();
+ }
+ },
+ cancel() {},
+ type: "bytes",
+ });
+
+ const chunks = await readableStreamToArray(stream);
+
+ expect(chunks[0].join("")).toBe(Buffer.from("abdefgh").join(""));
+});
+
+it("readableStreamToArrayBuffer (bytes)", async () => {
+ var queue = [Buffer.from("abdefgh")];
+ var stream = new ReadableStream({
+ pull(controller) {
+ var chunk = queue.shift();
+ if (chunk) {
+ controller.enqueue(chunk);
+ } else {
+ controller.close();
+ }
+ },
+ cancel() {},
+ type: "bytes",
+ });
+ const buffer = await readableStreamToArrayBuffer(stream);
+ expect(new TextDecoder().decode(new Uint8Array(buffer))).toBe("abdefgh");
+});
+
+it("readableStreamToArrayBuffer (default)", async () => {
+ var queue = [Buffer.from("abdefgh")];
+ var stream = new ReadableStream({
+ pull(controller) {
+ var chunk = queue.shift();
+ if (chunk) {
+ controller.enqueue(chunk);
+ } else {
+ controller.close();
+ }
+ },
+ cancel() {},
+ });
+
+ const buffer = await readableStreamToArrayBuffer(stream);
+ expect(new TextDecoder().decode(new Uint8Array(buffer))).toBe("abdefgh");
+});
+
+it("ReadableStream for Blob", async () => {
+ var blob = new Blob(["abdefgh", "ijklmnop"]);
+ expect(await blob.text()).toBe("abdefghijklmnop");
+ var stream = blob.stream();
+ const chunks = [];
+ var reader = stream.getReader();
+ while (true) {
+ const chunk = await reader.read();
+ if (chunk.done) break;
+ chunks.push(new TextDecoder().decode(chunk.value));
+ }
+ expect(chunks.join("")).toBe(
+ new TextDecoder().decode(Buffer.from("abdefghijklmnop"))
+ );
+});
+
+it("ReadableStream for File", async () => {
+ var blob = file(import.meta.dir + "/fetch.js.txt");
+ var stream = blob.stream(24);
+ const chunks = [];
+ var reader = stream.getReader();
+ stream = undefined;
+ while (true) {
+ const chunk = await reader.read();
+ gc(true);
+ if (chunk.done) break;
+ chunks.push(chunk.value);
+ expect(chunk.value.byteLength <= 24).toBe(true);
+ gc(true);
+ }
+ reader = undefined;
+ const output = new Uint8Array(await blob.arrayBuffer()).join("");
+ const input = chunks.map((a) => a.join("")).join("");
+ expect(output).toBe(input);
+ gc(true);
+});
+
+it("ReadableStream for File errors", async () => {
+ try {
+ var blob = file(import.meta.dir + "/fetch.js.txt.notfound");
+ blob.stream().getReader();
+ throw new Error("should not reach here");
+ } catch (e) {
+ expect(e.code).toBe("ENOENT");
+ expect(e.syscall).toBe("open");
+ }
+});
+
+it("ReadableStream for empty blob closes immediately", async () => {
+ var blob = new Blob([]);
+ var stream = blob.stream();
+ const chunks = [];
+ var reader = stream.getReader();
+ while (true) {
+ const chunk = await reader.read();
+ if (chunk.done) break;
+ chunks.push(chunk.value);
+ }
+
+ expect(chunks.length).toBe(0);
+});
+
+it("ReadableStream for empty file closes immediately", async () => {
+ writeFileSync("/tmp/bun-empty-file-123456", "");
+ var blob = file("/tmp/bun-empty-file-123456");
+ var stream = blob.stream();
+ const chunks = [];
+ var reader = stream.getReader();
+ while (true) {
+ const chunk = await reader.read();
+ if (chunk.done) break;
+ chunks.push(chunk.value);
+ }
+
+ expect(chunks.length).toBe(0);
+});
diff --git a/integration/bunjs-only-snippets/transpiler.test.js b/integration/bunjs-only-snippets/transpiler.test.js
index dd0ffdc8fb..30fc2afde5 100644
--- a/integration/bunjs-only-snippets/transpiler.test.js
+++ b/integration/bunjs-only-snippets/transpiler.test.js
@@ -291,6 +291,89 @@ describe("Bun.Transpiler", () => {
);
});
+ describe("inline JSX", () => {
+ const inliner = new Bun.Transpiler({
+ loader: "tsx",
+ define: {
+ "process.env.NODE_ENV": JSON.stringify("production"),
+ user_undefined: "undefined",
+ },
+ platform: "bun",
+ jsxOptimizationInline: true,
+ treeShaking: false,
+ });
+
+ it("inlines static JSX into object literals", () => {
+ expect(
+ inliner
+ .transformSync(
+ `
+export var hi = {123}
+export var hiWithKey = {123}
+export var hiWithRef = {123}
+
+export var ComponentThatChecksDefaultProps =
+export var ComponentThatChecksDefaultPropsAndHasChildren = my child
+export var ComponentThatHasSpreadCausesDeopt =
+
+`.trim()
+ )
+ .trim()
+ ).toBe(
+ `var $$typeof = Symbol.for("react.element");
+export var hi = {
+ $$typeof,
+ type: "div",
+ key: null,
+ ref: null,
+ props: {
+ children: 123
+ },
+ _owner: null
+};
+export var hiWithKey = {
+ $$typeof,
+ type: "div",
+ key: "hey",
+ ref: null,
+ props: {
+ children: 123
+ },
+ _owner: null
+};
+export var hiWithRef = jsx("div", {
+ ref: foo,
+ children: 123
+});
+export var ComponentThatChecksDefaultProps = {
+ $$typeof,
+ type: Hello,
+ key: null,
+ ref: null,
+ props: Hello.defaultProps || {},
+ _owner: null
+};
+export var ComponentThatChecksDefaultPropsAndHasChildren = {
+ $$typeof,
+ type: Hello,
+ key: null,
+ ref: null,
+ props: !Hello.defaultProps ? {
+ children: "my child"
+ } : {
+ ...Hello.defaultProps,
+ children: "my child"
+ },
+ _owner: null
+};
+export var ComponentThatHasSpreadCausesDeopt = jsx(Hello, {
+ ...spread
+});
+`.trim()
+ );
+ });
+ });
+
it("require with a dynamic non-string expression", () => {
var nodeTranspiler = new Bun.Transpiler({ platform: "node" });
expect(nodeTranspiler.transformSync("require('hi' + bar)")).toBe(
@@ -1355,21 +1438,22 @@ class Foo {
expectPrinted("'a' != '\\x62'", "true");
expectPrinted("'a' != 'abc'", "true");
- // TODO: string simplification
- // expectPrinted("'a' + 'b'", '"ab"');
- // expectPrinted("'a' + 'bc'", '"abc"');
- // expectPrinted("'ab' + 'c'", '"abc"');
- // expectPrinted("x + 'a' + 'b'", 'x + "ab"');
- // expectPrinted("x + 'a' + 'bc'", 'x + "abc"');
- // expectPrinted("x + 'ab' + 'c'", 'x + "abc"');
- // expectPrinted("'a' + 1", '"a" + 1;');
- // expectPrinted("x * 'a' + 'b'", 'x * "a" + "b"');
+ expectPrinted("'a' + 'b'", '"ab"');
+ expectPrinted("'a' + 'bc'", '"abc"');
+ expectPrinted("'ab' + 'c'", '"abc"');
+ expectPrinted("x + 'a' + 'b'", 'x + "ab"');
+ expectPrinted("x + 'a' + 'bc'", 'x + "abc"');
+ expectPrinted("x + 'ab' + 'c'", 'x + "abc"');
+ expectPrinted("'a' + 1", '"a" + 1');
+ expectPrinted("x * 'a' + 'b'", 'x * "a" + "b"');
- // TODO: string simplification
- // expectPrinted("'string' + `template`", "`stringtemplate`");
+ expectPrinted("'string' + `template`", `"stringtemplate"`);
+
+ expectPrinted("`template` + 'string'", "`templatestring`");
+
+ // TODO: string template simplification
// expectPrinted("'string' + `a${foo}b`", "`stringa${foo}b`");
// expectPrinted("'string' + tag`template`", '"string" + tag`template`;');
- // expectPrinted("`template` + 'string'", "`templatestring`");
// expectPrinted("`a${foo}b` + 'string'", "`a${foo}bstring`");
// expectPrinted("tag`template` + 'string'", 'tag`template` + "string"');
// expectPrinted("`template` + `a${foo}b`", "`templatea${foo}b`");
diff --git a/package.json b/package.json
index 1e7a82c3fa..8e6b1d5176 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"dependencies": {
- "mitata": "^0.0.10",
+ "mitata": "^0.1.3",
"peechy": "0.4.32",
"react": "^17.0.2"
},
@@ -9,6 +9,8 @@
"build-fallback": "esbuild --target=esnext --bundle src/fallback.ts --format=iife --platform=browser --minify > src/fallback.out.js"
},
"devDependencies": {
+ "he": "^1.2.0",
+ "html-entities": "^2.3.3",
"prettier": "^2.4.1",
"typescript": "4.6.3"
},
diff --git a/src/baby_list.zig b/src/baby_list.zig
new file mode 100644
index 0000000000..b1bfc1786b
--- /dev/null
+++ b/src/baby_list.zig
@@ -0,0 +1,104 @@
+const std = @import("std");
+const Environment = @import("./env.zig");
+
+/// This is like ArrayList except it stores the length and capacity as u32
+/// In practice, it is very unusual to have lengths above 4 GB
+///
+/// This lets us have array lists which occupy the same amount of space as a slice
+pub fn BabyList(comptime Type: type) type {
+ return struct {
+ const ListType = @This();
+ ptr: [*]Type = undefined,
+ len: u32 = 0,
+ cap: u32 = 0,
+
+ pub inline fn init(items: []const Type) ListType {
+ @setRuntimeSafety(false);
+ return ListType{
+ // Remove the const qualifier from the items
+ .ptr = @intToPtr([*]Type, @ptrToInt(items.ptr)),
+
+ .len = @truncate(u32, items.len),
+ .cap = @truncate(u32, items.len),
+ };
+ }
+
+ pub inline fn fromList(list_: anytype) ListType {
+ @setRuntimeSafety(false);
+
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(list_.items.len <= list_.capacity);
+ }
+
+ return ListType{
+ .ptr = list_.items.ptr,
+ .len = @truncate(u32, list_.items.len),
+ .cap = @truncate(u32, list_.capacity),
+ };
+ }
+
+ pub fn update(this: *ListType, list_: anytype) void {
+ @setRuntimeSafety(false);
+ this.ptr = list_.items.ptr;
+ this.len = @truncate(u32, list_.items.len);
+ this.cap = @truncate(u32, list_.capacity);
+
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(this.len <= this.cap);
+ }
+ }
+
+ pub fn list(this: ListType) std.ArrayListUnmanaged(Type) {
+ return std.ArrayListUnmanaged(Type){
+ .items = this.ptr[0..this.len],
+ .capacity = this.cap,
+ };
+ }
+
+ pub fn listManaged(this: ListType, allocator: std.mem.Allocator) std.ArrayList(Type) {
+ return std.ArrayList(Type){
+ .items = this.ptr[0..this.len],
+ .capacity = this.cap,
+ .allocator = allocator,
+ };
+ }
+
+ pub inline fn first(this: ListType) ?*Type {
+ return if (this.len > 0) this.ptr[0] else @as(?*Type, null);
+ }
+
+ pub inline fn last(this: ListType) ?*Type {
+ return if (this.len > 0) &this.ptr[this.len - 1] else @as(?*Type, null);
+ }
+
+ pub inline fn first_(this: ListType) Type {
+ return this.ptr[0];
+ }
+
+ pub fn one(allocator: std.mem.Allocator, value: Type) !ListType {
+ var items = try allocator.alloc(Type, 1);
+ items[0] = value;
+ return ListType{
+ .ptr = @ptrCast([*]Type, items.ptr),
+ .len = 1,
+ .cap = 1,
+ };
+ }
+
+ pub inline fn @"[0]"(this: ListType) Type {
+ return this.ptr[0];
+ }
+ const OOM = error{OutOfMemory};
+
+ pub fn push(this: *ListType, allocator: std.mem.Allocator, value: Type) OOM!void {
+ var list_ = this.list();
+ try list_.append(allocator, value);
+ this.update(list_);
+ }
+
+ pub inline fn slice(this: ListType) []Type {
+ @setRuntimeSafety(false);
+ return this.ptr[0..this.len];
+ }
+ };
+}
diff --git a/src/bun_js.zig b/src/bun_js.zig
index 29f1520493..7ccdc87472 100644
--- a/src/bun_js.zig
+++ b/src/bun_js.zig
@@ -120,8 +120,7 @@ pub const Run = struct {
Global.exit(1);
}
- const result = promise.result(this.vm.global.vm());
- JSC.C.JSValueProtect(this.vm.global.ref(), result.asObjectRef());
+ _ = promise.result(this.vm.global.vm());
if (this.vm.log.msgs.items.len > 0) {
if (Output.enable_ansi_colors) {
@@ -133,6 +132,8 @@ pub const Run = struct {
Output.flush();
}
+ this.vm.global.vm().releaseWeakRefs();
+ _ = this.vm.global.vm().runGC(false);
this.vm.tick();
{
diff --git a/src/bundler.zig b/src/bundler.zig
index 936f761b3e..edfdf2aa6c 100644
--- a/src/bundler.zig
+++ b/src/bundler.zig
@@ -345,6 +345,29 @@ pub const Bundler = struct {
} else {
try this.options.loadDefines(this.allocator, this.env, &this.options.env);
}
+
+ if (this.options.define.dots.get("NODE_ENV")) |NODE_ENV| {
+ if (NODE_ENV.len > 0 and NODE_ENV[0].data.value == .e_string and NODE_ENV[0].data.value.e_string.eqlComptime("production")) {
+ this.options.production = true;
+ this.options.jsx.development = false;
+
+ if (this.options.jsx.import_source.ptr == options.JSX.Pragma.Defaults.ImportSourceDev) {
+ this.options.jsx.import_source = options.JSX.Pragma.Defaults.ImportSource;
+ }
+
+ if (options.JSX.Pragma.Defaults.ImportSource.ptr == this.options.jsx.import_source.ptr or
+ strings.eqlComptime(this.options.jsx.import_source, comptime options.JSX.Pragma.Defaults.ImportSource) or strings.eqlComptime(this.options.jsx.package_name, "react"))
+ {
+ if (this.options.jsx_optimization_inline == null) {
+ this.options.jsx_optimization_inline = true;
+ }
+
+ if (this.options.jsx_optimization_hoist == null and (this.options.jsx_optimization_inline orelse false)) {
+ this.options.jsx_optimization_hoist = true;
+ }
+ }
+ }
+ }
}
pub fn configureFramework(
@@ -1096,6 +1119,7 @@ pub const Bundler = struct {
var jsx = this_parse.jsx;
jsx.parse = loader.isJSX();
+
var opts = js_parser.Parser.Options.init(jsx, loader);
opts.enable_bundling = false;
opts.transform_require_to_import = bundler.options.allow_runtime;
@@ -1122,6 +1146,11 @@ pub const Bundler = struct {
opts.filepath_hash_for_hmr = file_hash orelse 0;
opts.features.auto_import_jsx = bundler.options.auto_import_jsx;
opts.warn_about_unbundled_modules = platform.isNotBun();
+ opts.features.jsx_optimization_inline = (bundler.options.jsx_optimization_inline orelse (platform.isBun() and jsx.parse and
+ !jsx.development)) and
+ (jsx.runtime == .automatic or jsx.runtime == .classic);
+
+ opts.features.jsx_optimization_hoist = bundler.options.jsx_optimization_hoist orelse opts.features.jsx_optimization_inline;
if (bundler.macro_context == null) {
bundler.macro_context = js_ast.Macro.MacroContext.init(bundler);
diff --git a/src/bunfig.zig b/src/bunfig.zig
index b0c763498a..4fd3b7a555 100644
--- a/src/bunfig.zig
+++ b/src/bunfig.zig
@@ -126,7 +126,6 @@ pub const Bunfig = struct {
if (prop.value.?.data != .e_string) continue;
valid_count += 1;
}
-
var buffer = allocator.alloc([]const u8, valid_count * 2) catch unreachable;
var keys = buffer[0..valid_count];
var values = buffer[valid_count..];
@@ -442,19 +441,19 @@ pub const Bunfig = struct {
if (json.get("jsxImportSource")) |expr| {
if (expr.asString(allocator)) |value| {
- jsx_import_source = value;
+ jsx_import_source = try allocator.dupe(u8, value);
}
}
if (json.get("jsxFragment")) |expr| {
if (expr.asString(allocator)) |value| {
- jsx_fragment = value;
+ jsx_fragment = try allocator.dupe(u8, value);
}
}
if (json.get("jsxFactory")) |expr| {
if (expr.asString(allocator)) |value| {
- jsx_factory = value;
+ jsx_factory = try allocator.dupe(u8, value);
}
}
diff --git a/src/c.zig b/src/c.zig
index aaeb980da0..7817bdfe95 100644
--- a/src/c.zig
+++ b/src/c.zig
@@ -249,3 +249,59 @@ pub fn getSelfExeSharedLibPaths(allocator: std.mem.Allocator) error{OutOfMemory}
else => @compileError("getSelfExeSharedLibPaths unimplemented for this target"),
}
}
+
+/// The madvise() system call allows a process that has knowledge of its mem-ory memory
+/// ory behavior to describe it to the system. The advice passed in may be
+/// used by the system to alter its virtual memory paging strategy. This
+/// advice may improve application and system performance. The behavior
+/// specified in advice can only be one of the following values:
+///
+/// MADV_NORMAL Indicates that the application has no advice to give on
+/// its behavior in the specified address range. This is
+/// the system default behavior. This is used with
+/// madvise() system call.
+///
+/// POSIX_MADV_NORMAL
+/// Same as MADV_NORMAL but used with posix_madvise() system
+/// call.
+///
+/// MADV_SEQUENTIAL Indicates that the application expects to access this
+/// address range in a sequential manner. This is used with
+/// madvise() system call.
+///
+/// POSIX_MADV_SEQUENTIAL
+/// Same as MADV_SEQUENTIAL but used with posix_madvise()
+/// system call.
+///
+/// MADV_RANDOM Indicates that the application expects to access this
+/// address range in a random manner. This is used with
+/// madvise() system call.
+///
+/// POSIX_MADV_RANDOM
+/// Same as MADV_RANDOM but used with posix_madvise() system
+/// call.
+///
+/// MADV_WILLNEED Indicates that the application expects to access this
+/// address range soon. This is used with madvise() system
+/// call.
+///
+/// POSIX_MADV_WILLNEED
+/// Same as MADV_WILLNEED but used with posix_madvise() sys-tem system
+/// tem call.
+///
+/// MADV_DONTNEED Indicates that the application is not expecting to
+/// access this address range soon. This is used with
+/// madvise() system call.
+///
+/// POSIX_MADV_DONTNEED
+/// Same as MADV_DONTNEED but used with posix_madvise() sys-tem system
+/// tem call.
+///
+/// MADV_FREE Indicates that the application will not need the infor-mation information
+/// mation contained in this address range, so the pages may
+/// be reused right away. The address range will remain
+/// valid. This is used with madvise() system call.
+///
+/// The posix_madvise() behaves same as madvise() except that it uses values
+/// with POSIX_ prefix for the advice system call argument.
+pub extern "c" fn posix_madvise(ptr: *anyopaque, len: usize, advice: i32) c_int;
diff --git a/src/cli.zig b/src/cli.zig
index 5aa02284dd..10721a5d2c 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -512,7 +512,7 @@ pub const Arguments = struct {
var jsx_fragment = args.option("--jsx-fragment");
var jsx_import_source = args.option("--jsx-import-source");
var jsx_runtime = args.option("--jsx-runtime");
- var jsx_production = args.flag("--jsx-production") or production;
+ var jsx_production = args.flag("--jsx-production");
const react_fast_refresh = switch (comptime cmd) {
.BunCommand, .DevCommand => !(args.flag("--disable-react-fast-refresh") or jsx_production),
else => true,
@@ -611,7 +611,7 @@ pub const Arguments = struct {
.fragment = constStrToU8(jsx_fragment orelse opts.jsx.?.fragment),
.import_source = constStrToU8(jsx_import_source orelse opts.jsx.?.import_source),
.runtime = if (jsx_runtime != null) try resolve_jsx_runtime(jsx_runtime.?) else opts.jsx.?.runtime,
- .development = jsx_production,
+ .development = !jsx_production,
.react_fast_refresh = react_fast_refresh,
};
}
diff --git a/src/deps/mimalloc b/src/deps/mimalloc
index 9e41263d39..6d07c0b9ba 160000
--- a/src/deps/mimalloc
+++ b/src/deps/mimalloc
@@ -1 +1 @@
-Subproject commit 9e41263d39041aee3b647eff64d5ef4918a60cea
+Subproject commit 6d07c0b9ba535617cf9665ea77d099dad265818a
diff --git a/src/deps/uws.zig b/src/deps/uws.zig
index 101bac88e0..ae0efef79c 100644
--- a/src/deps/uws.zig
+++ b/src/deps/uws.zig
@@ -1,11 +1,13 @@
const Api = @import("../api/schema.zig").Api;
+const std = @import("std");
+const Environment = @import("../env.zig");
pub const u_int8_t = u8;
pub const u_int16_t = c_ushort;
pub const u_int32_t = c_uint;
pub const u_int64_t = c_ulonglong;
pub const LIBUS_LISTEN_DEFAULT: c_int = 0;
pub const LIBUS_LISTEN_EXCLUSIVE_PORT: c_int = 1;
-pub const us_socket_t = opaque {};
+pub const Socket = opaque {};
pub const us_timer_t = opaque {};
pub const us_socket_context_t = opaque {};
pub const Loop = opaque {
@@ -17,10 +19,13 @@ pub const Loop = opaque {
return us_wakeup_loop(this);
}
+ pub fn tick(this: *Loop) void {
+ us_loop_tick(this);
+ }
+
pub fn nextTick(this: *Loop, comptime UserType: type, user_data: UserType, comptime deferCallback: fn (ctx: UserType) void) void {
const Handler = struct {
pub fn callback(data: *anyopaque) callconv(.C) void {
- const std = @import("std");
deferCallback(@ptrCast(UserType, @alignCast(@alignOf(std.meta.Child(UserType)), data)));
}
};
@@ -34,7 +39,6 @@ pub const Loop = opaque {
return uws_loop_removePostHandler(handler.loop, callback);
}
pub fn callback(data: *anyopaque, _: *Loop) callconv(.C) void {
- const std = @import("std");
callback(@ptrCast(UserType, @alignCast(@alignOf(std.meta.Child(UserType)), data)));
}
};
@@ -56,6 +60,7 @@ pub const Loop = opaque {
extern fn us_loop_free(loop: ?*Loop) void;
extern fn us_loop_ext(loop: ?*Loop) ?*anyopaque;
extern fn us_loop_run(loop: ?*Loop) void;
+ extern fn us_loop_tick(loop: ?*Loop) void;
extern fn us_wakeup_loop(loop: ?*Loop) void;
extern fn us_loop_integrate(loop: ?*Loop) void;
extern fn us_loop_iteration_number(loop: ?*Loop) c_longlong;
@@ -85,26 +90,87 @@ extern fn us_socket_context_on_server_name(ssl: c_int, context: ?*us_socket_cont
extern fn us_socket_context_get_native_handle(ssl: c_int, context: ?*us_socket_context_t) ?*anyopaque;
extern fn us_create_socket_context(ssl: c_int, loop: ?*Loop, ext_size: c_int, options: us_socket_context_options_t) ?*us_socket_context_t;
extern fn us_socket_context_free(ssl: c_int, context: ?*us_socket_context_t) void;
-extern fn us_socket_context_on_open(ssl: c_int, context: ?*us_socket_context_t, on_open: ?fn (?*us_socket_t, c_int, [*c]u8, c_int) callconv(.C) ?*us_socket_t) void;
-extern fn us_socket_context_on_close(ssl: c_int, context: ?*us_socket_context_t, on_close: ?fn (?*us_socket_t, c_int, ?*anyopaque) callconv(.C) ?*us_socket_t) void;
-extern fn us_socket_context_on_data(ssl: c_int, context: ?*us_socket_context_t, on_data: ?fn (?*us_socket_t, [*c]u8, c_int) callconv(.C) ?*us_socket_t) void;
-extern fn us_socket_context_on_writable(ssl: c_int, context: ?*us_socket_context_t, on_writable: ?fn (*us_socket_t) callconv(.C) ?*us_socket_t) void;
-extern fn us_socket_context_on_timeout(ssl: c_int, context: ?*us_socket_context_t, on_timeout: ?fn (?*us_socket_t) callconv(.C) ?*us_socket_t) void;
-extern fn us_socket_context_on_connect_error(ssl: c_int, context: ?*us_socket_context_t, on_connect_error: ?fn (?*us_socket_t, c_int) callconv(.C) ?*us_socket_t) void;
-extern fn us_socket_context_on_end(ssl: c_int, context: ?*us_socket_context_t, on_end: ?fn (?*us_socket_t) callconv(.C) ?*us_socket_t) void;
+extern fn us_socket_context_on_open(ssl: c_int, context: ?*us_socket_context_t, on_open: ?fn (?*Socket, c_int, [*c]u8, c_int) callconv(.C) ?*Socket) void;
+extern fn us_socket_context_on_close(ssl: c_int, context: ?*us_socket_context_t, on_close: ?fn (?*Socket, c_int, ?*anyopaque) callconv(.C) ?*Socket) void;
+extern fn us_socket_context_on_data(ssl: c_int, context: ?*us_socket_context_t, on_data: ?fn (?*Socket, [*c]u8, c_int) callconv(.C) ?*Socket) void;
+extern fn us_socket_context_on_writable(ssl: c_int, context: ?*us_socket_context_t, on_writable: ?fn (*Socket) callconv(.C) ?*Socket) void;
+extern fn us_socket_context_on_timeout(ssl: c_int, context: ?*us_socket_context_t, on_timeout: ?fn (?*Socket) callconv(.C) ?*Socket) void;
+extern fn us_socket_context_on_connect_error(ssl: c_int, context: ?*us_socket_context_t, on_connect_error: ?fn (?*Socket, c_int) callconv(.C) ?*Socket) void;
+extern fn us_socket_context_on_end(ssl: c_int, context: ?*us_socket_context_t, on_end: ?fn (?*Socket) callconv(.C) ?*Socket) void;
extern fn us_socket_context_ext(ssl: c_int, context: ?*us_socket_context_t) ?*anyopaque;
extern fn us_socket_context_listen(ssl: c_int, context: ?*us_socket_context_t, host: [*c]const u8, port: c_int, options: c_int, socket_ext_size: c_int) ?*listen_socket_t;
-extern fn us_socket_context_connect(ssl: c_int, context: ?*us_socket_context_t, host: [*c]const u8, port: c_int, source_host: [*c]const u8, options: c_int, socket_ext_size: c_int) ?*us_socket_t;
-extern fn us_socket_is_established(ssl: c_int, s: ?*us_socket_t) c_int;
-extern fn us_socket_close_connecting(ssl: c_int, s: ?*us_socket_t) ?*us_socket_t;
+extern fn us_socket_context_connect(ssl: c_int, context: ?*us_socket_context_t, host: [*c]const u8, port: c_int, source_host: [*c]const u8, options: c_int, socket_ext_size: c_int) ?*Socket;
+extern fn us_socket_is_established(ssl: c_int, s: ?*Socket) c_int;
+extern fn us_socket_close_connecting(ssl: c_int, s: ?*Socket) ?*Socket;
extern fn us_socket_context_loop(ssl: c_int, context: ?*us_socket_context_t) ?*Loop;
-extern fn us_socket_context_adopt_socket(ssl: c_int, context: ?*us_socket_context_t, s: ?*us_socket_t, ext_size: c_int) ?*us_socket_t;
+extern fn us_socket_context_adopt_socket(ssl: c_int, context: ?*us_socket_context_t, s: ?*Socket, ext_size: c_int) ?*Socket;
extern fn us_create_child_socket_context(ssl: c_int, context: ?*us_socket_context_t, context_ext_size: c_int) ?*us_socket_context_t;
pub const Poll = opaque {
- extern fn us_create_poll(loop: ?*Loop, fallthrough: c_int, ext_size: c_uint) *Poll;
+ pub fn create(
+ loop: *Loop,
+ comptime Data: type,
+ file: c_int,
+ val: Data,
+ fallthrough: bool,
+ flags: Flags,
+ callback: CallbackType,
+ ) ?*Poll {
+ var poll = us_create_callback(loop, @as(c_int, @boolToInt(fallthrough)), file, @sizeOf(Data));
+ if (comptime Data != void) {
+ poll.data(Data).* = val;
+ }
+ var flags_int: c_int = 0;
+ if (flags.read) {
+ flags_int |= Flags.read_flag;
+ }
+
+ if (flags.write) {
+ flags_int |= Flags.write_flag;
+ }
+
+ us_callback_set(poll, flags_int, callback);
+ return poll;
+ }
+
+ pub fn stop(self: *Poll, loop: *Loop) void {
+ us_poll_stop(self, loop);
+ }
+
+ pub fn data(self: *Poll, comptime Data: type) *Data {
+ return us_poll_ext(self).?;
+ }
+
+ pub fn fd(self: *Poll) @import("std").os.fd_t {
+ return @intCast(@import("std").os.fd_t, us_poll_fd(self));
+ }
+
+ pub fn start(self: *Poll, poll_type: Flags) void {
+ // us_poll_start(self, loop: ?*Loop, events: c_int)
+ _ = self;
+ _ = poll_type;
+ }
+
+ pub const Flags = struct {
+ read: bool = false,
+ write: bool = false,
+
+ //#define LIBUS_SOCKET_READABLE
+ pub const read_flag = if (Environment.isLinux) std.os.linux.EPOLL.IN else 1;
+ // #define LIBUS_SOCKET_WRITABLE
+ pub const write_flag = if (Environment.isLinux) std.os.linux.EPOLL.OUT else 2;
+ };
+
+ pub fn deinit(self: *Poll) void {
+ us_poll_free(self);
+ }
+
+ // (void* userData, int fd, int events, int error, struct us_poll_t *poll)
+ pub const CallbackType = fn (?*anyopaque, c_int, c_int, c_int, *Poll) void;
+ extern fn us_create_callback(loop: ?*Loop, fallthrough: c_int, fd: c_int, ext_size: c_uint) *Poll;
+ extern fn us_callback_set(poll: *Poll, events: c_int, callback: CallbackType) *Poll;
extern fn us_poll_free(p: ?*Poll, loop: ?*Loop) void;
extern fn us_poll_init(p: ?*Poll, fd: c_int, poll_type: c_int) void;
extern fn us_poll_start(p: ?*Poll, loop: ?*Loop, events: c_int) void;
@@ -116,19 +182,19 @@ pub const Poll = opaque {
extern fn us_poll_resize(p: ?*Poll, loop: ?*Loop, ext_size: c_uint) ?*Poll;
};
-extern fn us_socket_get_native_handle(ssl: c_int, s: ?*us_socket_t) ?*anyopaque;
-extern fn us_socket_write(ssl: c_int, s: ?*us_socket_t, data: [*c]const u8, length: c_int, msg_more: c_int) c_int;
-extern fn us_socket_timeout(ssl: c_int, s: ?*us_socket_t, seconds: c_uint) void;
-extern fn us_socket_ext(ssl: c_int, s: ?*us_socket_t) ?*anyopaque;
-extern fn us_socket_context(ssl: c_int, s: ?*us_socket_t) ?*us_socket_context_t;
-extern fn us_socket_flush(ssl: c_int, s: ?*us_socket_t) void;
-extern fn us_socket_shutdown(ssl: c_int, s: ?*us_socket_t) void;
-extern fn us_socket_shutdown_read(ssl: c_int, s: ?*us_socket_t) void;
-extern fn us_socket_is_shut_down(ssl: c_int, s: ?*us_socket_t) c_int;
-extern fn us_socket_is_closed(ssl: c_int, s: ?*us_socket_t) c_int;
-extern fn us_socket_close(ssl: c_int, s: ?*us_socket_t, code: c_int, reason: ?*anyopaque) ?*us_socket_t;
-extern fn us_socket_local_port(ssl: c_int, s: ?*us_socket_t) c_int;
-extern fn us_socket_remote_address(ssl: c_int, s: ?*us_socket_t, buf: [*c]u8, length: [*c]c_int) void;
+extern fn us_socket_get_native_handle(ssl: c_int, s: ?*Socket) ?*anyopaque;
+extern fn us_socket_write(ssl: c_int, s: ?*Socket, data: [*c]const u8, length: c_int, msg_more: c_int) c_int;
+extern fn Socketimeout(ssl: c_int, s: ?*Socket, seconds: c_uint) void;
+extern fn us_socket_ext(ssl: c_int, s: ?*Socket) ?*anyopaque;
+extern fn us_socket_context(ssl: c_int, s: ?*Socket) ?*us_socket_context_t;
+extern fn us_socket_flush(ssl: c_int, s: ?*Socket) void;
+extern fn us_socket_shutdown(ssl: c_int, s: ?*Socket) void;
+extern fn us_socket_shutdown_read(ssl: c_int, s: ?*Socket) void;
+extern fn us_socket_is_shut_down(ssl: c_int, s: ?*Socket) c_int;
+extern fn us_socket_is_closed(ssl: c_int, s: ?*Socket) c_int;
+extern fn us_socket_close(ssl: c_int, s: ?*Socket, code: c_int, reason: ?*anyopaque) ?*Socket;
+extern fn us_socket_local_port(ssl: c_int, s: ?*Socket) c_int;
+extern fn us_socket_remote_address(ssl: c_int, s: ?*Socket, buf: [*c]u8, length: [*c]c_int) void;
pub const uws_app_s = opaque {};
pub const uws_req_s = opaque {};
pub const uws_websocket_s = opaque {};
@@ -607,7 +673,7 @@ pub fn NewApp(comptime ssl: bool) type {
// };
// const OnWritable = struct {
- // pub fn handle(socket: *us_socket_t) callconv(.C) ?*us_socket_t {
+ // pub fn handle(socket: *Socket) callconv(.C) ?*Socket {
// if (comptime UserDataType == void) {
// @call(.{ .modifier = .always_inline }, handler, .{
// void{},
@@ -644,7 +710,7 @@ pub fn NewApp(comptime ssl: bool) type {
};
}
extern fn uws_res_prepare_for_sendfile(ssl: c_int, res: *uws_res) void;
-extern fn uws_res_get_native_handle(ssl: c_int, res: *uws_res) *us_socket_t;
+extern fn uws_res_get_native_handle(ssl: c_int, res: *uws_res) *Socket;
extern fn uws_create_app(ssl: c_int, options: us_socket_context_options_t) *uws_app_t;
extern fn uws_app_destroy(ssl: c_int, app: *uws_app_t) void;
extern fn uws_app_get(ssl: c_int, app: *uws_app_t, pattern: [*c]const u8, handler: uws_method_handler, user_data: ?*anyopaque) void;
diff --git a/src/feature_flags.zig b/src/feature_flags.zig
index 02d09faeeb..4a9a7a776e 100644
--- a/src/feature_flags.zig
+++ b/src/feature_flags.zig
@@ -91,3 +91,6 @@ pub const atomic_file_watcher = env.isLinux;
pub const node_streams = env.isDebug or env.isTest;
pub const simd = true;
+
+// This change didn't seem to make a meaningful difference in microbenchmarks
+pub const latin1_is_now_ascii = false;
diff --git a/src/global.zig b/src/global.zig
index 9c506404ed..6160ce781c 100644
--- a/src/global.zig
+++ b/src/global.zig
@@ -8,6 +8,18 @@ pub const default_allocator: std.mem.Allocator = if (!use_mimalloc)
else
@import("./memory_allocator.zig").c_allocator;
+pub const huge_allocator: std.mem.Allocator = if (!use_mimalloc)
+ std.heap.c_allocator
+else
+ @import("./memory_allocator.zig").huge_allocator;
+
+pub const auto_allocator: std.mem.Allocator = if (!use_mimalloc)
+ std.heap.c_allocator
+else
+ @import("./memory_allocator.zig").auto_allocator;
+
+pub const huge_allocator_threshold: comptime_int = @import("./memory_allocator.zig").huge_threshold;
+
pub const C = @import("c.zig");
pub const FeatureFlags = @import("feature_flags.zig");
@@ -159,3 +171,33 @@ pub fn span(ptr: anytype) std.mem.Span(@TypeOf(ptr)) {
pub const IdentityContext = @import("./identity_context.zig").IdentityContext;
pub const ArrayIdentityContext = @import("./identity_context.zig").ArrayIdentityContext;
+pub const BabyList = @import("./baby_list.zig").BabyList;
+pub const ByteList = BabyList(u8);
+
+pub fn DebugOnly(comptime Type: type) type {
+ if (comptime Environment.isDebug) {
+ return Type;
+ }
+
+ return void;
+}
+
+pub fn DebugOnlyDefault(comptime val: anytype) if (Environment.isDebug) @TypeOf(val) else void {
+ if (comptime Environment.isDebug) {
+ return val;
+ }
+
+ return {};
+}
+
+pub inline fn range(comptime min: anytype, comptime max: anytype) [max - min]usize {
+ return comptime brk: {
+ var slice: [max - min]usize = undefined;
+ var i: usize = min;
+ while (i < max) {
+ slice[i - min] = i;
+ i += 1;
+ }
+ break :brk slice;
+ };
+}
diff --git a/src/io/io_darwin.zig b/src/io/io_darwin.zig
index 17cf9cca6f..f72ea73ae5 100644
--- a/src/io/io_darwin.zig
+++ b/src/io/io_darwin.zig
@@ -270,8 +270,9 @@ pub const darwin = struct {
pub extern "c" fn @"accept$NOCANCEL"(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) c_int;
pub extern "c" fn @"accept4$NOCANCEL"(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t, flags: c_uint) c_int;
pub extern "c" fn @"open$NOCANCEL"(path: [*:0]const u8, oflag: c_uint, ...) c_int;
+ pub extern "c" fn @"read$NOCANCEL"(fd: c.fd_t, buf: [*]u8, nbyte: usize) isize;
+ pub extern "c" fn @"pread$NOCANCEL"(fd: c.fd_t, buf: [*]u8, nbyte: usize, offset: c.off_t) isize;
};
-
pub const OpenError = error{
/// In WASI, this error may occur when the file descriptor does
/// not hold the required rights to open a new resource relative to it.
@@ -539,9 +540,11 @@ pub fn run_for_ns(self: *IO, nanoseconds: u63) !void {
}
}
+const default_timespec = std.mem.zeroInit(os.timespec, .{});
+
fn flush(self: *IO, wait_for_completions: bool) !void {
var io_pending = self.io_pending.peek();
- var events: [256]os.Kevent = undefined;
+ var events: [512]os.Kevent = undefined;
// Check timeouts and fill events with completions in io_pending
// (they will be submitted through kevent).
@@ -552,7 +555,7 @@ fn flush(self: *IO, wait_for_completions: bool) !void {
// Only call kevent() if we need to submit io events or if we need to wait for completions.
if (change_events > 0 or self.completed.peek() == null) {
// Zero timeouts for kevent() implies a non-blocking poll
- var ts = std.mem.zeroes(os.timespec);
+ var ts = default_timespec;
// We need to wait (not poll) on kevent if there's nothing to submit or complete.
// We should never wait indefinitely (timeout_ptr = null for kevent) given:
@@ -602,7 +605,6 @@ fn flush_io(_: *IO, events: []os.Kevent, io_pending_top: *?*Completion) usize {
for (events) |*kevent, flushed| {
const completion = io_pending_top.* orelse return flushed;
io_pending_top.* = completion.next;
-
const event_info = switch (completion.operation) {
.accept => |op| [3]c_int{
op.socket,
@@ -711,6 +713,7 @@ const Operation = union(enum) {
buf: [*]u8,
len: u32,
offset: u64,
+ positional: bool = true,
},
recv: struct {
socket: os.socket_t,
@@ -774,9 +777,13 @@ fn submitWithIncrementPending(
self.pending_count += 1;
const Context = @TypeOf(context);
const onCompleteFn = struct {
- fn onComplete(io: *IO, _completion: *Completion) void {
+ fn onComplete(
+ io: *IO,
+ _completion: *Completion,
+ ) void {
// Perform the actual operaton
const op_data = &@field(_completion.operation, @tagName(operation_tag));
+
const result = OperationImpl.doOperation(op_data);
// Requeue onto io_pending if error.WouldBlock
@@ -1161,8 +1168,9 @@ pub fn read(
completion: *Completion,
fd: os.fd_t,
buffer: []u8,
- offset: u64,
+ offset: ?u64,
) void {
+ const offset_ = offset orelse @as(u64, 0);
self.submit(
context,
callback,
@@ -1172,16 +1180,21 @@ pub fn read(
.fd = fd,
.buf = buffer.ptr,
.len = @intCast(u32, buffer_limit(buffer.len)),
- .offset = offset,
+ .offset = offset_,
+ .positional = offset != null,
},
struct {
fn doOperation(op: anytype) ReadError!usize {
while (true) {
- const rc = os.system.pread(
+ const rc = if (op.positional) os.system.pread(
op.fd,
op.buf,
op.len,
@bitCast(isize, op.offset),
+ ) else os.system.read(
+ op.fd,
+ op.buf,
+ op.len,
);
return switch (@enumToInt(os.errno(rc))) {
0 => @intCast(usize, rc),
diff --git a/src/io/io_linux.zig b/src/io/io_linux.zig
index 374ba9d789..b4f21dee59 100644
--- a/src/io/io_linux.zig
+++ b/src/io/io_linux.zig
@@ -1231,7 +1231,7 @@ pub fn read(
completion: *Completion,
fd: os.fd_t,
buffer: []u8,
- offset: u64,
+ offset: ?u64,
) void {
completion.* = .{
.io = self,
@@ -1250,7 +1250,8 @@ pub fn read(
.read = .{
.fd = fd,
.buffer = buffer,
- .offset = offset,
+ // pread is irrelevant here
+ .offset = offset orelse 0,
},
},
};
diff --git a/src/javascript/jsc/WebKit b/src/javascript/jsc/WebKit
index 06d0294f9c..ff1f8e24b7 160000
--- a/src/javascript/jsc/WebKit
+++ b/src/javascript/jsc/WebKit
@@ -1 +1 @@
-Subproject commit 06d0294f9cbf1ba697593322929271c695c629c6
+Subproject commit ff1f8e24b707d023a88aee5d9cd79b665c8471f3
diff --git a/src/javascript/jsc/api/bun.zig b/src/javascript/jsc/api/bun.zig
index 906e0e53cd..72d61d2e90 100644
--- a/src/javascript/jsc/api/bun.zig
+++ b/src/javascript/jsc/api/bun.zig
@@ -623,7 +623,7 @@ pub fn openInEditor(
) js.JSValueRef {
var edit = &VirtualMachine.vm.rareData().editor_context;
- var arguments = JSC.Node.ArgumentsSlice.from(args);
+ var arguments = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), args);
defer arguments.deinit();
var path: string = "";
var editor_choice: ?Editor = null;
@@ -822,7 +822,7 @@ fn doResolve(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) ?JSC.JSValue {
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
defer args.deinit();
const specifier = args.protectEatNext() orelse {
JSC.throwInvalidArguments("Expected a specifier and a from path", .{}, ctx, exception);
@@ -1543,7 +1543,7 @@ pub fn serve(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) js.JSValueRef {
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
var config = JSC.API.ServerConfig.fromJS(ctx.ptr(), &args, exception);
if (exception.* != null) {
return null;
@@ -1612,6 +1612,100 @@ pub fn serve(
unreachable;
}
+pub export fn Bun__escapeHTML(
+ globalObject: *JSGlobalObject,
+ callframe: *JSC.CallFrame,
+) JSC.JSValue {
+ const arguments = callframe.arguments();
+ if (arguments.len < 1) {
+ return ZigString.Empty.toValue(globalObject);
+ }
+
+ const input_value = arguments[0];
+ const zig_str = input_value.getZigString(globalObject);
+ if (zig_str.len == 0)
+ return ZigString.Empty.toValue(globalObject);
+
+ if (zig_str.is16Bit()) {
+ var input_slice = zig_str.utf16SliceAligned();
+ var escaped_html = strings.escapeHTMLForUTF16Input(globalObject.bunVM().allocator, input_slice) catch {
+ globalObject.vm().throwError(globalObject, ZigString.init("Out of memory").toValue(globalObject));
+ return JSC.JSValue.jsUndefined();
+ };
+
+ if (escaped_html.ptr == input_slice.ptr and escaped_html.len == input_slice.len) {
+ return input_value;
+ }
+
+ if (input_slice.len == 1) {
+ // single character escaped strings are statically allocated
+ return ZigString.init(std.mem.sliceAsBytes(escaped_html)).to16BitValue(globalObject);
+ }
+
+ if (comptime Environment.allow_assert) {
+ // assert that re-encoding the string produces the same result
+ std.debug.assert(
+ std.mem.eql(
+ u16,
+ (strings.toUTF16Alloc(bun.default_allocator, strings.toUTF8Alloc(bun.default_allocator, escaped_html) catch unreachable, false) catch unreachable).?,
+ escaped_html,
+ ),
+ );
+
+ // assert we do not allocate a new string unnecessarily
+ std.debug.assert(
+ !std.mem.eql(
+ u16,
+ input_slice,
+ escaped_html,
+ ),
+ );
+
+ // the output should always be longer than the input
+ std.debug.assert(escaped_html.len > input_slice.len);
+ }
+
+ return ZigString.from16(escaped_html.ptr, escaped_html.len).toExternalValue(globalObject);
+ } else {
+ var input_slice = zig_str.slice();
+ var escaped_html = strings.escapeHTMLForLatin1Input(globalObject.bunVM().allocator, input_slice) catch {
+ globalObject.vm().throwError(globalObject, ZigString.init("Out of memory").toValue(globalObject));
+ return JSC.JSValue.jsUndefined();
+ };
+
+ if (escaped_html.ptr == input_slice.ptr and escaped_html.len == input_slice.len) {
+ return input_value;
+ }
+
+ if (input_slice.len == 1) {
+ // single character escaped strings are statically allocated
+ return ZigString.init(escaped_html).toValue(globalObject);
+ }
+
+ if (comptime Environment.allow_assert) {
+ // the output should always be longer than the input
+ std.debug.assert(escaped_html.len > input_slice.len);
+
+ // assert we do not allocate a new string unnecessarily
+ std.debug.assert(
+ !std.mem.eql(
+ u8,
+ input_slice,
+ escaped_html,
+ ),
+ );
+ }
+
+ return ZigString.init(escaped_html).toExternalValue(globalObject);
+ }
+}
+
+comptime {
+ if (!JSC.is_bindgen) {
+ _ = Bun__escapeHTML;
+ }
+}
+
pub fn allocUnsafe(
_: void,
ctx: js.JSContextRef,
@@ -1620,7 +1714,7 @@ pub fn allocUnsafe(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) js.JSValueRef {
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
const length = @intCast(
usize,
@@ -1649,7 +1743,7 @@ pub fn mmapFile(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) js.JSValueRef {
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
var buf: [bun.MAX_PATH_BYTES]u8 = undefined;
const path = getFilePath(ctx, arguments[0..@minimum(1, arguments.len)], &buf, exception) orelse return null;
@@ -1795,7 +1889,7 @@ pub const Hash = struct {
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) js.JSValueRef {
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
var input: []const u8 = "";
var input_slice = ZigString.Slice.empty;
defer input_slice.deinit();
@@ -2375,7 +2469,7 @@ pub const FFI = struct {
return JSC.toInvalidArguments("ptr to invalid memory, that would segfault Bun :(", .{}, globalThis.ref());
}
- return JSC.JSValue.jsNumber(@bitCast(f64, @as(usize, addr)));
+ return JSC.JSValue.fromPtrAddress(addr);
}
const ValueOrError = union(enum) {
diff --git a/src/javascript/jsc/api/ffi.zig b/src/javascript/jsc/api/ffi.zig
index 820a0e3d57..864a5d889f 100644
--- a/src/javascript/jsc/api/ffi.zig
+++ b/src/javascript/jsc/api/ffi.zig
@@ -351,7 +351,7 @@ pub const FFI = struct {
return ZigString.init("Failed to compile (nothing happend!)").toErrorInstance(global);
},
.compiled => |compiled| {
- var cb = Bun__CreateFFIFunction(
+ var cb = JSC.NewFunctionPtr(
global,
&ZigString.init(std.mem.span(function_name)),
@intCast(u32, function.arg_types.items.len),
@@ -443,7 +443,7 @@ pub const FFI = struct {
return ZigString.init("Failed to compile (nothing happend!)").toErrorInstance(global);
},
.compiled => |compiled| {
- var cb = Bun__CreateFFIFunction(
+ var cb = JSC.NewFunctionPtr(
global,
&ZigString.init(std.mem.span(function_name)),
@intCast(u32, function.arg_types.items.len),
@@ -1434,10 +1434,3 @@ pub const FFI = struct {
}
};
};
-
-extern fn Bun__CreateFFIFunction(
- globalObject: *JSGlobalObject,
- symbolName: *const ZigString,
- argCount: u32,
- functionPointer: *anyopaque,
-) *anyopaque;
diff --git a/src/javascript/jsc/api/html_rewriter.zig b/src/javascript/jsc/api/html_rewriter.zig
index 70406ace5b..7605cfef7b 100644
--- a/src/javascript/jsc/api/html_rewriter.zig
+++ b/src/javascript/jsc/api/html_rewriter.zig
@@ -408,6 +408,124 @@ pub const HTMLRewriter = struct {
this.context.deinit(bun.default_allocator);
}
};
+
+ // pub const StreamOutputSink = struct {
+ // global: *JSGlobalObject,
+ // rewriter: *LOLHTML.HTMLRewriter,
+ // context: LOLHTMLContext,
+ // response: *Response,
+ // input: JSC.WebCore.Blob = undefined,
+ // pub fn init(context: LOLHTMLContext, global: *JSGlobalObject, original: *Response, builder: *LOLHTML.HTMLRewriter.Builder) JSValue {
+ // var result = bun.default_allocator.create(Response) catch unreachable;
+ // var sink = bun.default_allocator.create(StreamOutputSink) catch unreachable;
+ // sink.* = StreamOutputSink{
+ // .global = global,
+ // .rewriter = undefined,
+ // .context = context,
+ // .response = result,
+ // };
+
+ // for (sink.context.document_handlers.items) |doc| {
+ // doc.ctx = sink;
+ // }
+ // for (sink.context.element_handlers.items) |doc| {
+ // doc.ctx = sink;
+ // }
+
+ // sink.rewriter = builder.build(
+ // .UTF8,
+ // .{
+ // .preallocated_parsing_buffer_size = @maximum(original.body.len(), 1024),
+ // .max_allowed_memory_usage = std.math.maxInt(u32),
+ // },
+ // false,
+ // StreamOutputSink,
+ // sink,
+ // StreamOutputSink.write,
+ // StreamOutputSink.done,
+ // ) catch {
+ // sink.deinit();
+ // bun.default_allocator.destroy(result);
+
+ // return throwLOLHTMLError(global);
+ // };
+
+ // result.* = Response{
+ // .allocator = bun.default_allocator,
+ // .body = .{
+ // .init = .{
+ // .status_code = 200,
+ // },
+ // .value = .{
+ // .Locked = .{
+ // .global = global,
+ // .task = sink,
+ // },
+ // },
+ // },
+ // };
+
+ // result.body.init.headers = original.body.init.headers;
+ // result.body.init.method = original.body.init.method;
+ // result.body.init.status_code = original.body.init.status_code;
+
+ // result.url = bun.default_allocator.dupe(u8, original.url) catch unreachable;
+ // result.status_text = bun.default_allocator.dupe(u8, original.status_text) catch unreachable;
+
+ // var input: JSC.WebCore.Blob = original.body.value.use();
+
+ // const is_pending = input.needsToReadFile();
+ // defer if (!is_pending) input.detach();
+
+ // if (is_pending) {
+ // input.doReadFileInternal(*StreamOutputSink, sink, onFinishedLoading, global);
+ // } else if (sink.runOutputSink(input.sharedView(), false, false)) |error_value| {
+ // return error_value;
+ // }
+
+ // // Hold off on cloning until we're actually done.
+
+ // return JSC.JSValue.fromRef(
+ // Response.makeMaybePooled(sink.global.ref(), sink.response),
+ // );
+ // }
+
+ // pub fn runOutputSink(
+ // sink: *StreamOutputSink,
+ // bytes: []const u8,
+ // is_async: bool,
+ // free_bytes_on_end: bool,
+ // ) ?JSValue {
+ // defer if (free_bytes_on_end)
+ // bun.default_allocator.free(bun.constStrToU8(bytes));
+
+ // return null;
+ // }
+
+ // pub const Sync = enum { suspended, pending, done };
+
+ // pub fn done(this: *StreamOutputSink) void {
+ // var prev_value = this.response.body.value;
+ // var bytes = this.bytes.toOwnedSliceLeaky();
+ // this.response.body.value = .{
+ // .Blob = JSC.WebCore.Blob.init(bytes, this.bytes.allocator, this.global),
+ // };
+ // prev_value.resolve(
+ // &this.response.body.value,
+ // this.global,
+ // );
+ // }
+
+ // pub fn write(this: *StreamOutputSink, bytes: []const u8) void {
+ // this.bytes.append(bytes) catch unreachable;
+ // }
+
+ // pub fn deinit(this: *StreamOutputSink) void {
+ // this.bytes.deinit();
+
+ // this.context.deinit(bun.default_allocator);
+ // }
+ // };
};
const DocumentHandler = struct {
diff --git a/src/javascript/jsc/api/server.zig b/src/javascript/jsc/api/server.zig
index a76ddf9ab8..bec079e90f 100644
--- a/src/javascript/jsc/api/server.zig
+++ b/src/javascript/jsc/api/server.zig
@@ -238,7 +238,7 @@ pub const ServerConfig = struct {
};
pub fn fromJS(global: *JSC.JSGlobalObject, arguments: *JSC.Node.ArgumentsSlice, exception: JSC.C.ExceptionRef) ServerConfig {
- var env = VirtualMachine.vm.bundler.env;
+ var env = arguments.vm.bundler.env;
var args = ServerConfig{
.port = 3000,
@@ -250,7 +250,7 @@ pub const ServerConfig = struct {
args.development = false;
}
- if (VirtualMachine.vm.bundler.options.production) {
+ if (arguments.vm.bundler.options.production) {
args.development = false;
}
@@ -264,11 +264,11 @@ pub const ServerConfig = struct {
}
}
- if (VirtualMachine.vm.bundler.options.transform_options.port) |port| {
+ if (arguments.vm.bundler.options.transform_options.port) |port| {
args.port = port;
}
- if (VirtualMachine.vm.bundler.options.transform_options.origin) |origin| {
+ if (arguments.vm.bundler.options.transform_options.origin) |origin| {
args.base_uri = origin;
}
@@ -515,6 +515,11 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
url: string,
method: HTTP.Method,
aborted: bool = false,
+ finalized: bun.DebugOnly(bool) = bun.DebugOnlyDefault(false),
+
+ /// We can only safely free once the request body promise is finalized
+ /// and the response is rejected
+ pending_promises_for_abort: u8 = 0,
has_marked_complete: bool = false,
response_jsvalue: JSC.JSValue = JSC.JSValue.zero,
@@ -549,7 +554,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
arguments: []const JSC.JSValue,
) void {
if (ctx.aborted) {
- ctx.finalize();
+ ctx.finalizeForAbort();
return;
}
@@ -579,16 +584,20 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
ctx.render(response);
}
+ pub fn finalizeForAbort(this: *RequestContext) void {
+ this.pending_promises_for_abort -|= 1;
+ if (this.pending_promises_for_abort == 0) this.finalize();
+ }
+
pub fn onReject(
ctx: *RequestContext,
_: *JSC.JSGlobalObject,
arguments: []const JSC.JSValue,
) void {
if (ctx.aborted) {
- ctx.finalize();
+ ctx.finalizeForAbort();
return;
}
-
handleReject(ctx, if (arguments.len > 0) arguments[0] else JSC.JSValue.jsUndefined());
}
@@ -598,10 +607,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
);
if (ctx.aborted) {
- ctx.finalize();
+ ctx.finalizeForAbort();
return;
}
-
if (!ctx.resp.hasResponded()) {
ctx.renderMissing();
}
@@ -674,8 +682,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn onWritableResponseBuffer(this: *RequestContext, write_offset: c_ulong, resp: *App.Response) callconv(.C) bool {
+ std.debug.assert(this.resp == resp);
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return false;
}
return this.sendWritableBytes(this.response_buf_owned.items, write_offset, resp);
@@ -694,10 +703,69 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
};
}
- pub fn onAbort(this: *RequestContext, _: *App.Response) void {
+ pub fn isDeadRequest(this: *RequestContext) bool {
+ if (this.pending_promises_for_abort > 0) return false;
+
+ if (this.promise != null) {
+ return false;
+ }
+
+ if (this.request_js_object) |obj| {
+ if (obj.value().as(Request)) |req| {
+ if (req.body == .Locked) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ pub fn onAbort(this: *RequestContext, resp: *App.Response) void {
+ std.debug.assert(this.resp == resp);
+ std.debug.assert(!this.aborted);
this.aborted = true;
- this.finalizeWithoutDeinit();
- this.markComplete();
+
+ // if we can, free the request now.
+ if (this.isDeadRequest()) {
+ this.finalizeWithoutDeinit();
+ this.markComplete();
+ this.deinit();
+ } else {
+ this.pending_promises_for_abort = 0;
+
+ // if we cannot, we have to reject pending promises
+ // first, we reject the request body promise
+ if (this.request_js_object != null) {
+ var request_js = this.request_js_object.?.value();
+ request_js.ensureStillAlive();
+
+ this.request_js_object = null;
+ defer request_js.ensureStillAlive();
+ defer JSC.C.JSValueUnprotect(this.server.globalThis.ref(), request_js.asObjectRef());
+ // User called .blob(), .json(), text(), or .arrayBuffer() on the Request object
+ // but we received nothing or the connection was aborted
+ if (request_js.as(Request)) |req| {
+ // the promise is pending
+ if (req.body == .Locked and (req.body.Locked.action != .none or req.body.Locked.promise != null)) {
+ this.pending_promises_for_abort += 1;
+ req.body.toErrorInstance(JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis), this.server.globalThis);
+ }
+ req.uws_request = null;
+ }
+ }
+
+ // then, we reject the response promise
+ if (this.promise) |promise| {
+ this.pending_promises_for_abort += 1;
+ this.promise = null;
+ promise.asPromise().?.reject(this.server.globalThis, JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis));
+ }
+
+ if (this.pending_promises_for_abort > 0) {
+ this.server.vm.tick();
+ }
+ }
}
pub fn markComplete(this: *RequestContext) void {
@@ -709,7 +777,11 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
// so it's important that we can safely do that
pub fn finalizeWithoutDeinit(this: *RequestContext) void {
this.blob.detach();
- this.request_body_buf.clearAndFree(this.allocator);
+
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(!this.finalized);
+ this.finalized = true;
+ }
if (!this.response_jsvalue.isEmpty()) {
this.server.response_objects_pool.push(this.server.globalThis, this.response_jsvalue);
@@ -717,38 +789,56 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
if (this.request_js_object != null) {
+ var request_js = this.request_js_object.?.value();
+ request_js.ensureStillAlive();
+
+ this.request_js_object = null;
+ defer request_js.ensureStillAlive();
+ defer JSC.C.JSValueUnprotect(this.server.globalThis.ref(), request_js.asObjectRef());
// User called .blob(), .json(), text(), or .arrayBuffer() on the Request object
- // but we received nothing
- if (JSC.JSValue.fromRef(this.request_js_object).as(Request)) |req| {
+ // but we received nothing or the connection was aborted
+ if (request_js.as(Request)) |req| {
+ // the promise is pending
if (req.body == .Locked and req.body.Locked.action != .none and req.body.Locked.promise != null) {
- var old_body = req.body;
- req.body = JSC.WebCore.Body.Value.empty;
- old_body.Locked.callback = null;
- old_body.resolve(&req.body, this.server.globalThis);
- VirtualMachine.vm.tick();
+ req.body.toErrorInstance(JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis), this.server.globalThis);
}
req.uws_request = null;
- JSC.C.JSValueUnprotect(this.server.globalThis.ref(), this.request_js_object);
- this.request_js_object = null;
}
}
- if (this.promise != null) {
- JSC.C.JSValueUnprotect(this.server.globalThis.ref(), this.promise.?.asObjectRef());
+ if (this.promise) |promise| {
this.promise = null;
+
+ if (promise.asInternalPromise()) |prom| {
+ prom.rejectAsHandled(this.server.globalThis, (JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis)));
+ } else if (promise.asPromise()) |prom| {
+ prom.rejectAsHandled(this.server.globalThis, (JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis)));
+ }
+ JSC.C.JSValueUnprotect(this.server.globalThis.ref(), promise.asObjectRef());
}
if (this.response_headers != null) {
this.response_headers.?.deref();
this.response_headers = null;
}
-
- this.response_buf_owned.clearAndFree(this.allocator);
}
pub fn finalize(this: *RequestContext) void {
- var server = this.server;
this.finalizeWithoutDeinit();
this.markComplete();
+ this.deinit();
+ }
+
+ pub fn deinit(this: *RequestContext) void {
+ if (comptime Environment.allow_assert)
+ std.debug.assert(this.finalized);
+
+ if (comptime Environment.allow_assert)
+ std.debug.assert(this.has_marked_complete);
+
+ var server = this.server;
+ this.request_body_buf.clearAndFree(this.allocator);
+ this.response_buf_owned.clearAndFree(this.allocator);
+
server.request_pool_allocator.destroy(this);
}
@@ -855,8 +945,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn onWritableBytes(this: *RequestContext, write_offset: c_ulong, resp: *App.Response) callconv(.C) bool {
+ std.debug.assert(this.resp == resp);
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return false;
}
@@ -865,6 +956,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn sendWritableBytes(this: *RequestContext, bytes_: []const u8, write_offset: c_ulong, resp: *App.Response) bool {
+ std.debug.assert(this.resp == resp);
+
var bytes = bytes_[@minimum(bytes_.len, @truncate(usize, write_offset))..];
if (resp.tryEnd(bytes, bytes_.len)) {
this.finalize();
@@ -976,7 +1069,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
pub fn doSendfile(this: *RequestContext, blob: Blob) void {
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return;
}
@@ -994,7 +1087,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
pub fn onReadFile(this: *RequestContext, result: Blob.Store.ReadFile.ResultType) void {
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return;
}
@@ -1024,7 +1117,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
const err = value.Error;
_ = value.use();
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return;
}
this.runErrorHandler(err);
@@ -1034,7 +1127,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
this.blob = value.use();
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return;
}
@@ -1068,7 +1161,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
pub fn doRender(this: *RequestContext) void {
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return;
}
var response = this.response_ptr.?;
@@ -1232,7 +1325,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
pub fn resolveRequestBody(this: *RequestContext) void {
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return;
}
@@ -1251,7 +1344,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
}
- pub fn onBodyChunk(this: *RequestContext, _: *App.Response, chunk: []const u8, last: bool) void {
+ pub fn onBodyChunk(this: *RequestContext, resp: *App.Response, chunk: []const u8, last: bool) void {
+ std.debug.assert(this.resp == resp);
+
if (this.aborted) return;
this.request_body_buf.appendSlice(this.allocator, chunk) catch @panic("Out of memory while allocating request body");
if (last) {
@@ -1264,7 +1359,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
}
- pub fn onRequestData(this: *RequestContext) void {
+ pub fn onPull(this: *RequestContext) void {
if (this.req.header("content-length")) |content_length| {
const len = std.fmt.parseInt(usize, content_length, 10) catch 0;
if (len == 0) {
@@ -1301,8 +1396,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
this.resp.onData(*RequestContext, onBodyChunk, this);
}
- pub fn onRequestDataCallback(this: *anyopaque) void {
- onRequestData(bun.cast(*RequestContext, this));
+ pub fn onPullCallback(this: *anyopaque) void {
+ onPull(bun.cast(*RequestContext, this));
}
};
}
@@ -1522,7 +1617,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
this.listen_callback = JSC.AnyTask.New(ThisServer, run).init(this);
this.vm.eventLoop().enqueueTask(JSC.Task.init(&this.listen_callback));
if (needs_post_handler) {
- _ = this.vm.uws_event_loop.?.addPostHandler(*JSC.VirtualMachine.EventLoop, this.vm.eventLoop(), JSC.VirtualMachine.EventLoop.tick);
+ _ = this.vm.uws_event_loop.?.addPostHandler(*JSC.EventLoop, this.vm.eventLoop(), JSC.EventLoop.tick);
}
}
@@ -1605,7 +1700,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
.Locked = .{
.task = ctx,
.global = this.globalThis,
- .onRequestData = RequestContext.onRequestDataCallback,
+ .onPull = RequestContext.onPullCallback,
},
},
};
@@ -1617,10 +1712,9 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
const response_value = JSC.C.JSObjectCallAsFunctionReturnValue(this.globalThis.ref(), this.config.onRequest.asObjectRef(), this.thisObject.asObjectRef(), 1, &args);
if (ctx.aborted) {
- ctx.finalize();
+ ctx.finalizeForAbort();
return;
}
-
if (response_value.isEmptyOrUndefinedOrNull() and !ctx.resp.hasResponded()) {
ctx.renderMissing();
return;
diff --git a/src/javascript/jsc/api/transpiler.zig b/src/javascript/jsc/api/transpiler.zig
index b8a8192c6a..69732c643c 100644
--- a/src/javascript/jsc/api/transpiler.zig
+++ b/src/javascript/jsc/api/transpiler.zig
@@ -547,6 +547,19 @@ fn transformOptionsFromJSC(ctx: JSC.C.JSContextRef, temp_allocator: std.mem.Allo
transpiler.runtime.allow_runtime = flag.toBoolean();
}
+ if (object.get(globalThis, "jsxOptimizationInline")) |flag| {
+ transpiler.runtime.jsx_optimization_inline = flag.toBoolean();
+ }
+
+ if (object.get(globalThis, "jsxOptimizationHoist")) |flag| {
+ transpiler.runtime.jsx_optimization_hoist = flag.toBoolean();
+
+ if (!transpiler.runtime.jsx_optimization_inline and transpiler.runtime.jsx_optimization_hoist) {
+ JSC.throwInvalidArguments("jsxOptimizationHoist requires jsxOptimizationInline", .{}, ctx, exception);
+ return transpiler;
+ }
+ }
+
if (object.get(globalThis, "sourcemap")) |flag| {
if (flag.isBoolean() or flag.isUndefinedOrNull()) {
if (flag.toBoolean()) {
@@ -737,7 +750,7 @@ pub fn constructor(
exception: js.ExceptionRef,
) js.JSObjectRef {
var temp = std.heap.ArenaAllocator.init(getAllocator(ctx));
- var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
+ var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
defer temp.deinit();
const transpiler_options: TranspilerOptions = if (arguments.len > 0)
transformOptionsFromJSC(ctx, temp.allocator(), &args, exception) catch {
@@ -874,7 +887,7 @@ pub fn scan(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) JSC.C.JSObjectRef {
- var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
+ var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
defer args.arena.deinit();
const code_arg = args.next() orelse {
JSC.throwInvalidArguments("Expected a string or Uint8Array", .{}, ctx, exception);
@@ -965,7 +978,7 @@ pub fn transform(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) JSC.C.JSObjectRef {
- var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
+ var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
defer args.arena.deinit();
const code_arg = args.next() orelse {
JSC.throwInvalidArguments("Expected a string or Uint8Array", .{}, ctx, exception);
@@ -1006,7 +1019,7 @@ pub fn transformSync(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) JSC.C.JSObjectRef {
- var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
+ var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
defer args.arena.deinit();
const code_arg = args.next() orelse {
JSC.throwInvalidArguments("Expected a string or Uint8Array", .{}, ctx, exception);
@@ -1193,7 +1206,7 @@ pub fn scanImports(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) JSC.C.JSObjectRef {
- var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
+ var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
const code_arg = args.next() orelse {
JSC.throwInvalidArguments("Expected a string or Uint8Array", .{}, ctx, exception);
return null;
diff --git a/src/javascript/jsc/base.zig b/src/javascript/jsc/base.zig
index 70570ed201..777a5d6ef5 100644
--- a/src/javascript/jsc/base.zig
+++ b/src/javascript/jsc/base.zig
@@ -2553,6 +2553,7 @@ pub export fn MarkedArrayBuffer_deallocator(bytes_: *anyopaque, _: *anyopaque) v
// but we don't
mimalloc.mi_free(bytes_);
}
+
pub export fn BlobArrayBuffer_deallocator(_: *anyopaque, blob: *anyopaque) void {
// zig's memory allocator interface won't work here
// mimalloc knows the size of things
@@ -2646,7 +2647,6 @@ pub const JSPrivateDataPtr = TaggedPointerUnion(.{
Stats,
TextChunk,
TextDecoder,
- TextEncoder,
TimeoutTask,
Transpiler,
FFI,
@@ -2793,7 +2793,7 @@ pub fn wrapWithHasContainer(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) js.JSObjectRef {
- var iter = JSC.Node.ArgumentsSlice.from(arguments);
+ var iter = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
var args: Args = undefined;
comptime var i: usize = 0;
@@ -2934,14 +2934,15 @@ pub fn wrapWithHasContainer(
}
if (comptime maybe_async) {
- JavaScript.VirtualMachine.vm.tick();
+ var vm = ctx.ptr().bunVM();
+ vm.tick();
var promise = JSC.JSInternalPromise.resolvedPromise(ctx.ptr(), result);
switch (promise.status(ctx.ptr().vm())) {
JSC.JSPromise.Status.Pending => {
while (promise.status(ctx.ptr().vm()) == .Pending) {
- JavaScript.VirtualMachine.vm.tick();
+ vm.tick();
}
result = promise.result(ctx.ptr().vm());
},
diff --git a/src/javascript/jsc/bindings/BunBuiltinNames.h b/src/javascript/jsc/bindings/BunBuiltinNames.h
index 28ab0235d6..a2a6c6b3cd 100644
--- a/src/javascript/jsc/bindings/BunBuiltinNames.h
+++ b/src/javascript/jsc/bindings/BunBuiltinNames.h
@@ -23,49 +23,128 @@ using namespace JSC;
#define BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
+ macro(AbortSignal) \
+ macro(ReadableByteStreamController) \
+ macro(ReadableStream) \
+ macro(ReadableStreamBYOBReader) \
+ macro(ReadableStreamBYOBRequest) \
+ macro(ReadableStreamDefaultController) \
+ macro(ReadableStreamDefaultReader) \
+ macro(TransformStream) \
+ macro(TransformStreamDefaultController) \
+ macro(WritableStream) \
+ macro(WritableStreamDefaultController) \
+ macro(WritableStreamDefaultWriter) \
+ macro(abortAlgorithm) \
+ macro(abortSteps) \
macro(addEventListener) \
+ macro(appendFromJS) \
macro(argv) \
+ macro(associatedReadableByteStreamController) \
+ macro(autoAllocateChunkSize) \
+ macro(backingMap) \
+ macro(backingSet) \
+ macro(backpressure) \
+ macro(backpressureChangePromise) \
macro(basename) \
+ macro(body) \
+ macro(bunNativePtr) \
+ macro(bunNativeType) \
+ macro(byobRequest) \
+ macro(cancel) \
+ macro(cancelAlgorithm) \
macro(chdir) \
+ macro(cloneArrayBuffer) \
macro(close) \
+ macro(closeAlgorithm) \
+ macro(closeRequest) \
+ macro(closeRequested) \
+ macro(closed) \
+ macro(closedPromise) \
+ macro(closedPromiseCapability) \
macro(code) \
macro(connect) \
+ macro(controlledReadableStream) \
+ macro(controller) \
+ macro(consumeReadableStream) \
macro(cork) \
+ macro(createFIFO) \
+ macro(createNativeReadableStream) \
+ macro(createEmptyReadableStream) \
+ macro(createReadableStream) \
+ macro(createUninitializedArrayBuffer) \
+ macro(createWritableStreamFromInternal) \
macro(cwd) \
+ macro(dataView) \
+ macro(decode) \
macro(delimiter) \
- macro(whenSignalAborted) \
macro(destroy) \
macro(dir) \
macro(dirname) \
+ macro(disturbed) \
+ macro(document) \
+ macro(encode) \
+ macro(encoding) \
macro(end) \
macro(errno) \
+ macro(errorSteps) \
macro(execArgv) \
macro(extname) \
+ macro(failureKind) \
+ macro(fatal) \
+ macro(fetch) \
+ macro(fetchRequest) \
macro(file) \
macro(filePath) \
+ macro(fillFromJS) \
+ macro(finishConsumingStream) \
+ macro(flush) \
+ macro(flushAlgorithm) \
macro(format) \
macro(get) \
+ macro(getInternalWritableStream) \
+ macro(handleEvent) \
macro(hash) \
+ macro(header) \
+ macro(highWaterMark) \
macro(host) \
macro(hostname) \
macro(href) \
+ macro(ignoreBOM) \
+ macro(inFlightCloseRequest) \
+ macro(inFlightWriteRequest) \
+ macro(initializeWith) \
+ macro(internalStream) \
+ macro(internalWritable) \
+ macro(isAbortSignal) \
macro(isAbsolute) \
+ macro(isDisturbed) \
macro(isPaused) \
+ macro(isSecureContext) \
macro(isWindows) \
macro(join) \
+ macro(kind) \
+ macro(localStreams) \
+ macro(makeDOMException) \
+ macro(makeGetterTypeError) \
+ macro(makeThisTypeError) \
macro(map) \
+ macro(nativeReadableStreamPrototype) \
macro(nextTick) \
macro(normalize) \
macro(on) \
macro(once) \
macro(options) \
macro(origin) \
+ macro(ownerReadableStream) \
macro(parse) \
macro(password) \
macro(patch) \
macro(path) \
macro(pathname) \
macro(pause) \
+ macro(pendingAbortRequest) \
+ macro(pendingPullIntos) \
macro(pid) \
macro(pipe) \
macro(port) \
@@ -74,30 +153,78 @@ using namespace JSC;
macro(prependEventListener) \
macro(process) \
macro(protocol) \
+ macro(pull) \
+ macro(pullAgain) \
+ macro(pullAlgorithm) \
+ macro(pulling) \
macro(put) \
+ macro(queue) \
macro(read) \
+ macro(readIntoRequests) \
+ macro(readRequests) \
+ macro(readable) \
+ macro(readableStreamController) \
+ macro(readableStreamToArray) \
+ macro(reader) \
+ macro(readyPromise) \
+ macro(readyPromiseCapability) \
macro(relative) \
- macro(require) \
- macro(resolveSync) \
+ macro(releaseLock) \
macro(removeEventListener) \
+ macro(require) \
macro(resolve) \
+ macro(resolveSync) \
macro(resume) \
macro(search) \
macro(searchParams) \
+ macro(self) \
macro(sep) \
+ macro(setBody) \
+ macro(setStatus) \
+ macro(size) \
+ macro(start) \
+ macro(startConsumingStream) \
+ macro(started) \
+ macro(startedPromise) \
+ macro(state) \
+ macro(storedError) \
+ macro(strategy) \
+ macro(strategyHWM) \
+ macro(strategySizeAlgorithm) \
+ macro(stream) \
+ macro(streamClosed) \
+ macro(streamClosing) \
+ macro(streamErrored) \
+ macro(streamReadable) \
+ macro(streamWaiting) \
+ macro(streamWritable) \
+ macro(structuredCloneForStream) \
macro(syscall) \
- macro(title) \
+ macro(textDecoderStreamDecoder) \
+ macro(textDecoderStreamTransform) \
+ macro(textEncoderStreamEncoder) \
+ macro(textEncoderStreamTransform) \
macro(toNamespacedPath) \
macro(trace) \
+ macro(transformAlgorithm) \
macro(uncork) \
+ macro(underlyingByteSource) \
+ macro(underlyingSink) \
+ macro(underlyingSource) \
macro(unpipe) \
macro(unshift) \
macro(url) \
macro(username) \
macro(version) \
macro(versions) \
+ macro(view) \
+ macro(whenSignalAborted) \
+ macro(writable) \
macro(write) \
- macro(dataView) \
+ macro(writeAlgorithm) \
+ macro(writeRequests) \
+ macro(writer) \
+ macro(writing) \
BUN_ADDITIONAL_PRIVATE_IDENTIFIERS(macro) \
class BunBuiltinNames {
@@ -123,5 +250,7 @@ private:
BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(DECLARE_BUILTIN_NAMES)
};
+
+
} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/BunClientData.cpp b/src/javascript/jsc/bindings/BunClientData.cpp
index 807525a210..2cdd8b25a8 100644
--- a/src/javascript/jsc/bindings/BunClientData.cpp
+++ b/src/javascript/jsc/bindings/BunClientData.cpp
@@ -14,21 +14,23 @@
#include "wtf/MainThread.h"
#include "JSDOMConstructorBase.h"
+#include "JSDOMBuiltinConstructorBase.h"
#include "BunGCOutputConstraint.h"
#include "WebCoreTypedArrayController.h"
-#include "JavaScriptCore/AbstractSlotVisitorInlines.h"
-#include "JavaScriptCore/JSCellInlines.h"
-#include "JavaScriptCore/WeakInlines.h"
+#include "JavaScriptCore/JSCInlines.h"
+
+#include "JSDOMWrapper.h"
namespace WebCore {
using namespace JSC;
JSHeapData::JSHeapData(Heap& heap)
- // : m_domNamespaceObjectSpace ISO_SUBSPACE_INIT(heap, heap.cellHeapCellType, JSDOMObject)
- // ,
- : m_subspaces(makeUnique())
+ : m_heapCellTypeForJSWorkerGlobalScope(JSC::IsoHeapCellType::Args())
+ , m_domBuiltinConstructorSpace ISO_SUBSPACE_INIT(heap, heap.cellHeapCellType, JSDOMBuiltinConstructorBase)
, m_domConstructorSpace ISO_SUBSPACE_INIT(heap, heap.cellHeapCellType, JSDOMConstructorBase)
+ , m_domNamespaceObjectSpace ISO_SUBSPACE_INIT(heap, heap.cellHeapCellType, JSDOMObject)
+ , m_subspaces(makeUnique())
{
}
@@ -36,11 +38,14 @@ JSHeapData::JSHeapData(Heap& heap)
#define CLIENT_ISO_SUBSPACE_INIT(subspace) subspace(m_heapData->subspace)
JSVMClientData::JSVMClientData(VM& vm)
- : m_builtinNames(vm)
+ : m_builtinFunctions(vm)
+ , m_builtinNames(vm)
, m_heapData(JSHeapData::ensureHeapData(vm.heap))
+ , CLIENT_ISO_SUBSPACE_INIT(m_domBuiltinConstructorSpace)
, CLIENT_ISO_SUBSPACE_INIT(m_domConstructorSpace)
+ , CLIENT_ISO_SUBSPACE_INIT(m_domNamespaceObjectSpace)
, m_clientSubspaces(makeUnique())
- , m_builtinFunctions(vm)
+
{
}
@@ -59,8 +64,11 @@ JSHeapData* JSHeapData::ensureHeapData(Heap& heap)
return singleton;
}
-JSVMClientData::~JSVMClientData() {}
-
+JSVMClientData::~JSVMClientData()
+{
+ ASSERT(m_normalWorld->hasOneRef());
+ m_normalWorld = nullptr;
+}
void JSVMClientData::create(VM* vm)
{
JSVMClientData* clientData = new JSVMClientData(*vm);
@@ -68,7 +76,6 @@ void JSVMClientData::create(VM* vm)
clientData->m_normalWorld = DOMWrapperWorld::create(*vm, DOMWrapperWorld::Type::Normal);
vm->heap.addMarkingConstraint(makeUnique(*vm, clientData->heapData()));
-
vm->m_typedArrayController = adoptRef(new WebCoreTypedArrayController(true));
}
diff --git a/src/javascript/jsc/bindings/BunClientData.h b/src/javascript/jsc/bindings/BunClientData.h
index 800514efa4..e13ff84735 100644
--- a/src/javascript/jsc/bindings/BunClientData.h
+++ b/src/javascript/jsc/bindings/BunClientData.h
@@ -54,7 +54,7 @@ public:
func(*space);
}
- // JSC::IsoSubspace m_domNamespaceObjectSpace;
+ JSC::IsoHeapCellType m_heapCellTypeForJSWorkerGlobalScope;
private:
Lock m_lock;
@@ -62,6 +62,8 @@ private:
private:
std::unique_ptr m_subspaces;
JSC::IsoSubspace m_domConstructorSpace;
+ JSC::IsoSubspace m_domBuiltinConstructorSpace;
+ JSC::IsoSubspace m_domNamespaceObjectSpace;
Vector m_outputConstraintSpaces;
};
@@ -89,6 +91,8 @@ public:
Vector& outputConstraintSpaces() { return m_outputConstraintSpaces; }
+ JSC::GCClient::IsoSubspace& domBuiltinConstructorSpace() { return m_domBuiltinConstructorSpace; }
+
template void forEachOutputConstraintSpace(const Func& func)
{
for (auto* space : m_outputConstraintSpaces)
@@ -103,8 +107,8 @@ private:
RefPtr m_normalWorld;
JSC::GCClient::IsoSubspace m_domConstructorSpace;
-
- // JSC::IsoSubspace m_domNamespaceObjectSpace;
+ JSC::GCClient::IsoSubspace m_domBuiltinConstructorSpace;
+ JSC::GCClient::IsoSubspace m_domNamespaceObjectSpace;
std::unique_ptr m_clientSubspaces;
Vector m_outputConstraintSpaces;
@@ -168,9 +172,15 @@ static JSVMClientData* clientData(JSC::VM& vm)
return static_cast(vm.clientData);
}
+static inline BunBuiltinNames& builtinNames(JSC::VM& vm)
+{
+ return clientData(vm)->builtinNames();
+}
+
} // namespace WebCore
namespace WebCore {
using JSVMClientData = WebCore::JSVMClientData;
using JSHeapData = WebCore::JSHeapData;
+
}
\ No newline at end of file
diff --git a/src/javascript/jsc/bindings/BunGCOutputConstraint.cpp b/src/javascript/jsc/bindings/BunGCOutputConstraint.cpp
index ec487edc96..97ee0761ba 100644
--- a/src/javascript/jsc/bindings/BunGCOutputConstraint.cpp
+++ b/src/javascript/jsc/bindings/BunGCOutputConstraint.cpp
@@ -31,105 +31,105 @@
#include "JavaScriptCore/VM.h"
#include "JavaScriptCore/MarkingConstraint.h"
-namespace JSC {
+// namespace JSC {
-class VisitCounter {
-public:
- VisitCounter() {}
+// class VisitCounter {
+// public:
+// VisitCounter() {}
- VisitCounter(AbstractSlotVisitor& visitor)
- : m_visitor(&visitor)
- , m_initialVisitCount(visitor.visitCount())
- {
- }
+// VisitCounter(AbstractSlotVisitor& visitor)
+// : m_visitor(&visitor)
+// , m_initialVisitCount(visitor.visitCount())
+// {
+// }
- AbstractSlotVisitor& visitor() const { return *m_visitor; }
+// AbstractSlotVisitor& visitor() const { return *m_visitor; }
- size_t visitCount() const
- {
- return m_visitor->visitCount() - m_initialVisitCount;
- }
+// size_t visitCount() const
+// {
+// return m_visitor->visitCount() - m_initialVisitCount;
+// }
-private:
- AbstractSlotVisitor* m_visitor { nullptr };
- size_t m_initialVisitCount { 0 };
-};
+// private:
+// AbstractSlotVisitor* m_visitor { nullptr };
+// size_t m_initialVisitCount { 0 };
+// };
-static constexpr bool verboseMarkingConstraint = false;
+// static constexpr bool verboseMarkingConstraint = false;
-MarkingConstraint::MarkingConstraint(CString abbreviatedName, CString name, ConstraintVolatility volatility, ConstraintConcurrency concurrency, ConstraintParallelism parallelism)
- : m_abbreviatedName(abbreviatedName)
- , m_name(WTFMove(name))
- , m_volatility(volatility)
- , m_concurrency(concurrency)
- , m_parallelism(parallelism)
-{
-}
+// MarkingConstraint::MarkingConstraint(CString abbreviatedName, CString name, ConstraintVolatility volatility, ConstraintConcurrency concurrency, ConstraintParallelism parallelism)
+// : m_abbreviatedName(abbreviatedName)
+// , m_name(WTFMove(name))
+// , m_volatility(volatility)
+// , m_concurrency(concurrency)
+// , m_parallelism(parallelism)
+// {
+// }
-MarkingConstraint::~MarkingConstraint()
-{
-}
+// MarkingConstraint::~MarkingConstraint()
+// {
+// }
-void MarkingConstraint::resetStats()
-{
- m_lastVisitCount = 0;
-}
+// void MarkingConstraint::resetStats()
+// {
+// m_lastVisitCount = 0;
+// }
-void MarkingConstraint::execute(SlotVisitor& visitor)
-{
- ASSERT(!visitor.heap()->isMarkingForGCVerifier());
- VisitCounter visitCounter(visitor);
- executeImpl(visitor);
- m_lastVisitCount += visitCounter.visitCount();
- if (verboseMarkingConstraint && visitCounter.visitCount())
- dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in execute)");
-}
+// void MarkingConstraint::execute(SlotVisitor& visitor)
+// {
+// ASSERT(!visitor.heap()->isMarkingForGCVerifier());
+// VisitCounter visitCounter(visitor);
+// executeImpl(visitor);
+// m_lastVisitCount += visitCounter.visitCount();
+// if (verboseMarkingConstraint && visitCounter.visitCount())
+// dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in execute)");
+// }
-void MarkingConstraint::executeSynchronously(AbstractSlotVisitor& visitor)
-{
- prepareToExecuteImpl(NoLockingNecessary, visitor);
- executeImpl(visitor);
-}
+// void MarkingConstraint::executeSynchronously(AbstractSlotVisitor& visitor)
+// {
+// prepareToExecuteImpl(NoLockingNecessary, visitor);
+// executeImpl(visitor);
+// }
-double MarkingConstraint::quickWorkEstimate(SlotVisitor&)
-{
- return 0;
-}
+// double MarkingConstraint::quickWorkEstimate(SlotVisitor&)
+// {
+// return 0;
+// }
-double MarkingConstraint::workEstimate(SlotVisitor& visitor)
-{
- return lastVisitCount() + quickWorkEstimate(visitor);
-}
+// double MarkingConstraint::workEstimate(SlotVisitor& visitor)
+// {
+// return lastVisitCount() + quickWorkEstimate(visitor);
+// }
-void MarkingConstraint::prepareToExecute(const AbstractLocker& constraintSolvingLocker, SlotVisitor& visitor)
-{
- ASSERT(!visitor.heap()->isMarkingForGCVerifier());
- dataLogIf(Options::logGC(), abbreviatedName());
- VisitCounter visitCounter(visitor);
- prepareToExecuteImpl(constraintSolvingLocker, visitor);
- m_lastVisitCount = visitCounter.visitCount();
- if (verboseMarkingConstraint && visitCounter.visitCount())
- dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in prepareToExecute)");
-}
+// void MarkingConstraint::prepareToExecute(const AbstractLocker& constraintSolvingLocker, SlotVisitor& visitor)
+// {
+// ASSERT(!visitor.heap()->isMarkingForGCVerifier());
+// dataLogIf(Options::logGC(), abbreviatedName());
+// VisitCounter visitCounter(visitor);
+// prepareToExecuteImpl(constraintSolvingLocker, visitor);
+// m_lastVisitCount = visitCounter.visitCount();
+// if (verboseMarkingConstraint && visitCounter.visitCount())
+// dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in prepareToExecute)");
+// }
-void MarkingConstraint::doParallelWork(SlotVisitor& visitor, SharedTask& task)
-{
- ASSERT(!visitor.heap()->isMarkingForGCVerifier());
- VisitCounter visitCounter(visitor);
- task.run(visitor);
- if (verboseMarkingConstraint && visitCounter.visitCount())
- dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in doParallelWork)");
- {
- Locker locker { m_lock };
- m_lastVisitCount += visitCounter.visitCount();
- }
-}
+// void MarkingConstraint::doParallelWork(SlotVisitor& visitor, SharedTask& task)
+// {
+// ASSERT(!visitor.heap()->isMarkingForGCVerifier());
+// VisitCounter visitCounter(visitor);
+// task.run(visitor);
+// if (verboseMarkingConstraint && visitCounter.visitCount())
+// dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in doParallelWork)");
+// {
+// Locker locker { m_lock };
+// m_lastVisitCount += visitCounter.visitCount();
+// }
+// }
-void MarkingConstraint::prepareToExecuteImpl(const AbstractLocker&, AbstractSlotVisitor&)
-{
-}
+// void MarkingConstraint::prepareToExecuteImpl(const AbstractLocker&, AbstractSlotVisitor&)
+// {
+// }
-} // namespace JSC
+// } // namespace JSC
#include "BunGCOutputConstraint.h"
diff --git a/src/javascript/jsc/bindings/BunJSCModule.cpp b/src/javascript/jsc/bindings/BunJSCModule.cpp
new file mode 100644
index 0000000000..c9c2e6cfad
--- /dev/null
+++ b/src/javascript/jsc/bindings/BunJSCModule.cpp
@@ -0,0 +1,293 @@
+#include "root.h"
+#include "JavaScriptCore/JSCInlines.h"
+
+#include "JavaScriptCore/JavaScript.h"
+#include "wtf/MemoryFootprint.h"
+#include "JavaScriptCore/CodeBlock.h"
+#include "JavaScriptCore/JSCInlines.h"
+#include "JavaScriptCore/TestRunnerUtils.h"
+#include "JavaScriptCore/JIT.h"
+#include "JavaScriptCore/APICast.h"
+#include "JavaScriptCore/JSBasePrivate.h"
+#include "JavaScriptCore/ObjectConstructor.h"
+
+#include "mimalloc.h"
+
+using namespace JSC;
+using namespace WTF;
+
+JSC_DECLARE_HOST_FUNCTION(functionDescribe);
+JSC_DEFINE_HOST_FUNCTION(functionDescribe, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ VM& vm = globalObject->vm();
+ if (callFrame->argumentCount() < 1)
+ return JSValue::encode(jsUndefined());
+ return JSValue::encode(jsString(vm, toString(callFrame->argument(0))));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionDescribeArray);
+JSC_DEFINE_HOST_FUNCTION(functionDescribeArray, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ if (callFrame->argumentCount() < 1)
+ return JSValue::encode(jsUndefined());
+ VM& vm = globalObject->vm();
+ JSObject* object = jsDynamicCast(callFrame->argument(0));
+ if (!object)
+ return JSValue::encode(jsNontrivialString(vm, ""_s));
+ return JSValue::encode(jsNontrivialString(vm, toString("butterfly()), "; public length: ", object->getArrayLength(), "; vector length: ", object->getVectorLength(), ">")));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionGCAndSweep);
+JSC_DEFINE_HOST_FUNCTION(functionGCAndSweep, (JSGlobalObject * globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ JSLockHolder lock(vm);
+ vm.heap.collectNow(Sync, CollectionScope::Full);
+ return JSValue::encode(jsNumber(vm.heap.sizeAfterLastFullCollection()));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionFullGC);
+JSC_DEFINE_HOST_FUNCTION(functionFullGC, (JSGlobalObject * globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ JSLockHolder lock(vm);
+ vm.heap.collectSync(CollectionScope::Full);
+ return JSValue::encode(jsNumber(vm.heap.sizeAfterLastFullCollection()));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionEdenGC);
+JSC_DEFINE_HOST_FUNCTION(functionEdenGC, (JSGlobalObject * globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ JSLockHolder lock(vm);
+ vm.heap.collectSync(CollectionScope::Eden);
+ return JSValue::encode(jsNumber(vm.heap.sizeAfterLastEdenCollection()));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionHeapSize);
+JSC_DEFINE_HOST_FUNCTION(functionHeapSize, (JSGlobalObject * globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ JSLockHolder lock(vm);
+ return JSValue::encode(jsNumber(vm.heap.size()));
+}
+
+class JSCMemoryFootprint : public JSDestructibleObject {
+ using Base = JSDestructibleObject;
+
+public:
+ template
+ static CompleteSubspace* subspaceFor(VM& vm)
+ {
+ return &vm.destructibleObjectSpace();
+ }
+
+ JSCMemoryFootprint(VM& vm, Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+ {
+ return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
+ }
+
+ static JSCMemoryFootprint* create(VM& vm, JSGlobalObject* globalObject)
+ {
+ Structure* structure = createStructure(vm, globalObject, jsNull());
+ JSCMemoryFootprint* footprint = new (NotNull, allocateCell(vm)) JSCMemoryFootprint(vm, structure);
+ footprint->finishCreation(vm);
+ return footprint;
+ }
+
+ void finishCreation(VM& vm)
+ {
+ Base::finishCreation(vm);
+
+ auto addProperty = [&](VM& vm, ASCIILiteral name, JSValue value) {
+ JSCMemoryFootprint::addProperty(vm, name, value);
+ };
+
+ size_t elapsed_msecs = 0;
+ size_t user_msecs = 0;
+ size_t system_msecs = 0;
+ size_t current_rss = 0;
+ size_t peak_rss = 0;
+ size_t current_commit = 0;
+ size_t peak_commit = 0;
+ size_t page_faults = 0;
+
+ mi_process_info(&elapsed_msecs, &user_msecs, &system_msecs,
+ ¤t_rss, &peak_rss,
+ ¤t_commit, &peak_commit, &page_faults);
+
+ addProperty(vm, "current"_s, jsNumber(current_rss));
+ addProperty(vm, "peak"_s, jsNumber(peak_rss));
+ addProperty(vm, "currentCommit"_s, jsNumber(current_commit));
+ addProperty(vm, "peakCommit"_s, jsNumber(peak_commit));
+ addProperty(vm, "pageFaults"_s, jsNumber(page_faults));
+ }
+
+ DECLARE_INFO;
+
+private:
+ void addProperty(VM& vm, ASCIILiteral name, JSValue value)
+ {
+ Identifier identifier = Identifier::fromString(vm, name);
+ putDirect(vm, identifier, value);
+ }
+};
+
+const ClassInfo JSCMemoryFootprint::s_info = { "MemoryFootprint"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCMemoryFootprint) };
+
+JSC_DECLARE_HOST_FUNCTION(functionMemoryUsageStatistics);
+JSC_DEFINE_HOST_FUNCTION(functionMemoryUsageStatistics, (JSGlobalObject * globalObject, CallFrame*))
+{
+ auto contextRef = toRef(globalObject);
+ return JSValue::encode(toJS(JSGetMemoryUsageStatistics(contextRef)));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionCreateMemoryFootprint);
+JSC_DEFINE_HOST_FUNCTION(functionCreateMemoryFootprint, (JSGlobalObject * globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ JSLockHolder lock(vm);
+ return JSValue::encode(JSCMemoryFootprint::create(vm, globalObject));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionGetRandomSeed);
+JSC_DEFINE_HOST_FUNCTION(functionGetRandomSeed, (JSGlobalObject * globalObject, CallFrame*))
+{
+ return JSValue::encode(jsNumber(globalObject->weakRandom().seed()));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionSetRandomSeed);
+JSC_DEFINE_HOST_FUNCTION(functionSetRandomSeed, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ unsigned seed = callFrame->argument(0).toUInt32(globalObject);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ globalObject->weakRandom().setSeed(seed);
+ return JSValue::encode(jsUndefined());
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionIsRope);
+JSC_DEFINE_HOST_FUNCTION(functionIsRope, (JSGlobalObject*, CallFrame* callFrame))
+{
+ JSValue argument = callFrame->argument(0);
+ if (!argument.isString())
+ return JSValue::encode(jsBoolean(false));
+ const StringImpl* impl = asString(argument)->tryGetValueImpl();
+ return JSValue::encode(jsBoolean(!impl));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionCallerSourceOrigin);
+JSC_DEFINE_HOST_FUNCTION(functionCallerSourceOrigin, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ VM& vm = globalObject->vm();
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ if (sourceOrigin.url().isNull())
+ return JSValue::encode(jsNull());
+ return JSValue::encode(jsString(vm, sourceOrigin.string()));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionNoFTL);
+JSC_DEFINE_HOST_FUNCTION(functionNoFTL, (JSGlobalObject*, CallFrame* callFrame))
+{
+ if (callFrame->argumentCount()) {
+ FunctionExecutable* executable = getExecutableForFunction(callFrame->argument(0));
+ if (executable)
+ executable->setNeverFTLOptimize(true);
+ }
+ return JSValue::encode(jsUndefined());
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionNoOSRExitFuzzing);
+JSC_DEFINE_HOST_FUNCTION(functionNoOSRExitFuzzing, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ return JSValue::encode(setCannotUseOSRExitFuzzing(globalObject, callFrame));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionOptimizeNextInvocation);
+JSC_DEFINE_HOST_FUNCTION(functionOptimizeNextInvocation, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ return JSValue::encode(optimizeNextInvocation(globalObject, callFrame));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionNumberOfDFGCompiles);
+JSC_DEFINE_HOST_FUNCTION(functionNumberOfDFGCompiles, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ return JSValue::encode(numberOfDFGCompiles(globalObject, callFrame));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionReleaseWeakRefs);
+JSC_DEFINE_HOST_FUNCTION(functionReleaseWeakRefs, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ globalObject->vm().finalizeSynchronousJSExecution();
+ return JSValue::encode(jsUndefined());
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionTotalCompileTime);
+JSC_DEFINE_HOST_FUNCTION(functionTotalCompileTime, (JSGlobalObject*, CallFrame*))
+{
+ return JSValue::encode(jsNumber(JIT::totalCompileTime().milliseconds()));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionReoptimizationRetryCount);
+JSC_DEFINE_HOST_FUNCTION(functionReoptimizationRetryCount, (JSGlobalObject*, CallFrame* callFrame))
+{
+ if (callFrame->argumentCount() < 1)
+ return JSValue::encode(jsUndefined());
+
+ CodeBlock* block = getSomeBaselineCodeBlockForFunction(callFrame->argument(0));
+ if (!block)
+ return JSValue::encode(jsNumber(0));
+
+ return JSValue::encode(jsNumber(block->reoptimizationRetryCounter()));
+}
+
+extern "C" void Bun__drainMicrotasks();
+
+JSC_DECLARE_HOST_FUNCTION(functionDrainMicrotasks);
+JSC_DEFINE_HOST_FUNCTION(functionDrainMicrotasks, (JSGlobalObject * globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ vm.drainMicrotasks();
+ Bun__drainMicrotasks();
+ return JSValue::encode(jsUndefined());
+}
+
+JSC::JSObject* createJSCModule(JSC::JSGlobalObject* globalObject)
+{
+ VM& vm = globalObject->vm();
+ JSC::JSObject* object = nullptr;
+
+ {
+ JSC::ObjectInitializationScope initializationScope(vm);
+ object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 20);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "describe"_s), 1, functionDescribe, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "describeArray"_s), 1, functionDescribeArray, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "gcAndSweep"_s), 1, functionGCAndSweep, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "fullGC"_s), 1, functionFullGC, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "edenGC"_s), 1, functionEdenGC, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "heapSize"_s), 1, functionHeapSize, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "heapStats"_s), 1, functionMemoryUsageStatistics, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "memoryUsage"_s), 1, functionCreateMemoryFootprint, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "getRandomSeed"_s), 1, functionGetRandomSeed, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "setRandomSeed"_s), 1, functionSetRandomSeed, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "isRope"_s), 1, functionIsRope, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "callerSourceOrigin"_s), 1, functionCallerSourceOrigin, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "noFTL"_s), 1, functionNoFTL, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "noOSRExitFuzzing"_s), 1, functionNoOSRExitFuzzing, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "optimizeNextInvocation"_s), 1, functionOptimizeNextInvocation, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "numberOfDFGCompiles"_s), 1, functionNumberOfDFGCompiles, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "releaseWeakRefs"_s), 1, functionReleaseWeakRefs, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "totalCompileTime"_s), 1, functionTotalCompileTime, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "reoptimizationRetryCount"_s), 1, functionReoptimizationRetryCount, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "drainMicrotasks"_s), 1, functionDrainMicrotasks, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ }
+
+ return object;
+}
\ No newline at end of file
diff --git a/src/javascript/jsc/bindings/BunJSCModule.h b/src/javascript/jsc/bindings/BunJSCModule.h
new file mode 100644
index 0000000000..7df47a5664
--- /dev/null
+++ b/src/javascript/jsc/bindings/BunJSCModule.h
@@ -0,0 +1,4 @@
+#include "root.h"
+#include "JavaScriptCore/JSObject.h"
+
+JSC::JSObject* createJSCModule(JSC::JSGlobalObject* globalObject);
\ No newline at end of file
diff --git a/src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.cpp b/src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.cpp
new file mode 100644
index 0000000000..320cba7da5
--- /dev/null
+++ b/src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2015 Igalia
+ * Copyright (c) 2015 Igalia S.L.
+ * Copyright (c) 2015 Igalia.
+ * Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
+ * Copyright (c) 2015, 2016, 2017 Canon Inc.
+ * Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
+ * Copyright (c) 2022 Codeblog Corp. 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.
+ *
+ */
+
+// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
+// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
+
+#include "config.h"
+#include "ByteLengthQueuingStrategyBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_byteLengthQueuingStrategyHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_byteLengthQueuingStrategyHighWaterMarkCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_byteLengthQueuingStrategyHighWaterMarkCodeLength = 286;
+static const JSC::Intrinsic s_byteLengthQueuingStrategyHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_byteLengthQueuingStrategyHighWaterMarkCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const highWaterMark = @getByIdDirectPrivate(this, \"highWaterMark\");\n" \
+ " if (highWaterMark === @undefined)\n" \
+ " @throwTypeError(\"ByteLengthQueuingStrategy.highWaterMark getter called on incompatible |this| value.\");\n" \
+ "\n" \
+ " return highWaterMark;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_byteLengthQueuingStrategySizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_byteLengthQueuingStrategySizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_byteLengthQueuingStrategySizeCodeLength = 71;
+static const JSC::Intrinsic s_byteLengthQueuingStrategySizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_byteLengthQueuingStrategySizeCode =
+ "(function (chunk)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return chunk.byteLength;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeLength = 155;
+static const JSC::Intrinsic s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCode =
+ "(function (parameters)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @putByIdDirectPrivate(this, \"highWaterMark\", @extractHighWaterMarkFromQueuingStrategyInit(parameters));\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast(vm.clientData); \
+ return clientData->builtinFunctions().byteLengthQueuingStrategyBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().byteLengthQueuingStrategyBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.h b/src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.h
new file mode 100644
index 0000000000..964ce15afb
--- /dev/null
+++ b/src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2015 Igalia
+ * Copyright (c) 2015 Igalia S.L.
+ * Copyright (c) 2015 Igalia.
+ * Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
+ * Copyright (c) 2015, 2016, 2017 Canon Inc.
+ * Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
+ * Copyright (c) 2022 Codeblog Corp. 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.
+ *
+ */
+
+// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
+// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
+
+#pragma once
+
+#include
+#include
+#include
+#include
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* ByteLengthQueuingStrategy */
+extern const char* const s_byteLengthQueuingStrategyHighWaterMarkCode;
+extern const int s_byteLengthQueuingStrategyHighWaterMarkCodeLength;
+extern const JSC::ConstructAbility s_byteLengthQueuingStrategyHighWaterMarkCodeConstructAbility;
+extern const JSC::ConstructorKind s_byteLengthQueuingStrategyHighWaterMarkCodeConstructorKind;
+extern const char* const s_byteLengthQueuingStrategySizeCode;
+extern const int s_byteLengthQueuingStrategySizeCodeLength;
+extern const JSC::ConstructAbility s_byteLengthQueuingStrategySizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_byteLengthQueuingStrategySizeCodeConstructorKind;
+extern const char* const s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCode;
+extern const int s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeLength;
+extern const JSC::ConstructAbility s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructAbility;
+extern const JSC::ConstructorKind s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructorKind;
+
+#define WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_DATA(macro) \
+ macro(highWaterMark, byteLengthQueuingStrategyHighWaterMark, 0) \
+ macro(size, byteLengthQueuingStrategySize, 1) \
+ macro(initializeByteLengthQueuingStrategy, byteLengthQueuingStrategyInitializeByteLengthQueuingStrategy, 1) \
+
+#define WEBCORE_BUILTIN_BYTELENGTHQUEUINGSTRATEGY_HIGHWATERMARK 1
+#define WEBCORE_BUILTIN_BYTELENGTHQUEUINGSTRATEGY_SIZE 1
+#define WEBCORE_BUILTIN_BYTELENGTHQUEUINGSTRATEGY_INITIALIZEBYTELENGTHQUEUINGSTRATEGY 1
+
+#define WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(macro) \
+ macro(byteLengthQueuingStrategyHighWaterMarkCode, highWaterMark, "get highWaterMark"_s, s_byteLengthQueuingStrategyHighWaterMarkCodeLength) \
+ macro(byteLengthQueuingStrategySizeCode, size, ASCIILiteral(), s_byteLengthQueuingStrategySizeCodeLength) \
+ macro(byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCode, initializeByteLengthQueuingStrategy, ASCIILiteral(), s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeLength) \
+
+#define WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(macro) \
+ macro(highWaterMark) \
+ macro(initializeByteLengthQueuingStrategy) \
+ macro(size) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class ByteLengthQueuingStrategyBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit ByteLengthQueuingStrategyBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
+ WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
+#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
+ {
+ }
+
+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+ JSC::UnlinkedFunctionExecutable* name##Executable(); \
+ const JSC::SourceCode& name##Source() const { return m_##name##Source; }
+ WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak m_##name##Executable;
+ WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* ByteLengthQueuingStrategyBuiltinsWrapper::name##Executable() \
+{\
+ if (!m_##name##Executable) {\
+ JSC::Identifier executableName = functionName##PublicName();\
+ if (overriddenName)\
+ executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
+ m_##name##Executable = JSC::Weak(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
+ }\
+ return m_##name##Executable.get();\
+}
+WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void ByteLengthQueuingStrategyBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/CountQueuingStrategyBuiltins.cpp b/src/javascript/jsc/bindings/CountQueuingStrategyBuiltins.cpp
new file mode 100644
index 0000000000..1a7100f00a
--- /dev/null
+++ b/src/javascript/jsc/bindings/CountQueuingStrategyBuiltins.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2015 Igalia
+ * Copyright (c) 2015 Igalia S.L.
+ * Copyright (c) 2015 Igalia.
+ * Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
+ * Copyright (c) 2015, 2016, 2017 Canon Inc.
+ * Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
+ * Copyright (c) 2022 Codeblog Corp. 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.
+ *
+ */
+
+// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
+// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
+
+#include "config.h"
+#include "CountQueuingStrategyBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_countQueuingStrategyHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_countQueuingStrategyHighWaterMarkCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_countQueuingStrategyHighWaterMarkCodeLength = 281;
+static const JSC::Intrinsic s_countQueuingStrategyHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_countQueuingStrategyHighWaterMarkCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const highWaterMark = @getByIdDirectPrivate(this, \"highWaterMark\");\n" \
+ " if (highWaterMark === @undefined)\n" \
+ " @throwTypeError(\"CountQueuingStrategy.highWaterMark getter called on incompatible |this| value.\");\n" \
+ "\n" \
+ " return highWaterMark;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_countQueuingStrategySizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_countQueuingStrategySizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_countQueuingStrategySizeCodeLength = 51;
+static const JSC::Intrinsic s_countQueuingStrategySizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_countQueuingStrategySizeCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return 1;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_countQueuingStrategyInitializeCountQueuingStrategyCodeLength = 155;
+static const JSC::Intrinsic s_countQueuingStrategyInitializeCountQueuingStrategyCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_countQueuingStrategyInitializeCountQueuingStrategyCode =
+ "(function (parameters)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @putByIdDirectPrivate(this, \"highWaterMark\", @extractHighWaterMarkFromQueuingStrategyInit(parameters));\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast(vm.clientData); \
+ return clientData->builtinFunctions().countQueuingStrategyBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().countQueuingStrategyBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/CountQueuingStrategyBuiltins.h b/src/javascript/jsc/bindings/CountQueuingStrategyBuiltins.h
new file mode 100644
index 0000000000..3805d0873a
--- /dev/null
+++ b/src/javascript/jsc/bindings/CountQueuingStrategyBuiltins.h
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2015 Igalia
+ * Copyright (c) 2015 Igalia S.L.
+ * Copyright (c) 2015 Igalia.
+ * Copyright (c) 2015, 2016 Canon Inc. All rights reserved.
+ * Copyright (c) 2015, 2016, 2017 Canon Inc.
+ * Copyright (c) 2016, 2020 Apple Inc. All rights reserved.
+ * Copyright (c) 2022 Codeblog Corp. 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.
+ *
+ */
+
+// DO NOT EDIT THIS FILE. It is automatically generated from JavaScript files for
+// builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py
+
+#pragma once
+
+#include
+#include
+#include
+#include
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* CountQueuingStrategy */
+extern const char* const s_countQueuingStrategyHighWaterMarkCode;
+extern const int s_countQueuingStrategyHighWaterMarkCodeLength;
+extern const JSC::ConstructAbility s_countQueuingStrategyHighWaterMarkCodeConstructAbility;
+extern const JSC::ConstructorKind s_countQueuingStrategyHighWaterMarkCodeConstructorKind;
+extern const char* const s_countQueuingStrategySizeCode;
+extern const int s_countQueuingStrategySizeCodeLength;
+extern const JSC::ConstructAbility s_countQueuingStrategySizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_countQueuingStrategySizeCodeConstructorKind;
+extern const char* const s_countQueuingStrategyInitializeCountQueuingStrategyCode;
+extern const int s_countQueuingStrategyInitializeCountQueuingStrategyCodeLength;
+extern const JSC::ConstructAbility s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructAbility;
+extern const JSC::ConstructorKind s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructorKind;
+
+#define WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_DATA(macro) \
+ macro(highWaterMark, countQueuingStrategyHighWaterMark, 0) \
+ macro(size, countQueuingStrategySize, 0) \
+ macro(initializeCountQueuingStrategy, countQueuingStrategyInitializeCountQueuingStrategy, 1) \
+
+#define WEBCORE_BUILTIN_COUNTQUEUINGSTRATEGY_HIGHWATERMARK 1
+#define WEBCORE_BUILTIN_COUNTQUEUINGSTRATEGY_SIZE 1
+#define WEBCORE_BUILTIN_COUNTQUEUINGSTRATEGY_INITIALIZECOUNTQUEUINGSTRATEGY 1
+
+#define WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(macro) \
+ macro(countQueuingStrategyHighWaterMarkCode, highWaterMark, "get highWaterMark"_s, s_countQueuingStrategyHighWaterMarkCodeLength) \
+ macro(countQueuingStrategySizeCode, size, ASCIILiteral(), s_countQueuingStrategySizeCodeLength) \
+ macro(countQueuingStrategyInitializeCountQueuingStrategyCode, initializeCountQueuingStrategy, ASCIILiteral(), s_countQueuingStrategyInitializeCountQueuingStrategyCodeLength) \
+
+#define WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(macro) \
+ macro(highWaterMark) \
+ macro(initializeCountQueuingStrategy) \
+ macro(size) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class CountQueuingStrategyBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit CountQueuingStrategyBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) , m_##name##Source(JSC::makeSource(StringImpl::createWithoutCopying(s_##name, length), { }))
+ WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
+#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
+ {
+ }
+
+#define EXPOSE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+ JSC::UnlinkedFunctionExecutable* name##Executable(); \
+ const JSC::SourceCode& name##Source() const { return m_##name##Source; }
+ WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak m_##name##Executable;
+ WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* CountQueuingStrategyBuiltinsWrapper::name##Executable() \
+{\
+ if (!m_##name##Executable) {\
+ JSC::Identifier executableName = functionName##PublicName();\
+ if (overriddenName)\
+ executableName = JSC::Identifier::fromString(m_vm, overriddenName);\
+ m_##name##Executable = JSC::Weak(JSC::createBuiltinExecutable(m_vm, m_##name##Source, executableName, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\
+ }\
+ return m_##name##Executable.get();\
+}
+WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void CountQueuingStrategyBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/JSBuffer.cpp b/src/javascript/jsc/bindings/JSBuffer.cpp
index f4e6397832..daca676767 100644
--- a/src/javascript/jsc/bindings/JSBuffer.cpp
+++ b/src/javascript/jsc/bindings/JSBuffer.cpp
@@ -1308,16 +1308,16 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_concat, (JSGlobalObject * l
/* Hash table for constructor */
static const HashTableValue JSBufferConstructorTableValues[] = {
- { "alloc", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_alloc), (intptr_t)(3) } },
- { "allocUnsafe", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_allocUnsafe), (intptr_t)(1) } },
- { "allocUnsafeSlow", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_allocUnsafe), (intptr_t)(1) } },
- { "byteLength", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_byteLength), (intptr_t)(2) } },
- { "compare", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_compare), (intptr_t)(2) } },
- { "concat", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_concat), (intptr_t)(2) } },
- { "from", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFromCodeGenerator), (intptr_t)(1) } },
- { "isBuffer", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_isBuffer), (intptr_t)(1) } },
- { "toBuffer", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_toBuffer), (intptr_t)(1) } },
- { "isEncoding", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_isEncoding), (intptr_t)(1) } },
+ { "alloc"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_alloc), (intptr_t)(3) } },
+ { "allocUnsafe"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_allocUnsafe), (intptr_t)(1) } },
+ { "allocUnsafeSlow"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_allocUnsafe), (intptr_t)(1) } },
+ { "byteLength"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_byteLength), (intptr_t)(2) } },
+ { "compare"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_compare), (intptr_t)(2) } },
+ { "concat"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_concat), (intptr_t)(2) } },
+ { "from"_s, static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFromCodeGenerator), (intptr_t)(1) } },
+ { "isBuffer"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_isBuffer), (intptr_t)(1) } },
+ { "toBuffer"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_toBuffer), (intptr_t)(1) } },
+ { "isEncoding"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferConstructorFunction_isEncoding), (intptr_t)(1) } },
};
template<> EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSBufferConstructor::construct(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
@@ -1431,96 +1431,96 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_write, (JSGlobalObject * lexi
static const HashTableValue JSBufferPrototypeTableValues[]
= {
- { "asciiSlice", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeAsciiSliceCodeGenerator), (intptr_t)(2) } },
- { "asciiWrite", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeAsciiWriteCodeGenerator), (intptr_t)(1) } },
- { "base64Slice", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeBase64SliceCodeGenerator), (intptr_t)(2) } },
- { "base64urlSlice", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeBase64urlSliceCodeGenerator), (intptr_t)(2) } },
- { "base64urlWrite", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeBase64urlWriteCodeGenerator), (intptr_t)(1) } },
- { "base64Write", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeBase64WriteCodeGenerator), (intptr_t)(1) } },
- { "compare", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeFunction_compare), (intptr_t)(5) } },
- { "copy", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeFunction_copy), (intptr_t)(4) } },
- { "equals", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeFunction_equals), (intptr_t)(1) } },
- { "fill", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeFunction_fill), (intptr_t)(4) } },
- { "hexSlice", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeHexSliceCodeGenerator), (intptr_t)(2) } },
- { "hexWrite", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeHexWriteCodeGenerator), (intptr_t)(1) } },
- { "includes", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeFunction_includes), (intptr_t)(3) } },
- { "indexOf", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeFunction_indexOf), (intptr_t)(3) } },
- { "lastIndexOf", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeFunction_lastIndexOf), (intptr_t)(3) } },
- { "latin1Slice", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeLatin1SliceCodeGenerator), (intptr_t)(2) } },
- { "latin1Write", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeLatin1WriteCodeGenerator), (intptr_t)(1) } },
- { "readBigInt64", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadBigInt64LECodeGenerator), (intptr_t)(1) } },
- { "readBigInt64BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadBigInt64BECodeGenerator), (intptr_t)(1) } },
- { "readBigInt64LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadBigInt64LECodeGenerator), (intptr_t)(1) } },
- { "readBigUInt64", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadBigUInt64LECodeGenerator), (intptr_t)(1) } },
- { "readBigUInt64BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadBigUInt64BECodeGenerator), (intptr_t)(1) } },
- { "readBigUInt64LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadBigUInt64LECodeGenerator), (intptr_t)(1) } },
- { "readDouble", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadDoubleLECodeGenerator), (intptr_t)(1) } },
- { "readDoubleBE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadDoubleBECodeGenerator), (intptr_t)(1) } },
- { "readDoubleLE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadDoubleLECodeGenerator), (intptr_t)(1) } },
- { "readFloat", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadFloatLECodeGenerator), (intptr_t)(1) } },
- { "readFloatBE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadFloatBECodeGenerator), (intptr_t)(1) } },
- { "readFloatLE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadFloatLECodeGenerator), (intptr_t)(1) } },
- { "readInt16", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadInt16LECodeGenerator), (intptr_t)(1) } },
- { "readInt16BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadInt16BECodeGenerator), (intptr_t)(1) } },
- { "readInt16LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadInt16LECodeGenerator), (intptr_t)(1) } },
- { "readInt32", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadInt32LECodeGenerator), (intptr_t)(1) } },
- { "readInt32BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadInt32BECodeGenerator), (intptr_t)(1) } },
- { "readInt32LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadInt32LECodeGenerator), (intptr_t)(1) } },
- { "readInt8", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadInt8CodeGenerator), (intptr_t)(2) } },
- { "readUint16BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadUInt16BECodeGenerator), (intptr_t)(1) } },
- { "readUInt16BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadUInt16BECodeGenerator), (intptr_t)(1) } },
- { "readUint16LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadUInt16LECodeGenerator), (intptr_t)(1) } },
- { "readUInt16LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadUInt16LECodeGenerator), (intptr_t)(1) } },
- { "readUint32BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadUInt32BECodeGenerator), (intptr_t)(1) } },
- { "readUInt32BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadUInt32BECodeGenerator), (intptr_t)(1) } },
- { "readUint32LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadUInt32LECodeGenerator), (intptr_t)(1) } },
- { "readUInt32LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadUInt32LECodeGenerator), (intptr_t)(1) } },
- { "readUint8", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadUInt8CodeGenerator), (intptr_t)(1) } },
- { "readUInt8", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeReadUInt8CodeGenerator), (intptr_t)(1) } },
- { "slice", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeSliceCodeGenerator), (intptr_t)(2) } },
- { "subarray", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeSliceCodeGenerator), (intptr_t)(2) } },
- { "swap16", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeFunction_swap16), (intptr_t)(0) } },
- { "swap32", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeFunction_swap32), (intptr_t)(0) } },
- { "swap64", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeFunction_swap64), (intptr_t)(0) } },
- { "toString", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeFunction_toString), (intptr_t)(4) } },
- { "ucs2Slice", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeUcs2SliceCodeGenerator), (intptr_t)(2) } },
- { "ucs2Write", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeUcs2WriteCodeGenerator), (intptr_t)(1) } },
- { "utf16leSlice", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeUtf16leSliceCodeGenerator), (intptr_t)(2) } },
- { "utf16leWrite", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeUtf16leWriteCodeGenerator), (intptr_t)(1) } },
- { "utf8Slice", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeUtf8SliceCodeGenerator), (intptr_t)(2) } },
- { "utf8Write", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeUtf8WriteCodeGenerator), (intptr_t)(1) } },
- { "write", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeFunction_write), (intptr_t)(4) } },
- { "writeBigInt64BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteBigInt64BECodeGenerator), (intptr_t)(1) } },
- { "writeBigInt64LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteBigInt64LECodeGenerator), (intptr_t)(1) } },
- { "writeBigUint64BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteBigUInt64BECodeGenerator), (intptr_t)(1) } },
- { "writeBigUInt64BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteBigUInt64BECodeGenerator), (intptr_t)(1) } },
- { "writeBigUint64LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteBigUInt64LECodeGenerator), (intptr_t)(1) } },
- { "writeBigUInt64LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteBigUInt64LECodeGenerator), (intptr_t)(1) } },
- { "writeDouble", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteDoubleLECodeGenerator), (intptr_t)(1) } },
- { "writeDoubleBE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteDoubleBECodeGenerator), (intptr_t)(1) } },
- { "writeDoubleLE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteDoubleLECodeGenerator), (intptr_t)(1) } },
- { "writeFloat", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteFloatLECodeGenerator), (intptr_t)(1) } },
- { "writeFloatBE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteFloatBECodeGenerator), (intptr_t)(1) } },
- { "writeFloatLE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteFloatLECodeGenerator), (intptr_t)(1) } },
- { "writeInt16BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteInt16BECodeGenerator), (intptr_t)(1) } },
- { "writeInt16LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteInt16LECodeGenerator), (intptr_t)(1) } },
- { "writeInt32BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteInt32BECodeGenerator), (intptr_t)(1) } },
- { "writeInt32LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteInt32LECodeGenerator), (intptr_t)(1) } },
- { "writeInt8", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteInt8CodeGenerator), (intptr_t)(1) } },
- { "writeUint16", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
- { "writeUInt16", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
- { "writeUint16BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteUInt16BECodeGenerator), (intptr_t)(1) } },
- { "writeUInt16BE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteUInt16BECodeGenerator), (intptr_t)(1) } },
- { "writeUint16LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
- { "writeUInt16LE", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
- { "writeUint32", static_cast(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast