aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile13
-rw-r--r--bench/snippets/noop.js17
-rw-r--r--integration/bunjs-only-snippets/streams.test.js31
-rw-r--r--src/javascript/jsc/bindings/BunBuiltinNames.h127
-rw-r--r--src/javascript/jsc/bindings/BunClientData.cpp23
-rw-r--r--src/javascript/jsc/bindings/BunClientData.h16
-rw-r--r--src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.cpp104
-rw-r--r--src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.h143
-rw-r--r--src/javascript/jsc/bindings/CountQueuingStrategyBuiltins.cpp104
-rw-r--r--src/javascript/jsc/bindings/CountQueuingStrategyBuiltins.h143
-rw-r--r--src/javascript/jsc/bindings/JSBufferConstructorBuiltins.cpp7
-rw-r--r--src/javascript/jsc/bindings/JSBufferConstructorBuiltins.h7
-rw-r--r--src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp7
-rw-r--r--src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.h7
-rw-r--r--src/javascript/jsc/bindings/JSDOMExceptionHandling.cpp27
-rw-r--r--src/javascript/jsc/bindings/JSDOMExceptionHandling.h6
-rw-r--r--src/javascript/jsc/bindings/JSDOMWrapper.cpp1
-rw-r--r--src/javascript/jsc/bindings/JSDOMWrapperCache.h10
-rw-r--r--src/javascript/jsc/bindings/JSZigGlobalObjectBuiltins.cpp7
-rw-r--r--src/javascript/jsc/bindings/JSZigGlobalObjectBuiltins.h7
-rw-r--r--src/javascript/jsc/bindings/Process.cpp2
-rw-r--r--src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.cpp183
-rw-r--r--src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.h167
-rw-r--r--src/javascript/jsc/bindings/ReadableByteStreamInternalsBuiltins.cpp907
-rw-r--r--src/javascript/jsc/bindings/ReadableByteStreamInternalsBuiltins.h428
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamBYOBReaderBuiltins.cpp169
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamBYOBReaderBuiltins.h159
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamBYOBRequestBuiltins.cpp137
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamBYOBRequestBuiltins.h151
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamBuiltins.cpp310
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamBuiltins.h175
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamDefaultControllerBuiltins.cpp147
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamDefaultControllerBuiltins.h159
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamDefaultReaderBuiltins.cpp157
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamDefaultReaderBuiltins.h159
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.cpp1089
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.h484
-rw-r--r--src/javascript/jsc/bindings/StreamGlobals.h0
-rw-r--r--src/javascript/jsc/bindings/StreamInternalsBuiltins.cpp360
-rw-r--r--src/javascript/jsc/bindings/StreamInternalsBuiltins.h300
-rw-r--r--src/javascript/jsc/bindings/TransformStreamBuiltins.cpp170
-rw-r--r--src/javascript/jsc/bindings/TransformStreamBuiltins.h143
-rw-r--r--src/javascript/jsc/bindings/TransformStreamDefaultControllerBuiltins.cpp142
-rw-r--r--src/javascript/jsc/bindings/TransformStreamDefaultControllerBuiltins.h159
-rw-r--r--src/javascript/jsc/bindings/TransformStreamInternalsBuiltins.cpp492
-rw-r--r--src/javascript/jsc/bindings/TransformStreamInternalsBuiltins.h300
-rw-r--r--src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp49
-rw-r--r--src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h22
-rw-r--r--src/javascript/jsc/bindings/WebCoreJSBuiltins.h80
-rw-r--r--src/javascript/jsc/bindings/WritableStreamDefaultControllerBuiltins.cpp104
-rw-r--r--src/javascript/jsc/bindings/WritableStreamDefaultControllerBuiltins.h135
-rw-r--r--src/javascript/jsc/bindings/WritableStreamDefaultWriterBuiltins.cpp217
-rw-r--r--src/javascript/jsc/bindings/WritableStreamDefaultWriterBuiltins.h183
-rw-r--r--src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.cpp1102
-rw-r--r--src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.h540
-rw-r--r--src/javascript/jsc/bindings/ZigGlobalObject.cpp484
-rw-r--r--src/javascript/jsc/bindings/ZigGlobalObject.h32
-rw-r--r--src/javascript/jsc/bindings/builtins/js/ByteLengthQueuingStrategy.js51
-rw-r--r--src/javascript/jsc/bindings/builtins/js/CountQueuingStrategy.js50
-rw-r--r--src/javascript/jsc/bindings/builtins/js/ReadableByteStreamController.js112
-rw-r--r--src/javascript/jsc/bindings/builtins/js/ReadableByteStreamInternals.js673
-rw-r--r--src/javascript/jsc/bindings/builtins/js/ReadableStream.js233
-rw-r--r--src/javascript/jsc/bindings/builtins/js/ReadableStreamBYOBReader.js102
-rw-r--r--src/javascript/jsc/bindings/builtins/js/ReadableStreamBYOBRequest.js77
-rw-r--r--src/javascript/jsc/bindings/builtins/js/ReadableStreamDefaultController.js82
-rw-r--r--src/javascript/jsc/bindings/builtins/js/ReadableStreamDefaultReader.js91
-rw-r--r--src/javascript/jsc/bindings/builtins/js/ReadableStreamInternals.js814
-rw-r--r--src/javascript/jsc/bindings/builtins/js/StreamInternals.js218
-rw-r--r--src/javascript/jsc/bindings/builtins/js/TransformStream.js116
-rw-r--r--src/javascript/jsc/bindings/builtins/js/TransformStreamDefaultController.js76
-rw-r--r--src/javascript/jsc/bindings/builtins/js/TransformStreamInternals.js350
-rw-r--r--src/javascript/jsc/bindings/builtins/js/WritableStreamDefaultController.js56
-rw-r--r--src/javascript/jsc/bindings/builtins/js/WritableStreamDefaultWriter.js135
-rw-r--r--src/javascript/jsc/bindings/builtins/js/WritableStreamInternals.js781
-rw-r--r--src/javascript/jsc/bindings/headers.zig474
-rw-r--r--src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h36
-rw-r--r--src/javascript/jsc/bindings/webcore/DOMConstructors.h18
-rw-r--r--src/javascript/jsc/bindings/webcore/DOMIsoSubspaces.h37
-rw-r--r--src/javascript/jsc/bindings/webcore/DOMPromiseProxy.h350
-rw-r--r--src/javascript/jsc/bindings/webcore/InternalWritableStream.cpp167
-rw-r--r--src/javascript/jsc/bindings/webcore/InternalWritableStream.h53
-rw-r--r--src/javascript/jsc/bindings/webcore/JSByteLengthQueuingStrategy.cpp182
-rw-r--r--src/javascript/jsc/bindings/webcore/JSByteLengthQueuingStrategy.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSByteLengthQueuingStrategy.h64
-rw-r--r--src/javascript/jsc/bindings/webcore/JSCountQueuingStrategy.cpp182
-rw-r--r--src/javascript/jsc/bindings/webcore/JSCountQueuingStrategy.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSCountQueuingStrategy.h64
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMBinding.h44
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMBuiltinConstructor.h105
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMBuiltinConstructorBase.cpp47
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMBuiltinConstructorBase.h66
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMConvertPromise.h18
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMGuardedObject.cpp78
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMGuardedObject.h72
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMOperationReturningPromise.h93
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMPromise.cpp97
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMPromise.h63
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMPromiseDeferred.cpp300
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMPromiseDeferred.h376
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMWindow.h1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableByteStreamController.cpp185
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableByteStreamController.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableByteStreamController.h64
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStream.cpp186
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStream.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStream.h64
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBReader.cpp184
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBReader.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBReader.h64
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBRequest.cpp183
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBRequest.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBRequest.h64
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultController.cpp184
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultController.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultController.h64
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.cpp184
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.h64
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamSink.cpp243
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamSink.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamSink.h92
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamSource.cpp262
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamSource.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamSource.h102
-rw-r--r--src/javascript/jsc/bindings/webcore/JSReadableStreamSourceCustom.cpp65
-rw-r--r--src/javascript/jsc/bindings/webcore/JSTransformStream.cpp178
-rw-r--r--src/javascript/jsc/bindings/webcore/JSTransformStream.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSTransformStream.h64
-rw-r--r--src/javascript/jsc/bindings/webcore/JSTransformStreamDefaultController.cpp184
-rw-r--r--src/javascript/jsc/bindings/webcore/JSTransformStreamDefaultController.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSTransformStreamDefaultController.h64
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWritableStream.cpp311
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWritableStream.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWritableStream.h98
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultController.cpp180
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultController.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultController.h64
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultWriter.cpp187
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultWriter.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultWriter.h64
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWritableStreamSink.cpp248
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWritableStreamSink.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSWritableStreamSink.h92
-rw-r--r--src/javascript/jsc/bindings/webcore/ReadableStream.cpp199
-rw-r--r--src/javascript/jsc/bindings/webcore/ReadableStream.h97
-rw-r--r--src/javascript/jsc/bindings/webcore/ReadableStreamDefaultController.cpp133
-rw-r--r--src/javascript/jsc/bindings/webcore/ReadableStreamDefaultController.h73
-rw-r--r--src/javascript/jsc/bindings/webcore/ReadableStreamSink.cpp68
-rw-r--r--src/javascript/jsc/bindings/webcore/ReadableStreamSink.h65
-rw-r--r--src/javascript/jsc/bindings/webcore/ReadableStreamSource.cpp102
-rw-r--r--src/javascript/jsc/bindings/webcore/ReadableStreamSource.h90
-rw-r--r--src/javascript/jsc/bindings/webcore/StructuredClone.cpp113
-rw-r--r--src/javascript/jsc/bindings/webcore/StructuredClone.h40
-rw-r--r--src/javascript/jsc/bindings/webcore/WritableStream.cpp86
-rw-r--r--src/javascript/jsc/bindings/webcore/WritableStream.h59
-rw-r--r--src/javascript/jsc/bindings/webcore/WritableStream.idl45
-rw-r--r--src/javascript/jsc/bindings/webcore/WritableStreamSink.h73
157 files changed, 22415 insertions, 640 deletions
diff --git a/Makefile b/Makefile
index 8494a10a0..670283b7a 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)
@@ -260,7 +260,7 @@ 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 \
@@ -379,7 +379,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 +393,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 +548,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/
@@ -1147,7 +1144,7 @@ wasm-return1:
EMIT_LLVM_FOR_RELEASE= -emit-llvm
EMIT_LLVM_FOR_DEBUG=
-EMIT_LLVM=$(EMIT_LLVM_FOR_RELEASE)
+EMIT_LLVM=$(EMIT_LLVM_FOR_DEBUG)
# We do this outside of build.zig for performance reasons
# The C compilation stuff with build.zig is really slow and we don't need to run this as often as the rest
diff --git a/bench/snippets/noop.js b/bench/snippets/noop.js
new file mode 100644
index 000000000..789e6abbb
--- /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/streams.test.js b/integration/bunjs-only-snippets/streams.test.js
new file mode 100644
index 000000000..f7998d248
--- /dev/null
+++ b/integration/bunjs-only-snippets/streams.test.js
@@ -0,0 +1,31 @@
+import { expect, it } from "bun:test";
+
+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", 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(""));
+});
diff --git a/src/javascript/jsc/bindings/BunBuiltinNames.h b/src/javascript/jsc/bindings/BunBuiltinNames.h
index 28ab0235d..d0a60611d 100644
--- a/src/javascript/jsc/bindings/BunBuiltinNames.h
+++ b/src/javascript/jsc/bindings/BunBuiltinNames.h
@@ -23,36 +23,102 @@ 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(byobRequest) \
+ macro(cancel) \
+ macro(cancelAlgorithm) \
macro(chdir) \
+ macro(cloneArrayBuffer) \
macro(close) \
+ macro(closeAlgorithm) \
+ macro(closeRequest) \
+ macro(closeRequested) \
+ macro(closed) \
+ macro(closedPromiseCapability) \
macro(code) \
macro(connect) \
+ macro(controlledReadableStream) \
macro(cork) \
+ macro(createReadableStream) \
+ 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(nextTick) \
macro(normalize) \
@@ -60,12 +126,15 @@ using namespace JSC;
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 +143,76 @@ 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(reader) \
+ macro(readyPromise) \
+ macro(readyPromiseCapability) \
macro(relative) \
- macro(require) \
- macro(resolveSync) \
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 +238,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 807525a21..56fc51365 100644
--- a/src/javascript/jsc/bindings/BunClientData.cpp
+++ b/src/javascript/jsc/bindings/BunClientData.cpp
@@ -14,21 +14,24 @@
#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 "JSDOMWrapper.h"
namespace WebCore {
using namespace JSC;
JSHeapData::JSHeapData(Heap& heap)
- // : m_domNamespaceObjectSpace ISO_SUBSPACE_INIT(heap, heap.cellHeapCellType, JSDOMObject)
- // ,
- : m_subspaces(makeUnique<ExtendedDOMIsoSubspaces>())
+ : m_heapCellTypeForJSWorkerGlobalScope(JSC::IsoHeapCellType::Args<Zig::GlobalObject>())
+ , 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<ExtendedDOMIsoSubspaces>())
{
}
@@ -36,11 +39,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<ExtendedDOMClientIsoSubspaces>())
- , m_builtinFunctions(vm)
+
{
}
@@ -59,8 +65,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);
diff --git a/src/javascript/jsc/bindings/BunClientData.h b/src/javascript/jsc/bindings/BunClientData.h
index 800514efa..e13ff8473 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<ExtendedDOMIsoSubspaces> m_subspaces;
JSC::IsoSubspace m_domConstructorSpace;
+ JSC::IsoSubspace m_domBuiltinConstructorSpace;
+ JSC::IsoSubspace m_domNamespaceObjectSpace;
Vector<JSC::IsoSubspace*> m_outputConstraintSpaces;
};
@@ -89,6 +91,8 @@ public:
Vector<JSC::IsoSubspace*>& outputConstraintSpaces() { return m_outputConstraintSpaces; }
+ JSC::GCClient::IsoSubspace& domBuiltinConstructorSpace() { return m_domBuiltinConstructorSpace; }
+
template<typename Func> void forEachOutputConstraintSpace(const Func& func)
{
for (auto* space : m_outputConstraintSpaces)
@@ -103,8 +107,8 @@ private:
RefPtr<WebCore::DOMWrapperWorld> m_normalWorld;
JSC::GCClient::IsoSubspace m_domConstructorSpace;
-
- // JSC::IsoSubspace m_domNamespaceObjectSpace;
+ JSC::GCClient::IsoSubspace m_domBuiltinConstructorSpace;
+ JSC::GCClient::IsoSubspace m_domNamespaceObjectSpace;
std::unique_ptr<ExtendedDOMClientIsoSubspaces> m_clientSubspaces;
Vector<JSC::IsoSubspace*> m_outputConstraintSpaces;
@@ -168,9 +172,15 @@ static JSVMClientData* clientData(JSC::VM& vm)
return static_cast<WebCore::JSVMClientData*>(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/ByteLengthQueuingStrategyBuiltins.cpp b/src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.cpp
new file mode 100644
index 000000000..320cba7da
--- /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 <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+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<JSVMClientData*>(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 000000000..964ce15af
--- /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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+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<JSC::UnlinkedFunctionExecutable> 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::UnlinkedFunctionExecutable>(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 000000000..1a7100f00
--- /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 <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+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<JSVMClientData*>(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 000000000..3805d0873
--- /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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+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<JSC::UnlinkedFunctionExecutable> 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::UnlinkedFunctionExecutable>(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/JSBufferConstructorBuiltins.cpp b/src/javascript/jsc/bindings/JSBufferConstructorBuiltins.cpp
index 35f69dd8a..d605d5b1b 100644
--- a/src/javascript/jsc/bindings/JSBufferConstructorBuiltins.cpp
+++ b/src/javascript/jsc/bindings/JSBufferConstructorBuiltins.cpp
@@ -1,5 +1,10 @@
/*
- * Copyright (c) 2016 Apple Inc. All rights reserved.
+ * 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
diff --git a/src/javascript/jsc/bindings/JSBufferConstructorBuiltins.h b/src/javascript/jsc/bindings/JSBufferConstructorBuiltins.h
index 6b9ee6fa2..f24927923 100644
--- a/src/javascript/jsc/bindings/JSBufferConstructorBuiltins.h
+++ b/src/javascript/jsc/bindings/JSBufferConstructorBuiltins.h
@@ -1,6 +1,11 @@
//clang-format off
/*
- * Copyright (c) 2016 Apple Inc. All rights reserved.
+ * 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
diff --git a/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp b/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp
index a7548b22a..3925e54f7 100644
--- a/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp
+++ b/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.cpp
@@ -1,5 +1,10 @@
/*
- * Copyright (c) 2016 Apple Inc. All rights reserved.
+ * 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
diff --git a/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.h b/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.h
index 08fb50197..31aa31944 100644
--- a/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.h
+++ b/src/javascript/jsc/bindings/JSBufferPrototypeBuiltins.h
@@ -1,6 +1,11 @@
//clang-format off
/*
- * Copyright (c) 2016 Apple Inc. All rights reserved.
+ * 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
diff --git a/src/javascript/jsc/bindings/JSDOMExceptionHandling.cpp b/src/javascript/jsc/bindings/JSDOMExceptionHandling.cpp
index 473196641..b3627481d 100644
--- a/src/javascript/jsc/bindings/JSDOMExceptionHandling.cpp
+++ b/src/javascript/jsc/bindings/JSDOMExceptionHandling.cpp
@@ -24,6 +24,7 @@
#include "DOMException.h"
#include "JSDOMException.h"
#include "JSDOMExceptionHandling.h"
+#include "JSDOMPromiseDeferred.h"
#include "JavaScriptCore/ErrorHandlingScope.h"
#include "JavaScriptCore/Exception.h"
@@ -275,10 +276,10 @@ void throwNonFiniteTypeError(JSGlobalObject& lexicalGlobalObject, JSC::ThrowScop
throwTypeError(&lexicalGlobalObject, scope, "The provided value is non-finite"_s);
}
-// JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::JSGlobalObject& lexicalGlobalObject, const JSC::ClassInfo* classInfo, JSC::PropertyName attributeName)
-// {
-// return createRejectedPromiseWithTypeError(lexicalGlobalObject, JSC::makeDOMAttributeGetterTypeErrorMessage(classInfo->className, String(attributeName.uid())), RejectedPromiseWithTypeErrorCause::NativeGetter);
-// }
+JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::JSGlobalObject& lexicalGlobalObject, const JSC::ClassInfo* classInfo, JSC::PropertyName attributeName)
+{
+ return createRejectedPromiseWithTypeError(lexicalGlobalObject, JSC::makeDOMAttributeGetterTypeErrorMessage(classInfo->className, String(attributeName.uid())), RejectedPromiseWithTypeErrorCause::NativeGetter);
+}
String makeThisTypeErrorMessage(const char* interfaceName, const char* functionName)
{
@@ -295,16 +296,16 @@ EncodedJSValue throwThisTypeError(JSC::JSGlobalObject& lexicalGlobalObject, JSC:
return throwTypeError(lexicalGlobalObject, scope, makeThisTypeErrorMessage(interfaceName, functionName));
}
-// JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise& promise, const char* interfaceName, const char* methodName)
-// {
-// promise.reject(TypeError, makeThisTypeErrorMessage(interfaceName, methodName));
-// return JSValue::encode(jsUndefined());
-// }
+JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise& promise, const char* interfaceName, const char* methodName)
+{
+ promise.reject(TypeError, makeThisTypeErrorMessage(interfaceName, methodName));
+ return JSValue::encode(jsUndefined());
+}
-// JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject& lexicalGlobalObject, const char* interfaceName, const char* methodName)
-// {
-// return createRejectedPromiseWithTypeError(lexicalGlobalObject, makeThisTypeErrorMessage(interfaceName, methodName), RejectedPromiseWithTypeErrorCause::InvalidThis);
-// }
+JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject& lexicalGlobalObject, const char* interfaceName, const char* methodName)
+{
+ return createRejectedPromiseWithTypeError(lexicalGlobalObject, makeThisTypeErrorMessage(interfaceName, methodName), RejectedPromiseWithTypeErrorCause::InvalidThis);
+}
void throwDOMSyntaxError(JSC::JSGlobalObject& lexicalGlobalObject, JSC::ThrowScope& scope, ASCIILiteral message)
{
diff --git a/src/javascript/jsc/bindings/JSDOMExceptionHandling.h b/src/javascript/jsc/bindings/JSDOMExceptionHandling.h
index a130dfcde..01dc44790 100644
--- a/src/javascript/jsc/bindings/JSDOMExceptionHandling.h
+++ b/src/javascript/jsc/bindings/JSDOMExceptionHandling.h
@@ -60,9 +60,9 @@ String makeUnsupportedIndexedSetterErrorMessage(const char* interfaceName);
WEBCORE_EXPORT JSC::EncodedJSValue throwThisTypeError(JSC::JSGlobalObject&, JSC::ThrowScope&, const char* interfaceName, const char* functionName);
-// WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::JSGlobalObject&, const JSC::ClassInfo*, JSC::PropertyName attributeName);
-// WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise&, const char* interfaceName, const char* operationName);
-// WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject&, const char* interfaceName, const char* operationName);
+WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithGetterTypeError(JSC::JSGlobalObject&, const JSC::ClassInfo*, JSC::PropertyName attributeName);
+WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(DeferredPromise&, const char* interfaceName, const char* operationName);
+WEBCORE_EXPORT JSC::EncodedJSValue rejectPromiseWithThisTypeError(JSC::JSGlobalObject&, const char* interfaceName, const char* operationName);
String retrieveErrorMessageWithoutName(JSC::JSGlobalObject&, JSC::VM&, JSC::JSValue exception, JSC::CatchScope&);
String retrieveErrorMessage(JSC::JSGlobalObject&, JSC::VM&, JSC::JSValue exception, JSC::CatchScope&);
diff --git a/src/javascript/jsc/bindings/JSDOMWrapper.cpp b/src/javascript/jsc/bindings/JSDOMWrapper.cpp
index 379c1bc8c..3af4dff5e 100644
--- a/src/javascript/jsc/bindings/JSDOMWrapper.cpp
+++ b/src/javascript/jsc/bindings/JSDOMWrapper.cpp
@@ -56,6 +56,7 @@ JSC::JSValue cloneAcrossWorlds(JSC::JSGlobalObject& lexicalGlobalObject, const J
// FIXME: Why is owner->globalObject() better than lexicalGlobalObject.lexicalGlobalObject() here?
// Unlike this, isWorldCompatible uses lexicalGlobalObject.lexicalGlobalObject(); should the two match?
// return serializedValue->deserialize(lexicalGlobalObject, owner.globalObject());
+ return JSC::jsNull();
}
} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/JSDOMWrapperCache.h b/src/javascript/jsc/bindings/JSDOMWrapperCache.h
index 61d86d49e..7656c7c17 100644
--- a/src/javascript/jsc/bindings/JSDOMWrapperCache.h
+++ b/src/javascript/jsc/bindings/JSDOMWrapperCache.h
@@ -23,18 +23,16 @@
#pragma once
-#include "root.h"
-
#include "DOMWrapperWorld.h"
#include "JSDOMGlobalObject.h"
#include "JSDOMWrapper.h"
#include "ScriptWrappable.h"
#include "ScriptWrappableInlines.h"
#include "WebCoreTypedArrayController.h"
-#include "JavaScriptCore/JSArrayBuffer.h"
-#include "JavaScriptCore/TypedArrayInlines.h"
-#include "JavaScriptCore/Weak.h"
-#include "JavaScriptCore/WeakInlines.h"
+#include <JavaScriptCore/JSArrayBuffer.h>
+#include <JavaScriptCore/TypedArrayInlines.h>
+#include <JavaScriptCore/Weak.h>
+#include <JavaScriptCore/WeakInlines.h>
namespace WebCore {
diff --git a/src/javascript/jsc/bindings/JSZigGlobalObjectBuiltins.cpp b/src/javascript/jsc/bindings/JSZigGlobalObjectBuiltins.cpp
index f569f07d6..05863cc27 100644
--- a/src/javascript/jsc/bindings/JSZigGlobalObjectBuiltins.cpp
+++ b/src/javascript/jsc/bindings/JSZigGlobalObjectBuiltins.cpp
@@ -1,5 +1,10 @@
/*
- * Copyright (c) 2016 Apple Inc. All rights reserved.
+ * 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
diff --git a/src/javascript/jsc/bindings/JSZigGlobalObjectBuiltins.h b/src/javascript/jsc/bindings/JSZigGlobalObjectBuiltins.h
index 251e599d2..f02eec836 100644
--- a/src/javascript/jsc/bindings/JSZigGlobalObjectBuiltins.h
+++ b/src/javascript/jsc/bindings/JSZigGlobalObjectBuiltins.h
@@ -1,5 +1,10 @@
/*
- * Copyright (c) 2016 Apple Inc. All rights reserved.
+ * 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
diff --git a/src/javascript/jsc/bindings/Process.cpp b/src/javascript/jsc/bindings/Process.cpp
index 5fc15db4d..f1f609bb6 100644
--- a/src/javascript/jsc/bindings/Process.cpp
+++ b/src/javascript/jsc/bindings/Process.cpp
@@ -205,7 +205,7 @@ void Process::finishCreation(JSC::VM& vm)
JSC::CustomGetterSetter::create(vm, Process_getPPID, nullptr),
static_cast<unsigned>(JSC::PropertyAttribute::CustomValue));
- putDirectCustomAccessor(vm, clientData->builtinNames().titlePublicName(),
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "dlopen"_s),
JSC::CustomGetterSetter::create(vm, Process_getTitle, Process_setTitle),
static_cast<unsigned>(JSC::PropertyAttribute::CustomValue));
diff --git a/src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.cpp b/src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.cpp
new file mode 100644
index 000000000..2532f608b
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.cpp
@@ -0,0 +1,183 @@
+/*
+ * 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 "ReadableByteStreamControllerBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeLength = 366;
+static const JSC::Intrinsic s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamControllerInitializeReadableByteStreamControllerCode =
+ "(function (stream, underlyingByteSource, highWaterMark)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (arguments.length !== 4 && arguments[3] !== @isReadableStream)\n" \
+ " @throwTypeError(\"ReadableByteStreamController constructor should not be called directly\");\n" \
+ "\n" \
+ " return @privateInitializeReadableByteStreamController.@call(this, stream, underlyingByteSource, highWaterMark);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamControllerEnqueueCodeLength = 665;
+static const JSC::Intrinsic s_readableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamControllerEnqueueCode =
+ "(function (chunk)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableByteStreamController(this))\n" \
+ " throw @makeThisTypeError(\"ReadableByteStreamController\", \"enqueue\");\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(this, \"closeRequested\"))\n" \
+ " @throwTypeError(\"ReadableByteStreamController is requested to close\");\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, \"controlledReadableStream\"), \"state\") !== @streamReadable)\n" \
+ " @throwTypeError(\"ReadableStream is not readable\");\n" \
+ "\n" \
+ " if (!@isObject(chunk) || !@ArrayBuffer.@isView(chunk))\n" \
+ " @throwTypeError(\"Provided chunk is not a TypedArray\");\n" \
+ "\n" \
+ " return @readableByteStreamControllerEnqueue(this, chunk);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamControllerErrorCodeLength = 396;
+static const JSC::Intrinsic s_readableByteStreamControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamControllerErrorCode =
+ "(function (error)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableByteStreamController(this))\n" \
+ " throw @makeThisTypeError(\"ReadableByteStreamController\", \"error\");\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, \"controlledReadableStream\"), \"state\") !== @streamReadable)\n" \
+ " @throwTypeError(\"ReadableStream is not readable\");\n" \
+ "\n" \
+ " @readableByteStreamControllerError(this, error);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamControllerCloseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamControllerCloseCodeLength = 501;
+static const JSC::Intrinsic s_readableByteStreamControllerCloseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamControllerCloseCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableByteStreamController(this))\n" \
+ " throw @makeThisTypeError(\"ReadableByteStreamController\", \"close\");\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(this, \"closeRequested\"))\n" \
+ " @throwTypeError(\"Close has already been requested\");\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, \"controlledReadableStream\"), \"state\") !== @streamReadable)\n" \
+ " @throwTypeError(\"ReadableStream is not readable\");\n" \
+ "\n" \
+ " @readableByteStreamControllerClose(this);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamControllerByobRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamControllerByobRequestCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamControllerByobRequestCodeLength = 759;
+static const JSC::Intrinsic s_readableByteStreamControllerByobRequestCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamControllerByobRequestCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableByteStreamController(this))\n" \
+ " throw @makeGetterTypeError(\"ReadableByteStreamController\", \"byobRequest\");\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(this, \"byobRequest\") === @undefined && @getByIdDirectPrivate(this, \"pendingPullIntos\").length) {\n" \
+ " const firstDescriptor = @getByIdDirectPrivate(this, \"pendingPullIntos\")[0];\n" \
+ " const view = new @Uint8Array(firstDescriptor.buffer,\n" \
+ " firstDescriptor.byteOffset + firstDescriptor.bytesFilled,\n" \
+ " firstDescriptor.byteLength - firstDescriptor.bytesFilled);\n" \
+ " @putByIdDirectPrivate(this, \"byobRequest\", new @ReadableStreamBYOBRequest(this, view, @isReadableStream));\n" \
+ " }\n" \
+ "\n" \
+ " return @getByIdDirectPrivate(this, \"byobRequest\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamControllerDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamControllerDesiredSizeCodeLength = 231;
+static const JSC::Intrinsic s_readableByteStreamControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamControllerDesiredSizeCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableByteStreamController(this))\n" \
+ " throw @makeGetterTypeError(\"ReadableByteStreamController\", \"desiredSize\");\n" \
+ "\n" \
+ " return @readableByteStreamControllerGetDesiredSize(this);\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().readableByteStreamControllerBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableByteStreamControllerBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.h b/src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.h
new file mode 100644
index 000000000..5513883db
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.h
@@ -0,0 +1,167 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* ReadableByteStreamController */
+extern const char* const s_readableByteStreamControllerInitializeReadableByteStreamControllerCode;
+extern const int s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructorKind;
+extern const char* const s_readableByteStreamControllerEnqueueCode;
+extern const int s_readableByteStreamControllerEnqueueCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamControllerEnqueueCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamControllerEnqueueCodeConstructorKind;
+extern const char* const s_readableByteStreamControllerErrorCode;
+extern const int s_readableByteStreamControllerErrorCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamControllerErrorCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamControllerErrorCodeConstructorKind;
+extern const char* const s_readableByteStreamControllerCloseCode;
+extern const int s_readableByteStreamControllerCloseCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamControllerCloseCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamControllerCloseCodeConstructorKind;
+extern const char* const s_readableByteStreamControllerByobRequestCode;
+extern const int s_readableByteStreamControllerByobRequestCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamControllerByobRequestCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamControllerByobRequestCodeConstructorKind;
+extern const char* const s_readableByteStreamControllerDesiredSizeCode;
+extern const int s_readableByteStreamControllerDesiredSizeCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamControllerDesiredSizeCodeConstructorKind;
+
+#define WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_DATA(macro) \
+ macro(initializeReadableByteStreamController, readableByteStreamControllerInitializeReadableByteStreamController, 3) \
+ macro(enqueue, readableByteStreamControllerEnqueue, 1) \
+ macro(error, readableByteStreamControllerError, 1) \
+ macro(close, readableByteStreamControllerClose, 0) \
+ macro(byobRequest, readableByteStreamControllerByobRequest, 0) \
+ macro(desiredSize, readableByteStreamControllerDesiredSize, 0) \
+
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_INITIALIZEREADABLEBYTESTREAMCONTROLLER 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_ENQUEUE 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_ERROR 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_CLOSE 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_BYOBREQUEST 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_DESIREDSIZE 1
+
+#define WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(macro) \
+ macro(readableByteStreamControllerInitializeReadableByteStreamControllerCode, initializeReadableByteStreamController, ASCIILiteral(), s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeLength) \
+ macro(readableByteStreamControllerEnqueueCode, enqueue, ASCIILiteral(), s_readableByteStreamControllerEnqueueCodeLength) \
+ macro(readableByteStreamControllerErrorCode, error, ASCIILiteral(), s_readableByteStreamControllerErrorCodeLength) \
+ macro(readableByteStreamControllerCloseCode, close, ASCIILiteral(), s_readableByteStreamControllerCloseCodeLength) \
+ macro(readableByteStreamControllerByobRequestCode, byobRequest, "get byobRequest"_s, s_readableByteStreamControllerByobRequestCodeLength) \
+ macro(readableByteStreamControllerDesiredSizeCode, desiredSize, "get desiredSize"_s, s_readableByteStreamControllerDesiredSizeCodeLength) \
+
+#define WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_FUNCTION_NAME(macro) \
+ macro(byobRequest) \
+ macro(close) \
+ macro(desiredSize) \
+ macro(enqueue) \
+ macro(error) \
+ macro(initializeReadableByteStreamController) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class ReadableByteStreamControllerBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit ReadableByteStreamControllerBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_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_READABLEBYTESTREAMCONTROLLER_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_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* ReadableByteStreamControllerBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_READABLEBYTESTREAMCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void ReadableByteStreamControllerBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_READABLEBYTESTREAMCONTROLLER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableByteStreamInternalsBuiltins.cpp b/src/javascript/jsc/bindings/ReadableByteStreamInternalsBuiltins.cpp
new file mode 100644
index 000000000..9386bcb1c
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableByteStreamInternalsBuiltins.cpp
@@ -0,0 +1,907 @@
+/*
+ * 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 "ReadableByteStreamInternalsBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeLength = 2333;
+static const JSC::Intrinsic s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode =
+ "(function (stream, underlyingByteSource, highWaterMark)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStream(stream))\n" \
+ " @throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");\n" \
+ "\n" \
+ " //\n" \
+ " if (@getByIdDirectPrivate(stream, \"readableStreamController\") !== null)\n" \
+ " @throwTypeError(\"ReadableStream already has a controller\");\n" \
+ "\n" \
+ " @putByIdDirectPrivate(this, \"controlledReadableStream\", stream);\n" \
+ " @putByIdDirectPrivate(this, \"underlyingByteSource\", underlyingByteSource);\n" \
+ " @putByIdDirectPrivate(this, \"pullAgain\", false);\n" \
+ " @putByIdDirectPrivate(this, \"pulling\", false);\n" \
+ " @readableByteStreamControllerClearPendingPullIntos(this);\n" \
+ " @putByIdDirectPrivate(this, \"queue\", @newQueue());\n" \
+ " @putByIdDirectPrivate(this, \"started\", false);\n" \
+ " @putByIdDirectPrivate(this, \"closeRequested\", false);\n" \
+ "\n" \
+ " let hwm = @toNumber(highWaterMark);\n" \
+ " if (@isNaN(hwm) || hwm < 0)\n" \
+ " @throwRangeError(\"highWaterMark value is negative or not a number\");\n" \
+ " @putByIdDirectPrivate(this, \"strategyHWM\", hwm);\n" \
+ "\n" \
+ " let autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;\n" \
+ " if (autoAllocateChunkSize !== @undefined) {\n" \
+ " autoAllocateChunkSize = @toNumber(autoAllocateChunkSize);\n" \
+ " if (autoAllocateChunkSize <= 0 || autoAllocateChunkSize === @Infinity || autoAllocateChunkSize === -@Infinity)\n" \
+ " @throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\");\n" \
+ " }\n" \
+ " @putByIdDirectPrivate(this, \"autoAllocateChunkSize\", autoAllocateChunkSize);\n" \
+ " @putByIdDirectPrivate(this, \"pendingPullIntos\", []);\n" \
+ "\n" \
+ " const controller = this;\n" \
+ " const startResult = @promiseInvokeOrNoopNoCatch(underlyingByteSource, \"start\", [this]).@then(() => {\n" \
+ " @putByIdDirectPrivate(controller, \"started\", true);\n" \
+ " @assert(!@getByIdDirectPrivate(controller, \"pulling\"));\n" \
+ " @assert(!@getByIdDirectPrivate(controller, \"pullAgain\"));\n" \
+ " @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
+ " }, (error) => {\n" \
+ " if (@getByIdDirectPrivate(stream, \"state\") === @streamReadable)\n" \
+ " @readableByteStreamControllerError(controller, error);\n" \
+ " });\n" \
+ "\n" \
+ " @putByIdDirectPrivate(this, \"cancel\", @readableByteStreamControllerCancel);\n" \
+ " @putByIdDirectPrivate(this, \"pull\", @readableByteStreamControllerPull);\n" \
+ "\n" \
+ " return this;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeLength = 187;
+static const JSC::Intrinsic s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCode =
+ "(function (controller, view)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @putByIdDirectPrivate(this, \"associatedReadableByteStreamController\", controller);\n" \
+ " @putByIdDirectPrivate(this, \"view\", view);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableByteStreamControllerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsIsReadableByteStreamControllerCodeLength = 158;
+static const JSC::Intrinsic s_readableByteStreamInternalsIsReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsIsReadableByteStreamControllerCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " //\n" \
+ " //\n" \
+ " return @isObject(controller) && !!@getByIdDirectPrivate(controller, \"underlyingByteSource\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeLength = 179;
+static const JSC::Intrinsic s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsIsReadableStreamBYOBRequestCode =
+ "(function (byobRequest)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " //\n" \
+ " //\n" \
+ " return @isObject(byobRequest) && !!@getByIdDirectPrivate(byobRequest, \"associatedReadableByteStreamController\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeLength = 149;
+static const JSC::Intrinsic s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsIsReadableStreamBYOBReaderCode =
+ "(function (reader)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " return @isObject(reader) && !!@getByIdDirectPrivate(reader, \"readIntoRequests\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 392;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode =
+ "(function (controller, reason)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " var pendingPullIntos = @getByIdDirectPrivate(controller, \"pendingPullIntos\");\n" \
+ " if (pendingPullIntos.length > 0)\n" \
+ " pendingPullIntos[0].bytesFilled = 0;\n" \
+ " @putByIdDirectPrivate(controller, \"queue\", @newQueue());\n" \
+ " return @promiseInvokeOrNoop(@getByIdDirectPrivate(controller, \"underlyingByteSource\"), \"cancel\", [reason]);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeLength = 399;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerErrorCode =
+ "(function (controller, e)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable);\n" \
+ " @readableByteStreamControllerClearPendingPullIntos(controller);\n" \
+ " @putByIdDirectPrivate(controller, \"queue\", @newQueue());\n" \
+ " @readableStreamError(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), e);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeLength = 848;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerCloseCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(!@getByIdDirectPrivate(controller, \"closeRequested\"));\n" \
+ " @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable);\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(controller, \"queue\").size > 0) {\n" \
+ " @putByIdDirectPrivate(controller, \"closeRequested\", true);\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " var pendingPullIntos = @getByIdDirectPrivate(controller, \"pendingPullIntos\");\n" \
+ " if (pendingPullIntos.length > 0) {\n" \
+ " if (pendingPullIntos[0].bytesFilled > 0) {\n" \
+ " const e = @makeTypeError(\"Close requested while there remain pending bytes\");\n" \
+ " @readableByteStreamControllerError(controller, e);\n" \
+ " throw e;\n" \
+ " }\n" \
+ " }\n" \
+ "\n" \
+ " @readableStreamClose(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeLength = 178;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \
+ " @putByIdDirectPrivate(controller, \"pendingPullIntos\", []);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength = 406;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ "\n" \
+ " if (state === @streamErrored)\n" \
+ " return null;\n" \
+ " if (state === @streamClosed)\n" \
+ " return 0;\n" \
+ "\n" \
+ " return @getByIdDirectPrivate(controller, \"strategyHWM\") - @getByIdDirectPrivate(controller, \"queue\").size;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength = 176;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const reader = @getByIdDirectPrivate(stream, \"reader\");\n" \
+ " return reader !== @undefined && @isReadableStreamBYOBReader(reader);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeLength = 179;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const reader = @getByIdDirectPrivate(stream, \"reader\");\n" \
+ " return reader !== @undefined && @isReadableStreamDefaultReader(reader);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeLength = 458;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCode =
+ "(function (controller) {\n" \
+ "\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable);\n" \
+ " if (!@getByIdDirectPrivate(controller, \"queue\").size && @getByIdDirectPrivate(controller, \"closeRequested\"))\n" \
+ " @readableStreamClose(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\n" \
+ " else\n" \
+ " @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerPullCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1701;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
+ " @assert(@readableStreamHasDefaultReader(stream));\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(controller, \"queue\").size > 0) {\n" \
+ " @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\").length === 0);\n" \
+ " const entry = @getByIdDirectPrivate(controller, \"queue\").content.@shift();\n" \
+ " @getByIdDirectPrivate(controller, \"queue\").size -= entry.byteLength;\n" \
+ " @readableByteStreamControllerHandleQueueDrain(controller);\n" \
+ " let view;\n" \
+ " try {\n" \
+ " view = new @Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);\n" \
+ " } catch (error) {\n" \
+ " return @Promise.@reject(error);\n" \
+ " }\n" \
+ " return @createFulfilledPromise({ value: view, done: false });\n" \
+ " }\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(controller, \"autoAllocateChunkSize\") !== @undefined) {\n" \
+ " let buffer;\n" \
+ " try {\n" \
+ " buffer = new @ArrayBuffer(@getByIdDirectPrivate(controller, \"autoAllocateChunkSize\"));\n" \
+ " } catch (error) {\n" \
+ " return @Promise.@reject(error);\n" \
+ " }\n" \
+ " const pullIntoDescriptor = {\n" \
+ " buffer,\n" \
+ " byteOffset: 0,\n" \
+ " byteLength: @getByIdDirectPrivate(controller, \"autoAllocateChunkSize\"),\n" \
+ " bytesFilled: 0,\n" \
+ " elementSize: 1,\n" \
+ " ctor: @Uint8Array,\n" \
+ " readerType: 'default'\n" \
+ " };\n" \
+ " @arrayPush(@getByIdDirectPrivate(controller, \"pendingPullIntos\"), pullIntoDescriptor);\n" \
+ " }\n" \
+ "\n" \
+ " const promise = @readableStreamAddReadRequest(stream);\n" \
+ " @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
+ " return promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength = 815;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(stream, \"state\") !== @streamReadable)\n" \
+ " return false;\n" \
+ " if (@getByIdDirectPrivate(controller, \"closeRequested\"))\n" \
+ " return false;\n" \
+ " if (!@getByIdDirectPrivate(controller, \"started\"))\n" \
+ " return false;\n" \
+ " if (@readableStreamHasDefaultReader(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\").length > 0)\n" \
+ " return true;\n" \
+ " if (@readableStreamHasBYOBReader(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readIntoRequests\").length > 0)\n" \
+ " return true;\n" \
+ " if (@readableByteStreamControllerGetDesiredSize(controller) > 0)\n" \
+ " return true;\n" \
+ " return false;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeLength = 1002;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@readableByteStreamControllerShouldCallPull(controller))\n" \
+ " return;\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(controller, \"pulling\")) {\n" \
+ " @putByIdDirectPrivate(controller, \"pullAgain\", true);\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " @assert(!@getByIdDirectPrivate(controller, \"pullAgain\"));\n" \
+ " @putByIdDirectPrivate(controller, \"pulling\", true);\n" \
+ " @promiseInvokeOrNoop(@getByIdDirectPrivate(controller, \"underlyingByteSource\"), \"pull\", [controller]).@then(() => {\n" \
+ " @putByIdDirectPrivate(controller, \"pulling\", false);\n" \
+ " if (@getByIdDirectPrivate(controller, \"pullAgain\")) {\n" \
+ " @putByIdDirectPrivate(controller, \"pullAgain\", false);\n" \
+ " @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
+ " }\n" \
+ " }, (error) => {\n" \
+ " if (@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable)\n" \
+ " @readableByteStreamControllerError(controller, error);\n" \
+ " });\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeLength = 90;
+static const JSC::Intrinsic s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsTransferBufferToCurrentRealmCode =
+ "(function (buffer)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " return buffer;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength = 1423;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode =
+ "(function (controller, chunk)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
+ " @assert(!@getByIdDirectPrivate(controller, \"closeRequested\"));\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") === @streamReadable);\n" \
+ " const buffer = chunk.buffer;\n" \
+ " const byteOffset = chunk.byteOffset;\n" \
+ " const byteLength = chunk.byteLength;\n" \
+ " const transferredBuffer = @transferBufferToCurrentRealm(buffer);\n" \
+ "\n" \
+ " if (@readableStreamHasDefaultReader(stream)) {\n" \
+ " if (!@getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\").length)\n" \
+ " @readableByteStreamControllerEnqueueChunk(controller, transferredBuffer, byteOffset, byteLength);\n" \
+ " else {\n" \
+ " @assert(!@getByIdDirectPrivate(controller, \"queue\").content.length);\n" \
+ " let transferredView = new @Uint8Array(transferredBuffer, byteOffset, byteLength);\n" \
+ " @readableStreamFulfillReadRequest(stream, transferredView, false);\n" \
+ " }\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " if (@readableStreamHasBYOBReader(stream)) {\n" \
+ " @readableByteStreamControllerEnqueueChunk(controller, transferredBuffer, byteOffset, byteLength);\n" \
+ " @readableByteStreamControllerProcessPullDescriptors(controller);\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " @assert(!@isReadableStreamLocked(stream));\n" \
+ " @readableByteStreamControllerEnqueueChunk(controller, transferredBuffer, byteOffset, byteLength);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 310;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode =
+ "(function (controller, buffer, byteOffset, byteLength)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @arrayPush(@getByIdDirectPrivate(controller, \"queue\").content, {\n" \
+ " buffer: buffer,\n" \
+ " byteOffset: byteOffset,\n" \
+ " byteLength: byteLength\n" \
+ " });\n" \
+ " @getByIdDirectPrivate(controller, \"queue\").size += byteLength;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength = 609;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode =
+ "(function (controller, view)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(controller, \"pendingPullIntos\").length > 0);\n" \
+ "\n" \
+ " let firstDescriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\")[0];\n" \
+ "\n" \
+ " if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset)\n" \
+ " @throwRangeError(\"Invalid value for view.byteOffset\");\n" \
+ "\n" \
+ " if (firstDescriptor.byteLength !== view.byteLength)\n" \
+ " @throwRangeError(\"Invalid value for view.byteLength\");\n" \
+ "\n" \
+ " firstDescriptor.buffer = view.buffer;\n" \
+ " @readableByteStreamControllerRespondInternal(controller, view.byteLength);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeLength = 409;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode =
+ "(function (controller, bytesWritten)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " bytesWritten = @toNumber(bytesWritten);\n" \
+ "\n" \
+ " if (@isNaN(bytesWritten) || bytesWritten === @Infinity || bytesWritten < 0 )\n" \
+ " @throwRangeError(\"bytesWritten has an incorrect value\");\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(controller, \"pendingPullIntos\").length > 0);\n" \
+ "\n" \
+ " @readableByteStreamControllerRespondInternal(controller, bytesWritten);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeLength = 708;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode =
+ "(function (controller, bytesWritten)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " let firstDescriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\")[0];\n" \
+ " let stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(stream, \"state\") === @streamClosed) {\n" \
+ " if (bytesWritten !== 0)\n" \
+ " @throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");\n" \
+ " @readableByteStreamControllerRespondInClosedState(controller, firstDescriptor);\n" \
+ " } else {\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") === @streamReadable);\n" \
+ " @readableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 1439;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode =
+ "(function (controller, bytesWritten, pullIntoDescriptor)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength)\n" \
+ " @throwRangeError(\"bytesWritten value is too great\");\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(controller, \"pendingPullIntos\").length === 0 || @getByIdDirectPrivate(controller, \"pendingPullIntos\")[0] === pullIntoDescriptor);\n" \
+ " @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \
+ " pullIntoDescriptor.bytesFilled += bytesWritten;\n" \
+ "\n" \
+ " if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize)\n" \
+ " return;\n" \
+ "\n" \
+ " @readableByteStreamControllerShiftPendingDescriptor(controller);\n" \
+ " const remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;\n" \
+ "\n" \
+ " if (remainderSize > 0) {\n" \
+ " const end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;\n" \
+ " const remainder = @cloneArrayBuffer(pullIntoDescriptor.buffer, end - remainderSize, remainderSize);\n" \
+ " @readableByteStreamControllerEnqueueChunk(controller, remainder, 0, remainder.byteLength);\n" \
+ " }\n" \
+ "\n" \
+ " pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);\n" \
+ " pullIntoDescriptor.bytesFilled -= remainderSize;\n" \
+ " @readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), pullIntoDescriptor);\n" \
+ " @readableByteStreamControllerProcessPullDescriptors(controller);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeLength = 727;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCode =
+ "(function (controller, firstDescriptor)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " firstDescriptor.buffer = @transferBufferToCurrentRealm(firstDescriptor.buffer);\n" \
+ " @assert(firstDescriptor.bytesFilled === 0);\n" \
+ "\n" \
+ " if (@readableStreamHasBYOBReader(@getByIdDirectPrivate(controller, \"controlledReadableStream\"))) {\n" \
+ " while (@getByIdDirectPrivate(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"reader\"), \"readIntoRequests\").length > 0) {\n" \
+ " let pullIntoDescriptor = @readableByteStreamControllerShiftPendingDescriptor(controller);\n" \
+ " @readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), pullIntoDescriptor);\n" \
+ " }\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeLength = 706;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(!@getByIdDirectPrivate(controller, \"closeRequested\"));\n" \
+ " while (@getByIdDirectPrivate(controller, \"pendingPullIntos\").length > 0) {\n" \
+ " if (@getByIdDirectPrivate(controller, \"queue\").size === 0)\n" \
+ " return;\n" \
+ " let pullIntoDescriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\")[0];\n" \
+ " if (@readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor)) {\n" \
+ " @readableByteStreamControllerShiftPendingDescriptor(controller);\n" \
+ " @readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), pullIntoDescriptor);\n" \
+ " }\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeLength = 2355;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode =
+ "(function (controller, pullIntoDescriptor)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const currentAlignedBytes = pullIntoDescriptor.bytesFilled - (pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize);\n" \
+ " const maxBytesToCopy = @getByIdDirectPrivate(controller, \"queue\").size < pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled ?\n" \
+ " @getByIdDirectPrivate(controller, \"queue\").size : pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled;\n" \
+ " const maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;\n" \
+ " const maxAlignedBytes = maxBytesFilled - (maxBytesFilled % pullIntoDescriptor.elementSize);\n" \
+ " let totalBytesToCopyRemaining = maxBytesToCopy;\n" \
+ " let ready = false;\n" \
+ "\n" \
+ " if (maxAlignedBytes > currentAlignedBytes) {\n" \
+ " totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;\n" \
+ " ready = true;\n" \
+ " }\n" \
+ "\n" \
+ " while (totalBytesToCopyRemaining > 0) {\n" \
+ " let headOfQueue = @getByIdDirectPrivate(controller, \"queue\").content[0];\n" \
+ " const bytesToCopy = totalBytesToCopyRemaining < headOfQueue.byteLength ? totalBytesToCopyRemaining : headOfQueue.byteLength;\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " const destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;\n" \
+ " //\n" \
+ " //\n" \
+ " new @Uint8Array(pullIntoDescriptor.buffer).set(new @Uint8Array(headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy), destStart);\n" \
+ "\n" \
+ " if (headOfQueue.byteLength === bytesToCopy)\n" \
+ " @getByIdDirectPrivate(controller, \"queue\").content.@shift();\n" \
+ " else {\n" \
+ " headOfQueue.byteOffset += bytesToCopy;\n" \
+ " headOfQueue.byteLength -= bytesToCopy;\n" \
+ " }\n" \
+ "\n" \
+ " @getByIdDirectPrivate(controller, \"queue\").size -= bytesToCopy;\n" \
+ " @assert(@getByIdDirectPrivate(controller, \"pendingPullIntos\").length === 0 || @getByIdDirectPrivate(controller, \"pendingPullIntos\")[0] === pullIntoDescriptor);\n" \
+ " @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \
+ " pullIntoDescriptor.bytesFilled += bytesToCopy;\n" \
+ " totalBytesToCopyRemaining -= bytesToCopy;\n" \
+ " }\n" \
+ "\n" \
+ " if (!ready) {\n" \
+ " @assert(@getByIdDirectPrivate(controller, \"queue\").size === 0);\n" \
+ " @assert(pullIntoDescriptor.bytesFilled > 0);\n" \
+ " @assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize);\n" \
+ " }\n" \
+ "\n" \
+ " return ready;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeLength = 223;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " let descriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\").@shift();\n" \
+ " @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \
+ " return descriptor;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeLength = 430;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(controller, \"byobRequest\") === @undefined)\n" \
+ " return;\n" \
+ " const byobRequest = @getByIdDirectPrivate(controller, \"byobRequest\");\n" \
+ " @putByIdDirectPrivate(byobRequest, \"associatedReadableByteStreamController\", @undefined);\n" \
+ " @putByIdDirectPrivate(byobRequest, \"view\", @undefined);\n" \
+ " @putByIdDirectPrivate(controller, \"byobRequest\", @undefined);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeLength = 662;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCode =
+ "(function (stream, pullIntoDescriptor)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") !== @streamErrored);\n" \
+ " let done = false;\n" \
+ " if (@getByIdDirectPrivate(stream, \"state\") === @streamClosed) {\n" \
+ " @assert(!pullIntoDescriptor.bytesFilled);\n" \
+ " done = true;\n" \
+ " }\n" \
+ " let filledView = @readableByteStreamControllerConvertDescriptor(pullIntoDescriptor);\n" \
+ " if (pullIntoDescriptor.readerType === \"default\")\n" \
+ " @readableStreamFulfillReadRequest(stream, filledView, done);\n" \
+ " else {\n" \
+ " @assert(pullIntoDescriptor.readerType === \"byob\");\n" \
+ " @readableStreamFulfillReadIntoRequest(stream, filledView, done);\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeLength = 381;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCode =
+ "(function (pullIntoDescriptor)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(pullIntoDescriptor.bytesFilled <= pullIntoDescriptor.byteLength);\n" \
+ " @assert(pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize === 0);\n" \
+ "\n" \
+ " return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, pullIntoDescriptor.bytesFilled / pullIntoDescriptor.elementSize);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeLength = 244;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode =
+ "(function (stream, chunk, done)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ " const readIntoRequest = @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readIntoRequests\").@shift();\n" \
+ " @fulfillPromise(readIntoRequest, { value: chunk, done: done });\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeLength = 462;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode =
+ "(function (reader, view)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(reader, \"ownerReadableStream\");\n" \
+ " @assert(!!stream);\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"disturbed\", true);\n" \
+ " if (@getByIdDirectPrivate(stream, \"state\") === @streamErrored)\n" \
+ " return @Promise.@reject(@getByIdDirectPrivate(stream, \"storedError\"));\n" \
+ "\n" \
+ " return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(stream, \"readableStreamController\"), view);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeLength = 2216;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode =
+ "(function (controller, view)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
+ " let elementSize = 1;\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " if (view.BYTES_PER_ELEMENT !== @undefined)\n" \
+ " elementSize = view.BYTES_PER_ELEMENT;\n" \
+ "\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " const ctor = view.constructor;\n" \
+ "\n" \
+ " const pullIntoDescriptor = {\n" \
+ " buffer: view.buffer,\n" \
+ " byteOffset: view.byteOffset,\n" \
+ " byteLength: view.byteLength,\n" \
+ " bytesFilled: 0,\n" \
+ " elementSize,\n" \
+ " ctor,\n" \
+ " readerType: 'byob'\n" \
+ " };\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(controller, \"pendingPullIntos\").length) {\n" \
+ " pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);\n" \
+ " @arrayPush(@getByIdDirectPrivate(controller, \"pendingPullIntos\"), pullIntoDescriptor);\n" \
+ " return @readableStreamAddReadIntoRequest(stream);\n" \
+ " }\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(stream, \"state\") === @streamClosed) {\n" \
+ " const emptyView = new ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);\n" \
+ " return @createFulfilledPromise({ value: emptyView, done: true });\n" \
+ " }\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(controller, \"queue\").size > 0) {\n" \
+ " if (@readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor)) {\n" \
+ " const filledView = @readableByteStreamControllerConvertDescriptor(pullIntoDescriptor);\n" \
+ " @readableByteStreamControllerHandleQueueDrain(controller);\n" \
+ " return @createFulfilledPromise({ value: filledView, done: false });\n" \
+ " }\n" \
+ " if (@getByIdDirectPrivate(controller, \"closeRequested\")) {\n" \
+ " const e = @makeTypeError(\"Closing stream has been requested\");\n" \
+ " @readableByteStreamControllerError(controller, e);\n" \
+ " return @Promise.@reject(e);\n" \
+ " }\n" \
+ " }\n" \
+ "\n" \
+ " pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);\n" \
+ " @arrayPush(@getByIdDirectPrivate(controller, \"pendingPullIntos\"), pullIntoDescriptor);\n" \
+ " const promise = @readableStreamAddReadIntoRequest(stream);\n" \
+ " @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
+ " return promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeLength = 437;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@isReadableStreamBYOBReader(@getByIdDirectPrivate(stream, \"reader\")));\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") === @streamReadable || @getByIdDirectPrivate(stream, \"state\") === @streamClosed);\n" \
+ "\n" \
+ " const readRequest = @newPromise();\n" \
+ " @arrayPush(@getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readIntoRequests\"), readRequest);\n" \
+ "\n" \
+ " return readRequest;\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().readableByteStreamInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableByteStreamInternalsBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableByteStreamInternalsBuiltins.h b/src/javascript/jsc/bindings/ReadableByteStreamInternalsBuiltins.h
new file mode 100644
index 000000000..5389414ef
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableByteStreamInternalsBuiltins.h
@@ -0,0 +1,428 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* ReadableByteStreamInternals */
+extern const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode;
+extern const int s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCode;
+extern const int s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsIsReadableByteStreamControllerCode;
+extern const int s_readableByteStreamInternalsIsReadableByteStreamControllerCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableByteStreamControllerCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableByteStreamControllerCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsIsReadableStreamBYOBRequestCode;
+extern const int s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsIsReadableStreamBYOBReaderCode;
+extern const int s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerErrorCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerCloseCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode;
+extern const int s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode;
+extern const int s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerPullCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsTransferBufferToCurrentRealmCode;
+extern const int s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode;
+extern const int s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode;
+extern const int s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode;
+extern const int s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructorKind;
+extern const char* const s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCode;
+extern const int s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructorKind;
+
+#define WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_DATA(macro) \
+ macro(privateInitializeReadableByteStreamController, readableByteStreamInternalsPrivateInitializeReadableByteStreamController, 3) \
+ macro(privateInitializeReadableStreamBYOBRequest, readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequest, 2) \
+ macro(isReadableByteStreamController, readableByteStreamInternalsIsReadableByteStreamController, 1) \
+ macro(isReadableStreamBYOBRequest, readableByteStreamInternalsIsReadableStreamBYOBRequest, 1) \
+ macro(isReadableStreamBYOBReader, readableByteStreamInternalsIsReadableStreamBYOBReader, 1) \
+ macro(readableByteStreamControllerCancel, readableByteStreamInternalsReadableByteStreamControllerCancel, 2) \
+ macro(readableByteStreamControllerError, readableByteStreamInternalsReadableByteStreamControllerError, 2) \
+ macro(readableByteStreamControllerClose, readableByteStreamInternalsReadableByteStreamControllerClose, 1) \
+ macro(readableByteStreamControllerClearPendingPullIntos, readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntos, 1) \
+ macro(readableByteStreamControllerGetDesiredSize, readableByteStreamInternalsReadableByteStreamControllerGetDesiredSize, 1) \
+ macro(readableStreamHasBYOBReader, readableByteStreamInternalsReadableStreamHasBYOBReader, 1) \
+ macro(readableStreamHasDefaultReader, readableByteStreamInternalsReadableStreamHasDefaultReader, 1) \
+ macro(readableByteStreamControllerHandleQueueDrain, readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrain, 1) \
+ macro(readableByteStreamControllerPull, readableByteStreamInternalsReadableByteStreamControllerPull, 1) \
+ macro(readableByteStreamControllerShouldCallPull, readableByteStreamInternalsReadableByteStreamControllerShouldCallPull, 1) \
+ macro(readableByteStreamControllerCallPullIfNeeded, readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeeded, 1) \
+ macro(transferBufferToCurrentRealm, readableByteStreamInternalsTransferBufferToCurrentRealm, 1) \
+ macro(readableByteStreamControllerEnqueue, readableByteStreamInternalsReadableByteStreamControllerEnqueue, 2) \
+ macro(readableByteStreamControllerEnqueueChunk, readableByteStreamInternalsReadableByteStreamControllerEnqueueChunk, 4) \
+ macro(readableByteStreamControllerRespondWithNewView, readableByteStreamInternalsReadableByteStreamControllerRespondWithNewView, 2) \
+ macro(readableByteStreamControllerRespond, readableByteStreamInternalsReadableByteStreamControllerRespond, 2) \
+ macro(readableByteStreamControllerRespondInternal, readableByteStreamInternalsReadableByteStreamControllerRespondInternal, 2) \
+ macro(readableByteStreamControllerRespondInReadableState, readableByteStreamInternalsReadableByteStreamControllerRespondInReadableState, 3) \
+ macro(readableByteStreamControllerRespondInClosedState, readableByteStreamInternalsReadableByteStreamControllerRespondInClosedState, 2) \
+ macro(readableByteStreamControllerProcessPullDescriptors, readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptors, 1) \
+ macro(readableByteStreamControllerFillDescriptorFromQueue, readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueue, 2) \
+ macro(readableByteStreamControllerShiftPendingDescriptor, readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptor, 1) \
+ macro(readableByteStreamControllerInvalidateBYOBRequest, readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequest, 1) \
+ macro(readableByteStreamControllerCommitDescriptor, readableByteStreamInternalsReadableByteStreamControllerCommitDescriptor, 2) \
+ macro(readableByteStreamControllerConvertDescriptor, readableByteStreamInternalsReadableByteStreamControllerConvertDescriptor, 1) \
+ macro(readableStreamFulfillReadIntoRequest, readableByteStreamInternalsReadableStreamFulfillReadIntoRequest, 3) \
+ macro(readableStreamBYOBReaderRead, readableByteStreamInternalsReadableStreamBYOBReaderRead, 2) \
+ macro(readableByteStreamControllerPullInto, readableByteStreamInternalsReadableByteStreamControllerPullInto, 2) \
+ macro(readableStreamAddReadIntoRequest, readableByteStreamInternalsReadableStreamAddReadIntoRequest, 1) \
+
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_PRIVATEINITIALIZEREADABLEBYTESTREAMCONTROLLER 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_PRIVATEINITIALIZEREADABLESTREAMBYOBREQUEST 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_ISREADABLEBYTESTREAMCONTROLLER 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_ISREADABLESTREAMBYOBREQUEST 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_ISREADABLESTREAMBYOBREADER 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCANCEL 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERERROR 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCLOSE 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCLEARPENDINGPULLINTOS 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERGETDESIREDSIZE 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMHASBYOBREADER 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMHASDEFAULTREADER 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERHANDLEQUEUEDRAIN 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERPULL 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERSHOULDCALLPULL 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCALLPULLIFNEEDED 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_TRANSFERBUFFERTOCURRENTREALM 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERENQUEUE 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERENQUEUECHUNK 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPONDWITHNEWVIEW 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPOND 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPONDINTERNAL 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPONDINREADABLESTATE 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPONDINCLOSEDSTATE 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERPROCESSPULLDESCRIPTORS 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERFILLDESCRIPTORFROMQUEUE 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERSHIFTPENDINGDESCRIPTOR 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERINVALIDATEBYOBREQUEST 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCOMMITDESCRIPTOR 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCONVERTDESCRIPTOR 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMFULFILLREADINTOREQUEST 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMBYOBREADERREAD 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERPULLINTO 1
+#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMADDREADINTOREQUEST 1
+
+#define WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(macro) \
+ macro(readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode, privateInitializeReadableByteStreamController, ASCIILiteral(), s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeLength) \
+ macro(readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCode, privateInitializeReadableStreamBYOBRequest, ASCIILiteral(), s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeLength) \
+ macro(readableByteStreamInternalsIsReadableByteStreamControllerCode, isReadableByteStreamController, ASCIILiteral(), s_readableByteStreamInternalsIsReadableByteStreamControllerCodeLength) \
+ macro(readableByteStreamInternalsIsReadableStreamBYOBRequestCode, isReadableStreamBYOBRequest, ASCIILiteral(), s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeLength) \
+ macro(readableByteStreamInternalsIsReadableStreamBYOBReaderCode, isReadableStreamBYOBReader, ASCIILiteral(), s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerCancelCode, readableByteStreamControllerCancel, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerErrorCode, readableByteStreamControllerError, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerCloseCode, readableByteStreamControllerClose, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCode, readableByteStreamControllerClearPendingPullIntos, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode, readableByteStreamControllerGetDesiredSize, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength) \
+ macro(readableByteStreamInternalsReadableStreamHasBYOBReaderCode, readableStreamHasBYOBReader, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength) \
+ macro(readableByteStreamInternalsReadableStreamHasDefaultReaderCode, readableStreamHasDefaultReader, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCode, readableByteStreamControllerHandleQueueDrain, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerPullCode, readableByteStreamControllerPull, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode, readableByteStreamControllerShouldCallPull, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCode, readableByteStreamControllerCallPullIfNeeded, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeLength) \
+ macro(readableByteStreamInternalsTransferBufferToCurrentRealmCode, transferBufferToCurrentRealm, ASCIILiteral(), s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerEnqueueCode, readableByteStreamControllerEnqueue, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode, readableByteStreamControllerEnqueueChunk, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode, readableByteStreamControllerRespondWithNewView, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerRespondCode, readableByteStreamControllerRespond, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode, readableByteStreamControllerRespondInternal, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode, readableByteStreamControllerRespondInReadableState, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCode, readableByteStreamControllerRespondInClosedState, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCode, readableByteStreamControllerProcessPullDescriptors, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode, readableByteStreamControllerFillDescriptorFromQueue, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCode, readableByteStreamControllerShiftPendingDescriptor, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCode, readableByteStreamControllerInvalidateBYOBRequest, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCode, readableByteStreamControllerCommitDescriptor, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCode, readableByteStreamControllerConvertDescriptor, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeLength) \
+ macro(readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode, readableStreamFulfillReadIntoRequest, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeLength) \
+ macro(readableByteStreamInternalsReadableStreamBYOBReaderReadCode, readableStreamBYOBReaderRead, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeLength) \
+ macro(readableByteStreamInternalsReadableByteStreamControllerPullIntoCode, readableByteStreamControllerPullInto, ASCIILiteral(), s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeLength) \
+ macro(readableByteStreamInternalsReadableStreamAddReadIntoRequestCode, readableStreamAddReadIntoRequest, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeLength) \
+
+#define WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \
+ macro(isReadableByteStreamController) \
+ macro(isReadableStreamBYOBReader) \
+ macro(isReadableStreamBYOBRequest) \
+ macro(privateInitializeReadableByteStreamController) \
+ macro(privateInitializeReadableStreamBYOBRequest) \
+ macro(readableByteStreamControllerCallPullIfNeeded) \
+ macro(readableByteStreamControllerCancel) \
+ macro(readableByteStreamControllerClearPendingPullIntos) \
+ macro(readableByteStreamControllerClose) \
+ macro(readableByteStreamControllerCommitDescriptor) \
+ macro(readableByteStreamControllerConvertDescriptor) \
+ macro(readableByteStreamControllerEnqueue) \
+ macro(readableByteStreamControllerEnqueueChunk) \
+ macro(readableByteStreamControllerError) \
+ macro(readableByteStreamControllerFillDescriptorFromQueue) \
+ macro(readableByteStreamControllerGetDesiredSize) \
+ macro(readableByteStreamControllerHandleQueueDrain) \
+ macro(readableByteStreamControllerInvalidateBYOBRequest) \
+ macro(readableByteStreamControllerProcessPullDescriptors) \
+ macro(readableByteStreamControllerPull) \
+ macro(readableByteStreamControllerPullInto) \
+ macro(readableByteStreamControllerRespond) \
+ macro(readableByteStreamControllerRespondInClosedState) \
+ macro(readableByteStreamControllerRespondInReadableState) \
+ macro(readableByteStreamControllerRespondInternal) \
+ macro(readableByteStreamControllerRespondWithNewView) \
+ macro(readableByteStreamControllerShiftPendingDescriptor) \
+ macro(readableByteStreamControllerShouldCallPull) \
+ macro(readableStreamAddReadIntoRequest) \
+ macro(readableStreamBYOBReaderRead) \
+ macro(readableStreamFulfillReadIntoRequest) \
+ macro(readableStreamHasBYOBReader) \
+ macro(readableStreamHasDefaultReader) \
+ macro(transferBufferToCurrentRealm) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class ReadableByteStreamInternalsBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit ReadableByteStreamInternalsBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_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_READABLEBYTESTREAMINTERNALS_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_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* ReadableByteStreamInternalsBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void ReadableByteStreamInternalsBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+class ReadableByteStreamInternalsBuiltinFunctions {
+public:
+ explicit ReadableByteStreamInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { }
+
+ void init(JSC::JSGlobalObject&);
+ template<typename Visitor> void visit(Visitor&);
+
+public:
+ JSC::VM& m_vm;
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \
+ JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function;
+ WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+};
+
+inline void ReadableByteStreamInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
+{
+#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
+ m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
+ WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION)
+#undef EXPORT_FUNCTION
+}
+
+template<typename Visitor>
+inline void ReadableByteStreamInternalsBuiltinFunctions::visit(Visitor& visitor)
+{
+#define VISIT_FUNCTION(name) visitor.append(m_##name##Function);
+ WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION)
+#undef VISIT_FUNCTION
+}
+
+template void ReadableByteStreamInternalsBuiltinFunctions::visit(JSC::AbstractSlotVisitor&);
+template void ReadableByteStreamInternalsBuiltinFunctions::visit(JSC::SlotVisitor&);
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableStreamBYOBReaderBuiltins.cpp b/src/javascript/jsc/bindings/ReadableStreamBYOBReaderBuiltins.cpp
new file mode 100644
index 000000000..c6514f616
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamBYOBReaderBuiltins.cpp
@@ -0,0 +1,169 @@
+/*
+ * 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 "ReadableStreamBYOBReaderBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeLength = 574;
+static const JSC::Intrinsic s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStream(stream))\n" \
+ " @throwTypeError(\"ReadableStreamBYOBReader needs a ReadableStream\");\n" \
+ " if (!@isReadableByteStreamController(@getByIdDirectPrivate(stream, \"readableStreamController\")))\n" \
+ " @throwTypeError(\"ReadableStreamBYOBReader needs a ReadableByteStreamController\");\n" \
+ " if (@isReadableStreamLocked(stream))\n" \
+ " @throwTypeError(\"ReadableStream is locked\");\n" \
+ "\n" \
+ " @readableStreamReaderGenericInitialize(this, stream);\n" \
+ " @putByIdDirectPrivate(this, \"readIntoRequests\", []);\n" \
+ "\n" \
+ " return this;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamBYOBReaderCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamBYOBReaderCancelCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamBYOBReaderCancelCodeLength = 410;
+static const JSC::Intrinsic s_readableStreamBYOBReaderCancelCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamBYOBReaderCancelCode =
+ "(function (reason)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamBYOBReader(this))\n" \
+ " return @Promise.@reject(@makeThisTypeError(\"ReadableStreamBYOBReader\", \"cancel\"));\n" \
+ "\n" \
+ " if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
+ " return @Promise.@reject(@makeTypeError(\"cancel() called on a reader owned by no readable stream\"));\n" \
+ "\n" \
+ " return @readableStreamReaderGenericCancel(this, reason);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamBYOBReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamBYOBReaderReadCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamBYOBReaderReadCodeLength = 762;
+static const JSC::Intrinsic s_readableStreamBYOBReaderReadCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamBYOBReaderReadCode =
+ "(function (view)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamBYOBReader(this))\n" \
+ " return @Promise.@reject(@makeThisTypeError(\"ReadableStreamBYOBReader\", \"read\"));\n" \
+ "\n" \
+ " if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
+ " return @Promise.@reject(@makeTypeError(\"read() called on a reader owned by no readable stream\"));\n" \
+ "\n" \
+ " if (!@isObject(view))\n" \
+ " return @Promise.@reject(@makeTypeError(\"Provided view is not an object\"));\n" \
+ "\n" \
+ " if (!@ArrayBuffer.@isView(view))\n" \
+ " return @Promise.@reject(@makeTypeError(\"Provided view is not an ArrayBufferView\"));\n" \
+ "\n" \
+ " if (view.byteLength === 0)\n" \
+ " return @Promise.@reject(@makeTypeError(\"Provided view cannot have a 0 byteLength\"));\n" \
+ "\n" \
+ " return @readableStreamBYOBReaderRead(this, view);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamBYOBReaderReleaseLockCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamBYOBReaderReleaseLockCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamBYOBReaderReleaseLockCodeLength = 440;
+static const JSC::Intrinsic s_readableStreamBYOBReaderReleaseLockCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamBYOBReaderReleaseLockCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamBYOBReader(this))\n" \
+ " throw @makeThisTypeError(\"ReadableStreamBYOBReader\", \"releaseLock\");\n" \
+ "\n" \
+ " if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
+ " return;\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(this, \"readIntoRequests\").length)\n" \
+ " @throwTypeError(\"There are still pending read requests, cannot release the lock\");\n" \
+ "\n" \
+ " @readableStreamReaderGenericRelease(this);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamBYOBReaderClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamBYOBReaderClosedCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamBYOBReaderClosedCodeLength = 251;
+static const JSC::Intrinsic s_readableStreamBYOBReaderClosedCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamBYOBReaderClosedCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamBYOBReader(this))\n" \
+ " return @Promise.@reject(@makeGetterTypeError(\"ReadableStreamBYOBReader\", \"closed\"));\n" \
+ "\n" \
+ " return @getByIdDirectPrivate(this, \"closedPromiseCapability\").@promise;\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().readableStreamBYOBReaderBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamBYOBReaderBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableStreamBYOBReaderBuiltins.h b/src/javascript/jsc/bindings/ReadableStreamBYOBReaderBuiltins.h
new file mode 100644
index 000000000..0011df117
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamBYOBReaderBuiltins.h
@@ -0,0 +1,159 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* ReadableStreamBYOBReader */
+extern const char* const s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCode;
+extern const int s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeLength;
+extern const JSC::ConstructAbility s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructorKind;
+extern const char* const s_readableStreamBYOBReaderCancelCode;
+extern const int s_readableStreamBYOBReaderCancelCodeLength;
+extern const JSC::ConstructAbility s_readableStreamBYOBReaderCancelCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamBYOBReaderCancelCodeConstructorKind;
+extern const char* const s_readableStreamBYOBReaderReadCode;
+extern const int s_readableStreamBYOBReaderReadCodeLength;
+extern const JSC::ConstructAbility s_readableStreamBYOBReaderReadCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamBYOBReaderReadCodeConstructorKind;
+extern const char* const s_readableStreamBYOBReaderReleaseLockCode;
+extern const int s_readableStreamBYOBReaderReleaseLockCodeLength;
+extern const JSC::ConstructAbility s_readableStreamBYOBReaderReleaseLockCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamBYOBReaderReleaseLockCodeConstructorKind;
+extern const char* const s_readableStreamBYOBReaderClosedCode;
+extern const int s_readableStreamBYOBReaderClosedCodeLength;
+extern const JSC::ConstructAbility s_readableStreamBYOBReaderClosedCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamBYOBReaderClosedCodeConstructorKind;
+
+#define WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_DATA(macro) \
+ macro(initializeReadableStreamBYOBReader, readableStreamBYOBReaderInitializeReadableStreamBYOBReader, 1) \
+ macro(cancel, readableStreamBYOBReaderCancel, 1) \
+ macro(read, readableStreamBYOBReaderRead, 1) \
+ macro(releaseLock, readableStreamBYOBReaderReleaseLock, 0) \
+ macro(closed, readableStreamBYOBReaderClosed, 0) \
+
+#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_INITIALIZEREADABLESTREAMBYOBREADER 1
+#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_CANCEL 1
+#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_READ 1
+#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_RELEASELOCK 1
+#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_CLOSED 1
+
+#define WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_CODE(macro) \
+ macro(readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCode, initializeReadableStreamBYOBReader, ASCIILiteral(), s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeLength) \
+ macro(readableStreamBYOBReaderCancelCode, cancel, ASCIILiteral(), s_readableStreamBYOBReaderCancelCodeLength) \
+ macro(readableStreamBYOBReaderReadCode, read, ASCIILiteral(), s_readableStreamBYOBReaderReadCodeLength) \
+ macro(readableStreamBYOBReaderReleaseLockCode, releaseLock, ASCIILiteral(), s_readableStreamBYOBReaderReleaseLockCodeLength) \
+ macro(readableStreamBYOBReaderClosedCode, closed, "get closed"_s, s_readableStreamBYOBReaderClosedCodeLength) \
+
+#define WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_FUNCTION_NAME(macro) \
+ macro(cancel) \
+ macro(closed) \
+ macro(initializeReadableStreamBYOBReader) \
+ macro(read) \
+ macro(releaseLock) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class ReadableStreamBYOBReaderBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit ReadableStreamBYOBReaderBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_READABLESTREAMBYOBREADER_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_READABLESTREAMBYOBREADER_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_READABLESTREAMBYOBREADER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* ReadableStreamBYOBReaderBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_READABLESTREAMBYOBREADER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void ReadableStreamBYOBReaderBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_READABLESTREAMBYOBREADER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableStreamBYOBRequestBuiltins.cpp b/src/javascript/jsc/bindings/ReadableStreamBYOBRequestBuiltins.cpp
new file mode 100644
index 000000000..1c4d9fdb3
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamBYOBRequestBuiltins.cpp
@@ -0,0 +1,137 @@
+/*
+ * 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 "ReadableStreamBYOBRequestBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeLength = 306;
+static const JSC::Intrinsic s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCode =
+ "(function (controller, view)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (arguments.length !== 3 && arguments[2] !== @isReadableStream)\n" \
+ " @throwTypeError(\"ReadableStreamBYOBRequest constructor should not be called directly\");\n" \
+ "\n" \
+ " return @privateInitializeReadableStreamBYOBRequest.@call(this, controller, view);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamBYOBRequestRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamBYOBRequestRespondCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamBYOBRequestRespondCodeLength = 504;
+static const JSC::Intrinsic s_readableStreamBYOBRequestRespondCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamBYOBRequestRespondCode =
+ "(function (bytesWritten)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamBYOBRequest(this))\n" \
+ " throw @makeThisTypeError(\"ReadableStreamBYOBRequest\", \"respond\");\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(this, \"associatedReadableByteStreamController\") === @undefined)\n" \
+ " @throwTypeError(\"ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined\");\n" \
+ "\n" \
+ " return @readableByteStreamControllerRespond(@getByIdDirectPrivate(this, \"associatedReadableByteStreamController\"), bytesWritten);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamBYOBRequestRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamBYOBRequestRespondWithNewViewCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamBYOBRequestRespondWithNewViewCodeLength = 691;
+static const JSC::Intrinsic s_readableStreamBYOBRequestRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamBYOBRequestRespondWithNewViewCode =
+ "(function (view)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamBYOBRequest(this))\n" \
+ " throw @makeThisTypeError(\"ReadableStreamBYOBRequest\", \"respond\");\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(this, \"associatedReadableByteStreamController\") === @undefined)\n" \
+ " @throwTypeError(\"ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined\");\n" \
+ "\n" \
+ " if (!@isObject(view))\n" \
+ " @throwTypeError(\"Provided view is not an object\");\n" \
+ "\n" \
+ " if (!@ArrayBuffer.@isView(view))\n" \
+ " @throwTypeError(\"Provided view is not an ArrayBufferView\");\n" \
+ "\n" \
+ " return @readableByteStreamControllerRespondWithNewView(@getByIdDirectPrivate(this, \"associatedReadableByteStreamController\"), view);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamBYOBRequestViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamBYOBRequestViewCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamBYOBRequestViewCodeLength = 204;
+static const JSC::Intrinsic s_readableStreamBYOBRequestViewCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamBYOBRequestViewCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamBYOBRequest(this))\n" \
+ " throw @makeGetterTypeError(\"ReadableStreamBYOBRequest\", \"view\");\n" \
+ "\n" \
+ " return @getByIdDirectPrivate(this, \"view\");\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().readableStreamBYOBRequestBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamBYOBRequestBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableStreamBYOBRequestBuiltins.h b/src/javascript/jsc/bindings/ReadableStreamBYOBRequestBuiltins.h
new file mode 100644
index 000000000..8e8aedff3
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamBYOBRequestBuiltins.h
@@ -0,0 +1,151 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* ReadableStreamBYOBRequest */
+extern const char* const s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCode;
+extern const int s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeLength;
+extern const JSC::ConstructAbility s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructorKind;
+extern const char* const s_readableStreamBYOBRequestRespondCode;
+extern const int s_readableStreamBYOBRequestRespondCodeLength;
+extern const JSC::ConstructAbility s_readableStreamBYOBRequestRespondCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamBYOBRequestRespondCodeConstructorKind;
+extern const char* const s_readableStreamBYOBRequestRespondWithNewViewCode;
+extern const int s_readableStreamBYOBRequestRespondWithNewViewCodeLength;
+extern const JSC::ConstructAbility s_readableStreamBYOBRequestRespondWithNewViewCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamBYOBRequestRespondWithNewViewCodeConstructorKind;
+extern const char* const s_readableStreamBYOBRequestViewCode;
+extern const int s_readableStreamBYOBRequestViewCodeLength;
+extern const JSC::ConstructAbility s_readableStreamBYOBRequestViewCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamBYOBRequestViewCodeConstructorKind;
+
+#define WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_DATA(macro) \
+ macro(initializeReadableStreamBYOBRequest, readableStreamBYOBRequestInitializeReadableStreamBYOBRequest, 2) \
+ macro(respond, readableStreamBYOBRequestRespond, 1) \
+ macro(respondWithNewView, readableStreamBYOBRequestRespondWithNewView, 1) \
+ macro(view, readableStreamBYOBRequestView, 0) \
+
+#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_INITIALIZEREADABLESTREAMBYOBREQUEST 1
+#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_RESPOND 1
+#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_RESPONDWITHNEWVIEW 1
+#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_VIEW 1
+
+#define WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(macro) \
+ macro(readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCode, initializeReadableStreamBYOBRequest, ASCIILiteral(), s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeLength) \
+ macro(readableStreamBYOBRequestRespondCode, respond, ASCIILiteral(), s_readableStreamBYOBRequestRespondCodeLength) \
+ macro(readableStreamBYOBRequestRespondWithNewViewCode, respondWithNewView, ASCIILiteral(), s_readableStreamBYOBRequestRespondWithNewViewCodeLength) \
+ macro(readableStreamBYOBRequestViewCode, view, "get view"_s, s_readableStreamBYOBRequestViewCodeLength) \
+
+#define WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(macro) \
+ macro(initializeReadableStreamBYOBRequest) \
+ macro(respond) \
+ macro(respondWithNewView) \
+ macro(view) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class ReadableStreamBYOBRequestBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit ReadableStreamBYOBRequestBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_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_READABLESTREAMBYOBREQUEST_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_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* ReadableStreamBYOBRequestBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_READABLESTREAMBYOBREQUEST_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void ReadableStreamBYOBRequestBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_READABLESTREAMBYOBREQUEST_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableStreamBuiltins.cpp b/src/javascript/jsc/bindings/ReadableStreamBuiltins.cpp
new file mode 100644
index 000000000..928e875be
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamBuiltins.cpp
@@ -0,0 +1,310 @@
+/*
+ * 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 "ReadableStreamBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_readableStreamInitializeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInitializeReadableStreamCodeLength = 2408;
+static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInitializeReadableStreamCode =
+ "(function (underlyingSource, strategy)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (underlyingSource === @undefined)\n" \
+ " underlyingSource = { };\n" \
+ " if (strategy === @undefined)\n" \
+ " strategy = { };\n" \
+ "\n" \
+ " if (!@isObject(underlyingSource))\n" \
+ " @throwTypeError(\"ReadableStream constructor takes an object as first argument\");\n" \
+ "\n" \
+ " if (strategy !== @undefined && !@isObject(strategy))\n" \
+ " @throwTypeError(\"ReadableStream constructor takes an object as second argument, if any\");\n" \
+ "\n" \
+ " @putByIdDirectPrivate(this, \"state\", @streamReadable);\n" \
+ " \n" \
+ " @putByIdDirectPrivate(this, \"reader\", @undefined);\n" \
+ " \n" \
+ " @putByIdDirectPrivate(this, \"storedError\", @undefined);\n" \
+ " \n" \
+ " @putByIdDirectPrivate(this, \"disturbed\", false);\n" \
+ " \n" \
+ " //\n" \
+ " @putByIdDirectPrivate(this, \"readableStreamController\", null);\n" \
+ " \n" \
+ "\n" \
+ " //\n" \
+ " //\n" \
+ " if (@getByIdDirectPrivate(underlyingSource, \"pull\") !== @undefined) {\n" \
+ " \n" \
+ " const size = @getByIdDirectPrivate(strategy, \"size\");\n" \
+ " const highWaterMark = @getByIdDirectPrivate(strategy, \"highWaterMark\");\n" \
+ " @setupReadableStreamDefaultController(this, underlyingSource, size, highWaterMark !== @undefined ? highWaterMark : 1, @getByIdDirectPrivate(underlyingSource, \"start\"), @getByIdDirectPrivate(underlyingSource, \"pull\"), @getByIdDirectPrivate(underlyingSource, \"cancel\"));\n" \
+ " \n" \
+ " return this;\n" \
+ " }\n" \
+ "\n" \
+ " const type = underlyingSource.type;\n" \
+ " const typeString = @toString(type);\n" \
+ "\n" \
+ " if (typeString === \"bytes\") {\n" \
+ " //\n" \
+ " //\n" \
+ "\n" \
+ " if (strategy.highWaterMark === @undefined)\n" \
+ " strategy.highWaterMark = 0;\n" \
+ " if (strategy.size !== @undefined)\n" \
+ " @throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");\n" \
+ "\n" \
+ " let readableByteStreamControllerConstructor = @ReadableByteStreamController;\n" \
+ " \n" \
+ " @putByIdDirectPrivate(this, \"readableStreamController\", new @ReadableByteStreamController(this, underlyingSource, strategy.highWaterMark, @isReadableStream));\n" \
+ " } else if (type === @undefined) {\n" \
+ " if (strategy.highWaterMark === @undefined)\n" \
+ " strategy.highWaterMark = 1;\n" \
+ " \n" \
+ " @setupReadableStreamDefaultController(this, underlyingSource, strategy.size, strategy.highWaterMark, underlyingSource.start, underlyingSource.pull, underlyingSource.cancel);\n" \
+ " } else\n" \
+ " @throwRangeError(\"Invalid type for underlying source\");\n" \
+ "\n" \
+ " return this;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamCancelCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamCancelCodeLength = 324;
+static const JSC::Intrinsic s_readableStreamCancelCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamCancelCode =
+ "(function (reason)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStream(this))\n" \
+ " return @Promise.@reject(@makeThisTypeError(\"ReadableStream\", \"cancel\"));\n" \
+ "\n" \
+ " if (@isReadableStreamLocked(this))\n" \
+ " return @Promise.@reject(@makeTypeError(\"ReadableStream is locked\"));\n" \
+ "\n" \
+ " return @readableStreamCancel(this, reason);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamGetReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamGetReaderCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamGetReaderCodeLength = 476;
+static const JSC::Intrinsic s_readableStreamGetReaderCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamGetReaderCode =
+ "(function (options)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStream(this))\n" \
+ " throw @makeThisTypeError(\"ReadableStream\", \"getReader\");\n" \
+ "\n" \
+ " const mode = @toDictionary(options, { }, \"ReadableStream.getReader takes an object as first argument\").mode;\n" \
+ " if (mode === @undefined)\n" \
+ " return new @ReadableStreamDefaultReader(this);\n" \
+ "\n" \
+ " //\n" \
+ " if (mode == 'byob')\n" \
+ " return new @ReadableStreamBYOBReader(this);\n" \
+ "\n" \
+ " @throwTypeError(\"Invalid mode is specified\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamPipeThroughCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamPipeThroughCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamPipeThroughCodeLength = 1485;
+static const JSC::Intrinsic s_readableStreamPipeThroughCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamPipeThroughCode =
+ "(function (streams, options)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const transforms = streams;\n" \
+ "\n" \
+ " const readable = transforms[\"readable\"];\n" \
+ " if (!@isReadableStream(readable))\n" \
+ " throw @makeTypeError(\"readable should be ReadableStream\");\n" \
+ "\n" \
+ " const writable = transforms[\"writable\"];\n" \
+ " const internalWritable = @getInternalWritableStream(writable);\n" \
+ " if (!@isWritableStream(internalWritable))\n" \
+ " throw @makeTypeError(\"writable should be WritableStream\");\n" \
+ "\n" \
+ " let preventClose = false;\n" \
+ " let preventAbort = false;\n" \
+ " let preventCancel = false;\n" \
+ " let signal;\n" \
+ " if (!@isUndefinedOrNull(options)) {\n" \
+ " if (!@isObject(options))\n" \
+ " throw @makeTypeError(\"options must be an object\");\n" \
+ "\n" \
+ " preventAbort = !!options[\"preventAbort\"];\n" \
+ " preventCancel = !!options[\"preventCancel\"];\n" \
+ " preventClose = !!options[\"preventClose\"];\n" \
+ "\n" \
+ " signal = options[\"signal\"];\n" \
+ " if (signal !== @undefined && !@isAbortSignal(signal))\n" \
+ " throw @makeTypeError(\"options.signal must be AbortSignal\");\n" \
+ " }\n" \
+ "\n" \
+ " if (!@isReadableStream(this))\n" \
+ " throw @makeThisTypeError(\"ReadableStream\", \"pipeThrough\");\n" \
+ "\n" \
+ " if (@isReadableStreamLocked(this))\n" \
+ " throw @makeTypeError(\"ReadableStream is locked\");\n" \
+ "\n" \
+ " if (@isWritableStreamLocked(internalWritable))\n" \
+ " throw @makeTypeError(\"WritableStream is locked\");\n" \
+ "\n" \
+ " @readableStreamPipeToWritableStream(this, internalWritable, preventClose, preventAbort, preventCancel, signal);\n" \
+ "\n" \
+ " return readable;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamPipeToCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamPipeToCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamPipeToCodeLength = 1523;
+static const JSC::Intrinsic s_readableStreamPipeToCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamPipeToCode =
+ "(function (destination)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " //\n" \
+ " //\n" \
+ " let options = arguments[1];\n" \
+ "\n" \
+ " let preventClose = false;\n" \
+ " let preventAbort = false;\n" \
+ " let preventCancel = false;\n" \
+ " let signal;\n" \
+ " if (!@isUndefinedOrNull(options)) {\n" \
+ " if (!@isObject(options))\n" \
+ " return @Promise.@reject(@makeTypeError(\"options must be an object\"));\n" \
+ "\n" \
+ " try {\n" \
+ " preventAbort = !!options[\"preventAbort\"];\n" \
+ " preventCancel = !!options[\"preventCancel\"];\n" \
+ " preventClose = !!options[\"preventClose\"];\n" \
+ "\n" \
+ " signal = options[\"signal\"];\n" \
+ " } catch(e) {\n" \
+ " return @Promise.@reject(e);\n" \
+ " }\n" \
+ "\n" \
+ " if (signal !== @undefined && !@isAbortSignal(signal))\n" \
+ " return @Promise.@reject(@makeTypeError(\"options.signal must be AbortSignal\"));\n" \
+ " }\n" \
+ "\n" \
+ " const internalDestination = @getInternalWritableStream(destination);\n" \
+ " if (!@isWritableStream(internalDestination))\n" \
+ " return @Promise.@reject(@makeTypeError(\"ReadableStream pipeTo requires a WritableStream\"));\n" \
+ "\n" \
+ " if (!@isReadableStream(this))\n" \
+ " return @Promise.@reject(@makeThisTypeError(\"ReadableStream\", \"pipeTo\"));\n" \
+ "\n" \
+ " if (@isReadableStreamLocked(this))\n" \
+ " return @Promise.@reject(@makeTypeError(\"ReadableStream is locked\"));\n" \
+ "\n" \
+ " if (@isWritableStreamLocked(internalDestination))\n" \
+ " return @Promise.@reject(@makeTypeError(\"WritableStream is locked\"));\n" \
+ "\n" \
+ " return @readableStreamPipeToWritableStream(this, internalDestination, preventClose, preventAbort, preventCancel, signal);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamTeeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamTeeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamTeeCodeLength = 175;
+static const JSC::Intrinsic s_readableStreamTeeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamTeeCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStream(this))\n" \
+ " throw @makeThisTypeError(\"ReadableStream\", \"tee\");\n" \
+ "\n" \
+ " return @readableStreamTee(this, false);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamLockedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamLockedCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamLockedCodeLength = 178;
+static const JSC::Intrinsic s_readableStreamLockedCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamLockedCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStream(this))\n" \
+ " throw @makeGetterTypeError(\"ReadableStream\", \"locked\");\n" \
+ "\n" \
+ " return @isReadableStreamLocked(this);\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().readableStreamBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableStreamBuiltins.h b/src/javascript/jsc/bindings/ReadableStreamBuiltins.h
new file mode 100644
index 000000000..356d47eb7
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamBuiltins.h
@@ -0,0 +1,175 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* ReadableStream */
+extern const char* const s_readableStreamInitializeReadableStreamCode;
+extern const int s_readableStreamInitializeReadableStreamCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInitializeReadableStreamCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstructorKind;
+extern const char* const s_readableStreamCancelCode;
+extern const int s_readableStreamCancelCodeLength;
+extern const JSC::ConstructAbility s_readableStreamCancelCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamCancelCodeConstructorKind;
+extern const char* const s_readableStreamGetReaderCode;
+extern const int s_readableStreamGetReaderCodeLength;
+extern const JSC::ConstructAbility s_readableStreamGetReaderCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamGetReaderCodeConstructorKind;
+extern const char* const s_readableStreamPipeThroughCode;
+extern const int s_readableStreamPipeThroughCodeLength;
+extern const JSC::ConstructAbility s_readableStreamPipeThroughCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamPipeThroughCodeConstructorKind;
+extern const char* const s_readableStreamPipeToCode;
+extern const int s_readableStreamPipeToCodeLength;
+extern const JSC::ConstructAbility s_readableStreamPipeToCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamPipeToCodeConstructorKind;
+extern const char* const s_readableStreamTeeCode;
+extern const int s_readableStreamTeeCodeLength;
+extern const JSC::ConstructAbility s_readableStreamTeeCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamTeeCodeConstructorKind;
+extern const char* const s_readableStreamLockedCode;
+extern const int s_readableStreamLockedCodeLength;
+extern const JSC::ConstructAbility s_readableStreamLockedCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamLockedCodeConstructorKind;
+
+#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_DATA(macro) \
+ macro(initializeReadableStream, readableStreamInitializeReadableStream, 2) \
+ macro(cancel, readableStreamCancel, 1) \
+ macro(getReader, readableStreamGetReader, 1) \
+ macro(pipeThrough, readableStreamPipeThrough, 2) \
+ macro(pipeTo, readableStreamPipeTo, 1) \
+ macro(tee, readableStreamTee, 0) \
+ macro(locked, readableStreamLocked, 0) \
+
+#define WEBCORE_BUILTIN_READABLESTREAM_INITIALIZEREADABLESTREAM 1
+#define WEBCORE_BUILTIN_READABLESTREAM_CANCEL 1
+#define WEBCORE_BUILTIN_READABLESTREAM_GETREADER 1
+#define WEBCORE_BUILTIN_READABLESTREAM_PIPETHROUGH 1
+#define WEBCORE_BUILTIN_READABLESTREAM_PIPETO 1
+#define WEBCORE_BUILTIN_READABLESTREAM_TEE 1
+#define WEBCORE_BUILTIN_READABLESTREAM_LOCKED 1
+
+#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(macro) \
+ macro(readableStreamInitializeReadableStreamCode, initializeReadableStream, ASCIILiteral(), s_readableStreamInitializeReadableStreamCodeLength) \
+ macro(readableStreamCancelCode, cancel, ASCIILiteral(), s_readableStreamCancelCodeLength) \
+ macro(readableStreamGetReaderCode, getReader, ASCIILiteral(), s_readableStreamGetReaderCodeLength) \
+ macro(readableStreamPipeThroughCode, pipeThrough, ASCIILiteral(), s_readableStreamPipeThroughCodeLength) \
+ macro(readableStreamPipeToCode, pipeTo, ASCIILiteral(), s_readableStreamPipeToCodeLength) \
+ macro(readableStreamTeeCode, tee, ASCIILiteral(), s_readableStreamTeeCodeLength) \
+ macro(readableStreamLockedCode, locked, "get locked"_s, s_readableStreamLockedCodeLength) \
+
+#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_FUNCTION_NAME(macro) \
+ macro(cancel) \
+ macro(getReader) \
+ macro(initializeReadableStream) \
+ macro(locked) \
+ macro(pipeThrough) \
+ macro(pipeTo) \
+ macro(tee) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class ReadableStreamBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit ReadableStreamBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_READABLESTREAM_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_READABLESTREAM_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_READABLESTREAM_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_READABLESTREAM_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_READABLESTREAM_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* ReadableStreamBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_READABLESTREAM_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void ReadableStreamBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_READABLESTREAM_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableStreamDefaultControllerBuiltins.cpp b/src/javascript/jsc/bindings/ReadableStreamDefaultControllerBuiltins.cpp
new file mode 100644
index 000000000..a7be93e52
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamDefaultControllerBuiltins.cpp
@@ -0,0 +1,147 @@
+/*
+ * 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 "ReadableStreamDefaultControllerBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeLength = 376;
+static const JSC::Intrinsic s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCode =
+ "(function (stream, underlyingSource, size, highWaterMark)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (arguments.length !== 5 && arguments[4] !== @isReadableStream)\n" \
+ " @throwTypeError(\"ReadableStreamDefaultController constructor should not be called directly\");\n" \
+ "\n" \
+ " return @privateInitializeReadableStreamDefaultController.@call(this, stream, underlyingSource, size, highWaterMark);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamDefaultControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamDefaultControllerEnqueueCodeLength = 412;
+static const JSC::Intrinsic s_readableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamDefaultControllerEnqueueCode =
+ "(function (chunk)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamDefaultController(this))\n" \
+ " throw @makeThisTypeError(\"ReadableStreamDefaultController\", \"enqueue\");\n" \
+ "\n" \
+ " if (!@readableStreamDefaultControllerCanCloseOrEnqueue(this))\n" \
+ " @throwTypeError(\"ReadableStreamDefaultController is not in a state where chunk can be enqueued\");\n" \
+ "\n" \
+ " return @readableStreamDefaultControllerEnqueue(this, chunk);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamDefaultControllerErrorCodeLength = 228;
+static const JSC::Intrinsic s_readableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamDefaultControllerErrorCode =
+ "(function (error)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamDefaultController(this))\n" \
+ " throw @makeThisTypeError(\"ReadableStreamDefaultController\", \"error\");\n" \
+ "\n" \
+ " @readableStreamDefaultControllerError(this, error);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamDefaultControllerCloseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamDefaultControllerCloseCodeLength = 384;
+static const JSC::Intrinsic s_readableStreamDefaultControllerCloseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamDefaultControllerCloseCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamDefaultController(this))\n" \
+ " throw @makeThisTypeError(\"ReadableStreamDefaultController\", \"close\");\n" \
+ "\n" \
+ " if (!@readableStreamDefaultControllerCanCloseOrEnqueue(this))\n" \
+ " @throwTypeError(\"ReadableStreamDefaultController is not in a state where it can be closed\");\n" \
+ "\n" \
+ " @readableStreamDefaultControllerClose(this);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamDefaultControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamDefaultControllerDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamDefaultControllerDesiredSizeCodeLength = 240;
+static const JSC::Intrinsic s_readableStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamDefaultControllerDesiredSizeCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamDefaultController(this))\n" \
+ " throw @makeGetterTypeError(\"ReadableStreamDefaultController\", \"desiredSize\");\n" \
+ "\n" \
+ " return @readableStreamDefaultControllerGetDesiredSize(this);\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().readableStreamDefaultControllerBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamDefaultControllerBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableStreamDefaultControllerBuiltins.h b/src/javascript/jsc/bindings/ReadableStreamDefaultControllerBuiltins.h
new file mode 100644
index 000000000..625da2f88
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamDefaultControllerBuiltins.h
@@ -0,0 +1,159 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* ReadableStreamDefaultController */
+extern const char* const s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCode;
+extern const int s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeLength;
+extern const JSC::ConstructAbility s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeConstructorKind;
+extern const char* const s_readableStreamDefaultControllerEnqueueCode;
+extern const int s_readableStreamDefaultControllerEnqueueCodeLength;
+extern const JSC::ConstructAbility s_readableStreamDefaultControllerEnqueueCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamDefaultControllerEnqueueCodeConstructorKind;
+extern const char* const s_readableStreamDefaultControllerErrorCode;
+extern const int s_readableStreamDefaultControllerErrorCodeLength;
+extern const JSC::ConstructAbility s_readableStreamDefaultControllerErrorCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamDefaultControllerErrorCodeConstructorKind;
+extern const char* const s_readableStreamDefaultControllerCloseCode;
+extern const int s_readableStreamDefaultControllerCloseCodeLength;
+extern const JSC::ConstructAbility s_readableStreamDefaultControllerCloseCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamDefaultControllerCloseCodeConstructorKind;
+extern const char* const s_readableStreamDefaultControllerDesiredSizeCode;
+extern const int s_readableStreamDefaultControllerDesiredSizeCodeLength;
+extern const JSC::ConstructAbility s_readableStreamDefaultControllerDesiredSizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamDefaultControllerDesiredSizeCodeConstructorKind;
+
+#define WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_DATA(macro) \
+ macro(initializeReadableStreamDefaultController, readableStreamDefaultControllerInitializeReadableStreamDefaultController, 4) \
+ macro(enqueue, readableStreamDefaultControllerEnqueue, 1) \
+ macro(error, readableStreamDefaultControllerError, 1) \
+ macro(close, readableStreamDefaultControllerClose, 0) \
+ macro(desiredSize, readableStreamDefaultControllerDesiredSize, 0) \
+
+#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_INITIALIZEREADABLESTREAMDEFAULTCONTROLLER 1
+#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_ENQUEUE 1
+#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_ERROR 1
+#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_CLOSE 1
+#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_DESIREDSIZE 1
+
+#define WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(macro) \
+ macro(readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCode, initializeReadableStreamDefaultController, ASCIILiteral(), s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeLength) \
+ macro(readableStreamDefaultControllerEnqueueCode, enqueue, ASCIILiteral(), s_readableStreamDefaultControllerEnqueueCodeLength) \
+ macro(readableStreamDefaultControllerErrorCode, error, ASCIILiteral(), s_readableStreamDefaultControllerErrorCodeLength) \
+ macro(readableStreamDefaultControllerCloseCode, close, ASCIILiteral(), s_readableStreamDefaultControllerCloseCodeLength) \
+ macro(readableStreamDefaultControllerDesiredSizeCode, desiredSize, "get desiredSize"_s, s_readableStreamDefaultControllerDesiredSizeCodeLength) \
+
+#define WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(macro) \
+ macro(close) \
+ macro(desiredSize) \
+ macro(enqueue) \
+ macro(error) \
+ macro(initializeReadableStreamDefaultController) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class ReadableStreamDefaultControllerBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit ReadableStreamDefaultControllerBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_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_READABLESTREAMDEFAULTCONTROLLER_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_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* ReadableStreamDefaultControllerBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void ReadableStreamDefaultControllerBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_READABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableStreamDefaultReaderBuiltins.cpp b/src/javascript/jsc/bindings/ReadableStreamDefaultReaderBuiltins.cpp
new file mode 100644
index 000000000..817f396b7
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamDefaultReaderBuiltins.cpp
@@ -0,0 +1,157 @@
+/*
+ * 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 "ReadableStreamDefaultReaderBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeLength = 382;
+static const JSC::Intrinsic s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStream(stream))\n" \
+ " @throwTypeError(\"ReadableStreamDefaultReader needs a ReadableStream\");\n" \
+ " if (@isReadableStreamLocked(stream))\n" \
+ " @throwTypeError(\"ReadableStream is locked\");\n" \
+ "\n" \
+ " @readableStreamReaderGenericInitialize(this, stream);\n" \
+ " @putByIdDirectPrivate(this, \"readRequests\", []);\n" \
+ "\n" \
+ " return this;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamDefaultReaderCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamDefaultReaderCancelCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamDefaultReaderCancelCodeLength = 416;
+static const JSC::Intrinsic s_readableStreamDefaultReaderCancelCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamDefaultReaderCancelCode =
+ "(function (reason)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamDefaultReader(this))\n" \
+ " return @Promise.@reject(@makeThisTypeError(\"ReadableStreamDefaultReader\", \"cancel\"));\n" \
+ "\n" \
+ " if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
+ " return @Promise.@reject(@makeTypeError(\"cancel() called on a reader owned by no readable stream\"));\n" \
+ "\n" \
+ " return @readableStreamReaderGenericCancel(this, reason);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamDefaultReaderReadCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamDefaultReaderReadCodeLength = 395;
+static const JSC::Intrinsic s_readableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamDefaultReaderReadCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamDefaultReader(this))\n" \
+ " return @Promise.@reject(@makeThisTypeError(\"ReadableStreamDefaultReader\", \"read\"));\n" \
+ " if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
+ " return @Promise.@reject(@makeTypeError(\"read() called on a reader owned by no readable stream\"));\n" \
+ "\n" \
+ " return @readableStreamDefaultReaderRead(this);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamDefaultReaderReleaseLockCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamDefaultReaderReleaseLockCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamDefaultReaderReleaseLockCodeLength = 442;
+static const JSC::Intrinsic s_readableStreamDefaultReaderReleaseLockCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamDefaultReaderReleaseLockCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamDefaultReader(this))\n" \
+ " throw @makeThisTypeError(\"ReadableStreamDefaultReader\", \"releaseLock\");\n" \
+ "\n" \
+ " if (!@getByIdDirectPrivate(this, \"ownerReadableStream\"))\n" \
+ " return;\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(this, \"readRequests\").length)\n" \
+ " @throwTypeError(\"There are still pending read requests, cannot release the lock\");\n" \
+ "\n" \
+ " @readableStreamReaderGenericRelease(this);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamDefaultReaderClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamDefaultReaderClosedCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamDefaultReaderClosedCodeLength = 257;
+static const JSC::Intrinsic s_readableStreamDefaultReaderClosedCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamDefaultReaderClosedCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamDefaultReader(this))\n" \
+ " return @Promise.@reject(@makeGetterTypeError(\"ReadableStreamDefaultReader\", \"closed\"));\n" \
+ "\n" \
+ " return @getByIdDirectPrivate(this, \"closedPromiseCapability\").@promise;\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().readableStreamDefaultReaderBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamDefaultReaderBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableStreamDefaultReaderBuiltins.h b/src/javascript/jsc/bindings/ReadableStreamDefaultReaderBuiltins.h
new file mode 100644
index 000000000..e728e4061
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamDefaultReaderBuiltins.h
@@ -0,0 +1,159 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* ReadableStreamDefaultReader */
+extern const char* const s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCode;
+extern const int s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeLength;
+extern const JSC::ConstructAbility s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructorKind;
+extern const char* const s_readableStreamDefaultReaderCancelCode;
+extern const int s_readableStreamDefaultReaderCancelCodeLength;
+extern const JSC::ConstructAbility s_readableStreamDefaultReaderCancelCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamDefaultReaderCancelCodeConstructorKind;
+extern const char* const s_readableStreamDefaultReaderReadCode;
+extern const int s_readableStreamDefaultReaderReadCodeLength;
+extern const JSC::ConstructAbility s_readableStreamDefaultReaderReadCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamDefaultReaderReadCodeConstructorKind;
+extern const char* const s_readableStreamDefaultReaderReleaseLockCode;
+extern const int s_readableStreamDefaultReaderReleaseLockCodeLength;
+extern const JSC::ConstructAbility s_readableStreamDefaultReaderReleaseLockCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamDefaultReaderReleaseLockCodeConstructorKind;
+extern const char* const s_readableStreamDefaultReaderClosedCode;
+extern const int s_readableStreamDefaultReaderClosedCodeLength;
+extern const JSC::ConstructAbility s_readableStreamDefaultReaderClosedCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamDefaultReaderClosedCodeConstructorKind;
+
+#define WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_DATA(macro) \
+ macro(initializeReadableStreamDefaultReader, readableStreamDefaultReaderInitializeReadableStreamDefaultReader, 1) \
+ macro(cancel, readableStreamDefaultReaderCancel, 1) \
+ macro(read, readableStreamDefaultReaderRead, 0) \
+ macro(releaseLock, readableStreamDefaultReaderReleaseLock, 0) \
+ macro(closed, readableStreamDefaultReaderClosed, 0) \
+
+#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_INITIALIZEREADABLESTREAMDEFAULTREADER 1
+#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_CANCEL 1
+#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_READ 1
+#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_RELEASELOCK 1
+#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_CLOSED 1
+
+#define WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(macro) \
+ macro(readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCode, initializeReadableStreamDefaultReader, ASCIILiteral(), s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeLength) \
+ macro(readableStreamDefaultReaderCancelCode, cancel, ASCIILiteral(), s_readableStreamDefaultReaderCancelCodeLength) \
+ macro(readableStreamDefaultReaderReadCode, read, ASCIILiteral(), s_readableStreamDefaultReaderReadCodeLength) \
+ macro(readableStreamDefaultReaderReleaseLockCode, releaseLock, ASCIILiteral(), s_readableStreamDefaultReaderReleaseLockCodeLength) \
+ macro(readableStreamDefaultReaderClosedCode, closed, "get closed"_s, s_readableStreamDefaultReaderClosedCodeLength) \
+
+#define WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_FUNCTION_NAME(macro) \
+ macro(cancel) \
+ macro(closed) \
+ macro(initializeReadableStreamDefaultReader) \
+ macro(read) \
+ macro(releaseLock) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class ReadableStreamDefaultReaderBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit ReadableStreamDefaultReaderBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_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_READABLESTREAMDEFAULTREADER_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_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* ReadableStreamDefaultReaderBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_READABLESTREAMDEFAULTREADER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void ReadableStreamDefaultReaderBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_READABLESTREAMDEFAULTREADER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.cpp b/src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.cpp
new file mode 100644
index 000000000..761764b05
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.cpp
@@ -0,0 +1,1089 @@
+/*
+ * 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 "ReadableStreamInternalsBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeLength = 756;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamReaderGenericInitializeCode =
+ "(function (reader, stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @putByIdDirectPrivate(reader, \"ownerReadableStream\", stream);\n" \
+ " @putByIdDirectPrivate(stream, \"reader\", reader);\n" \
+ " if (@getByIdDirectPrivate(stream, \"state\") === @streamReadable)\n" \
+ " @putByIdDirectPrivate(reader, \"closedPromiseCapability\", @newPromiseCapability(@Promise));\n" \
+ " else if (@getByIdDirectPrivate(stream, \"state\") === @streamClosed)\n" \
+ " @putByIdDirectPrivate(reader, \"closedPromiseCapability\", { @promise: @Promise.@resolve() });\n" \
+ " else {\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") === @streamErrored);\n" \
+ " @putByIdDirectPrivate(reader, \"closedPromiseCapability\", { @promise: @newHandledRejectedPromise(@getByIdDirectPrivate(stream, \"storedError\")) });\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeLength = 908;
+static const JSC::Intrinsic s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCode =
+ "(function (stream, underlyingSource, size, highWaterMark)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ " \n" \
+ " if (!@isReadableStream(stream))\n" \
+ " @throwTypeError(\"ReadableStreamDefaultController needs a ReadableStream\");\n" \
+ "\n" \
+ " //\n" \
+ " if (@getByIdDirectPrivate(stream, \"readableStreamController\") !== null)\n" \
+ " @throwTypeError(\"ReadableStream already has a controller\");\n" \
+ "\n" \
+ " \n" \
+ "\n" \
+ " @putByIdDirectPrivate(this, \"controlledReadableStream\", stream);\n" \
+ " @putByIdDirectPrivate(this, \"underlyingSource\", underlyingSource);\n" \
+ " @putByIdDirectPrivate(this, \"queue\", @newQueue());\n" \
+ " @putByIdDirectPrivate(this, \"started\", false);\n" \
+ " @putByIdDirectPrivate(this, \"closeRequested\", false);\n" \
+ " @putByIdDirectPrivate(this, \"pullAgain\", false);\n" \
+ " @putByIdDirectPrivate(this, \"pulling\", false);\n" \
+ " @putByIdDirectPrivate(this, \"strategy\", @validateAndNormalizeQueuingStrategy(size, highWaterMark));\n" \
+ " \n" \
+ "\n" \
+ "\n" \
+ " return this;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeLength = 1378;
+static const JSC::Intrinsic s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode =
+ "(function (stream, underlyingSource, size, highWaterMark, startMethod, pullMethod, cancelMethod)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ " \n" \
+ " const controller = new @ReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark, @isReadableStream);\n" \
+ " const startAlgorithm = () => @promiseInvokeOrNoopMethodNoCatch(underlyingSource, startMethod, [controller]);\n" \
+ " const pullAlgorithm = () => @promiseInvokeOrNoopMethod(underlyingSource, pullMethod, [controller]);\n" \
+ " const cancelAlgorithm = (reason) => @promiseInvokeOrNoopMethod(underlyingSource, cancelMethod, [reason]);\n" \
+ " \n" \
+ " @putByIdDirectPrivate(controller, \"pullAlgorithm\", pullAlgorithm);\n" \
+ " @putByIdDirectPrivate(controller, \"cancelAlgorithm\", cancelAlgorithm);\n" \
+ " @putByIdDirectPrivate(controller, \"pull\", @readableStreamDefaultControllerPull);\n" \
+ " @putByIdDirectPrivate(controller, \"cancel\", @readableStreamDefaultControllerCancel);\n" \
+ " @putByIdDirectPrivate(stream, \"readableStreamController\", controller);\n" \
+ "\n" \
+ " startAlgorithm().@then(() => {\n" \
+ " @putByIdDirectPrivate(controller, \"started\", true);\n" \
+ " @assert(!@getByIdDirectPrivate(controller, \"pulling\"));\n" \
+ " @assert(!@getByIdDirectPrivate(controller, \"pullAgain\"));\n" \
+ " @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \
+ " \n" \
+ " }, (error) => {\n" \
+ " @readableStreamDefaultControllerError(controller, error);\n" \
+ " });\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeLength = 322;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamDefaultControllerErrorCode =
+ "(function (controller, error)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
+ " if (@getByIdDirectPrivate(stream, \"state\") !== @streamReadable)\n" \
+ " return;\n" \
+ " @putByIdDirectPrivate(controller, \"queue\", @newQueue());\n" \
+ " @readableStreamError(stream, error);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamPipeToCodeLength = 778;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamPipeToCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamPipeToCode =
+ "(function (stream, sink)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ " @assert(@isReadableStream(stream));\n" \
+ "\n" \
+ " const reader = new @ReadableStreamDefaultReader(stream);\n" \
+ "\n" \
+ " @getByIdDirectPrivate(reader, \"closedPromiseCapability\").@promise.@then(() => { }, (e) => { sink.error(e); });\n" \
+ "\n" \
+ " function doPipe() {\n" \
+ " @readableStreamDefaultReaderRead(reader).@then(function(result) {\n" \
+ " if (result.done) {\n" \
+ " sink.close();\n" \
+ " return;\n" \
+ " }\n" \
+ " try {\n" \
+ " sink.enqueue(result.value);\n" \
+ " } catch (e) {\n" \
+ " sink.error(\"ReadableStream chunk enqueueing in the sink failed\");\n" \
+ " return;\n" \
+ " }\n" \
+ " doPipe();\n" \
+ " }, function(e) {\n" \
+ " sink.error(e);\n" \
+ " });\n" \
+ " }\n" \
+ " doPipe();\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeLength = 77;
+static const JSC::Intrinsic s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsAcquireReadableStreamDefaultReaderCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " return new @ReadableStreamDefaultReader(stream);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeLength = 3210;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode =
+ "(function (source, destination, preventClose, preventAbort, preventCancel, signal)\n" \
+ "{\n" \
+ " @assert(@isReadableStream(source));\n" \
+ " @assert(@isWritableStream(destination));\n" \
+ " @assert(!@isReadableStreamLocked(source));\n" \
+ " @assert(!@isWritableStreamLocked(destination));\n" \
+ " @assert(signal === @undefined || @isAbortSignal(signal));\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(source, \"underlyingByteSource\") !== @undefined)\n" \
+ " return @Promise.@reject(\"Piping of readable by strean is not supported\");\n" \
+ "\n" \
+ " let pipeState = { source : source, destination : destination, preventAbort : preventAbort, preventCancel : preventCancel, preventClose : preventClose, signal : signal };\n" \
+ "\n" \
+ " pipeState.reader = @acquireReadableStreamDefaultReader(source);\n" \
+ " pipeState.writer = @acquireWritableStreamDefaultWriter(destination);\n" \
+ "\n" \
+ " @putByIdDirectPrivate(source, \"disturbed\", true);\n" \
+ "\n" \
+ " pipeState.finalized = false;\n" \
+ " pipeState.shuttingDown = false;\n" \
+ " pipeState.promiseCapability = @newPromiseCapability(@Promise);\n" \
+ " pipeState.pendingReadPromiseCapability = @newPromiseCapability(@Promise);\n" \
+ " pipeState.pendingReadPromiseCapability.@resolve.@call();\n" \
+ " pipeState.pendingWritePromise = @Promise.@resolve();\n" \
+ "\n" \
+ " if (signal !== @undefined) {\n" \
+ " const algorithm = () => {\n" \
+ " if (pipeState.finalized)\n" \
+ " return;\n" \
+ "\n" \
+ " const error = @makeDOMException(\"AbortError\", \"abort pipeTo from signal\");\n" \
+ "\n" \
+ " @pipeToShutdownWithAction(pipeState, () => {\n" \
+ " const shouldAbortDestination = !pipeState.preventAbort && @getByIdDirectPrivate(pipeState.destination, \"state\") === \"writable\";\n" \
+ " const promiseDestination = shouldAbortDestination ? @writableStreamAbort(pipeState.destination, error) : @Promise.@resolve();\n" \
+ "\n" \
+ " const shouldAbortSource = !pipeState.preventCancel && @getByIdDirectPrivate(pipeState.source, \"state\") === @streamReadable;\n" \
+ " const promiseSource = shouldAbortSource ? @readableStreamCancel(pipeState.source, error) : @Promise.@resolve();\n" \
+ "\n" \
+ " let promiseCapability = @newPromiseCapability(@Promise);\n" \
+ " let shouldWait = true;\n" \
+ " let handleResolvedPromise = () => {\n" \
+ " if (shouldWait) {\n" \
+ " shouldWait = false;\n" \
+ " return;\n" \
+ " }\n" \
+ " promiseCapability.@resolve.@call();\n" \
+ " }\n" \
+ " let handleRejectedPromise = (e) => {\n" \
+ " promiseCapability.@reject.@call(@undefined, e);\n" \
+ " }\n" \
+ " promiseDestination.@then(handleResolvedPromise, handleRejectedPromise);\n" \
+ " promiseSource.@then(handleResolvedPromise, handleRejectedPromise);\n" \
+ " return promiseCapability.@promise;\n" \
+ " }, error);\n" \
+ " };\n" \
+ " if (@whenSignalAborted(signal, algorithm))\n" \
+ " return pipeState.promiseCapability.@promise;\n" \
+ " }\n" \
+ "\n" \
+ " @pipeToErrorsMustBePropagatedForward(pipeState);\n" \
+ " @pipeToErrorsMustBePropagatedBackward(pipeState);\n" \
+ " @pipeToClosingMustBePropagatedForward(pipeState);\n" \
+ " @pipeToClosingMustBePropagatedBackward(pipeState);\n" \
+ "\n" \
+ " @pipeToLoop(pipeState);\n" \
+ "\n" \
+ " return pipeState.promiseCapability.@promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsPipeToLoopCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsPipeToLoopCodeLength = 194;
+static const JSC::Intrinsic s_readableStreamInternalsPipeToLoopCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsPipeToLoopCode =
+ "(function (pipeState)\n" \
+ "{\n" \
+ " if (pipeState.shuttingDown)\n" \
+ " return;\n" \
+ "\n" \
+ " @pipeToDoReadWrite(pipeState).@then((result) => {\n" \
+ " if (result)\n" \
+ " @pipeToLoop(pipeState);\n" \
+ " });\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsPipeToDoReadWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsPipeToDoReadWriteCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsPipeToDoReadWriteCodeLength = 1108;
+static const JSC::Intrinsic s_readableStreamInternalsPipeToDoReadWriteCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsPipeToDoReadWriteCode =
+ "(function (pipeState)\n" \
+ "{\n" \
+ " @assert(!pipeState.shuttingDown);\n" \
+ "\n" \
+ " pipeState.pendingReadPromiseCapability = @newPromiseCapability(@Promise);\n" \
+ " @getByIdDirectPrivate(pipeState.writer, \"readyPromise\").@promise.@then(() => {\n" \
+ " if (pipeState.shuttingDown) {\n" \
+ " pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " @readableStreamDefaultReaderRead(pipeState.reader).@then((result) => {\n" \
+ " const canWrite = !result.done && @getByIdDirectPrivate(pipeState.writer, \"stream\") !== @undefined;\n" \
+ " pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, canWrite);\n" \
+ " if (!canWrite)\n" \
+ " return;\n" \
+ "\n" \
+ " pipeState.pendingWritePromise = @writableStreamDefaultWriterWrite(pipeState.writer, result.value);\n" \
+ " }, (e) => {\n" \
+ " pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);\n" \
+ " });\n" \
+ " }, (e) => {\n" \
+ " pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);\n" \
+ " });\n" \
+ " return pipeState.pendingReadPromiseCapability.@promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeLength = 676;
+static const JSC::Intrinsic s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode =
+ "(function (pipeState)\n" \
+ "{\n" \
+ " const action = () => {\n" \
+ " pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);\n" \
+ " const error = @getByIdDirectPrivate(pipeState.source, \"storedError\");\n" \
+ " if (!pipeState.preventAbort) {\n" \
+ " @pipeToShutdownWithAction(pipeState, () => @writableStreamAbort(pipeState.destination, error), error);\n" \
+ " return;\n" \
+ " }\n" \
+ " @pipeToShutdown(pipeState, error);\n" \
+ " };\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(pipeState.source, \"state\") === @streamErrored) {\n" \
+ " action();\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " @getByIdDirectPrivate(pipeState.reader, \"closedPromiseCapability\").@promise.@then(@undefined, action);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeLength = 584;
+static const JSC::Intrinsic s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode =
+ "(function (pipeState)\n" \
+ "{\n" \
+ " const action = () => {\n" \
+ " const error = @getByIdDirectPrivate(pipeState.destination, \"storedError\");\n" \
+ " if (!pipeState.preventCancel) {\n" \
+ " @pipeToShutdownWithAction(pipeState, () => @readableStreamCancel(pipeState.source, error), error);\n" \
+ " return;\n" \
+ " }\n" \
+ " @pipeToShutdown(pipeState, error);\n" \
+ " };\n" \
+ " if (@getByIdDirectPrivate(pipeState.destination, \"state\") === \"errored\") {\n" \
+ " action();\n" \
+ " return;\n" \
+ " }\n" \
+ " @getByIdDirectPrivate(pipeState.writer, \"closedPromise\").@promise.@then(@undefined, action);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeLength = 680;
+static const JSC::Intrinsic s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCode =
+ "(function (pipeState)\n" \
+ "{\n" \
+ " const action = () => {\n" \
+ " pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);\n" \
+ " const error = @getByIdDirectPrivate(pipeState.source, \"storedError\");\n" \
+ " if (!pipeState.preventClose) {\n" \
+ " @pipeToShutdownWithAction(pipeState, () => @writableStreamDefaultWriterCloseWithErrorPropagation(pipeState.writer));\n" \
+ " return;\n" \
+ " }\n" \
+ " @pipeToShutdown(pipeState);\n" \
+ " };\n" \
+ " if (@getByIdDirectPrivate(pipeState.source, \"state\") === @streamClosed) {\n" \
+ " action();\n" \
+ " return;\n" \
+ " }\n" \
+ " @getByIdDirectPrivate(pipeState.reader, \"closedPromiseCapability\").@promise.@then(action, @undefined);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeLength = 464;
+static const JSC::Intrinsic s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCode =
+ "(function (pipeState)\n" \
+ "{\n" \
+ " if (!@writableStreamCloseQueuedOrInFlight(pipeState.destination) && @getByIdDirectPrivate(pipeState.destination, \"state\") !== \"closed\")\n" \
+ " return;\n" \
+ "\n" \
+ " //\n" \
+ "\n" \
+ " const error = @makeTypeError(\"closing is propagated backward\");\n" \
+ " if (!pipeState.preventCancel) {\n" \
+ " @pipeToShutdownWithAction(pipeState, () => @readableStreamCancel(pipeState.source, error), error);\n" \
+ " return;\n" \
+ " }\n" \
+ " @pipeToShutdown(pipeState, error);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownWithActionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownWithActionCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsPipeToShutdownWithActionCodeLength = 882;
+static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownWithActionCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsPipeToShutdownWithActionCode =
+ "(function (pipeState, action)\n" \
+ "{\n" \
+ " if (pipeState.shuttingDown)\n" \
+ " return;\n" \
+ "\n" \
+ " pipeState.shuttingDown = true;\n" \
+ "\n" \
+ " const hasError = arguments.length > 2;\n" \
+ " const error = arguments[2];\n" \
+ " const finalize = () => {\n" \
+ " const promise = action();\n" \
+ " promise.@then(() => {\n" \
+ " if (hasError)\n" \
+ " @pipeToFinalize(pipeState, error);\n" \
+ " else\n" \
+ " @pipeToFinalize(pipeState);\n" \
+ " }, (e) => {\n" \
+ " @pipeToFinalize(pipeState, e);\n" \
+ " });\n" \
+ " };\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(pipeState.destination, \"state\") === \"writable\" && !@writableStreamCloseQueuedOrInFlight(pipeState.destination)) {\n" \
+ " pipeState.pendingReadPromiseCapability.@promise.@then(() => {\n" \
+ " pipeState.pendingWritePromise.@then(finalize, finalize);\n" \
+ " }, (e) => @pipeToFinalize(pipeState, e));\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " finalize();\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsPipeToShutdownCodeLength = 717;
+static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsPipeToShutdownCode =
+ "(function (pipeState)\n" \
+ "{\n" \
+ " if (pipeState.shuttingDown)\n" \
+ " return;\n" \
+ "\n" \
+ " pipeState.shuttingDown = true;\n" \
+ "\n" \
+ " const hasError = arguments.length > 1;\n" \
+ " const error = arguments[1];\n" \
+ " const finalize = () => {\n" \
+ " if (hasError)\n" \
+ " @pipeToFinalize(pipeState, error);\n" \
+ " else\n" \
+ " @pipeToFinalize(pipeState);\n" \
+ " };\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(pipeState.destination, \"state\") === \"writable\" && !@writableStreamCloseQueuedOrInFlight(pipeState.destination)) {\n" \
+ " pipeState.pendingReadPromiseCapability.@promise.@then(() => {\n" \
+ " pipeState.pendingWritePromise.@then(finalize, finalize);\n" \
+ " }, (e) => @pipeToFinalize(pipeState, e));\n" \
+ " return;\n" \
+ " }\n" \
+ " finalize();\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsPipeToFinalizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsPipeToFinalizeCodeLength = 356;
+static const JSC::Intrinsic s_readableStreamInternalsPipeToFinalizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsPipeToFinalizeCode =
+ "(function (pipeState)\n" \
+ "{\n" \
+ " @writableStreamDefaultWriterRelease(pipeState.writer);\n" \
+ " @readableStreamReaderGenericRelease(pipeState.reader);\n" \
+ "\n" \
+ " //\n" \
+ " pipeState.finalized = true;\n" \
+ "\n" \
+ " if (arguments.length > 1)\n" \
+ " pipeState.promiseCapability.@reject.@call(@undefined, arguments[1]);\n" \
+ " else\n" \
+ " pipeState.promiseCapability.@resolve.@call();\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamTeeCodeLength = 1671;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamTeeCode =
+ "(function (stream, shouldClone)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@isReadableStream(stream));\n" \
+ " @assert(typeof(shouldClone) === \"boolean\");\n" \
+ "\n" \
+ " const reader = new @ReadableStreamDefaultReader(stream);\n" \
+ "\n" \
+ " const teeState = {\n" \
+ " closedOrErrored: false,\n" \
+ " canceled1: false,\n" \
+ " canceled2: false,\n" \
+ " reason1: @undefined,\n" \
+ " reason2: @undefined,\n" \
+ " };\n" \
+ "\n" \
+ " teeState.cancelPromiseCapability = @newPromiseCapability(@Promise);\n" \
+ "\n" \
+ " const pullFunction = @readableStreamTeePullFunction(teeState, reader, shouldClone);\n" \
+ "\n" \
+ " const branch1Source = { };\n" \
+ " @putByIdDirectPrivate(branch1Source, \"pull\", pullFunction);\n" \
+ " @putByIdDirectPrivate(branch1Source, \"cancel\", @readableStreamTeeBranch1CancelFunction(teeState, stream));\n" \
+ "\n" \
+ " const branch2Source = { };\n" \
+ " @putByIdDirectPrivate(branch2Source, \"pull\", pullFunction);\n" \
+ " @putByIdDirectPrivate(branch2Source, \"cancel\", @readableStreamTeeBranch2CancelFunction(teeState, stream));\n" \
+ "\n" \
+ " const branch1 = new @ReadableStream(branch1Source);\n" \
+ " const branch2 = new @ReadableStream(branch2Source);\n" \
+ "\n" \
+ " @getByIdDirectPrivate(reader, \"closedPromiseCapability\").@promise.@then(@undefined, function(e) {\n" \
+ " if (teeState.closedOrErrored)\n" \
+ " return;\n" \
+ " @readableStreamDefaultControllerError(branch1.@readableStreamController, e);\n" \
+ " @readableStreamDefaultControllerError(branch2.@readableStreamController, e);\n" \
+ " teeState.closedOrErrored = true;\n" \
+ " if (!teeState.canceled1 || !teeState.canceled2)\n" \
+ " teeState.cancelPromiseCapability.@resolve.@call();\n" \
+ " });\n" \
+ "\n" \
+ " //\n" \
+ " teeState.branch1 = branch1;\n" \
+ " teeState.branch2 = branch2;\n" \
+ "\n" \
+ " return [branch1, branch2];\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamTeePullFunctionCodeLength = 1275;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeePullFunctionCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamTeePullFunctionCode =
+ "(function (teeState, reader, shouldClone)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return function() {\n" \
+ " @Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(reader), function(result) {\n" \
+ " @assert(@isObject(result));\n" \
+ " @assert(typeof result.done === \"boolean\");\n" \
+ " if (result.done && !teeState.closedOrErrored) {\n" \
+ " if (!teeState.canceled1)\n" \
+ " @readableStreamDefaultControllerClose(teeState.branch1.@readableStreamController);\n" \
+ " if (!teeState.canceled2)\n" \
+ " @readableStreamDefaultControllerClose(teeState.branch2.@readableStreamController);\n" \
+ " teeState.closedOrErrored = true;\n" \
+ " if (!teeState.canceled1 || !teeState.canceled2)\n" \
+ " teeState.cancelPromiseCapability.@resolve.@call();\n" \
+ " }\n" \
+ " if (teeState.closedOrErrored)\n" \
+ " return;\n" \
+ " if (!teeState.canceled1)\n" \
+ " @readableStreamDefaultControllerEnqueue(teeState.branch1.@readableStreamController, result.value);\n" \
+ " if (!teeState.canceled2)\n" \
+ " @readableStreamDefaultControllerEnqueue(teeState.branch2.@readableStreamController, shouldClone ? @structuredCloneForStream(result.value) : result.value);\n" \
+ " });\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeLength = 456;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode =
+ "(function (teeState, stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return function(r) {\n" \
+ " teeState.canceled1 = true;\n" \
+ " teeState.reason1 = r;\n" \
+ " if (teeState.canceled2) {\n" \
+ " @readableStreamCancel(stream, [teeState.reason1, teeState.reason2]).@then(\n" \
+ " teeState.cancelPromiseCapability.@resolve,\n" \
+ " teeState.cancelPromiseCapability.@reject);\n" \
+ " }\n" \
+ " return teeState.cancelPromiseCapability.@promise;\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeLength = 456;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCode =
+ "(function (teeState, stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return function(r) {\n" \
+ " teeState.canceled2 = true;\n" \
+ " teeState.reason2 = r;\n" \
+ " if (teeState.canceled1) {\n" \
+ " @readableStreamCancel(stream, [teeState.reason1, teeState.reason2]).@then(\n" \
+ " teeState.cancelPromiseCapability.@resolve,\n" \
+ " teeState.cancelPromiseCapability.@reject);\n" \
+ " }\n" \
+ " return teeState.cancelPromiseCapability.@promise;\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsIsReadableStreamCodeLength = 170;
+static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsIsReadableStreamCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " return @isObject(stream) && @getByIdDirectPrivate(stream, \"readableStreamController\") !== @undefined;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsIsReadableStreamDefaultReaderCodeLength = 145;
+static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamDefaultReaderCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsIsReadableStreamDefaultReaderCode =
+ "(function (reader)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " return @isObject(reader) && !!@getByIdDirectPrivate(reader, \"readRequests\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsIsReadableStreamDefaultControllerCodeLength = 168;
+static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsIsReadableStreamDefaultControllerCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " return @isObject(controller) && !!@getByIdDirectPrivate(controller, \"underlyingSource\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamErrorCodeLength = 1283;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamErrorCode =
+ "(function (stream, error)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@isReadableStream(stream));\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") === @streamReadable);\n" \
+ " @putByIdDirectPrivate(stream, \"state\", @streamErrored);\n" \
+ " @putByIdDirectPrivate(stream, \"storedError\", error);\n" \
+ "\n" \
+ " if (!@getByIdDirectPrivate(stream, \"reader\"))\n" \
+ " return;\n" \
+ "\n" \
+ " const reader = @getByIdDirectPrivate(stream, \"reader\");\n" \
+ "\n" \
+ " if (@isReadableStreamDefaultReader(reader)) {\n" \
+ " const requests = @getByIdDirectPrivate(reader, \"readRequests\");\n" \
+ " @putByIdDirectPrivate(reader, \"readRequests\", []);\n" \
+ " for (let index = 0, length = requests.length; index < length; ++index)\n" \
+ " @rejectPromise(requests[index], error);\n" \
+ " } else {\n" \
+ " @assert(@isReadableStreamBYOBReader(reader));\n" \
+ " const requests = @getByIdDirectPrivate(reader, \"readIntoRequests\");\n" \
+ " @putByIdDirectPrivate(reader, \"readIntoRequests\", []);\n" \
+ " for (let index = 0, length = requests.length; index < length; ++index)\n" \
+ " @rejectPromise(requests[index], error);\n" \
+ " }\n" \
+ "\n" \
+ " @getByIdDirectPrivate(reader, \"closedPromiseCapability\").@reject.@call(@undefined, error);\n" \
+ " const promise = @getByIdDirectPrivate(reader, \"closedPromiseCapability\").@promise;\n" \
+ " @markPromiseAsHandled(promise);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeLength = 652;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
+ "\n" \
+ " if (!@readableStreamDefaultControllerCanCloseOrEnqueue(controller))\n" \
+ " return false;\n" \
+ " if (!@getByIdDirectPrivate(controller, \"started\"))\n" \
+ " return false;\n" \
+ " if ((!@isReadableStreamLocked(stream) || !@getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\").length) && @readableStreamDefaultControllerGetDesiredSize(controller) <= 0)\n" \
+ " return false;\n" \
+ " const desiredSize = @readableStreamDefaultControllerGetDesiredSize(controller);\n" \
+ " @assert(desiredSize !== null);\n" \
+ " return desiredSize > 0;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeLength = 1239;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " //\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
+ "\n" \
+ " if (!@readableStreamDefaultControllerCanCloseOrEnqueue(controller))\n" \
+ " return;\n" \
+ " if (!@getByIdDirectPrivate(controller, \"started\"))\n" \
+ " return;\n" \
+ " if ((!@isReadableStreamLocked(stream) || !@getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\").length) && @readableStreamDefaultControllerGetDesiredSize(controller) <= 0)\n" \
+ " return;\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(controller, \"pulling\")) {\n" \
+ " @putByIdDirectPrivate(controller, \"pullAgain\", true);\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " @assert(!@getByIdDirectPrivate(controller, \"pullAgain\"));\n" \
+ " @putByIdDirectPrivate(controller, \"pulling\", true);\n" \
+ "\n" \
+ " @getByIdDirectPrivate(controller, \"pullAlgorithm\").@call(@undefined).@then(function() {\n" \
+ " @putByIdDirectPrivate(controller, \"pulling\", false);\n" \
+ " if (@getByIdDirectPrivate(controller, \"pullAgain\")) {\n" \
+ " @putByIdDirectPrivate(controller, \"pullAgain\", false);\n" \
+ " @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \
+ " }\n" \
+ " }, function(error) {\n" \
+ " @readableStreamDefaultControllerError(controller, error);\n" \
+ " });\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamLockedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamLockedCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsIsReadableStreamLockedCodeLength = 136;
+static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamLockedCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsIsReadableStreamLockedCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@isReadableStream(stream));\n" \
+ " return !!@getByIdDirectPrivate(stream, \"reader\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength = 416;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ "\n" \
+ " if (state === @streamErrored)\n" \
+ " return null;\n" \
+ " if (state === @streamClosed)\n" \
+ " return 0;\n" \
+ "\n" \
+ " return @getByIdDirectPrivate(controller, \"strategy\").highWaterMark - @getByIdDirectPrivate(controller, \"queue\").size;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength = 197;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericCancelCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode =
+ "(function (reader, reason)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(reader, \"ownerReadableStream\");\n" \
+ " @assert(!!stream);\n" \
+ " return @readableStreamCancel(stream, reason);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamCancelCodeLength = 547;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamCancelCode =
+ "(function (stream, reason)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"disturbed\", true);\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " if (state === @streamClosed)\n" \
+ " return @Promise.@resolve();\n" \
+ " if (state === @streamErrored)\n" \
+ " return @Promise.@reject(@getByIdDirectPrivate(stream, \"storedError\"));\n" \
+ " @readableStreamClose(stream);\n" \
+ " return @getByIdDirectPrivate(stream, \"readableStreamController\").@cancel(@getByIdDirectPrivate(stream, \"readableStreamController\"), reason).@then(function() { });\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeLength = 207;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamDefaultControllerCancelCode =
+ "(function (controller, reason)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @putByIdDirectPrivate(controller, \"queue\", @newQueue());\n" \
+ " return @getByIdDirectPrivate(controller, \"cancelAlgorithm\").@call(@undefined, reason);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength = 777;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerPullCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
+ " if (@getByIdDirectPrivate(controller, \"queue\").content.length) {\n" \
+ " const chunk = @dequeueValue(@getByIdDirectPrivate(controller, \"queue\"));\n" \
+ " if (@getByIdDirectPrivate(controller, \"closeRequested\") && @getByIdDirectPrivate(controller, \"queue\").content.length === 0)\n" \
+ " @readableStreamClose(stream);\n" \
+ " else\n" \
+ " @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \
+ "\n" \
+ " return @createFulfilledPromise({ value: chunk, done: false });\n" \
+ " }\n" \
+ " const pendingPromise = @readableStreamAddReadRequest(stream);\n" \
+ " @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \
+ " return pendingPromise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeLength = 352;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamDefaultControllerCloseCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@readableStreamDefaultControllerCanCloseOrEnqueue(controller));\n" \
+ " @putByIdDirectPrivate(controller, \"closeRequested\", true);\n" \
+ " if (@getByIdDirectPrivate(controller, \"queue\").content.length === 0)\n" \
+ " @readableStreamClose(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamCloseCodeLength = 697;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCloseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamCloseCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") === @streamReadable);\n" \
+ " @putByIdDirectPrivate(stream, \"state\", @streamClosed);\n" \
+ " const reader = @getByIdDirectPrivate(stream, \"reader\");\n" \
+ "\n" \
+ " if (!reader)\n" \
+ " return;\n" \
+ "\n" \
+ " if (@isReadableStreamDefaultReader(reader)) {\n" \
+ " const requests = @getByIdDirectPrivate(reader, \"readRequests\");\n" \
+ " @putByIdDirectPrivate(reader, \"readRequests\", []);\n" \
+ " for (let index = 0, length = requests.length; index < length; ++index)\n" \
+ " @fulfillPromise(requests[index], { value: @undefined, done: true });\n" \
+ " }\n" \
+ "\n" \
+ " @getByIdDirectPrivate(reader, \"closedPromiseCapability\").@resolve.@call();\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength = 232;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamFulfillReadRequestCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode =
+ "(function (stream, chunk, done)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ " const readRequest = @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\").@shift();\n" \
+ " @fulfillPromise(readRequest, { value: chunk, done: done });\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength = 979;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode =
+ "(function (controller, chunk)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \
+ " @assert(@readableStreamDefaultControllerCanCloseOrEnqueue(controller));\n" \
+ "\n" \
+ " if (@isReadableStreamLocked(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\").length) {\n" \
+ " @readableStreamFulfillReadRequest(stream, chunk, false);\n" \
+ " @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " try {\n" \
+ " let chunkSize = 1;\n" \
+ " if (@getByIdDirectPrivate(controller, \"strategy\").size !== @undefined)\n" \
+ " chunkSize = @getByIdDirectPrivate(controller, \"strategy\").size(chunk);\n" \
+ " @enqueueValueWithSize(@getByIdDirectPrivate(controller, \"queue\"), chunk, chunkSize);\n" \
+ " }\n" \
+ " catch(error) {\n" \
+ " @readableStreamDefaultControllerError(controller, error);\n" \
+ " throw error;\n" \
+ " }\n" \
+ " @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength = 649;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode =
+ "(function (reader)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(reader, \"ownerReadableStream\");\n" \
+ " @assert(!!stream);\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"disturbed\", true);\n" \
+ " if (state === @streamClosed)\n" \
+ " return @createFulfilledPromise({ value: @undefined, done: true });\n" \
+ " if (state === @streamErrored)\n" \
+ " return @Promise.@reject(@getByIdDirectPrivate(stream, \"storedError\"));\n" \
+ " @assert(state === @streamReadable);\n" \
+ "\n" \
+ " return @getByIdDirectPrivate(stream, \"readableStreamController\").@pull(@getByIdDirectPrivate(stream, \"readableStreamController\"));\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamAddReadRequestCodeLength = 375;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamAddReadRequestCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamAddReadRequestCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@isReadableStreamDefaultReader(@getByIdDirectPrivate(stream, \"reader\")));\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") == @streamReadable);\n" \
+ "\n" \
+ " const readRequest = @newPromise();\n" \
+ " @arrayPush(@getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\"), readRequest);\n" \
+ "\n" \
+ " return readRequest;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDisturbedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDisturbedCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsIsReadableStreamDisturbedCodeLength = 138;
+static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamDisturbedCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsIsReadableStreamDisturbedCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@isReadableStream(stream));\n" \
+ " return @getByIdDirectPrivate(stream, \"disturbed\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeLength = 968;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamReaderGenericReleaseCode =
+ "(function (reader)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(!!@getByIdDirectPrivate(reader, \"ownerReadableStream\"));\n" \
+ " @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(reader, \"ownerReadableStream\"), \"reader\") === reader);\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(@getByIdDirectPrivate(reader, \"ownerReadableStream\"), \"state\") === @streamReadable)\n" \
+ " @getByIdDirectPrivate(reader, \"closedPromiseCapability\").@reject.@call(@undefined, @makeTypeError(\"releasing lock of reader whose stream is still in readable state\"));\n" \
+ " else\n" \
+ " @putByIdDirectPrivate(reader, \"closedPromiseCapability\", { @promise: @newHandledRejectedPromise(@makeTypeError(\"reader released lock\")) });\n" \
+ "\n" \
+ " const promise = @getByIdDirectPrivate(reader, \"closedPromiseCapability\").@promise;\n" \
+ " @markPromiseAsHandled(promise);\n" \
+ " @putByIdDirectPrivate(@getByIdDirectPrivate(reader, \"ownerReadableStream\"), \"reader\", @undefined);\n" \
+ " @putByIdDirectPrivate(reader, \"ownerReadableStream\", @undefined);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeLength = 229;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return !@getByIdDirectPrivate(controller, \"closeRequested\") && @getByIdDirectPrivate(@getByIdDirectPrivate(controller, \"controlledReadableStream\"), \"state\") === @streamReadable;\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().readableStreamInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().readableStreamInternalsBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.h b/src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.h
new file mode 100644
index 000000000..b6f90268b
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.h
@@ -0,0 +1,484 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* ReadableStreamInternals */
+extern const char* const s_readableStreamInternalsReadableStreamReaderGenericInitializeCode;
+extern const int s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeConstructorKind;
+extern const char* const s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCode;
+extern const int s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeConstructorKind;
+extern const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode;
+extern const int s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerErrorCode;
+extern const int s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamPipeToCode;
+extern const int s_readableStreamInternalsReadableStreamPipeToCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToCodeConstructorKind;
+extern const char* const s_readableStreamInternalsAcquireReadableStreamDefaultReaderCode;
+extern const int s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode;
+extern const int s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructorKind;
+extern const char* const s_readableStreamInternalsPipeToLoopCode;
+extern const int s_readableStreamInternalsPipeToLoopCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsPipeToLoopCodeConstructorKind;
+extern const char* const s_readableStreamInternalsPipeToDoReadWriteCode;
+extern const int s_readableStreamInternalsPipeToDoReadWriteCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsPipeToDoReadWriteCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsPipeToDoReadWriteCodeConstructorKind;
+extern const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode;
+extern const int s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeConstructorKind;
+extern const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode;
+extern const int s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructorKind;
+extern const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCode;
+extern const int s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructorKind;
+extern const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCode;
+extern const int s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeConstructorKind;
+extern const char* const s_readableStreamInternalsPipeToShutdownWithActionCode;
+extern const int s_readableStreamInternalsPipeToShutdownWithActionCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownWithActionCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownWithActionCodeConstructorKind;
+extern const char* const s_readableStreamInternalsPipeToShutdownCode;
+extern const int s_readableStreamInternalsPipeToShutdownCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownCodeConstructorKind;
+extern const char* const s_readableStreamInternalsPipeToFinalizeCode;
+extern const int s_readableStreamInternalsPipeToFinalizeCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsPipeToFinalizeCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamTeeCode;
+extern const int s_readableStreamInternalsReadableStreamTeeCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamTeePullFunctionCode;
+extern const int s_readableStreamInternalsReadableStreamTeePullFunctionCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode;
+extern const int s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCode;
+extern const int s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructorKind;
+extern const char* const s_readableStreamInternalsIsReadableStreamCode;
+extern const int s_readableStreamInternalsIsReadableStreamCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamCodeConstructorKind;
+extern const char* const s_readableStreamInternalsIsReadableStreamDefaultReaderCode;
+extern const int s_readableStreamInternalsIsReadableStreamDefaultReaderCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDefaultReaderCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDefaultReaderCodeConstructorKind;
+extern const char* const s_readableStreamInternalsIsReadableStreamDefaultControllerCode;
+extern const int s_readableStreamInternalsIsReadableStreamDefaultControllerCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDefaultControllerCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDefaultControllerCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamErrorCode;
+extern const int s_readableStreamInternalsReadableStreamErrorCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamErrorCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCode;
+extern const int s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCode;
+extern const int s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeConstructorKind;
+extern const char* const s_readableStreamInternalsIsReadableStreamLockedCode;
+extern const int s_readableStreamInternalsIsReadableStreamLockedCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamLockedCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamLockedCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode;
+extern const int s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode;
+extern const int s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamCancelCode;
+extern const int s_readableStreamInternalsReadableStreamCancelCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerCancelCode;
+extern const int s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode;
+extern const int s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerCloseCode;
+extern const int s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamCloseCode;
+extern const int s_readableStreamInternalsReadableStreamCloseCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCloseCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode;
+extern const int s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode;
+extern const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode;
+extern const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamAddReadRequestCode;
+extern const int s_readableStreamInternalsReadableStreamAddReadRequestCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructorKind;
+extern const char* const s_readableStreamInternalsIsReadableStreamDisturbedCode;
+extern const int s_readableStreamInternalsIsReadableStreamDisturbedCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDisturbedCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDisturbedCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamReaderGenericReleaseCode;
+extern const int s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeConstructorKind;
+extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCode;
+extern const int s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeLength;
+extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructorKind;
+
+#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_DATA(macro) \
+ macro(readableStreamReaderGenericInitialize, readableStreamInternalsReadableStreamReaderGenericInitialize, 2) \
+ macro(privateInitializeReadableStreamDefaultController, readableStreamInternalsPrivateInitializeReadableStreamDefaultController, 4) \
+ macro(setupReadableStreamDefaultController, readableStreamInternalsSetupReadableStreamDefaultController, 7) \
+ macro(readableStreamDefaultControllerError, readableStreamInternalsReadableStreamDefaultControllerError, 2) \
+ macro(readableStreamPipeTo, readableStreamInternalsReadableStreamPipeTo, 2) \
+ macro(acquireReadableStreamDefaultReader, readableStreamInternalsAcquireReadableStreamDefaultReader, 1) \
+ macro(readableStreamPipeToWritableStream, readableStreamInternalsReadableStreamPipeToWritableStream, 6) \
+ macro(pipeToLoop, readableStreamInternalsPipeToLoop, 1) \
+ macro(pipeToDoReadWrite, readableStreamInternalsPipeToDoReadWrite, 1) \
+ macro(pipeToErrorsMustBePropagatedForward, readableStreamInternalsPipeToErrorsMustBePropagatedForward, 1) \
+ macro(pipeToErrorsMustBePropagatedBackward, readableStreamInternalsPipeToErrorsMustBePropagatedBackward, 1) \
+ macro(pipeToClosingMustBePropagatedForward, readableStreamInternalsPipeToClosingMustBePropagatedForward, 1) \
+ macro(pipeToClosingMustBePropagatedBackward, readableStreamInternalsPipeToClosingMustBePropagatedBackward, 1) \
+ macro(pipeToShutdownWithAction, readableStreamInternalsPipeToShutdownWithAction, 2) \
+ macro(pipeToShutdown, readableStreamInternalsPipeToShutdown, 1) \
+ macro(pipeToFinalize, readableStreamInternalsPipeToFinalize, 1) \
+ macro(readableStreamTee, readableStreamInternalsReadableStreamTee, 2) \
+ macro(readableStreamTeePullFunction, readableStreamInternalsReadableStreamTeePullFunction, 3) \
+ macro(readableStreamTeeBranch1CancelFunction, readableStreamInternalsReadableStreamTeeBranch1CancelFunction, 2) \
+ macro(readableStreamTeeBranch2CancelFunction, readableStreamInternalsReadableStreamTeeBranch2CancelFunction, 2) \
+ macro(isReadableStream, readableStreamInternalsIsReadableStream, 1) \
+ macro(isReadableStreamDefaultReader, readableStreamInternalsIsReadableStreamDefaultReader, 1) \
+ macro(isReadableStreamDefaultController, readableStreamInternalsIsReadableStreamDefaultController, 1) \
+ macro(readableStreamError, readableStreamInternalsReadableStreamError, 2) \
+ macro(readableStreamDefaultControllerShouldCallPull, readableStreamInternalsReadableStreamDefaultControllerShouldCallPull, 1) \
+ macro(readableStreamDefaultControllerCallPullIfNeeded, readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeeded, 1) \
+ macro(isReadableStreamLocked, readableStreamInternalsIsReadableStreamLocked, 1) \
+ macro(readableStreamDefaultControllerGetDesiredSize, readableStreamInternalsReadableStreamDefaultControllerGetDesiredSize, 1) \
+ macro(readableStreamReaderGenericCancel, readableStreamInternalsReadableStreamReaderGenericCancel, 2) \
+ macro(readableStreamCancel, readableStreamInternalsReadableStreamCancel, 2) \
+ macro(readableStreamDefaultControllerCancel, readableStreamInternalsReadableStreamDefaultControllerCancel, 2) \
+ macro(readableStreamDefaultControllerPull, readableStreamInternalsReadableStreamDefaultControllerPull, 1) \
+ macro(readableStreamDefaultControllerClose, readableStreamInternalsReadableStreamDefaultControllerClose, 1) \
+ macro(readableStreamClose, readableStreamInternalsReadableStreamClose, 1) \
+ macro(readableStreamFulfillReadRequest, readableStreamInternalsReadableStreamFulfillReadRequest, 3) \
+ macro(readableStreamDefaultControllerEnqueue, readableStreamInternalsReadableStreamDefaultControllerEnqueue, 2) \
+ macro(readableStreamDefaultReaderRead, readableStreamInternalsReadableStreamDefaultReaderRead, 1) \
+ macro(readableStreamAddReadRequest, readableStreamInternalsReadableStreamAddReadRequest, 1) \
+ macro(isReadableStreamDisturbed, readableStreamInternalsIsReadableStreamDisturbed, 1) \
+ macro(readableStreamReaderGenericRelease, readableStreamInternalsReadableStreamReaderGenericRelease, 1) \
+ macro(readableStreamDefaultControllerCanCloseOrEnqueue, readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueue, 1) \
+
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMREADERGENERICINITIALIZE 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PRIVATEINITIALIZEREADABLESTREAMDEFAULTCONTROLLER 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_SETUPREADABLESTREAMDEFAULTCONTROLLER 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERERROR 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMPIPETO 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ACQUIREREADABLESTREAMDEFAULTREADER 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMPIPETOWRITABLESTREAM 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOLOOP 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETODOREADWRITE 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOERRORSMUSTBEPROPAGATEDFORWARD 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOERRORSMUSTBEPROPAGATEDBACKWARD 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOCLOSINGMUSTBEPROPAGATEDFORWARD 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOCLOSINGMUSTBEPROPAGATEDBACKWARD 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOSHUTDOWNWITHACTION 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOSHUTDOWN 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOFINALIZE 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTEE 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTEEPULLFUNCTION 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTEEBRANCH1CANCELFUNCTION 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTEEBRANCH2CANCELFUNCTION 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAM 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAMDEFAULTREADER 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAMDEFAULTCONTROLLER 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMERROR 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERSHOULDCALLPULL 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERCALLPULLIFNEEDED 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAMLOCKED 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERGETDESIREDSIZE 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMREADERGENERICCANCEL 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMCANCEL 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERCANCEL 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERPULL 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERCLOSE 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMCLOSE 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMFULFILLREADREQUEST 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERENQUEUE 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTREADERREAD 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMADDREADREQUEST 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAMDISTURBED 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMREADERGENERICRELEASE 1
+#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERCANCLOSEORENQUEUE 1
+
+#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(macro) \
+ macro(readableStreamInternalsReadableStreamReaderGenericInitializeCode, readableStreamReaderGenericInitialize, ASCIILiteral(), s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeLength) \
+ macro(readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCode, privateInitializeReadableStreamDefaultController, ASCIILiteral(), s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeLength) \
+ macro(readableStreamInternalsSetupReadableStreamDefaultControllerCode, setupReadableStreamDefaultController, ASCIILiteral(), s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeLength) \
+ macro(readableStreamInternalsReadableStreamDefaultControllerErrorCode, readableStreamDefaultControllerError, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeLength) \
+ macro(readableStreamInternalsReadableStreamPipeToCode, readableStreamPipeTo, ASCIILiteral(), s_readableStreamInternalsReadableStreamPipeToCodeLength) \
+ macro(readableStreamInternalsAcquireReadableStreamDefaultReaderCode, acquireReadableStreamDefaultReader, ASCIILiteral(), s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeLength) \
+ macro(readableStreamInternalsReadableStreamPipeToWritableStreamCode, readableStreamPipeToWritableStream, ASCIILiteral(), s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeLength) \
+ macro(readableStreamInternalsPipeToLoopCode, pipeToLoop, ASCIILiteral(), s_readableStreamInternalsPipeToLoopCodeLength) \
+ macro(readableStreamInternalsPipeToDoReadWriteCode, pipeToDoReadWrite, ASCIILiteral(), s_readableStreamInternalsPipeToDoReadWriteCodeLength) \
+ macro(readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode, pipeToErrorsMustBePropagatedForward, ASCIILiteral(), s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeLength) \
+ macro(readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode, pipeToErrorsMustBePropagatedBackward, ASCIILiteral(), s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeLength) \
+ macro(readableStreamInternalsPipeToClosingMustBePropagatedForwardCode, pipeToClosingMustBePropagatedForward, ASCIILiteral(), s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeLength) \
+ macro(readableStreamInternalsPipeToClosingMustBePropagatedBackwardCode, pipeToClosingMustBePropagatedBackward, ASCIILiteral(), s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeLength) \
+ macro(readableStreamInternalsPipeToShutdownWithActionCode, pipeToShutdownWithAction, ASCIILiteral(), s_readableStreamInternalsPipeToShutdownWithActionCodeLength) \
+ macro(readableStreamInternalsPipeToShutdownCode, pipeToShutdown, ASCIILiteral(), s_readableStreamInternalsPipeToShutdownCodeLength) \
+ macro(readableStreamInternalsPipeToFinalizeCode, pipeToFinalize, ASCIILiteral(), s_readableStreamInternalsPipeToFinalizeCodeLength) \
+ macro(readableStreamInternalsReadableStreamTeeCode, readableStreamTee, ASCIILiteral(), s_readableStreamInternalsReadableStreamTeeCodeLength) \
+ macro(readableStreamInternalsReadableStreamTeePullFunctionCode, readableStreamTeePullFunction, ASCIILiteral(), s_readableStreamInternalsReadableStreamTeePullFunctionCodeLength) \
+ macro(readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode, readableStreamTeeBranch1CancelFunction, ASCIILiteral(), s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeLength) \
+ macro(readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCode, readableStreamTeeBranch2CancelFunction, ASCIILiteral(), s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeLength) \
+ macro(readableStreamInternalsIsReadableStreamCode, isReadableStream, ASCIILiteral(), s_readableStreamInternalsIsReadableStreamCodeLength) \
+ macro(readableStreamInternalsIsReadableStreamDefaultReaderCode, isReadableStreamDefaultReader, ASCIILiteral(), s_readableStreamInternalsIsReadableStreamDefaultReaderCodeLength) \
+ macro(readableStreamInternalsIsReadableStreamDefaultControllerCode, isReadableStreamDefaultController, ASCIILiteral(), s_readableStreamInternalsIsReadableStreamDefaultControllerCodeLength) \
+ macro(readableStreamInternalsReadableStreamErrorCode, readableStreamError, ASCIILiteral(), s_readableStreamInternalsReadableStreamErrorCodeLength) \
+ macro(readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCode, readableStreamDefaultControllerShouldCallPull, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeLength) \
+ macro(readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCode, readableStreamDefaultControllerCallPullIfNeeded, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeLength) \
+ macro(readableStreamInternalsIsReadableStreamLockedCode, isReadableStreamLocked, ASCIILiteral(), s_readableStreamInternalsIsReadableStreamLockedCodeLength) \
+ macro(readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode, readableStreamDefaultControllerGetDesiredSize, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength) \
+ macro(readableStreamInternalsReadableStreamReaderGenericCancelCode, readableStreamReaderGenericCancel, ASCIILiteral(), s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength) \
+ macro(readableStreamInternalsReadableStreamCancelCode, readableStreamCancel, ASCIILiteral(), s_readableStreamInternalsReadableStreamCancelCodeLength) \
+ macro(readableStreamInternalsReadableStreamDefaultControllerCancelCode, readableStreamDefaultControllerCancel, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeLength) \
+ macro(readableStreamInternalsReadableStreamDefaultControllerPullCode, readableStreamDefaultControllerPull, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength) \
+ macro(readableStreamInternalsReadableStreamDefaultControllerCloseCode, readableStreamDefaultControllerClose, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeLength) \
+ macro(readableStreamInternalsReadableStreamCloseCode, readableStreamClose, ASCIILiteral(), s_readableStreamInternalsReadableStreamCloseCodeLength) \
+ macro(readableStreamInternalsReadableStreamFulfillReadRequestCode, readableStreamFulfillReadRequest, ASCIILiteral(), s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength) \
+ macro(readableStreamInternalsReadableStreamDefaultControllerEnqueueCode, readableStreamDefaultControllerEnqueue, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength) \
+ macro(readableStreamInternalsReadableStreamDefaultReaderReadCode, readableStreamDefaultReaderRead, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength) \
+ macro(readableStreamInternalsReadableStreamAddReadRequestCode, readableStreamAddReadRequest, ASCIILiteral(), s_readableStreamInternalsReadableStreamAddReadRequestCodeLength) \
+ macro(readableStreamInternalsIsReadableStreamDisturbedCode, isReadableStreamDisturbed, ASCIILiteral(), s_readableStreamInternalsIsReadableStreamDisturbedCodeLength) \
+ macro(readableStreamInternalsReadableStreamReaderGenericReleaseCode, readableStreamReaderGenericRelease, ASCIILiteral(), s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeLength) \
+ macro(readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCode, readableStreamDefaultControllerCanCloseOrEnqueue, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeLength) \
+
+#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \
+ macro(acquireReadableStreamDefaultReader) \
+ macro(isReadableStream) \
+ macro(isReadableStreamDefaultController) \
+ macro(isReadableStreamDefaultReader) \
+ macro(isReadableStreamDisturbed) \
+ macro(isReadableStreamLocked) \
+ macro(pipeToClosingMustBePropagatedBackward) \
+ macro(pipeToClosingMustBePropagatedForward) \
+ macro(pipeToDoReadWrite) \
+ macro(pipeToErrorsMustBePropagatedBackward) \
+ macro(pipeToErrorsMustBePropagatedForward) \
+ macro(pipeToFinalize) \
+ macro(pipeToLoop) \
+ macro(pipeToShutdown) \
+ macro(pipeToShutdownWithAction) \
+ macro(privateInitializeReadableStreamDefaultController) \
+ macro(readableStreamAddReadRequest) \
+ macro(readableStreamCancel) \
+ macro(readableStreamClose) \
+ macro(readableStreamDefaultControllerCallPullIfNeeded) \
+ macro(readableStreamDefaultControllerCanCloseOrEnqueue) \
+ macro(readableStreamDefaultControllerCancel) \
+ macro(readableStreamDefaultControllerClose) \
+ macro(readableStreamDefaultControllerEnqueue) \
+ macro(readableStreamDefaultControllerError) \
+ macro(readableStreamDefaultControllerGetDesiredSize) \
+ macro(readableStreamDefaultControllerPull) \
+ macro(readableStreamDefaultControllerShouldCallPull) \
+ macro(readableStreamDefaultReaderRead) \
+ macro(readableStreamError) \
+ macro(readableStreamFulfillReadRequest) \
+ macro(readableStreamPipeTo) \
+ macro(readableStreamPipeToWritableStream) \
+ macro(readableStreamReaderGenericCancel) \
+ macro(readableStreamReaderGenericInitialize) \
+ macro(readableStreamReaderGenericRelease) \
+ macro(readableStreamTee) \
+ macro(readableStreamTeeBranch1CancelFunction) \
+ macro(readableStreamTeeBranch2CancelFunction) \
+ macro(readableStreamTeePullFunction) \
+ macro(setupReadableStreamDefaultController) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class ReadableStreamInternalsBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit ReadableStreamInternalsBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_READABLESTREAMINTERNALS_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_READABLESTREAMINTERNALS_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_READABLESTREAMINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* ReadableStreamInternalsBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_READABLESTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void ReadableStreamInternalsBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+class ReadableStreamInternalsBuiltinFunctions {
+public:
+ explicit ReadableStreamInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { }
+
+ void init(JSC::JSGlobalObject&);
+ template<typename Visitor> void visit(Visitor&);
+
+public:
+ JSC::VM& m_vm;
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \
+ JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function;
+ WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+};
+
+inline void ReadableStreamInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
+{
+#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
+ m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
+ WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION)
+#undef EXPORT_FUNCTION
+}
+
+template<typename Visitor>
+inline void ReadableStreamInternalsBuiltinFunctions::visit(Visitor& visitor)
+{
+#define VISIT_FUNCTION(name) visitor.append(m_##name##Function);
+ WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION)
+#undef VISIT_FUNCTION
+}
+
+template void ReadableStreamInternalsBuiltinFunctions::visit(JSC::AbstractSlotVisitor&);
+template void ReadableStreamInternalsBuiltinFunctions::visit(JSC::SlotVisitor&);
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/StreamGlobals.h b/src/javascript/jsc/bindings/StreamGlobals.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/javascript/jsc/bindings/StreamGlobals.h
diff --git a/src/javascript/jsc/bindings/StreamInternalsBuiltins.cpp b/src/javascript/jsc/bindings/StreamInternalsBuiltins.cpp
new file mode 100644
index 000000000..1910dd83d
--- /dev/null
+++ b/src/javascript/jsc/bindings/StreamInternalsBuiltins.cpp
@@ -0,0 +1,360 @@
+/*
+ * 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 "StreamInternalsBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_streamInternalsMarkPromiseAsHandledCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsMarkPromiseAsHandledCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsMarkPromiseAsHandledCodeLength = 217;
+static const JSC::Intrinsic s_streamInternalsMarkPromiseAsHandledCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsMarkPromiseAsHandledCode =
+ "(function (promise)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@isPromise(promise));\n" \
+ " @putPromiseInternalField(promise, @promiseFieldFlags, @getPromiseInternalField(promise, @promiseFieldFlags) | @promiseFlagsIsHandled);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsShieldingPromiseResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsShieldingPromiseResolveCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsShieldingPromiseResolveCodeLength = 198;
+static const JSC::Intrinsic s_streamInternalsShieldingPromiseResolveCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsShieldingPromiseResolveCode =
+ "(function (result)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const promise = @Promise.@resolve(result);\n" \
+ " if (promise.@then === @undefined)\n" \
+ " promise.@then = @Promise.prototype.@then;\n" \
+ " return promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeLength = 190;
+static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCode =
+ "(function (object, method, args)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (method === @undefined)\n" \
+ " return @Promise.@resolve();\n" \
+ " return @shieldingPromiseResolve(method.@apply(object, args));\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsPromiseInvokeOrNoopNoCatchCodeLength = 127;
+static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopNoCatchCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsPromiseInvokeOrNoopNoCatchCode =
+ "(function (object, key, args)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return @promiseInvokeOrNoopMethodNoCatch(object, object[key], args);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopMethodCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopMethodCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsPromiseInvokeOrNoopMethodCodeLength = 210;
+static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopMethodCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsPromiseInvokeOrNoopMethodCode =
+ "(function (object, method, args)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " try {\n" \
+ " return @promiseInvokeOrNoopMethodNoCatch(object, method, args);\n" \
+ " }\n" \
+ " catch(error) {\n" \
+ " return @Promise.@reject(error);\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsPromiseInvokeOrNoopCodeLength = 198;
+static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsPromiseInvokeOrNoopCode =
+ "(function (object, key, args)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " try {\n" \
+ " return @promiseInvokeOrNoopNoCatch(object, key, args);\n" \
+ " }\n" \
+ " catch(error) {\n" \
+ " return @Promise.@reject(error);\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeLength = 362;
+static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsPromiseInvokeOrFallbackOrNoopCode =
+ "(function (object, key1, args1, key2, args2)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " try {\n" \
+ " const method = object[key1];\n" \
+ " if (method === @undefined)\n" \
+ " return @promiseInvokeOrNoopNoCatch(object, key2, args2);\n" \
+ " return @shieldingPromiseResolve(method.@apply(object, args1));\n" \
+ " }\n" \
+ " catch(error) {\n" \
+ " return @Promise.@reject(error);\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsValidateAndNormalizeQueuingStrategyCodeLength = 486;
+static const JSC::Intrinsic s_streamInternalsValidateAndNormalizeQueuingStrategyCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsValidateAndNormalizeQueuingStrategyCode =
+ "(function (size, highWaterMark)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (size !== @undefined && typeof size !== \"function\")\n" \
+ " @throwTypeError(\"size parameter must be a function\");\n" \
+ "\n" \
+ " const normalizedStrategy = {\n" \
+ " size: size,\n" \
+ " highWaterMark: @toNumber(highWaterMark)\n" \
+ " };\n" \
+ "\n" \
+ " if (@isNaN(normalizedStrategy.highWaterMark) || normalizedStrategy.highWaterMark < 0)\n" \
+ " @throwRangeError(\"highWaterMark value is negative or not a number\");\n" \
+ "\n" \
+ " return normalizedStrategy;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsNewQueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsNewQueueCodeLength = 74;
+static const JSC::Intrinsic s_streamInternalsNewQueueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsNewQueueCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return { content: [], size: 0 };\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsDequeueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsDequeueValueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsDequeueValueCodeLength = 196;
+static const JSC::Intrinsic s_streamInternalsDequeueValueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsDequeueValueCode =
+ "(function (queue)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const record = queue.content.@shift();\n" \
+ " queue.size -= record.size;\n" \
+ " //\n" \
+ " if (queue.size < 0)\n" \
+ " queue.size = 0;\n" \
+ " return record.value;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsEnqueueValueWithSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsEnqueueValueWithSizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsEnqueueValueWithSizeCodeLength = 250;
+static const JSC::Intrinsic s_streamInternalsEnqueueValueWithSizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsEnqueueValueWithSizeCode =
+ "(function (queue, value, size)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " size = @toNumber(size);\n" \
+ " if (!@isFinite(size) || size < 0)\n" \
+ " @throwRangeError(\"size has an incorrect value\");\n" \
+ " @arrayPush(queue.content, { value, size });\n" \
+ " queue.size += size;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsPeekQueueValueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsPeekQueueValueCodeLength = 117;
+static const JSC::Intrinsic s_streamInternalsPeekQueueValueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsPeekQueueValueCode =
+ "(function (queue)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(queue.content.length > 0);\n" \
+ "\n" \
+ " return queue.content[0].value;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsResetQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsResetQueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsResetQueueCodeLength = 149;
+static const JSC::Intrinsic s_streamInternalsResetQueueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsResetQueueCode =
+ "(function (queue)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(\"content\" in queue);\n" \
+ " @assert(\"size\" in queue);\n" \
+ " queue.content = [];\n" \
+ " queue.size = 0;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsExtractSizeAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsExtractSizeAlgorithmCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsExtractSizeAlgorithmCodeLength = 288;
+static const JSC::Intrinsic s_streamInternalsExtractSizeAlgorithmCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsExtractSizeAlgorithmCode =
+ "(function (strategy)\n" \
+ "{\n" \
+ " if (!(\"size\" in strategy))\n" \
+ " return () => 1;\n" \
+ " const sizeAlgorithm = strategy[\"size\"];\n" \
+ " if (typeof sizeAlgorithm !== \"function\")\n" \
+ " @throwTypeError(\"strategy.size must be a function\");\n" \
+ "\n" \
+ " return (chunk) => { return sizeAlgorithm(chunk); };\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsExtractHighWaterMarkCodeLength = 325;
+static const JSC::Intrinsic s_streamInternalsExtractHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsExtractHighWaterMarkCode =
+ "(function (strategy, defaultHWM)\n" \
+ "{\n" \
+ " if (!(\"highWaterMark\" in strategy))\n" \
+ " return defaultHWM;\n" \
+ " const highWaterMark = strategy[\"highWaterMark\"];\n" \
+ " if (@isNaN(highWaterMark) || highWaterMark < 0)\n" \
+ " @throwRangeError(\"highWaterMark value is negative or not a number\");\n" \
+ "\n" \
+ " return @toNumber(highWaterMark);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeLength = 335;
+static const JSC::Intrinsic s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCode =
+ "(function (init)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isObject(init))\n" \
+ " @throwTypeError(\"QueuingStrategyInit argument must be an object.\");\n" \
+ " const {highWaterMark} = init;\n" \
+ " if (highWaterMark === @undefined)\n" \
+ " @throwTypeError(\"QueuingStrategyInit.highWaterMark member is required.\");\n" \
+ "\n" \
+ " return @toNumber(highWaterMark);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsCreateFulfilledPromiseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsCreateFulfilledPromiseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsCreateFulfilledPromiseCodeLength = 115;
+static const JSC::Intrinsic s_streamInternalsCreateFulfilledPromiseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsCreateFulfilledPromiseCode =
+ "(function (value)\n" \
+ "{\n" \
+ " const promise = @newPromise();\n" \
+ " @fulfillPromise(promise, value);\n" \
+ " return promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsToDictionaryCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsToDictionaryCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsToDictionaryCodeLength = 212;
+static const JSC::Intrinsic s_streamInternalsToDictionaryCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsToDictionaryCode =
+ "(function (value, defaultValue, errorMessage)\n" \
+ "{\n" \
+ " if (value === @undefined || value === null)\n" \
+ " return defaultValue;\n" \
+ " if (!@isObject(value))\n" \
+ " @throwTypeError(errorMessage);\n" \
+ " return value;\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().streamInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().streamInternalsBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/StreamInternalsBuiltins.h b/src/javascript/jsc/bindings/StreamInternalsBuiltins.h
new file mode 100644
index 000000000..20c41ddb9
--- /dev/null
+++ b/src/javascript/jsc/bindings/StreamInternalsBuiltins.h
@@ -0,0 +1,300 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* StreamInternals */
+extern const char* const s_streamInternalsMarkPromiseAsHandledCode;
+extern const int s_streamInternalsMarkPromiseAsHandledCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsMarkPromiseAsHandledCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsMarkPromiseAsHandledCodeConstructorKind;
+extern const char* const s_streamInternalsShieldingPromiseResolveCode;
+extern const int s_streamInternalsShieldingPromiseResolveCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsShieldingPromiseResolveCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsShieldingPromiseResolveCodeConstructorKind;
+extern const char* const s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCode;
+extern const int s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeConstructorKind;
+extern const char* const s_streamInternalsPromiseInvokeOrNoopNoCatchCode;
+extern const int s_streamInternalsPromiseInvokeOrNoopNoCatchCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructorKind;
+extern const char* const s_streamInternalsPromiseInvokeOrNoopMethodCode;
+extern const int s_streamInternalsPromiseInvokeOrNoopMethodCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopMethodCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopMethodCodeConstructorKind;
+extern const char* const s_streamInternalsPromiseInvokeOrNoopCode;
+extern const int s_streamInternalsPromiseInvokeOrNoopCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopCodeConstructorKind;
+extern const char* const s_streamInternalsPromiseInvokeOrFallbackOrNoopCode;
+extern const int s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructorKind;
+extern const char* const s_streamInternalsValidateAndNormalizeQueuingStrategyCode;
+extern const int s_streamInternalsValidateAndNormalizeQueuingStrategyCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructorKind;
+extern const char* const s_streamInternalsNewQueueCode;
+extern const int s_streamInternalsNewQueueCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsNewQueueCodeConstructorKind;
+extern const char* const s_streamInternalsDequeueValueCode;
+extern const int s_streamInternalsDequeueValueCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsDequeueValueCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsDequeueValueCodeConstructorKind;
+extern const char* const s_streamInternalsEnqueueValueWithSizeCode;
+extern const int s_streamInternalsEnqueueValueWithSizeCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsEnqueueValueWithSizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsEnqueueValueWithSizeCodeConstructorKind;
+extern const char* const s_streamInternalsPeekQueueValueCode;
+extern const int s_streamInternalsPeekQueueValueCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsPeekQueueValueCodeConstructorKind;
+extern const char* const s_streamInternalsResetQueueCode;
+extern const int s_streamInternalsResetQueueCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsResetQueueCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsResetQueueCodeConstructorKind;
+extern const char* const s_streamInternalsExtractSizeAlgorithmCode;
+extern const int s_streamInternalsExtractSizeAlgorithmCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsExtractSizeAlgorithmCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsExtractSizeAlgorithmCodeConstructorKind;
+extern const char* const s_streamInternalsExtractHighWaterMarkCode;
+extern const int s_streamInternalsExtractHighWaterMarkCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkCodeConstructorKind;
+extern const char* const s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCode;
+extern const int s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructorKind;
+extern const char* const s_streamInternalsCreateFulfilledPromiseCode;
+extern const int s_streamInternalsCreateFulfilledPromiseCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsCreateFulfilledPromiseCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsCreateFulfilledPromiseCodeConstructorKind;
+extern const char* const s_streamInternalsToDictionaryCode;
+extern const int s_streamInternalsToDictionaryCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsToDictionaryCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsToDictionaryCodeConstructorKind;
+
+#define WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_DATA(macro) \
+ macro(markPromiseAsHandled, streamInternalsMarkPromiseAsHandled, 1) \
+ macro(shieldingPromiseResolve, streamInternalsShieldingPromiseResolve, 1) \
+ macro(promiseInvokeOrNoopMethodNoCatch, streamInternalsPromiseInvokeOrNoopMethodNoCatch, 3) \
+ macro(promiseInvokeOrNoopNoCatch, streamInternalsPromiseInvokeOrNoopNoCatch, 3) \
+ macro(promiseInvokeOrNoopMethod, streamInternalsPromiseInvokeOrNoopMethod, 3) \
+ macro(promiseInvokeOrNoop, streamInternalsPromiseInvokeOrNoop, 3) \
+ macro(promiseInvokeOrFallbackOrNoop, streamInternalsPromiseInvokeOrFallbackOrNoop, 5) \
+ macro(validateAndNormalizeQueuingStrategy, streamInternalsValidateAndNormalizeQueuingStrategy, 2) \
+ macro(newQueue, streamInternalsNewQueue, 0) \
+ macro(dequeueValue, streamInternalsDequeueValue, 1) \
+ macro(enqueueValueWithSize, streamInternalsEnqueueValueWithSize, 3) \
+ macro(peekQueueValue, streamInternalsPeekQueueValue, 1) \
+ macro(resetQueue, streamInternalsResetQueue, 1) \
+ macro(extractSizeAlgorithm, streamInternalsExtractSizeAlgorithm, 1) \
+ macro(extractHighWaterMark, streamInternalsExtractHighWaterMark, 2) \
+ macro(extractHighWaterMarkFromQueuingStrategyInit, streamInternalsExtractHighWaterMarkFromQueuingStrategyInit, 1) \
+ macro(createFulfilledPromise, streamInternalsCreateFulfilledPromise, 1) \
+ macro(toDictionary, streamInternalsToDictionary, 3) \
+
+#define WEBCORE_BUILTIN_STREAMINTERNALS_MARKPROMISEASHANDLED 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_SHIELDINGPROMISERESOLVE 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOPMETHODNOCATCH 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOPNOCATCH 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOPMETHOD 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOP 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORFALLBACKORNOOP 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_VALIDATEANDNORMALIZEQUEUINGSTRATEGY 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_NEWQUEUE 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_DEQUEUEVALUE 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_ENQUEUEVALUEWITHSIZE 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_PEEKQUEUEVALUE 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_RESETQUEUE 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_EXTRACTSIZEALGORITHM 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_EXTRACTHIGHWATERMARK 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_EXTRACTHIGHWATERMARKFROMQUEUINGSTRATEGYINIT 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_CREATEFULFILLEDPROMISE 1
+#define WEBCORE_BUILTIN_STREAMINTERNALS_TODICTIONARY 1
+
+#define WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(macro) \
+ macro(streamInternalsMarkPromiseAsHandledCode, markPromiseAsHandled, ASCIILiteral(), s_streamInternalsMarkPromiseAsHandledCodeLength) \
+ macro(streamInternalsShieldingPromiseResolveCode, shieldingPromiseResolve, ASCIILiteral(), s_streamInternalsShieldingPromiseResolveCodeLength) \
+ macro(streamInternalsPromiseInvokeOrNoopMethodNoCatchCode, promiseInvokeOrNoopMethodNoCatch, ASCIILiteral(), s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeLength) \
+ macro(streamInternalsPromiseInvokeOrNoopNoCatchCode, promiseInvokeOrNoopNoCatch, ASCIILiteral(), s_streamInternalsPromiseInvokeOrNoopNoCatchCodeLength) \
+ macro(streamInternalsPromiseInvokeOrNoopMethodCode, promiseInvokeOrNoopMethod, ASCIILiteral(), s_streamInternalsPromiseInvokeOrNoopMethodCodeLength) \
+ macro(streamInternalsPromiseInvokeOrNoopCode, promiseInvokeOrNoop, ASCIILiteral(), s_streamInternalsPromiseInvokeOrNoopCodeLength) \
+ macro(streamInternalsPromiseInvokeOrFallbackOrNoopCode, promiseInvokeOrFallbackOrNoop, ASCIILiteral(), s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeLength) \
+ macro(streamInternalsValidateAndNormalizeQueuingStrategyCode, validateAndNormalizeQueuingStrategy, ASCIILiteral(), s_streamInternalsValidateAndNormalizeQueuingStrategyCodeLength) \
+ macro(streamInternalsNewQueueCode, newQueue, ASCIILiteral(), s_streamInternalsNewQueueCodeLength) \
+ macro(streamInternalsDequeueValueCode, dequeueValue, ASCIILiteral(), s_streamInternalsDequeueValueCodeLength) \
+ macro(streamInternalsEnqueueValueWithSizeCode, enqueueValueWithSize, ASCIILiteral(), s_streamInternalsEnqueueValueWithSizeCodeLength) \
+ macro(streamInternalsPeekQueueValueCode, peekQueueValue, ASCIILiteral(), s_streamInternalsPeekQueueValueCodeLength) \
+ macro(streamInternalsResetQueueCode, resetQueue, ASCIILiteral(), s_streamInternalsResetQueueCodeLength) \
+ macro(streamInternalsExtractSizeAlgorithmCode, extractSizeAlgorithm, ASCIILiteral(), s_streamInternalsExtractSizeAlgorithmCodeLength) \
+ macro(streamInternalsExtractHighWaterMarkCode, extractHighWaterMark, ASCIILiteral(), s_streamInternalsExtractHighWaterMarkCodeLength) \
+ macro(streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCode, extractHighWaterMarkFromQueuingStrategyInit, ASCIILiteral(), s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeLength) \
+ macro(streamInternalsCreateFulfilledPromiseCode, createFulfilledPromise, ASCIILiteral(), s_streamInternalsCreateFulfilledPromiseCodeLength) \
+ macro(streamInternalsToDictionaryCode, toDictionary, ASCIILiteral(), s_streamInternalsToDictionaryCodeLength) \
+
+#define WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \
+ macro(createFulfilledPromise) \
+ macro(dequeueValue) \
+ macro(enqueueValueWithSize) \
+ macro(extractHighWaterMark) \
+ macro(extractHighWaterMarkFromQueuingStrategyInit) \
+ macro(extractSizeAlgorithm) \
+ macro(markPromiseAsHandled) \
+ macro(newQueue) \
+ macro(peekQueueValue) \
+ macro(promiseInvokeOrFallbackOrNoop) \
+ macro(promiseInvokeOrNoop) \
+ macro(promiseInvokeOrNoopMethod) \
+ macro(promiseInvokeOrNoopMethodNoCatch) \
+ macro(promiseInvokeOrNoopNoCatch) \
+ macro(resetQueue) \
+ macro(shieldingPromiseResolve) \
+ macro(toDictionary) \
+ macro(validateAndNormalizeQueuingStrategy) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class StreamInternalsBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit StreamInternalsBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_STREAMINTERNALS_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_STREAMINTERNALS_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_STREAMINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* StreamInternalsBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_STREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void StreamInternalsBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+class StreamInternalsBuiltinFunctions {
+public:
+ explicit StreamInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { }
+
+ void init(JSC::JSGlobalObject&);
+ template<typename Visitor> void visit(Visitor&);
+
+public:
+ JSC::VM& m_vm;
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \
+ JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function;
+ WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+};
+
+inline void StreamInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
+{
+#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
+ m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
+ WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION)
+#undef EXPORT_FUNCTION
+}
+
+template<typename Visitor>
+inline void StreamInternalsBuiltinFunctions::visit(Visitor& visitor)
+{
+#define VISIT_FUNCTION(name) visitor.append(m_##name##Function);
+ WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION)
+#undef VISIT_FUNCTION
+}
+
+template void StreamInternalsBuiltinFunctions::visit(JSC::AbstractSlotVisitor&);
+template void StreamInternalsBuiltinFunctions::visit(JSC::SlotVisitor&);
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/TransformStreamBuiltins.cpp b/src/javascript/jsc/bindings/TransformStreamBuiltins.cpp
new file mode 100644
index 000000000..027abb5c8
--- /dev/null
+++ b/src/javascript/jsc/bindings/TransformStreamBuiltins.cpp
@@ -0,0 +1,170 @@
+/*
+ * 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 "TransformStreamBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_transformStreamInitializeTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInitializeTransformStreamCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInitializeTransformStreamCodeLength = 2727;
+static const JSC::Intrinsic s_transformStreamInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInitializeTransformStreamCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " let transformer = arguments[0];\n" \
+ "\n" \
+ " //\n" \
+ " if (@isObject(transformer) && @getByIdDirectPrivate(transformer, \"TransformStream\"))\n" \
+ " return this;\n" \
+ "\n" \
+ " let writableStrategy = arguments[1];\n" \
+ " let readableStrategy = arguments[2];\n" \
+ "\n" \
+ " if (transformer === @undefined)\n" \
+ " transformer = null;\n" \
+ "\n" \
+ " if (readableStrategy === @undefined)\n" \
+ " readableStrategy = { };\n" \
+ "\n" \
+ " if (writableStrategy === @undefined)\n" \
+ " writableStrategy = { };\n" \
+ "\n" \
+ " let transformerDict = { };\n" \
+ " if (transformer !== null) {\n" \
+ " if (\"start\" in transformer) {\n" \
+ " transformerDict[\"start\"] = transformer[\"start\"];\n" \
+ " if (typeof transformerDict[\"start\"] !== \"function\")\n" \
+ " @throwTypeError(\"transformer.start should be a function\");\n" \
+ " }\n" \
+ " if (\"transform\" in transformer) {\n" \
+ " transformerDict[\"transform\"] = transformer[\"transform\"];\n" \
+ " if (typeof transformerDict[\"transform\"] !== \"function\")\n" \
+ " @throwTypeError(\"transformer.transform should be a function\");\n" \
+ " }\n" \
+ " if (\"flush\" in transformer) {\n" \
+ " transformerDict[\"flush\"] = transformer[\"flush\"];\n" \
+ " if (typeof transformerDict[\"flush\"] !== \"function\")\n" \
+ " @throwTypeError(\"transformer.flush should be a function\");\n" \
+ " }\n" \
+ "\n" \
+ " if (\"readableType\" in transformer)\n" \
+ " @throwRangeError(\"TransformStream transformer has a readableType\");\n" \
+ " if (\"writableType\" in transformer)\n" \
+ " @throwRangeError(\"TransformStream transformer has a writableType\");\n" \
+ " }\n" \
+ "\n" \
+ " const readableHighWaterMark = @extractHighWaterMark(readableStrategy, 0);\n" \
+ " const readableSizeAlgorithm = @extractSizeAlgorithm(readableStrategy);\n" \
+ "\n" \
+ " const writableHighWaterMark = @extractHighWaterMark(writableStrategy, 1);\n" \
+ " const writableSizeAlgorithm = @extractSizeAlgorithm(writableStrategy);\n" \
+ "\n" \
+ " const startPromiseCapability = @newPromiseCapability(@Promise);\n" \
+ " @initializeTransformStream(this, startPromiseCapability.@promise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);\n" \
+ " @setUpTransformStreamDefaultControllerFromTransformer(this, transformer, transformerDict);\n" \
+ "\n" \
+ " if (\"start\" in transformerDict) {\n" \
+ " const controller = @getByIdDirectPrivate(this, \"controller\");\n" \
+ " const startAlgorithm = () => @promiseInvokeOrNoopMethodNoCatch(transformer, transformerDict[\"start\"], [controller]);\n" \
+ " startAlgorithm().@then(() => {\n" \
+ " //\n" \
+ " startPromiseCapability.@resolve.@call();\n" \
+ " }, (error) => {\n" \
+ " startPromiseCapability.@reject.@call(@undefined, error);\n" \
+ " });\n" \
+ " } else\n" \
+ " startPromiseCapability.@resolve.@call();\n" \
+ "\n" \
+ " return this;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamReadableCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamReadableCodeLength = 190;
+static const JSC::Intrinsic s_transformStreamReadableCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamReadableCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isTransformStream(this))\n" \
+ " throw @makeThisTypeError(\"TransformStream\", \"readable\");\n" \
+ "\n" \
+ " return @getByIdDirectPrivate(this, \"readable\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamWritableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamWritableCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamWritableCodeLength = 190;
+static const JSC::Intrinsic s_transformStreamWritableCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamWritableCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isTransformStream(this))\n" \
+ " throw @makeThisTypeError(\"TransformStream\", \"writable\");\n" \
+ "\n" \
+ " return @getByIdDirectPrivate(this, \"writable\");\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().transformStreamBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().transformStreamBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/TransformStreamBuiltins.h b/src/javascript/jsc/bindings/TransformStreamBuiltins.h
new file mode 100644
index 000000000..bdf0c07cc
--- /dev/null
+++ b/src/javascript/jsc/bindings/TransformStreamBuiltins.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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* TransformStream */
+extern const char* const s_transformStreamInitializeTransformStreamCode;
+extern const int s_transformStreamInitializeTransformStreamCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInitializeTransformStreamCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInitializeTransformStreamCodeConstructorKind;
+extern const char* const s_transformStreamReadableCode;
+extern const int s_transformStreamReadableCodeLength;
+extern const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamReadableCodeConstructorKind;
+extern const char* const s_transformStreamWritableCode;
+extern const int s_transformStreamWritableCodeLength;
+extern const JSC::ConstructAbility s_transformStreamWritableCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamWritableCodeConstructorKind;
+
+#define WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_DATA(macro) \
+ macro(initializeTransformStream, transformStreamInitializeTransformStream, 0) \
+ macro(readable, transformStreamReadable, 0) \
+ macro(writable, transformStreamWritable, 0) \
+
+#define WEBCORE_BUILTIN_TRANSFORMSTREAM_INITIALIZETRANSFORMSTREAM 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAM_READABLE 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAM_WRITABLE 1
+
+#define WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_CODE(macro) \
+ macro(transformStreamInitializeTransformStreamCode, initializeTransformStream, ASCIILiteral(), s_transformStreamInitializeTransformStreamCodeLength) \
+ macro(transformStreamReadableCode, readable, "get readable"_s, s_transformStreamReadableCodeLength) \
+ macro(transformStreamWritableCode, writable, ASCIILiteral(), s_transformStreamWritableCodeLength) \
+
+#define WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_FUNCTION_NAME(macro) \
+ macro(initializeTransformStream) \
+ macro(readable) \
+ macro(writable) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class TransformStreamBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit TransformStreamBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_TRANSFORMSTREAM_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_TRANSFORMSTREAM_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_TRANSFORMSTREAM_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* TransformStreamBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_TRANSFORMSTREAM_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void TransformStreamBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/TransformStreamDefaultControllerBuiltins.cpp b/src/javascript/jsc/bindings/TransformStreamDefaultControllerBuiltins.cpp
new file mode 100644
index 000000000..31c509a1c
--- /dev/null
+++ b/src/javascript/jsc/bindings/TransformStreamDefaultControllerBuiltins.cpp
@@ -0,0 +1,142 @@
+/*
+ * 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 "TransformStreamDefaultControllerBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeLength = 54;
+static const JSC::Intrinsic s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return this;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamDefaultControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamDefaultControllerDesiredSizeCodeLength = 465;
+static const JSC::Intrinsic s_transformStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamDefaultControllerDesiredSizeCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isTransformStreamDefaultController(this))\n" \
+ " throw @makeThisTypeError(\"TransformStreamDefaultController\", \"enqueue\");\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(this, \"stream\");\n" \
+ " const readable = @getByIdDirectPrivate(stream, \"readable\");\n" \
+ " const readableController = @getByIdDirectPrivate(readable, \"readableStreamController\");\n" \
+ "\n" \
+ " return @readableStreamDefaultControllerGetDesiredSize(readableController);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamDefaultControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamDefaultControllerEnqueueCodeLength = 235;
+static const JSC::Intrinsic s_transformStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamDefaultControllerEnqueueCode =
+ "(function (chunk)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isTransformStreamDefaultController(this))\n" \
+ " throw @makeThisTypeError(\"TransformStreamDefaultController\", \"enqueue\");\n" \
+ "\n" \
+ " @transformStreamDefaultControllerEnqueue(this, chunk);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamDefaultControllerErrorCodeLength = 223;
+static const JSC::Intrinsic s_transformStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamDefaultControllerErrorCode =
+ "(function (e)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isTransformStreamDefaultController(this))\n" \
+ " throw @makeThisTypeError(\"TransformStreamDefaultController\", \"error\");\n" \
+ "\n" \
+ " @transformStreamDefaultControllerError(this, e);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamDefaultControllerTerminateCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamDefaultControllerTerminateCodeLength = 227;
+static const JSC::Intrinsic s_transformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamDefaultControllerTerminateCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isTransformStreamDefaultController(this))\n" \
+ " throw @makeThisTypeError(\"TransformStreamDefaultController\", \"terminate\");\n" \
+ "\n" \
+ " @transformStreamDefaultControllerTerminate(this);\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().transformStreamDefaultControllerBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().transformStreamDefaultControllerBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/TransformStreamDefaultControllerBuiltins.h b/src/javascript/jsc/bindings/TransformStreamDefaultControllerBuiltins.h
new file mode 100644
index 000000000..302e2e21c
--- /dev/null
+++ b/src/javascript/jsc/bindings/TransformStreamDefaultControllerBuiltins.h
@@ -0,0 +1,159 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* TransformStreamDefaultController */
+extern const char* const s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCode;
+extern const int s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeLength;
+extern const JSC::ConstructAbility s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeConstructorKind;
+extern const char* const s_transformStreamDefaultControllerDesiredSizeCode;
+extern const int s_transformStreamDefaultControllerDesiredSizeCodeLength;
+extern const JSC::ConstructAbility s_transformStreamDefaultControllerDesiredSizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeConstructorKind;
+extern const char* const s_transformStreamDefaultControllerEnqueueCode;
+extern const int s_transformStreamDefaultControllerEnqueueCodeLength;
+extern const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamDefaultControllerEnqueueCodeConstructorKind;
+extern const char* const s_transformStreamDefaultControllerErrorCode;
+extern const int s_transformStreamDefaultControllerErrorCodeLength;
+extern const JSC::ConstructAbility s_transformStreamDefaultControllerErrorCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamDefaultControllerErrorCodeConstructorKind;
+extern const char* const s_transformStreamDefaultControllerTerminateCode;
+extern const int s_transformStreamDefaultControllerTerminateCodeLength;
+extern const JSC::ConstructAbility s_transformStreamDefaultControllerTerminateCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamDefaultControllerTerminateCodeConstructorKind;
+
+#define WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_DATA(macro) \
+ macro(initializeTransformStreamDefaultController, transformStreamDefaultControllerInitializeTransformStreamDefaultController, 0) \
+ macro(desiredSize, transformStreamDefaultControllerDesiredSize, 0) \
+ macro(enqueue, transformStreamDefaultControllerEnqueue, 1) \
+ macro(error, transformStreamDefaultControllerError, 1) \
+ macro(terminate, transformStreamDefaultControllerTerminate, 0) \
+
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_INITIALIZETRANSFORMSTREAMDEFAULTCONTROLLER 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_DESIREDSIZE 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_ENQUEUE 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_ERROR 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_TERMINATE 1
+
+#define WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(macro) \
+ macro(transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCode, initializeTransformStreamDefaultController, ASCIILiteral(), s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeLength) \
+ macro(transformStreamDefaultControllerDesiredSizeCode, desiredSize, "get desiredSize"_s, s_transformStreamDefaultControllerDesiredSizeCodeLength) \
+ macro(transformStreamDefaultControllerEnqueueCode, enqueue, ASCIILiteral(), s_transformStreamDefaultControllerEnqueueCodeLength) \
+ macro(transformStreamDefaultControllerErrorCode, error, ASCIILiteral(), s_transformStreamDefaultControllerErrorCodeLength) \
+ macro(transformStreamDefaultControllerTerminateCode, terminate, ASCIILiteral(), s_transformStreamDefaultControllerTerminateCodeLength) \
+
+#define WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(macro) \
+ macro(desiredSize) \
+ macro(enqueue) \
+ macro(error) \
+ macro(initializeTransformStreamDefaultController) \
+ macro(terminate) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class TransformStreamDefaultControllerBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit TransformStreamDefaultControllerBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_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_TRANSFORMSTREAMDEFAULTCONTROLLER_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_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* TransformStreamDefaultControllerBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void TransformStreamDefaultControllerBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/TransformStreamInternalsBuiltins.cpp b/src/javascript/jsc/bindings/TransformStreamInternalsBuiltins.cpp
new file mode 100644
index 000000000..560a6350c
--- /dev/null
+++ b/src/javascript/jsc/bindings/TransformStreamInternalsBuiltins.cpp
@@ -0,0 +1,492 @@
+/*
+ * 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 "TransformStreamInternalsBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_transformStreamInternalsIsTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsIsTransformStreamCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsIsTransformStreamCodeLength = 120;
+static const JSC::Intrinsic s_transformStreamInternalsIsTransformStreamCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsIsTransformStreamCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return @isObject(stream) && !!@getByIdDirectPrivate(stream, \"readable\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsIsTransformStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsIsTransformStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsIsTransformStreamDefaultControllerCodeLength = 142;
+static const JSC::Intrinsic s_transformStreamInternalsIsTransformStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsIsTransformStreamDefaultControllerCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return @isObject(controller) && !!@getByIdDirectPrivate(controller, \"transformAlgorithm\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsCreateTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsCreateTransformStreamCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsCreateTransformStreamCodeLength = 1317;
+static const JSC::Intrinsic s_transformStreamInternalsCreateTransformStreamCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsCreateTransformStreamCode =
+ "(function (startAlgorithm, transformAlgorithm, flushAlgorithm, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm)\n" \
+ "{\n" \
+ " if (writableHighWaterMark === @undefined)\n" \
+ " writableHighWaterMark = 1;\n" \
+ " if (writableSizeAlgorithm === @undefined)\n" \
+ " writableSizeAlgorithm = () => 1;\n" \
+ " if (readableHighWaterMark === @undefined)\n" \
+ " readableHighWaterMark = 0;\n" \
+ " if (readableSizeAlgorithm === @undefined)\n" \
+ " readableSizeAlgorithm = () => 1;\n" \
+ " @assert(writableHighWaterMark >= 0);\n" \
+ " @assert(readableHighWaterMark >= 0);\n" \
+ "\n" \
+ " const transform = {};\n" \
+ " @putByIdDirectPrivate(transform, \"TransformStream\", true);\n" \
+ "\n" \
+ " const stream = new @TransformStream(transform);\n" \
+ " const startPromiseCapability = @newPromiseCapability(@Promise);\n" \
+ " @initializeTransformStream(stream, startPromiseCapability.@promise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);\n" \
+ "\n" \
+ " const controller = new @TransformStreamDefaultController();\n" \
+ " @setUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm);\n" \
+ "\n" \
+ " startAlgorithm().@then(() => {\n" \
+ " startPromiseCapability.@resolve.@call();\n" \
+ " }, (error) => {\n" \
+ " startPromiseCapability.@reject.@call(@undefined, error);\n" \
+ " });\n" \
+ "\n" \
+ " return stream;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsInitializeTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsInitializeTransformStreamCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsInitializeTransformStreamCodeLength = 1881;
+static const JSC::Intrinsic s_transformStreamInternalsInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsInitializeTransformStreamCode =
+ "(function (stream, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const startAlgorithm = () => { return startPromise; };\n" \
+ " const writeAlgorithm = (chunk) => { return @transformStreamDefaultSinkWriteAlgorithm(stream, chunk); }\n" \
+ " const abortAlgorithm = (reason) => { return @transformStreamDefaultSinkAbortAlgorithm(stream, reason); }\n" \
+ " const closeAlgorithm = () => { return @transformStreamDefaultSinkCloseAlgorithm(stream); }\n" \
+ " const writable = @createWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, writableHighWaterMark, writableSizeAlgorithm);\n" \
+ "\n" \
+ " const pullAlgorithm = () => { return @transformStreamDefaultSourcePullAlgorithm(stream); };\n" \
+ " const cancelAlgorithm = (reason) => {\n" \
+ " @transformStreamErrorWritableAndUnblockWrite(stream, reason);\n" \
+ " return @Promise.@resolve();\n" \
+ " };\n" \
+ " const underlyingSource = { };\n" \
+ " @putByIdDirectPrivate(underlyingSource, \"start\", startAlgorithm);\n" \
+ " @putByIdDirectPrivate(underlyingSource, \"pull\", pullAlgorithm);\n" \
+ " @putByIdDirectPrivate(underlyingSource, \"cancel\", cancelAlgorithm);\n" \
+ " const options = { };\n" \
+ " @putByIdDirectPrivate(options, \"size\", readableSizeAlgorithm);\n" \
+ " @putByIdDirectPrivate(options, \"highWaterMark\", readableHighWaterMark);\n" \
+ " const readable = new @ReadableStream(underlyingSource, options);\n" \
+ "\n" \
+ " //\n" \
+ " @putByIdDirectPrivate(stream, \"writable\", writable);\n" \
+ " //\n" \
+ " @putByIdDirectPrivate(stream, \"internalWritable\", @getInternalWritableStream(writable));\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"readable\", readable);\n" \
+ " @putByIdDirectPrivate(stream, \"backpressure\", @undefined);\n" \
+ " @putByIdDirectPrivate(stream, \"backpressureChangePromise\", @undefined);\n" \
+ "\n" \
+ " @transformStreamSetBackpressure(stream, true);\n" \
+ " @putByIdDirectPrivate(stream, \"controller\", @undefined);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsTransformStreamErrorCodeLength = 330;
+static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsTransformStreamErrorCode =
+ "(function (stream, e)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const readable = @getByIdDirectPrivate(stream, \"readable\");\n" \
+ " const readableController = @getByIdDirectPrivate(readable, \"readableStreamController\");\n" \
+ " @readableStreamDefaultControllerError(readableController, e);\n" \
+ "\n" \
+ " @transformStreamErrorWritableAndUnblockWrite(stream, e);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeLength = 431;
+static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode =
+ "(function (stream, e)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(stream, \"controller\"));\n" \
+ "\n" \
+ " const writable = @getByIdDirectPrivate(stream, \"internalWritable\");\n" \
+ " @writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(writable, \"controller\"), e);\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(stream, \"backpressure\"))\n" \
+ " @transformStreamSetBackpressure(stream, false);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsTransformStreamSetBackpressureCodeLength = 498;
+static const JSC::Intrinsic s_transformStreamInternalsTransformStreamSetBackpressureCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsTransformStreamSetBackpressureCode =
+ "(function (stream, backpressure)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"backpressure\") !== backpressure);\n" \
+ "\n" \
+ " const backpressureChangePromise = @getByIdDirectPrivate(stream, \"backpressureChangePromise\");\n" \
+ " if (backpressureChangePromise !== @undefined)\n" \
+ " backpressureChangePromise.@resolve.@call();\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"backpressureChangePromise\", @newPromiseCapability(@Promise));\n" \
+ " @putByIdDirectPrivate(stream, \"backpressure\", backpressure);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeLength = 478;
+static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerCode =
+ "(function (stream, controller, transformAlgorithm, flushAlgorithm)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@isTransformStream(stream));\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"controller\") === @undefined);\n" \
+ "\n" \
+ " @putByIdDirectPrivate(controller, \"stream\", stream);\n" \
+ " @putByIdDirectPrivate(stream, \"controller\", controller);\n" \
+ " @putByIdDirectPrivate(controller, \"transformAlgorithm\", transformAlgorithm);\n" \
+ " @putByIdDirectPrivate(controller, \"flushAlgorithm\", flushAlgorithm);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 940;
+static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode =
+ "(function (stream, transformer, transformerDict)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const controller = new @TransformStreamDefaultController();\n" \
+ " let transformAlgorithm = (chunk) => {\n" \
+ " try {\n" \
+ " @transformStreamDefaultControllerEnqueue(controller, chunk);\n" \
+ " } catch (e) {\n" \
+ " return @Promise.@reject(e);\n" \
+ " }\n" \
+ " return @Promise.@resolve();\n" \
+ " };\n" \
+ " let flushAlgorithm = () => { return @Promise.@resolve(); };\n" \
+ "\n" \
+ " if (\"transform\" in transformerDict)\n" \
+ " transformAlgorithm = (chunk) => {\n" \
+ " return @promiseInvokeOrNoopMethod(transformer, transformerDict[\"transform\"], [chunk, controller]);\n" \
+ " };\n" \
+ "\n" \
+ " if (\"flush\" in transformerDict) {\n" \
+ " flushAlgorithm = () => {\n" \
+ " return @promiseInvokeOrNoopMethod(transformer, transformerDict[\"flush\"], [controller]);\n" \
+ " };\n" \
+ " }\n" \
+ "\n" \
+ " @setUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeLength = 190;
+static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " //\n" \
+ " @putByIdDirectPrivate(controller, \"transformAlgorithm\", true);\n" \
+ " @putByIdDirectPrivate(controller, \"flushAlgorithm\", @undefined);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeLength = 979;
+static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode =
+ "(function (controller, chunk)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"stream\");\n" \
+ " const readable = @getByIdDirectPrivate(stream, \"readable\");\n" \
+ " const readableController = @getByIdDirectPrivate(readable, \"readableStreamController\");\n" \
+ "\n" \
+ " @assert(readableController !== @undefined);\n" \
+ " if (!@readableStreamDefaultControllerCanCloseOrEnqueue(readableController))\n" \
+ " @throwTypeError(\"TransformStream.readable cannot close or enqueue\");\n" \
+ "\n" \
+ " try {\n" \
+ " @readableStreamDefaultControllerEnqueue(readableController, chunk);\n" \
+ " } catch (e) {\n" \
+ " @transformStreamErrorWritableAndUnblockWrite(stream, e);\n" \
+ " throw @getByIdDirectPrivate(readable, \"storedError\");\n" \
+ " }\n" \
+ "\n" \
+ " const backpressure = !@readableStreamDefaultControllerShouldCallPull(readableController);\n" \
+ " if (backpressure !== @getByIdDirectPrivate(stream, \"backpressure\")) {\n" \
+ " @assert(backpressure);\n" \
+ " @transformStreamSetBackpressure(stream, true);\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeLength = 125;
+static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsTransformStreamDefaultControllerErrorCode =
+ "(function (controller, e)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @transformStreamError(@getByIdDirectPrivate(controller, \"stream\"), e);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength = 500;
+static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode =
+ "(function (controller, chunk)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const promiseCapability = @newPromiseCapability(@Promise);\n" \
+ "\n" \
+ " const transformPromise = @getByIdDirectPrivate(controller, \"transformAlgorithm\").@call(@undefined, chunk);\n" \
+ " transformPromise.@then(() => {\n" \
+ " promiseCapability.@resolve();\n" \
+ " }, (r) => {\n" \
+ " @transformStreamError(@getByIdDirectPrivate(controller, \"stream\"), r);\n" \
+ " promiseCapability.@reject.@call(@undefined, r);\n" \
+ " });\n" \
+ " return promiseCapability.@promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength = 554;
+static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"stream\");\n" \
+ " const readable = @getByIdDirectPrivate(stream, \"readable\");\n" \
+ " const readableController = @getByIdDirectPrivate(readable, \"readableStreamController\");\n" \
+ "\n" \
+ " //\n" \
+ " if (@readableStreamDefaultControllerCanCloseOrEnqueue(readableController))\n" \
+ " @readableStreamDefaultControllerClose(readableController);\n" \
+ " const error = @makeTypeError(\"the stream has been terminated\");\n" \
+ " @transformStreamErrorWritableAndUnblockWrite(stream, error);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeLength = 1373;
+static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode =
+ "(function (stream, chunk)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const writable = @getByIdDirectPrivate(stream, \"internalWritable\");\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(writable, \"state\") === \"writable\");\n" \
+ "\n" \
+ " const controller = @getByIdDirectPrivate(stream, \"controller\");\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(stream, \"backpressure\")) {\n" \
+ " const promiseCapability = @newPromiseCapability(@Promise);\n" \
+ "\n" \
+ " const backpressureChangePromise = @getByIdDirectPrivate(stream, \"backpressureChangePromise\");\n" \
+ " @assert(backpressureChangePromise !== @undefined);\n" \
+ " backpressureChangePromise.@promise.@then(() => {\n" \
+ " const state = @getByIdDirectPrivate(writable, \"state\");\n" \
+ " if (state === \"erroring\") {\n" \
+ " promiseCapability.@reject.@call(@undefined, @getByIdDirectPrivate(writable, \"storedError\"));\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " @assert(state === \"writable\");\n" \
+ " @transformStreamDefaultControllerPerformTransform(controller, chunk).@then(() => {\n" \
+ " promiseCapability.@resolve();\n" \
+ " }, (e) => {\n" \
+ " promiseCapability.@reject.@call(@undefined, e);\n" \
+ " });\n" \
+ " }, (e) => {\n" \
+ " promiseCapability.@reject.@call(@undefined, e);\n" \
+ " });\n" \
+ "\n" \
+ " return promiseCapability.@promise;\n" \
+ " }\n" \
+ " return @transformStreamDefaultControllerPerformTransform(controller, chunk);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeLength = 126;
+static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode =
+ "(function (stream, reason)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @transformStreamError(stream, reason);\n" \
+ " return @Promise.@resolve();\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeLength = 1295;
+static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ " const readable = @getByIdDirectPrivate(stream, \"readable\");\n" \
+ " const controller = @getByIdDirectPrivate(stream, \"controller\");\n" \
+ " const readableController = @getByIdDirectPrivate(readable, \"readableStreamController\");\n" \
+ "\n" \
+ " const flushAlgorithm = @getByIdDirectPrivate(controller, \"flushAlgorithm\");\n" \
+ " @assert(flushAlgorithm !== @undefined);\n" \
+ " const flushPromise = @getByIdDirectPrivate(controller, \"flushAlgorithm\").@call();\n" \
+ " @transformStreamDefaultControllerClearAlgorithms(controller);\n" \
+ "\n" \
+ " const promiseCapability = @newPromiseCapability(@Promise);\n" \
+ " flushPromise.@then(() => {\n" \
+ " if (@getByIdDirectPrivate(readable, \"state\") === @streamErrored) {\n" \
+ " promiseCapability.@reject.@call(@undefined, @getByIdDirectPrivate(readable, \"storedError\"));\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " //\n" \
+ " if (@readableStreamDefaultControllerCanCloseOrEnqueue(readableController))\n" \
+ " @readableStreamDefaultControllerClose(readableController);\n" \
+ " promiseCapability.@resolve();\n" \
+ " }, (r) => {\n" \
+ " @transformStreamError(@getByIdDirectPrivate(controller, \"stream\"), r);\n" \
+ " promiseCapability.@reject.@call(@undefined, @getByIdDirectPrivate(readable, \"storedError\"));\n" \
+ " });\n" \
+ " return promiseCapability.@promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeLength = 325;
+static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"backpressure\"));\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"backpressureChangePromise\") !== @undefined);\n" \
+ "\n" \
+ " @transformStreamSetBackpressure(stream, false);\n" \
+ "\n" \
+ " return @getByIdDirectPrivate(stream, \"backpressureChangePromise\").@promise;\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().transformStreamInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().transformStreamInternalsBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/TransformStreamInternalsBuiltins.h b/src/javascript/jsc/bindings/TransformStreamInternalsBuiltins.h
new file mode 100644
index 000000000..ad19d0a7e
--- /dev/null
+++ b/src/javascript/jsc/bindings/TransformStreamInternalsBuiltins.h
@@ -0,0 +1,300 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* TransformStreamInternals */
+extern const char* const s_transformStreamInternalsIsTransformStreamCode;
+extern const int s_transformStreamInternalsIsTransformStreamCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsIsTransformStreamCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsIsTransformStreamCodeConstructorKind;
+extern const char* const s_transformStreamInternalsIsTransformStreamDefaultControllerCode;
+extern const int s_transformStreamInternalsIsTransformStreamDefaultControllerCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsIsTransformStreamDefaultControllerCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsIsTransformStreamDefaultControllerCodeConstructorKind;
+extern const char* const s_transformStreamInternalsCreateTransformStreamCode;
+extern const int s_transformStreamInternalsCreateTransformStreamCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsCreateTransformStreamCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsCreateTransformStreamCodeConstructorKind;
+extern const char* const s_transformStreamInternalsInitializeTransformStreamCode;
+extern const int s_transformStreamInternalsInitializeTransformStreamCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsInitializeTransformStreamCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsInitializeTransformStreamCodeConstructorKind;
+extern const char* const s_transformStreamInternalsTransformStreamErrorCode;
+extern const int s_transformStreamInternalsTransformStreamErrorCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorCodeConstructorKind;
+extern const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode;
+extern const int s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructorKind;
+extern const char* const s_transformStreamInternalsTransformStreamSetBackpressureCode;
+extern const int s_transformStreamInternalsTransformStreamSetBackpressureCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructorKind;
+extern const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerCode;
+extern const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeConstructorKind;
+extern const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode;
+extern const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructorKind;
+extern const char* const s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCode;
+extern const int s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructorKind;
+extern const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode;
+extern const int s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeConstructorKind;
+extern const char* const s_transformStreamInternalsTransformStreamDefaultControllerErrorCode;
+extern const int s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructorKind;
+extern const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode;
+extern const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeConstructorKind;
+extern const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode;
+extern const int s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructorKind;
+extern const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode;
+extern const int s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructorKind;
+extern const char* const s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode;
+extern const int s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructorKind;
+extern const char* const s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode;
+extern const int s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructorKind;
+extern const char* const s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCode;
+extern const int s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeLength;
+extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility;
+extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructorKind;
+
+#define WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_DATA(macro) \
+ macro(isTransformStream, transformStreamInternalsIsTransformStream, 1) \
+ macro(isTransformStreamDefaultController, transformStreamInternalsIsTransformStreamDefaultController, 1) \
+ macro(createTransformStream, transformStreamInternalsCreateTransformStream, 7) \
+ macro(initializeTransformStream, transformStreamInternalsInitializeTransformStream, 6) \
+ macro(transformStreamError, transformStreamInternalsTransformStreamError, 2) \
+ macro(transformStreamErrorWritableAndUnblockWrite, transformStreamInternalsTransformStreamErrorWritableAndUnblockWrite, 2) \
+ macro(transformStreamSetBackpressure, transformStreamInternalsTransformStreamSetBackpressure, 2) \
+ macro(setUpTransformStreamDefaultController, transformStreamInternalsSetUpTransformStreamDefaultController, 4) \
+ macro(setUpTransformStreamDefaultControllerFromTransformer, transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformer, 3) \
+ macro(transformStreamDefaultControllerClearAlgorithms, transformStreamInternalsTransformStreamDefaultControllerClearAlgorithms, 1) \
+ macro(transformStreamDefaultControllerEnqueue, transformStreamInternalsTransformStreamDefaultControllerEnqueue, 2) \
+ macro(transformStreamDefaultControllerError, transformStreamInternalsTransformStreamDefaultControllerError, 2) \
+ macro(transformStreamDefaultControllerPerformTransform, transformStreamInternalsTransformStreamDefaultControllerPerformTransform, 2) \
+ macro(transformStreamDefaultControllerTerminate, transformStreamInternalsTransformStreamDefaultControllerTerminate, 1) \
+ macro(transformStreamDefaultSinkWriteAlgorithm, transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithm, 2) \
+ macro(transformStreamDefaultSinkAbortAlgorithm, transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithm, 2) \
+ macro(transformStreamDefaultSinkCloseAlgorithm, transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithm, 1) \
+ macro(transformStreamDefaultSourcePullAlgorithm, transformStreamInternalsTransformStreamDefaultSourcePullAlgorithm, 1) \
+
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_ISTRANSFORMSTREAM 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_ISTRANSFORMSTREAMDEFAULTCONTROLLER 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_CREATETRANSFORMSTREAM 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_INITIALIZETRANSFORMSTREAM 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMERROR 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMERRORWRITABLEANDUNBLOCKWRITE 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMSETBACKPRESSURE 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_SETUPTRANSFORMSTREAMDEFAULTCONTROLLER 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_SETUPTRANSFORMSTREAMDEFAULTCONTROLLERFROMTRANSFORMER 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERCLEARALGORITHMS 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERENQUEUE 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERERROR 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERPERFORMTRANSFORM 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERTERMINATE 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTSINKWRITEALGORITHM 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTSINKABORTALGORITHM 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTSINKCLOSEALGORITHM 1
+#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTSOURCEPULLALGORITHM 1
+
+#define WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(macro) \
+ macro(transformStreamInternalsIsTransformStreamCode, isTransformStream, ASCIILiteral(), s_transformStreamInternalsIsTransformStreamCodeLength) \
+ macro(transformStreamInternalsIsTransformStreamDefaultControllerCode, isTransformStreamDefaultController, ASCIILiteral(), s_transformStreamInternalsIsTransformStreamDefaultControllerCodeLength) \
+ macro(transformStreamInternalsCreateTransformStreamCode, createTransformStream, ASCIILiteral(), s_transformStreamInternalsCreateTransformStreamCodeLength) \
+ macro(transformStreamInternalsInitializeTransformStreamCode, initializeTransformStream, ASCIILiteral(), s_transformStreamInternalsInitializeTransformStreamCodeLength) \
+ macro(transformStreamInternalsTransformStreamErrorCode, transformStreamError, ASCIILiteral(), s_transformStreamInternalsTransformStreamErrorCodeLength) \
+ macro(transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode, transformStreamErrorWritableAndUnblockWrite, ASCIILiteral(), s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeLength) \
+ macro(transformStreamInternalsTransformStreamSetBackpressureCode, transformStreamSetBackpressure, ASCIILiteral(), s_transformStreamInternalsTransformStreamSetBackpressureCodeLength) \
+ macro(transformStreamInternalsSetUpTransformStreamDefaultControllerCode, setUpTransformStreamDefaultController, ASCIILiteral(), s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeLength) \
+ macro(transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode, setUpTransformStreamDefaultControllerFromTransformer, ASCIILiteral(), s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength) \
+ macro(transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCode, transformStreamDefaultControllerClearAlgorithms, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeLength) \
+ macro(transformStreamInternalsTransformStreamDefaultControllerEnqueueCode, transformStreamDefaultControllerEnqueue, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeLength) \
+ macro(transformStreamInternalsTransformStreamDefaultControllerErrorCode, transformStreamDefaultControllerError, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeLength) \
+ macro(transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode, transformStreamDefaultControllerPerformTransform, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength) \
+ macro(transformStreamInternalsTransformStreamDefaultControllerTerminateCode, transformStreamDefaultControllerTerminate, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength) \
+ macro(transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode, transformStreamDefaultSinkWriteAlgorithm, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeLength) \
+ macro(transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode, transformStreamDefaultSinkAbortAlgorithm, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeLength) \
+ macro(transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode, transformStreamDefaultSinkCloseAlgorithm, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeLength) \
+ macro(transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCode, transformStreamDefaultSourcePullAlgorithm, ASCIILiteral(), s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeLength) \
+
+#define WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \
+ macro(createTransformStream) \
+ macro(initializeTransformStream) \
+ macro(isTransformStream) \
+ macro(isTransformStreamDefaultController) \
+ macro(setUpTransformStreamDefaultController) \
+ macro(setUpTransformStreamDefaultControllerFromTransformer) \
+ macro(transformStreamDefaultControllerClearAlgorithms) \
+ macro(transformStreamDefaultControllerEnqueue) \
+ macro(transformStreamDefaultControllerError) \
+ macro(transformStreamDefaultControllerPerformTransform) \
+ macro(transformStreamDefaultControllerTerminate) \
+ macro(transformStreamDefaultSinkAbortAlgorithm) \
+ macro(transformStreamDefaultSinkCloseAlgorithm) \
+ macro(transformStreamDefaultSinkWriteAlgorithm) \
+ macro(transformStreamDefaultSourcePullAlgorithm) \
+ macro(transformStreamError) \
+ macro(transformStreamErrorWritableAndUnblockWrite) \
+ macro(transformStreamSetBackpressure) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class TransformStreamInternalsBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit TransformStreamInternalsBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_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_TRANSFORMSTREAMINTERNALS_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_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* TransformStreamInternalsBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void TransformStreamInternalsBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+class TransformStreamInternalsBuiltinFunctions {
+public:
+ explicit TransformStreamInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { }
+
+ void init(JSC::JSGlobalObject&);
+ template<typename Visitor> void visit(Visitor&);
+
+public:
+ JSC::VM& m_vm;
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \
+ JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function;
+ WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+};
+
+inline void TransformStreamInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
+{
+#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
+ m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
+ WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION)
+#undef EXPORT_FUNCTION
+}
+
+template<typename Visitor>
+inline void TransformStreamInternalsBuiltinFunctions::visit(Visitor& visitor)
+{
+#define VISIT_FUNCTION(name) visitor.append(m_##name##Function);
+ WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION)
+#undef VISIT_FUNCTION
+}
+
+template void TransformStreamInternalsBuiltinFunctions::visit(JSC::AbstractSlotVisitor&);
+template void TransformStreamInternalsBuiltinFunctions::visit(JSC::SlotVisitor&);
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp b/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp
index 310df6a35..159e2f45b 100644
--- a/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp
+++ b/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.cpp
@@ -1,5 +1,10 @@
/*
- * Copyright (c) 2016 Apple Inc. All rights reserved.
+ * 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
@@ -42,6 +47,11 @@ namespace WebCore {
JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm)
: m_vm(vm)
+ , m_readableByteStreamInternals(m_vm)
+ , m_readableStreamInternals(m_vm)
+ , m_streamInternals(m_vm)
+ , m_transformStreamInternals(m_vm)
+ , m_writableStreamInternals(m_vm)
{
UNUSED_PARAM(vm);
}
@@ -49,6 +59,11 @@ JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm)
template<typename Visitor>
void JSBuiltinInternalFunctions::visit(Visitor& visitor)
{
+ m_readableByteStreamInternals.visit(visitor);
+ m_readableStreamInternals.visit(visitor);
+ m_streamInternals.visit(visitor);
+ m_transformStreamInternals.visit(visitor);
+ m_writableStreamInternals.visit(visitor);
UNUSED_PARAM(visitor);
}
@@ -58,11 +73,41 @@ template void JSBuiltinInternalFunctions::visit(SlotVisitor&);
SUPPRESS_ASAN void JSBuiltinInternalFunctions::initialize(JSDOMGlobalObject& globalObject)
{
UNUSED_PARAM(globalObject);
+ m_readableByteStreamInternals.init(globalObject);
+ m_readableStreamInternals.init(globalObject);
+ m_streamInternals.init(globalObject);
+ m_transformStreamInternals.init(globalObject);
+ m_writableStreamInternals.init(globalObject);
JSVMClientData& clientData = *static_cast<JSVMClientData*>(m_vm.clientData);
JSDOMGlobalObject::GlobalPropertyInfo staticGlobals[] = {
+#define DECLARE_GLOBAL_STATIC(name) \
+ JSDOMGlobalObject::GlobalPropertyInfo( \
+ clientData.builtinFunctions().readableByteStreamInternalsBuiltins().name##PrivateName(), readableByteStreamInternals().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly),
+ WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
+#undef DECLARE_GLOBAL_STATIC
+#define DECLARE_GLOBAL_STATIC(name) \
+ JSDOMGlobalObject::GlobalPropertyInfo( \
+ clientData.builtinFunctions().readableStreamInternalsBuiltins().name##PrivateName(), readableStreamInternals().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly),
+ WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
+#undef DECLARE_GLOBAL_STATIC
+#define DECLARE_GLOBAL_STATIC(name) \
+ JSDOMGlobalObject::GlobalPropertyInfo( \
+ clientData.builtinFunctions().streamInternalsBuiltins().name##PrivateName(), streamInternals().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly),
+ WEBCORE_FOREACH_STREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
+#undef DECLARE_GLOBAL_STATIC
+#define DECLARE_GLOBAL_STATIC(name) \
+ JSDOMGlobalObject::GlobalPropertyInfo( \
+ clientData.builtinFunctions().transformStreamInternalsBuiltins().name##PrivateName(), transformStreamInternals().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly),
+ WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
+#undef DECLARE_GLOBAL_STATIC
+#define DECLARE_GLOBAL_STATIC(name) \
+ JSDOMGlobalObject::GlobalPropertyInfo( \
+ clientData.builtinFunctions().writableStreamInternalsBuiltins().name##PrivateName(), writableStreamInternals().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly),
+ WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC)
+#undef DECLARE_GLOBAL_STATIC
};
- //globalObject.addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
+ globalObject.addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
UNUSED_PARAM(clientData);
}
diff --git a/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h b/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h
index bb7b79d89..c52f65d85 100644
--- a/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h
+++ b/src/javascript/jsc/bindings/WebCoreJSBuiltinInternals.h
@@ -1,7 +1,12 @@
//clang-format off
namespace Zig { class GlobalObject; }
/*
- * Copyright (c) 2016 Apple Inc. All rights reserved.
+ * 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
@@ -32,6 +37,11 @@ namespace Zig { class GlobalObject; }
#pragma once
+#include "ReadableByteStreamInternalsBuiltins.h"
+#include "ReadableStreamInternalsBuiltins.h"
+#include "StreamInternalsBuiltins.h"
+#include "TransformStreamInternalsBuiltins.h"
+#include "WritableStreamInternalsBuiltins.h"
#include <JavaScriptCore/VM.h>
#include <JavaScriptCore/WeakInlines.h>
@@ -46,9 +56,19 @@ public:
template<typename Visitor> void visit(Visitor&);
void initialize(JSDOMGlobalObject&);
+ ReadableByteStreamInternalsBuiltinFunctions& readableByteStreamInternals() { return m_readableByteStreamInternals; }
+ ReadableStreamInternalsBuiltinFunctions& readableStreamInternals() { return m_readableStreamInternals; }
+ StreamInternalsBuiltinFunctions& streamInternals() { return m_streamInternals; }
+ TransformStreamInternalsBuiltinFunctions& transformStreamInternals() { return m_transformStreamInternals; }
+ WritableStreamInternalsBuiltinFunctions& writableStreamInternals() { return m_writableStreamInternals; }
private:
JSC::VM& m_vm;
+ ReadableByteStreamInternalsBuiltinFunctions m_readableByteStreamInternals;
+ ReadableStreamInternalsBuiltinFunctions m_readableStreamInternals;
+ StreamInternalsBuiltinFunctions m_streamInternals;
+ TransformStreamInternalsBuiltinFunctions m_transformStreamInternals;
+ WritableStreamInternalsBuiltinFunctions m_writableStreamInternals;
};
} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/WebCoreJSBuiltins.h b/src/javascript/jsc/bindings/WebCoreJSBuiltins.h
index 2c136b3ac..0650e1613 100644
--- a/src/javascript/jsc/bindings/WebCoreJSBuiltins.h
+++ b/src/javascript/jsc/bindings/WebCoreJSBuiltins.h
@@ -1,5 +1,10 @@
/*
- * Copyright (c) 2016 Apple Inc. All rights reserved.
+ * 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
@@ -30,9 +35,26 @@
#pragma once
+#include "ByteLengthQueuingStrategyBuiltins.h"
+#include "CountQueuingStrategyBuiltins.h"
#include "JSBufferConstructorBuiltins.h"
#include "JSBufferPrototypeBuiltins.h"
#include "JSZigGlobalObjectBuiltins.h"
+#include "ReadableByteStreamControllerBuiltins.h"
+#include "ReadableByteStreamInternalsBuiltins.h"
+#include "ReadableStreamBYOBReaderBuiltins.h"
+#include "ReadableStreamBYOBRequestBuiltins.h"
+#include "ReadableStreamBuiltins.h"
+#include "ReadableStreamDefaultControllerBuiltins.h"
+#include "ReadableStreamDefaultReaderBuiltins.h"
+#include "ReadableStreamInternalsBuiltins.h"
+#include "StreamInternalsBuiltins.h"
+#include "TransformStreamBuiltins.h"
+#include "TransformStreamDefaultControllerBuiltins.h"
+#include "TransformStreamInternalsBuiltins.h"
+#include "WritableStreamDefaultControllerBuiltins.h"
+#include "WritableStreamDefaultWriterBuiltins.h"
+#include "WritableStreamInternalsBuiltins.h"
#include <JavaScriptCore/VM.h>
namespace WebCore {
@@ -41,21 +63,77 @@ class JSBuiltinFunctions {
public:
explicit JSBuiltinFunctions(JSC::VM& vm)
: m_vm(vm)
+ , m_byteLengthQueuingStrategyBuiltins(m_vm)
+ , m_countQueuingStrategyBuiltins(m_vm)
, m_jsBufferConstructorBuiltins(m_vm)
, m_jsBufferPrototypeBuiltins(m_vm)
, m_jsZigGlobalObjectBuiltins(m_vm)
+ , m_readableByteStreamControllerBuiltins(m_vm)
+ , m_readableByteStreamInternalsBuiltins(m_vm)
+ , m_readableStreamBuiltins(m_vm)
+ , m_readableStreamBYOBReaderBuiltins(m_vm)
+ , m_readableStreamBYOBRequestBuiltins(m_vm)
+ , m_readableStreamDefaultControllerBuiltins(m_vm)
+ , m_readableStreamDefaultReaderBuiltins(m_vm)
+ , m_readableStreamInternalsBuiltins(m_vm)
+ , m_streamInternalsBuiltins(m_vm)
+ , m_transformStreamBuiltins(m_vm)
+ , m_transformStreamDefaultControllerBuiltins(m_vm)
+ , m_transformStreamInternalsBuiltins(m_vm)
+ , m_writableStreamDefaultControllerBuiltins(m_vm)
+ , m_writableStreamDefaultWriterBuiltins(m_vm)
+ , m_writableStreamInternalsBuiltins(m_vm)
{
+ m_readableByteStreamInternalsBuiltins.exportNames();
+ m_readableStreamInternalsBuiltins.exportNames();
+ m_streamInternalsBuiltins.exportNames();
+ m_transformStreamInternalsBuiltins.exportNames();
+ m_writableStreamInternalsBuiltins.exportNames();
}
+ ByteLengthQueuingStrategyBuiltinsWrapper& byteLengthQueuingStrategyBuiltins() { return m_byteLengthQueuingStrategyBuiltins; }
+ CountQueuingStrategyBuiltinsWrapper& countQueuingStrategyBuiltins() { return m_countQueuingStrategyBuiltins; }
JSBufferConstructorBuiltinsWrapper& jsBufferConstructorBuiltins() { return m_jsBufferConstructorBuiltins; }
JSBufferPrototypeBuiltinsWrapper& jsBufferPrototypeBuiltins() { return m_jsBufferPrototypeBuiltins; }
JSZigGlobalObjectBuiltinsWrapper& jsZigGlobalObjectBuiltins() { return m_jsZigGlobalObjectBuiltins; }
+ ReadableByteStreamControllerBuiltinsWrapper& readableByteStreamControllerBuiltins() { return m_readableByteStreamControllerBuiltins; }
+ ReadableByteStreamInternalsBuiltinsWrapper& readableByteStreamInternalsBuiltins() { return m_readableByteStreamInternalsBuiltins; }
+ ReadableStreamBuiltinsWrapper& readableStreamBuiltins() { return m_readableStreamBuiltins; }
+ ReadableStreamBYOBReaderBuiltinsWrapper& readableStreamBYOBReaderBuiltins() { return m_readableStreamBYOBReaderBuiltins; }
+ ReadableStreamBYOBRequestBuiltinsWrapper& readableStreamBYOBRequestBuiltins() { return m_readableStreamBYOBRequestBuiltins; }
+ ReadableStreamDefaultControllerBuiltinsWrapper& readableStreamDefaultControllerBuiltins() { return m_readableStreamDefaultControllerBuiltins; }
+ ReadableStreamDefaultReaderBuiltinsWrapper& readableStreamDefaultReaderBuiltins() { return m_readableStreamDefaultReaderBuiltins; }
+ ReadableStreamInternalsBuiltinsWrapper& readableStreamInternalsBuiltins() { return m_readableStreamInternalsBuiltins; }
+ StreamInternalsBuiltinsWrapper& streamInternalsBuiltins() { return m_streamInternalsBuiltins; }
+ TransformStreamBuiltinsWrapper& transformStreamBuiltins() { return m_transformStreamBuiltins; }
+ TransformStreamDefaultControllerBuiltinsWrapper& transformStreamDefaultControllerBuiltins() { return m_transformStreamDefaultControllerBuiltins; }
+ TransformStreamInternalsBuiltinsWrapper& transformStreamInternalsBuiltins() { return m_transformStreamInternalsBuiltins; }
+ WritableStreamDefaultControllerBuiltinsWrapper& writableStreamDefaultControllerBuiltins() { return m_writableStreamDefaultControllerBuiltins; }
+ WritableStreamDefaultWriterBuiltinsWrapper& writableStreamDefaultWriterBuiltins() { return m_writableStreamDefaultWriterBuiltins; }
+ WritableStreamInternalsBuiltinsWrapper& writableStreamInternalsBuiltins() { return m_writableStreamInternalsBuiltins; }
private:
JSC::VM& m_vm;
+ ByteLengthQueuingStrategyBuiltinsWrapper m_byteLengthQueuingStrategyBuiltins;
+ CountQueuingStrategyBuiltinsWrapper m_countQueuingStrategyBuiltins;
JSBufferConstructorBuiltinsWrapper m_jsBufferConstructorBuiltins;
JSBufferPrototypeBuiltinsWrapper m_jsBufferPrototypeBuiltins;
JSZigGlobalObjectBuiltinsWrapper m_jsZigGlobalObjectBuiltins;
+ ReadableByteStreamControllerBuiltinsWrapper m_readableByteStreamControllerBuiltins;
+ ReadableByteStreamInternalsBuiltinsWrapper m_readableByteStreamInternalsBuiltins;
+ ReadableStreamBuiltinsWrapper m_readableStreamBuiltins;
+ ReadableStreamBYOBReaderBuiltinsWrapper m_readableStreamBYOBReaderBuiltins;
+ ReadableStreamBYOBRequestBuiltinsWrapper m_readableStreamBYOBRequestBuiltins;
+ ReadableStreamDefaultControllerBuiltinsWrapper m_readableStreamDefaultControllerBuiltins;
+ ReadableStreamDefaultReaderBuiltinsWrapper m_readableStreamDefaultReaderBuiltins;
+ ReadableStreamInternalsBuiltinsWrapper m_readableStreamInternalsBuiltins;
+ StreamInternalsBuiltinsWrapper m_streamInternalsBuiltins;
+ TransformStreamBuiltinsWrapper m_transformStreamBuiltins;
+ TransformStreamDefaultControllerBuiltinsWrapper m_transformStreamDefaultControllerBuiltins;
+ TransformStreamInternalsBuiltinsWrapper m_transformStreamInternalsBuiltins;
+ WritableStreamDefaultControllerBuiltinsWrapper m_writableStreamDefaultControllerBuiltins;
+ WritableStreamDefaultWriterBuiltinsWrapper m_writableStreamDefaultWriterBuiltins;
+ WritableStreamInternalsBuiltinsWrapper m_writableStreamInternalsBuiltins;
};
} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/WritableStreamDefaultControllerBuiltins.cpp b/src/javascript/jsc/bindings/WritableStreamDefaultControllerBuiltins.cpp
new file mode 100644
index 000000000..c259364d7
--- /dev/null
+++ b/src/javascript/jsc/bindings/WritableStreamDefaultControllerBuiltins.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 "WritableStreamDefaultControllerBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeLength = 482;
+static const JSC::Intrinsic s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @putByIdDirectPrivate(this, \"queue\", @newQueue());\n" \
+ " @putByIdDirectPrivate(this, \"abortSteps\", (reason) => {\n" \
+ " const result = @getByIdDirectPrivate(this, \"abortAlgorithm\").@call(@undefined, reason);\n" \
+ " @writableStreamDefaultControllerClearAlgorithms(this);\n" \
+ " return result;\n" \
+ " });\n" \
+ "\n" \
+ " @putByIdDirectPrivate(this, \"errorSteps\", () => {\n" \
+ " @resetQueue(@getByIdDirectPrivate(this, \"queue\"));\n" \
+ " });\n" \
+ "\n" \
+ " return this;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamDefaultControllerErrorCodeLength = 372;
+static const JSC::Intrinsic s_writableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamDefaultControllerErrorCode =
+ "(function (e)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(this, \"abortSteps\") === @undefined)\n" \
+ " throw @makeThisTypeError(\"WritableStreamDefaultController\", \"error\");\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(this, \"stream\");\n" \
+ " if (@getByIdDirectPrivate(stream, \"state\") !== \"writable\")\n" \
+ " return;\n" \
+ " @writableStreamDefaultControllerError(this, e);\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().writableStreamDefaultControllerBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().writableStreamDefaultControllerBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/WritableStreamDefaultControllerBuiltins.h b/src/javascript/jsc/bindings/WritableStreamDefaultControllerBuiltins.h
new file mode 100644
index 000000000..5ffd82b88
--- /dev/null
+++ b/src/javascript/jsc/bindings/WritableStreamDefaultControllerBuiltins.h
@@ -0,0 +1,135 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* WritableStreamDefaultController */
+extern const char* const s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCode;
+extern const int s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeLength;
+extern const JSC::ConstructAbility s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeConstructorKind;
+extern const char* const s_writableStreamDefaultControllerErrorCode;
+extern const int s_writableStreamDefaultControllerErrorCodeLength;
+extern const JSC::ConstructAbility s_writableStreamDefaultControllerErrorCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamDefaultControllerErrorCodeConstructorKind;
+
+#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_DATA(macro) \
+ macro(initializeWritableStreamDefaultController, writableStreamDefaultControllerInitializeWritableStreamDefaultController, 0) \
+ macro(error, writableStreamDefaultControllerError, 1) \
+
+#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTCONTROLLER_INITIALIZEWRITABLESTREAMDEFAULTCONTROLLER 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTCONTROLLER_ERROR 1
+
+#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(macro) \
+ macro(writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCode, initializeWritableStreamDefaultController, ASCIILiteral(), s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeLength) \
+ macro(writableStreamDefaultControllerErrorCode, error, ASCIILiteral(), s_writableStreamDefaultControllerErrorCodeLength) \
+
+#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(macro) \
+ macro(error) \
+ macro(initializeWritableStreamDefaultController) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class WritableStreamDefaultControllerBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit WritableStreamDefaultControllerBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_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_WRITABLESTREAMDEFAULTCONTROLLER_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_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* WritableStreamDefaultControllerBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void WritableStreamDefaultControllerBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/WritableStreamDefaultWriterBuiltins.cpp b/src/javascript/jsc/bindings/WritableStreamDefaultWriterBuiltins.cpp
new file mode 100644
index 000000000..160f7af20
--- /dev/null
+++ b/src/javascript/jsc/bindings/WritableStreamDefaultWriterBuiltins.cpp
@@ -0,0 +1,217 @@
+/*
+ * 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 "WritableStreamDefaultWriterBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeLength = 376;
+static const JSC::Intrinsic s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " //\n" \
+ " //\n" \
+ " const internalStream = @getInternalWritableStream(stream);\n" \
+ " if (internalStream)\n" \
+ " stream = internalStream;\n" \
+ "\n" \
+ " if (!@isWritableStream(stream))\n" \
+ " @throwTypeError(\"WritableStreamDefaultWriter constructor takes a WritableStream\");\n" \
+ "\n" \
+ " @setUpWritableStreamDefaultWriter(this, stream);\n" \
+ " return this;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamDefaultWriterClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamDefaultWriterClosedCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamDefaultWriterClosedCodeLength = 247;
+static const JSC::Intrinsic s_writableStreamDefaultWriterClosedCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamDefaultWriterClosedCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isWritableStreamDefaultWriter(this))\n" \
+ " return @Promise.@reject(@makeGetterTypeError(\"WritableStreamDefaultWriter\", \"closed\"));\n" \
+ "\n" \
+ " return @getByIdDirectPrivate(this, \"closedPromise\").@promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamDefaultWriterDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamDefaultWriterDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamDefaultWriterDesiredSizeCodeLength = 359;
+static const JSC::Intrinsic s_writableStreamDefaultWriterDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamDefaultWriterDesiredSizeCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isWritableStreamDefaultWriter(this))\n" \
+ " throw @makeThisTypeError(\"WritableStreamDefaultWriter\", \"desiredSize\");\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(this, \"stream\") === @undefined)\n" \
+ " @throwTypeError(\"WritableStreamDefaultWriter has no stream\");\n" \
+ "\n" \
+ " return @writableStreamDefaultWriterGetDesiredSize(this);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamDefaultWriterReadyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamDefaultWriterReadyCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamDefaultWriterReadyCodeLength = 243;
+static const JSC::Intrinsic s_writableStreamDefaultWriterReadyCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamDefaultWriterReadyCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isWritableStreamDefaultWriter(this))\n" \
+ " return @Promise.@reject(@makeThisTypeError(\"WritableStreamDefaultWriter\", \"ready\"));\n" \
+ "\n" \
+ " return @getByIdDirectPrivate(this, \"readyPromise\").@promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamDefaultWriterAbortCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamDefaultWriterAbortCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamDefaultWriterAbortCodeLength = 401;
+static const JSC::Intrinsic s_writableStreamDefaultWriterAbortCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamDefaultWriterAbortCode =
+ "(function (reason)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isWritableStreamDefaultWriter(this))\n" \
+ " return @Promise.@reject(@makeThisTypeError(\"WritableStreamDefaultWriter\", \"abort\"));\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(this, \"stream\") === @undefined)\n" \
+ " return @Promise.@reject(@makeTypeError(\"WritableStreamDefaultWriter has no stream\"));\n" \
+ "\n" \
+ " return @writableStreamDefaultWriterAbort(this, reason);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamDefaultWriterCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamDefaultWriterCloseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamDefaultWriterCloseCodeLength = 569;
+static const JSC::Intrinsic s_writableStreamDefaultWriterCloseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamDefaultWriterCloseCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isWritableStreamDefaultWriter(this))\n" \
+ " return @Promise.@reject(@makeThisTypeError(\"WritableStreamDefaultWriter\", \"close\"));\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(this, \"stream\");\n" \
+ " if (stream === @undefined)\n" \
+ " return @Promise.@reject(@makeTypeError(\"WritableStreamDefaultWriter has no stream\"));\n" \
+ "\n" \
+ " if (@writableStreamCloseQueuedOrInFlight(stream))\n" \
+ " return @Promise.@reject(@makeTypeError(\"WritableStreamDefaultWriter is being closed\"));\n" \
+ " \n" \
+ " return @writableStreamDefaultWriterClose(this);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamDefaultWriterReleaseLockCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamDefaultWriterReleaseLockCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamDefaultWriterReleaseLockCodeLength = 387;
+static const JSC::Intrinsic s_writableStreamDefaultWriterReleaseLockCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamDefaultWriterReleaseLockCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isWritableStreamDefaultWriter(this))\n" \
+ " throw @makeThisTypeError(\"WritableStreamDefaultWriter\", \"releaseLock\");\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(this, \"stream\");\n" \
+ " if (stream === @undefined)\n" \
+ " return;\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"writer\") !== @undefined);\n" \
+ " @writableStreamDefaultWriterRelease(this);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamDefaultWriterWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamDefaultWriterWriteCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamDefaultWriterWriteCodeLength = 399;
+static const JSC::Intrinsic s_writableStreamDefaultWriterWriteCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamDefaultWriterWriteCode =
+ "(function (chunk)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isWritableStreamDefaultWriter(this))\n" \
+ " return @Promise.@reject(@makeThisTypeError(\"WritableStreamDefaultWriter\", \"write\"));\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(this, \"stream\") === @undefined)\n" \
+ " return @Promise.@reject(@makeTypeError(\"WritableStreamDefaultWriter has no stream\"));\n" \
+ "\n" \
+ " return @writableStreamDefaultWriterWrite(this, chunk);\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().writableStreamDefaultWriterBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().writableStreamDefaultWriterBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/WritableStreamDefaultWriterBuiltins.h b/src/javascript/jsc/bindings/WritableStreamDefaultWriterBuiltins.h
new file mode 100644
index 000000000..28455eedf
--- /dev/null
+++ b/src/javascript/jsc/bindings/WritableStreamDefaultWriterBuiltins.h
@@ -0,0 +1,183 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* WritableStreamDefaultWriter */
+extern const char* const s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCode;
+extern const int s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeLength;
+extern const JSC::ConstructAbility s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeConstructorKind;
+extern const char* const s_writableStreamDefaultWriterClosedCode;
+extern const int s_writableStreamDefaultWriterClosedCodeLength;
+extern const JSC::ConstructAbility s_writableStreamDefaultWriterClosedCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamDefaultWriterClosedCodeConstructorKind;
+extern const char* const s_writableStreamDefaultWriterDesiredSizeCode;
+extern const int s_writableStreamDefaultWriterDesiredSizeCodeLength;
+extern const JSC::ConstructAbility s_writableStreamDefaultWriterDesiredSizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamDefaultWriterDesiredSizeCodeConstructorKind;
+extern const char* const s_writableStreamDefaultWriterReadyCode;
+extern const int s_writableStreamDefaultWriterReadyCodeLength;
+extern const JSC::ConstructAbility s_writableStreamDefaultWriterReadyCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamDefaultWriterReadyCodeConstructorKind;
+extern const char* const s_writableStreamDefaultWriterAbortCode;
+extern const int s_writableStreamDefaultWriterAbortCodeLength;
+extern const JSC::ConstructAbility s_writableStreamDefaultWriterAbortCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamDefaultWriterAbortCodeConstructorKind;
+extern const char* const s_writableStreamDefaultWriterCloseCode;
+extern const int s_writableStreamDefaultWriterCloseCodeLength;
+extern const JSC::ConstructAbility s_writableStreamDefaultWriterCloseCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamDefaultWriterCloseCodeConstructorKind;
+extern const char* const s_writableStreamDefaultWriterReleaseLockCode;
+extern const int s_writableStreamDefaultWriterReleaseLockCodeLength;
+extern const JSC::ConstructAbility s_writableStreamDefaultWriterReleaseLockCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamDefaultWriterReleaseLockCodeConstructorKind;
+extern const char* const s_writableStreamDefaultWriterWriteCode;
+extern const int s_writableStreamDefaultWriterWriteCodeLength;
+extern const JSC::ConstructAbility s_writableStreamDefaultWriterWriteCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamDefaultWriterWriteCodeConstructorKind;
+
+#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_DATA(macro) \
+ macro(initializeWritableStreamDefaultWriter, writableStreamDefaultWriterInitializeWritableStreamDefaultWriter, 1) \
+ macro(closed, writableStreamDefaultWriterClosed, 0) \
+ macro(desiredSize, writableStreamDefaultWriterDesiredSize, 0) \
+ macro(ready, writableStreamDefaultWriterReady, 0) \
+ macro(abort, writableStreamDefaultWriterAbort, 1) \
+ macro(close, writableStreamDefaultWriterClose, 0) \
+ macro(releaseLock, writableStreamDefaultWriterReleaseLock, 0) \
+ macro(write, writableStreamDefaultWriterWrite, 1) \
+
+#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_INITIALIZEWRITABLESTREAMDEFAULTWRITER 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_CLOSED 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_DESIREDSIZE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_READY 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_ABORT 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_CLOSE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_RELEASELOCK 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_WRITE 1
+
+#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(macro) \
+ macro(writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCode, initializeWritableStreamDefaultWriter, ASCIILiteral(), s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeLength) \
+ macro(writableStreamDefaultWriterClosedCode, closed, "get closed"_s, s_writableStreamDefaultWriterClosedCodeLength) \
+ macro(writableStreamDefaultWriterDesiredSizeCode, desiredSize, "get desiredSize"_s, s_writableStreamDefaultWriterDesiredSizeCodeLength) \
+ macro(writableStreamDefaultWriterReadyCode, ready, "get ready"_s, s_writableStreamDefaultWriterReadyCodeLength) \
+ macro(writableStreamDefaultWriterAbortCode, abort, ASCIILiteral(), s_writableStreamDefaultWriterAbortCodeLength) \
+ macro(writableStreamDefaultWriterCloseCode, close, ASCIILiteral(), s_writableStreamDefaultWriterCloseCodeLength) \
+ macro(writableStreamDefaultWriterReleaseLockCode, releaseLock, ASCIILiteral(), s_writableStreamDefaultWriterReleaseLockCodeLength) \
+ macro(writableStreamDefaultWriterWriteCode, write, ASCIILiteral(), s_writableStreamDefaultWriterWriteCodeLength) \
+
+#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_FUNCTION_NAME(macro) \
+ macro(abort) \
+ macro(close) \
+ macro(closed) \
+ macro(desiredSize) \
+ macro(initializeWritableStreamDefaultWriter) \
+ macro(ready) \
+ macro(releaseLock) \
+ macro(write) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class WritableStreamDefaultWriterBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit WritableStreamDefaultWriterBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_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_WRITABLESTREAMDEFAULTWRITER_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_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* WritableStreamDefaultWriterBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void WritableStreamDefaultWriterBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.cpp b/src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.cpp
new file mode 100644
index 000000000..2e0a4b1df
--- /dev/null
+++ b/src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.cpp
@@ -0,0 +1,1102 @@
+/*
+ * 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 "WritableStreamInternalsBuiltins.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/Intrinsic.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/VM.h>
+
+namespace WebCore {
+
+const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsIsWritableStreamCodeLength = 126;
+static const JSC::Intrinsic s_writableStreamInternalsIsWritableStreamCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsIsWritableStreamCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return @isObject(stream) && !!@getByIdDirectPrivate(stream, \"underlyingSink\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamDefaultWriterCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamDefaultWriterCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsIsWritableStreamDefaultWriterCodeLength = 125;
+static const JSC::Intrinsic s_writableStreamInternalsIsWritableStreamDefaultWriterCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsIsWritableStreamDefaultWriterCode =
+ "(function (writer)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return @isObject(writer) && !!@getByIdDirectPrivate(writer, \"closedPromise\");\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeLength = 77;
+static const JSC::Intrinsic s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsAcquireWritableStreamDefaultWriterCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " return new @WritableStreamDefaultWriter(stream);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsCreateWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsCreateWritableStreamCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsCreateWritableStreamCodeLength = 588;
+static const JSC::Intrinsic s_writableStreamInternalsCreateWritableStreamCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsCreateWritableStreamCode =
+ "(function (startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm)\n" \
+ "{\n" \
+ " @assert(typeof highWaterMark === \"number\" && !@isNaN(highWaterMark) && highWaterMark >= 0);\n" \
+ "\n" \
+ " const internalStream = { };\n" \
+ " @initializeWritableStreamSlots(internalStream, { });\n" \
+ " const controller = new @WritableStreamDefaultController();\n" \
+ "\n" \
+ " @setUpWritableStreamDefaultController(internalStream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);\n" \
+ "\n" \
+ " return @createWritableStreamFromInternal(internalStream);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength = 1776;
+static const JSC::Intrinsic s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode =
+ "(function (underlyingSink, strategy)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " const stream = { };\n" \
+ "\n" \
+ " if (underlyingSink === @undefined)\n" \
+ " underlyingSink = { };\n" \
+ "\n" \
+ " if (strategy === @undefined)\n" \
+ " strategy = { };\n" \
+ "\n" \
+ " if (!@isObject(underlyingSink))\n" \
+ " @throwTypeError(\"WritableStream constructor takes an object as first argument\");\n" \
+ "\n" \
+ " if (\"type\" in underlyingSink)\n" \
+ " @throwRangeError(\"Invalid type is specified\");\n" \
+ "\n" \
+ " const sizeAlgorithm = @extractSizeAlgorithm(strategy);\n" \
+ " const highWaterMark = @extractHighWaterMark(strategy, 1);\n" \
+ "\n" \
+ " const underlyingSinkDict = { };\n" \
+ " if (\"start\" in underlyingSink) {\n" \
+ " underlyingSinkDict[\"start\"] = underlyingSink[\"start\"];\n" \
+ " if (typeof underlyingSinkDict[\"start\"] !== \"function\")\n" \
+ " @throwTypeError(\"underlyingSink.start should be a function\");\n" \
+ " }\n" \
+ " if (\"write\" in underlyingSink) {\n" \
+ " underlyingSinkDict[\"write\"] = underlyingSink[\"write\"];\n" \
+ " if (typeof underlyingSinkDict[\"write\"] !== \"function\")\n" \
+ " @throwTypeError(\"underlyingSink.write should be a function\");\n" \
+ " }\n" \
+ " if (\"close\" in underlyingSink) {\n" \
+ " underlyingSinkDict[\"close\"] = underlyingSink[\"close\"];\n" \
+ " if (typeof underlyingSinkDict[\"close\"] !== \"function\")\n" \
+ " @throwTypeError(\"underlyingSink.close should be a function\");\n" \
+ " }\n" \
+ " if (\"abort\" in underlyingSink) {\n" \
+ " underlyingSinkDict[\"abort\"] = underlyingSink[\"abort\"];\n" \
+ " if (typeof underlyingSinkDict[\"abort\"] !== \"function\")\n" \
+ " @throwTypeError(\"underlyingSink.abort should be a function\");\n" \
+ " }\n" \
+ "\n" \
+ " @initializeWritableStreamSlots(stream, underlyingSink);\n" \
+ " @setUpWritableStreamDefaultControllerFromUnderlyingSink(stream, underlyingSink, underlyingSinkDict, highWaterMark, sizeAlgorithm);\n" \
+ "\n" \
+ " return stream;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsInitializeWritableStreamSlotsCodeLength = 734;
+static const JSC::Intrinsic s_writableStreamInternalsInitializeWritableStreamSlotsCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsInitializeWritableStreamSlotsCode =
+ "(function (stream, underlyingSink)\n" \
+ "{\n" \
+ " @putByIdDirectPrivate(stream, \"state\", \"writable\");\n" \
+ " @putByIdDirectPrivate(stream, \"storedError\", @undefined);\n" \
+ " @putByIdDirectPrivate(stream, \"writer\", @undefined);\n" \
+ " @putByIdDirectPrivate(stream, \"controller\", @undefined);\n" \
+ " @putByIdDirectPrivate(stream, \"inFlightWriteRequest\", @undefined);\n" \
+ " @putByIdDirectPrivate(stream, \"closeRequest\", @undefined);\n" \
+ " @putByIdDirectPrivate(stream, \"inFlightCloseRequest\", @undefined);\n" \
+ " @putByIdDirectPrivate(stream, \"pendingAbortRequest\", @undefined);\n" \
+ " @putByIdDirectPrivate(stream, \"writeRequests\", []);\n" \
+ " @putByIdDirectPrivate(stream, \"backpressure\", false);\n" \
+ " @putByIdDirectPrivate(stream, \"underlyingSink\", underlyingSink);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseForBindingsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseForBindingsCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamCloseForBindingsCodeLength = 417;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamCloseForBindingsCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamCloseForBindingsCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " if (@isWritableStreamLocked(stream))\n" \
+ " return @Promise.@reject(@makeTypeError(\"WritableStream.close method can only be used on non locked WritableStream\"));\n" \
+ "\n" \
+ " if (@writableStreamCloseQueuedOrInFlight(stream))\n" \
+ " return @Promise.@reject(@makeTypeError(\"WritableStream.close method can only be used on a being close WritableStream\"));\n" \
+ "\n" \
+ " return @writableStreamClose(stream);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAbortForBindingsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAbortForBindingsCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamAbortForBindingsCodeLength = 249;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAbortForBindingsCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamAbortForBindingsCode =
+ "(function (stream, reason)\n" \
+ "{\n" \
+ " if (@isWritableStreamLocked(stream))\n" \
+ " return @Promise.@reject(@makeTypeError(\"WritableStream.abort method can only be used on non locked WritableStream\"));\n" \
+ "\n" \
+ " return @writableStreamAbort(stream, reason);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamLockedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamLockedCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsIsWritableStreamLockedCodeLength = 91;
+static const JSC::Intrinsic s_writableStreamInternalsIsWritableStreamLockedCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsIsWritableStreamLockedCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " return @getByIdDirectPrivate(stream, \"writer\") !== @undefined;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeLength = 1521;
+static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsSetUpWritableStreamDefaultWriterCode =
+ "(function (writer, stream)\n" \
+ "{\n" \
+ " if (@isWritableStreamLocked(stream))\n" \
+ " @throwTypeError(\"WritableStream is locked\");\n" \
+ "\n" \
+ " @putByIdDirectPrivate(writer, \"stream\", stream);\n" \
+ " @putByIdDirectPrivate(stream, \"writer\", writer);\n" \
+ "\n" \
+ " const readyPromiseCapability = @newPromiseCapability(@Promise);\n" \
+ " const closedPromiseCapability = @newPromiseCapability(@Promise);\n" \
+ " @putByIdDirectPrivate(writer, \"readyPromise\", readyPromiseCapability);\n" \
+ " @putByIdDirectPrivate(writer, \"closedPromise\", closedPromiseCapability);\n" \
+ "\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " if (state === \"writable\") {\n" \
+ " if (@writableStreamCloseQueuedOrInFlight(stream) || !@getByIdDirectPrivate(stream, \"backpressure\"))\n" \
+ " readyPromiseCapability.@resolve.@call();\n" \
+ " } else if (state === \"erroring\") {\n" \
+ " readyPromiseCapability.@reject.@call(@undefined, @getByIdDirectPrivate(stream, \"storedError\"));\n" \
+ " @markPromiseAsHandled(readyPromiseCapability.@promise);\n" \
+ " } else if (state === \"closed\") {\n" \
+ " readyPromiseCapability.@resolve.@call();\n" \
+ " closedPromiseCapability.@resolve.@call();\n" \
+ " } else {\n" \
+ " @assert(state === \"errored\");\n" \
+ " const storedError = @getByIdDirectPrivate(stream, \"storedError\");\n" \
+ " readyPromiseCapability.@reject.@call(@undefined, storedError);\n" \
+ " @markPromiseAsHandled(readyPromiseCapability.@promise);\n" \
+ " closedPromiseCapability.@reject.@call(@undefined, storedError);\n" \
+ " @markPromiseAsHandled(closedPromiseCapability.@promise);\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAbortCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAbortCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamAbortCodeLength = 910;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAbortCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamAbortCode =
+ "(function (stream, reason)\n" \
+ "{\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " if (state === \"closed\" || state === \"errored\")\n" \
+ " return @Promise.@resolve();\n" \
+ "\n" \
+ " const pendingAbortRequest = @getByIdDirectPrivate(stream, \"pendingAbortRequest\");\n" \
+ " if (pendingAbortRequest !== @undefined)\n" \
+ " return pendingAbortRequest.promise.@promise;\n" \
+ "\n" \
+ " @assert(state === \"writable\" || state === \"erroring\");\n" \
+ " let wasAlreadyErroring = false;\n" \
+ " if (state === \"erroring\") {\n" \
+ " wasAlreadyErroring = true;\n" \
+ " reason = @undefined;\n" \
+ " }\n" \
+ "\n" \
+ " const abortPromiseCapability = @newPromiseCapability(@Promise);\n" \
+ " @putByIdDirectPrivate(stream, \"pendingAbortRequest\", { promise : abortPromiseCapability, reason : reason, wasAlreadyErroring : wasAlreadyErroring });\n" \
+ "\n" \
+ " if (!wasAlreadyErroring)\n" \
+ " @writableStreamStartErroring(stream, reason);\n" \
+ " return abortPromiseCapability.@promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamCloseCodeLength = 885;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamCloseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamCloseCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " if (state === \"closed\" || state === \"errored\")\n" \
+ " return @Promise.@reject(@makeTypeError(\"Cannot close a writable stream that is closed or errored\"));\n" \
+ "\n" \
+ " @assert(state === \"writable\" || state === \"erroring\");\n" \
+ " @assert(!@writableStreamCloseQueuedOrInFlight(stream));\n" \
+ "\n" \
+ " const closePromiseCapability = @newPromiseCapability(@Promise);\n" \
+ " @putByIdDirectPrivate(stream, \"closeRequest\", closePromiseCapability);\n" \
+ "\n" \
+ " const writer = @getByIdDirectPrivate(stream, \"writer\");\n" \
+ " if (writer !== @undefined && @getByIdDirectPrivate(stream, \"backpressure\") && state === \"writable\")\n" \
+ " @getByIdDirectPrivate(writer, \"readyPromise\").@resolve.@call();\n" \
+ " \n" \
+ " @writableStreamDefaultControllerClose(@getByIdDirectPrivate(stream, \"controller\"));\n" \
+ "\n" \
+ " return closePromiseCapability.@promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAddWriteRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAddWriteRequestCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamAddWriteRequestCodeLength = 379;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAddWriteRequestCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamAddWriteRequestCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " @assert(@isWritableStreamLocked(stream))\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") === \"writable\");\n" \
+ "\n" \
+ " const writePromiseCapability = @newPromiseCapability(@Promise);\n" \
+ " const writeRequests = @getByIdDirectPrivate(stream, \"writeRequests\");\n" \
+ " @arrayPush(writeRequests, writePromiseCapability);\n" \
+ " return writePromiseCapability.@promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeLength = 169;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " return @getByIdDirectPrivate(stream, \"closeRequest\") !== @undefined || @getByIdDirectPrivate(stream, \"inFlightCloseRequest\") !== @undefined;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDealWithRejectionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDealWithRejectionCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDealWithRejectionCodeLength = 275;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDealWithRejectionCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode =
+ "(function (stream, error)\n" \
+ "{\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " if (state === \"writable\") {\n" \
+ " @writableStreamStartErroring(stream, error);\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " @assert(state === \"erroring\");\n" \
+ " @writableStreamFinishErroring(stream);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishErroringCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishErroringCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamFinishErroringCodeLength = 1543;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishErroringCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamFinishErroringCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") === \"erroring\");\n" \
+ " @assert(!@writableStreamHasOperationMarkedInFlight(stream));\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"state\", \"errored\");\n" \
+ "\n" \
+ " const controller = @getByIdDirectPrivate(stream, \"controller\");\n" \
+ " @getByIdDirectPrivate(controller, \"errorSteps\").@call();\n" \
+ "\n" \
+ " const storedError = @getByIdDirectPrivate(stream, \"storedError\");\n" \
+ " const requests = @getByIdDirectPrivate(stream, \"writeRequests\");\n" \
+ " for (let index = 0, length = requests.length; index < length; ++index)\n" \
+ " requests[index].@reject.@call(@undefined, storedError);\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"writeRequests\", []);\n" \
+ "\n" \
+ " const abortRequest = @getByIdDirectPrivate(stream, \"pendingAbortRequest\");\n" \
+ " if (abortRequest === @undefined) {\n" \
+ " @writableStreamRejectCloseAndClosedPromiseIfNeeded(stream);\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"pendingAbortRequest\", @undefined);\n" \
+ " if (abortRequest.wasAlreadyErroring) {\n" \
+ " abortRequest.promise.@reject.@call(@undefined, storedError);\n" \
+ " @writableStreamRejectCloseAndClosedPromiseIfNeeded(stream);\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " @getByIdDirectPrivate(controller, \"abortSteps\").@call(@undefined, abortRequest.reason).@then(() => {\n" \
+ " abortRequest.promise.@resolve.@call();\n" \
+ " @writableStreamRejectCloseAndClosedPromiseIfNeeded(stream);\n" \
+ " }, (reason) => {\n" \
+ " abortRequest.promise.@reject.@call(@undefined, reason);\n" \
+ " @writableStreamRejectCloseAndClosedPromiseIfNeeded(stream);\n" \
+ " });\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength = 1092;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " const inFlightCloseRequest = @getByIdDirectPrivate(stream, \"inFlightCloseRequest\");\n" \
+ " inFlightCloseRequest.@resolve.@call();\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"inFlightCloseRequest\", @undefined);\n" \
+ "\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " @assert(state === \"writable\" || state === \"erroring\");\n" \
+ "\n" \
+ " if (state === \"erroring\") {\n" \
+ " @putByIdDirectPrivate(stream, \"storedError\", @undefined);\n" \
+ " const abortRequest = @getByIdDirectPrivate(stream, \"pendingAbortRequest\");\n" \
+ " if (abortRequest !== @undefined) {\n" \
+ " abortRequest.promise.@resolve.@call();\n" \
+ " @putByIdDirectPrivate(stream, \"pendingAbortRequest\", @undefined);\n" \
+ " }\n" \
+ " }\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"state\", \"closed\");\n" \
+ "\n" \
+ " const writer = @getByIdDirectPrivate(stream, \"writer\");\n" \
+ " if (writer !== @undefined)\n" \
+ " @getByIdDirectPrivate(writer, \"closedPromise\").@resolve.@call();\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"pendingAbortRequest\") === @undefined);\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"storedError\") === @undefined);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeLength = 734;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode =
+ "(function (stream, error)\n" \
+ "{\n" \
+ " const inFlightCloseRequest = @getByIdDirectPrivate(stream, \"inFlightCloseRequest\");\n" \
+ " @assert(inFlightCloseRequest !== @undefined);\n" \
+ " inFlightCloseRequest.@reject.@call(@undefined, error);\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"inFlightCloseRequest\", @undefined);\n" \
+ "\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " @assert(state === \"writable\" || state === \"erroring\");\n" \
+ "\n" \
+ " const abortRequest = @getByIdDirectPrivate(stream, \"pendingAbortRequest\");\n" \
+ " if (abortRequest !== @undefined) {\n" \
+ " abortRequest.promise.@reject.@call(@undefined, error);\n" \
+ " @putByIdDirectPrivate(stream, \"pendingAbortRequest\", @undefined);\n" \
+ " }\n" \
+ "\n" \
+ " @writableStreamDealWithRejection(stream, error);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeLength = 277;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " const inFlightWriteRequest = @getByIdDirectPrivate(stream, \"inFlightWriteRequest\");\n" \
+ " @assert(inFlightWriteRequest !== @undefined);\n" \
+ " inFlightWriteRequest.@resolve.@call();\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"inFlightWriteRequest\", @undefined);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeLength = 472;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCode =
+ "(function (stream, error)\n" \
+ "{\n" \
+ " const inFlightWriteRequest = @getByIdDirectPrivate(stream, \"inFlightWriteRequest\");\n" \
+ " @assert(inFlightWriteRequest !== @undefined);\n" \
+ " inFlightWriteRequest.@reject.@call(@undefined, error);\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"inFlightWriteRequest\", @undefined);\n" \
+ "\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " @assert(state === \"writable\" || state === \"erroring\");\n" \
+ "\n" \
+ " @writableStreamDealWithRejection(stream, error);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeLength = 177;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " return @getByIdDirectPrivate(stream, \"inFlightWriteRequest\") !== @undefined || @getByIdDirectPrivate(stream, \"inFlightCloseRequest\") !== @undefined;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeLength = 358;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " const closeRequest = @getByIdDirectPrivate(stream, \"closeRequest\");\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"inFlightCloseRequest\") === @undefined);\n" \
+ " @assert(closeRequest !== @undefined);\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"inFlightCloseRequest\", closeRequest);\n" \
+ " @putByIdDirectPrivate(stream, \"closeRequest\", @undefined);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeLength = 343;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " const writeRequests = @getByIdDirectPrivate(stream, \"writeRequests\");\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"inFlightWriteRequest\") === @undefined);\n" \
+ " @assert(writeRequests.length > 0);\n" \
+ "\n" \
+ " const writeRequest = writeRequests.@shift();\n" \
+ " @putByIdDirectPrivate(stream, \"inFlightWriteRequest\", writeRequest);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength = 790;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode =
+ "(function (stream)\n" \
+ "{\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") === \"errored\");\n" \
+ "\n" \
+ " const storedError = @getByIdDirectPrivate(stream, \"storedError\");\n" \
+ "\n" \
+ " const closeRequest = @getByIdDirectPrivate(stream, \"closeRequest\");\n" \
+ " if (closeRequest !== @undefined) {\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"inFlightCloseRequest\") === @undefined);\n" \
+ " closeRequest.@reject.@call(@undefined, storedError);\n" \
+ " @putByIdDirectPrivate(stream, \"closeRequest\", @undefined);\n" \
+ " }\n" \
+ "\n" \
+ " const writer = @getByIdDirectPrivate(stream, \"writer\");\n" \
+ " if (writer !== @undefined) {\n" \
+ " const closedPromise = @getByIdDirectPrivate(writer, \"closedPromise\");\n" \
+ " closedPromise.@reject.@call(@undefined, storedError);\n" \
+ " @markPromiseAsHandled(closedPromise.@promise);\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamStartErroringCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamStartErroringCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamStartErroringCodeLength = 727;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamStartErroringCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamStartErroringCode =
+ "(function (stream, reason)\n" \
+ "{\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"storedError\") === @undefined);\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") === \"writable\");\n" \
+ " \n" \
+ " const controller = @getByIdDirectPrivate(stream, \"controller\");\n" \
+ " @assert(controller !== @undefined);\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"state\", \"erroring\");\n" \
+ " @putByIdDirectPrivate(stream, \"storedError\", reason);\n" \
+ "\n" \
+ " const writer = @getByIdDirectPrivate(stream, \"writer\");\n" \
+ " if (writer !== @undefined)\n" \
+ " @writableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason);\n" \
+ "\n" \
+ " if (!@writableStreamHasOperationMarkedInFlight(stream) && @getByIdDirectPrivate(controller, \"started\"))\n" \
+ " @writableStreamFinishErroring(stream);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamUpdateBackpressureCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamUpdateBackpressureCodeLength = 603;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamUpdateBackpressureCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamUpdateBackpressureCode =
+ "(function (stream, backpressure)\n" \
+ "{\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") === \"writable\");\n" \
+ " @assert(!@writableStreamCloseQueuedOrInFlight(stream));\n" \
+ "\n" \
+ " const writer = @getByIdDirectPrivate(stream, \"writer\");\n" \
+ " if (writer !== @undefined && backpressure !== @getByIdDirectPrivate(stream, \"backpressure\")) {\n" \
+ " if (backpressure)\n" \
+ " @putByIdDirectPrivate(writer, \"readyPromise\", @newPromiseCapability(@Promise));\n" \
+ " else\n" \
+ " @getByIdDirectPrivate(writer, \"readyPromise\").@resolve.@call();\n" \
+ " }\n" \
+ " @putByIdDirectPrivate(stream, \"backpressure\", backpressure);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeLength = 177;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode =
+ "(function (writer, reason)\n" \
+ "{\n" \
+ " const stream = @getByIdDirectPrivate(writer, \"stream\");\n" \
+ " @assert(stream !== @undefined);\n" \
+ " return @writableStreamAbort(stream, reason);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeLength = 161;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode =
+ "(function (writer)\n" \
+ "{\n" \
+ " const stream = @getByIdDirectPrivate(writer, \"stream\");\n" \
+ " @assert(stream !== @undefined);\n" \
+ " return @writableStreamClose(stream);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeLength = 515;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode =
+ "(function (writer)\n" \
+ "{\n" \
+ " const stream = @getByIdDirectPrivate(writer, \"stream\");\n" \
+ " @assert(stream !== @undefined);\n" \
+ "\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ "\n" \
+ " if (@writableStreamCloseQueuedOrInFlight(stream) || state === \"closed\")\n" \
+ " return @Promise.@resolve();\n" \
+ "\n" \
+ " if (state === \"errored\")\n" \
+ " return @Promise.@reject(@getByIdDirectPrivate(stream, \"storedError\"));\n" \
+ "\n" \
+ " @assert(state === \"writable\" || state === \"erroring\");\n" \
+ " return @writableStreamDefaultWriterClose(writer);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeLength = 607;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode =
+ "(function (writer, error)\n" \
+ "{\n" \
+ " let closedPromiseCapability = @getByIdDirectPrivate(writer, \"closedPromise\");\n" \
+ " let closedPromise = closedPromiseCapability.@promise;\n" \
+ "\n" \
+ " if ((@getPromiseInternalField(closedPromise, @promiseFieldFlags) & @promiseStateMask) !== @promiseStatePending) {\n" \
+ " closedPromiseCapability = @newPromiseCapability(@Promise);\n" \
+ " closedPromise = closedPromiseCapability.@promise;\n" \
+ " @putByIdDirectPrivate(writer, \"closedPromise\", closedPromiseCapability);\n" \
+ " }\n" \
+ "\n" \
+ " closedPromiseCapability.@reject.@call(@undefined, error);\n" \
+ " @markPromiseAsHandled(closedPromise);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength = 595;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode =
+ "(function (writer, error)\n" \
+ "{\n" \
+ " let readyPromiseCapability = @getByIdDirectPrivate(writer, \"readyPromise\");\n" \
+ " let readyPromise = readyPromiseCapability.@promise;\n" \
+ "\n" \
+ " if ((@getPromiseInternalField(readyPromise, @promiseFieldFlags) & @promiseStateMask) !== @promiseStatePending) {\n" \
+ " readyPromiseCapability = @newPromiseCapability(@Promise);\n" \
+ " readyPromise = readyPromiseCapability.@promise;\n" \
+ " @putByIdDirectPrivate(writer, \"readyPromise\", readyPromiseCapability);\n" \
+ " }\n" \
+ "\n" \
+ " readyPromiseCapability.@reject.@call(@undefined, error);\n" \
+ " @markPromiseAsHandled(readyPromise);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeLength = 406;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode =
+ "(function (writer)\n" \
+ "{\n" \
+ " const stream = @getByIdDirectPrivate(writer, \"stream\");\n" \
+ " @assert(stream !== @undefined);\n" \
+ "\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ "\n" \
+ " if (state === \"errored\" || state === \"erroring\")\n" \
+ " return null;\n" \
+ "\n" \
+ " if (state === \"closed\")\n" \
+ " return 0;\n" \
+ "\n" \
+ " return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(stream, \"controller\"));\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeLength = 549;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultWriterReleaseCode =
+ "(function (writer)\n" \
+ "{\n" \
+ " const stream = @getByIdDirectPrivate(writer, \"stream\");\n" \
+ " @assert(stream !== @undefined);\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"writer\") === writer);\n" \
+ "\n" \
+ " const releasedError = @makeTypeError(\"writableStreamDefaultWriterRelease\");\n" \
+ "\n" \
+ " @writableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);\n" \
+ " @writableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);\n" \
+ "\n" \
+ " @putByIdDirectPrivate(stream, \"writer\", @undefined);\n" \
+ " @putByIdDirectPrivate(writer, \"stream\", @undefined);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeLength = 1247;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode =
+ "(function (writer, chunk)\n" \
+ "{\n" \
+ " const stream = @getByIdDirectPrivate(writer, \"stream\");\n" \
+ " @assert(stream !== @undefined);\n" \
+ "\n" \
+ " const controller = @getByIdDirectPrivate(stream, \"controller\");\n" \
+ " @assert(controller !== @undefined);\n" \
+ " const chunkSize = @writableStreamDefaultControllerGetChunkSize(controller, chunk);\n" \
+ "\n" \
+ " if (stream !== @getByIdDirectPrivate(writer, \"stream\"))\n" \
+ " return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));\n" \
+ "\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " if (state === \"errored\")\n" \
+ " return @Promise.@reject(@getByIdDirectPrivate(stream, \"storedError\"));\n" \
+ "\n" \
+ " if (@writableStreamCloseQueuedOrInFlight(stream) || state === \"closed\")\n" \
+ " return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));\n" \
+ "\n" \
+ " if (@writableStreamCloseQueuedOrInFlight(stream) || state === \"closed\")\n" \
+ " return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));\n" \
+ "\n" \
+ " if (state === \"erroring\")\n" \
+ " return @Promise.@reject(@getByIdDirectPrivate(stream, \"storedError\"));\n" \
+ "\n" \
+ " @assert(state === \"writable\");\n" \
+ "\n" \
+ " const promise = @writableStreamAddWriteRequest(stream);\n" \
+ " @writableStreamDefaultControllerWrite(controller, chunk, chunkSize);\n" \
+ " return promise;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeLength = 1587;
+static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode =
+ "(function (stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm)\n" \
+ "{\n" \
+ " @assert(@isWritableStream(stream));\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"controller\") === @undefined);\n" \
+ "\n" \
+ " @putByIdDirectPrivate(controller, \"stream\", stream);\n" \
+ " @putByIdDirectPrivate(stream, \"controller\", controller);\n" \
+ "\n" \
+ " @resetQueue(@getByIdDirectPrivate(controller, \"queue\"));\n" \
+ "\n" \
+ " @putByIdDirectPrivate(controller, \"started\", false);\n" \
+ " @putByIdDirectPrivate(controller, \"strategySizeAlgorithm\", sizeAlgorithm);\n" \
+ " @putByIdDirectPrivate(controller, \"strategyHWM\", highWaterMark);\n" \
+ " @putByIdDirectPrivate(controller, \"writeAlgorithm\", writeAlgorithm);\n" \
+ " @putByIdDirectPrivate(controller, \"closeAlgorithm\", closeAlgorithm);\n" \
+ " @putByIdDirectPrivate(controller, \"abortAlgorithm\", abortAlgorithm);\n" \
+ "\n" \
+ " const backpressure = @writableStreamDefaultControllerGetBackpressure(controller);\n" \
+ " @writableStreamUpdateBackpressure(stream, backpressure);\n" \
+ "\n" \
+ " @Promise.@resolve(startAlgorithm.@call()).@then(() => {\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " @assert(state === \"writable\" || state === \"erroring\");\n" \
+ " @putByIdDirectPrivate(controller, \"started\", true);\n" \
+ " @writableStreamDefaultControllerAdvanceQueueIfNeeded(controller);\n" \
+ " }, (error) => {\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " @assert(state === \"writable\" || state === \"erroring\");\n" \
+ " @putByIdDirectPrivate(controller, \"started\", true);\n" \
+ " @writableStreamDealWithRejection(stream, error);\n" \
+ " });\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 1376;
+static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode =
+ "(function (stream, underlyingSink, underlyingSinkDict, highWaterMark, sizeAlgorithm)\n" \
+ "{\n" \
+ " const controller = new @WritableStreamDefaultController();\n" \
+ "\n" \
+ " let startAlgorithm = () => { };\n" \
+ " let writeAlgorithm = () => { return @Promise.@resolve(); };\n" \
+ " let closeAlgorithm = () => { return @Promise.@resolve(); };\n" \
+ " let abortAlgorithm = () => { return @Promise.@resolve(); };\n" \
+ "\n" \
+ " if (\"start\" in underlyingSinkDict) {\n" \
+ " const startMethod = underlyingSinkDict[\"start\"];\n" \
+ " startAlgorithm = () => @promiseInvokeOrNoopMethodNoCatch(underlyingSink, startMethod, [controller]);\n" \
+ " }\n" \
+ " if (\"write\" in underlyingSinkDict) {\n" \
+ " const writeMethod = underlyingSinkDict[\"write\"];\n" \
+ " writeAlgorithm = (chunk) => @promiseInvokeOrNoopMethod(underlyingSink, writeMethod, [chunk, controller]);\n" \
+ " }\n" \
+ " if (\"close\" in underlyingSinkDict) {\n" \
+ " const closeMethod = underlyingSinkDict[\"close\"];\n" \
+ " closeAlgorithm = () => @promiseInvokeOrNoopMethod(underlyingSink, closeMethod, []);\n" \
+ " }\n" \
+ " if (\"abort\" in underlyingSinkDict) {\n" \
+ " const abortMethod = underlyingSinkDict[\"abort\"];\n" \
+ " abortAlgorithm = (reason) => @promiseInvokeOrNoopMethod(underlyingSink, abortMethod, [reason]);\n" \
+ " }\n" \
+ "\n" \
+ " @setUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeLength = 865;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"stream\");\n" \
+ "\n" \
+ " if (!@getByIdDirectPrivate(controller, \"started\"))\n" \
+ " return;\n" \
+ "\n" \
+ " @assert(stream !== @undefined);\n" \
+ " if (@getByIdDirectPrivate(stream, \"inFlightWriteRequest\") !== @undefined)\n" \
+ " return;\n" \
+ "\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " @assert(state !== \"closed\" || state !== \"errored\");\n" \
+ " if (state === \"erroring\") {\n" \
+ " @writableStreamFinishErroring(stream);\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(controller, \"queue\").content.length === 0)\n" \
+ " return;\n" \
+ "\n" \
+ " const value = @peekQueueValue(@getByIdDirectPrivate(controller, \"queue\"));\n" \
+ " if (value === @isCloseSentinel)\n" \
+ " @writableStreamDefaultControllerProcessClose(controller);\n" \
+ " else\n" \
+ " @writableStreamDefaultControllerProcessWrite(controller, value);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsIsCloseSentinelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsIsCloseSentinelCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsIsCloseSentinelCodeLength = 18;
+static const JSC::Intrinsic s_writableStreamInternalsIsCloseSentinelCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsIsCloseSentinelCode =
+ "(function ()\n" \
+ "{\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeLength = 311;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " @putByIdDirectPrivate(controller, \"writeAlgorithm\", @undefined);\n" \
+ " @putByIdDirectPrivate(controller, \"closeAlgorithm\", @undefined);\n" \
+ " @putByIdDirectPrivate(controller, \"abortAlgorithm\", @undefined);\n" \
+ " @putByIdDirectPrivate(controller, \"strategySizeAlgorithm\", @undefined);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeLength = 190;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultControllerCloseCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " @enqueueValueWithSize(@getByIdDirectPrivate(controller, \"queue\"), @isCloseSentinel, 0);\n" \
+ " @writableStreamDefaultControllerAdvanceQueueIfNeeded(controller);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeLength = 318;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode =
+ "(function (controller, error)\n" \
+ "{\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"stream\");\n" \
+ " @assert(stream !== @undefined);\n" \
+ " @assert(@getByIdDirectPrivate(stream, \"state\") === \"writable\");\n" \
+ "\n" \
+ " @writableStreamDefaultControllerClearAlgorithms(controller);\n" \
+ " @writableStreamStartErroring(stream, error);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeLength = 228;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCode =
+ "(function (controller, error)\n" \
+ "{\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"stream\");\n" \
+ " if (@getByIdDirectPrivate(stream, \"state\") === \"writable\")\n" \
+ " @writableStreamDefaultControllerError(controller, error);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeLength = 141;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " const desiredSize = @writableStreamDefaultControllerGetDesiredSize(controller);\n" \
+ " return desiredSize <= 0;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeLength = 257;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCode =
+ "(function (controller, chunk)\n" \
+ "{\n" \
+ " try {\n" \
+ " return @getByIdDirectPrivate(controller, \"strategySizeAlgorithm\").@call(@undefined, chunk);\n" \
+ " } catch (e) {\n" \
+ " @writableStreamDefaultControllerErrorIfNeeded(controller, e);\n" \
+ " return 1;\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeLength = 139;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " return @getByIdDirectPrivate(controller, \"strategyHWM\") - @getByIdDirectPrivate(controller, \"queue\").size;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeLength = 630;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"stream\");\n" \
+ "\n" \
+ " @writableStreamMarkCloseRequestInFlight(stream);\n" \
+ " @dequeueValue(@getByIdDirectPrivate(controller, \"queue\"));\n" \
+ "\n" \
+ " @assert(@getByIdDirectPrivate(controller, \"queue\").content.length === 0);\n" \
+ "\n" \
+ " const sinkClosePromise = @getByIdDirectPrivate(controller, \"closeAlgorithm\").@call();\n" \
+ " @writableStreamDefaultControllerClearAlgorithms(controller);\n" \
+ "\n" \
+ " sinkClosePromise.@then(() => {\n" \
+ " @writableStreamFinishInFlightClose(stream);\n" \
+ " }, (reason) => {\n" \
+ " @writableStreamFinishInFlightCloseWithError(stream, reason);\n" \
+ " });\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeLength = 1147;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode =
+ "(function (controller, chunk)\n" \
+ "{\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"stream\");\n" \
+ "\n" \
+ " @writableStreamMarkFirstWriteRequestInFlight(stream);\n" \
+ "\n" \
+ " const sinkWritePromise = @getByIdDirectPrivate(controller, \"writeAlgorithm\").@call(@undefined, chunk);\n" \
+ "\n" \
+ " sinkWritePromise.@then(() => {\n" \
+ " @writableStreamFinishInFlightWrite(stream);\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " @assert(state === \"writable\" || state === \"erroring\");\n" \
+ "\n" \
+ " @dequeueValue(@getByIdDirectPrivate(controller, \"queue\"));\n" \
+ " if (!@writableStreamCloseQueuedOrInFlight(stream) && state === \"writable\") {\n" \
+ " const backpressure = @writableStreamDefaultControllerGetBackpressure(controller);\n" \
+ " @writableStreamUpdateBackpressure(stream, backpressure);\n" \
+ " }\n" \
+ " @writableStreamDefaultControllerAdvanceQueueIfNeeded(controller);\n" \
+ " }, (reason) => {\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " if (state === \"writable\")\n" \
+ " @writableStreamDefaultControllerClearAlgorithms(controller);\n" \
+ "\n" \
+ " @writableStreamFinishInFlightWriteWithError(stream, reason);\n" \
+ " });\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeLength = 707;
+static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode =
+ "(function (controller, chunk, chunkSize)\n" \
+ "{\n" \
+ " try {\n" \
+ " @enqueueValueWithSize(@getByIdDirectPrivate(controller, \"queue\"), chunk, chunkSize);\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(controller, \"stream\");\n" \
+ "\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " if (!@writableStreamCloseQueuedOrInFlight(stream) && state === \"writable\") {\n" \
+ " const backpressure = @writableStreamDefaultControllerGetBackpressure(controller);\n" \
+ " @writableStreamUpdateBackpressure(stream, backpressure);\n" \
+ " }\n" \
+ " @writableStreamDefaultControllerAdvanceQueueIfNeeded(controller);\n" \
+ " } catch (e) {\n" \
+ " @writableStreamDefaultControllerErrorIfNeeded(controller, e);\n" \
+ " }\n" \
+ "})\n" \
+;
+
+
+#define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \
+{\
+ JSVMClientData* clientData = static_cast<JSVMClientData*>(vm.clientData); \
+ return clientData->builtinFunctions().writableStreamInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().writableStreamInternalsBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \
+}
+WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR)
+#undef DEFINE_BUILTIN_GENERATOR
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.h b/src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.h
new file mode 100644
index 000000000..675534830
--- /dev/null
+++ b/src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.h
@@ -0,0 +1,540 @@
+/*
+ * 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 <JavaScriptCore/BuiltinUtils.h>
+#include <JavaScriptCore/Identifier.h>
+#include <JavaScriptCore/JSFunction.h>
+#include <JavaScriptCore/UnlinkedFunctionExecutable.h>
+
+namespace JSC {
+class FunctionExecutable;
+}
+
+namespace WebCore {
+
+/* WritableStreamInternals */
+extern const char* const s_writableStreamInternalsIsWritableStreamCode;
+extern const int s_writableStreamInternalsIsWritableStreamCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamCodeConstructorKind;
+extern const char* const s_writableStreamInternalsIsWritableStreamDefaultWriterCode;
+extern const int s_writableStreamInternalsIsWritableStreamDefaultWriterCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamDefaultWriterCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamDefaultWriterCodeConstructorKind;
+extern const char* const s_writableStreamInternalsAcquireWritableStreamDefaultWriterCode;
+extern const int s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeConstructorKind;
+extern const char* const s_writableStreamInternalsCreateWritableStreamCode;
+extern const int s_writableStreamInternalsCreateWritableStreamCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsCreateWritableStreamCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsCreateWritableStreamCodeConstructorKind;
+extern const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode;
+extern const int s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructorKind;
+extern const char* const s_writableStreamInternalsInitializeWritableStreamSlotsCode;
+extern const int s_writableStreamInternalsInitializeWritableStreamSlotsCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamCloseForBindingsCode;
+extern const int s_writableStreamInternalsWritableStreamCloseForBindingsCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseForBindingsCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseForBindingsCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamAbortForBindingsCode;
+extern const int s_writableStreamInternalsWritableStreamAbortForBindingsCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAbortForBindingsCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAbortForBindingsCodeConstructorKind;
+extern const char* const s_writableStreamInternalsIsWritableStreamLockedCode;
+extern const int s_writableStreamInternalsIsWritableStreamLockedCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamLockedCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamLockedCodeConstructorKind;
+extern const char* const s_writableStreamInternalsSetUpWritableStreamDefaultWriterCode;
+extern const int s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamAbortCode;
+extern const int s_writableStreamInternalsWritableStreamAbortCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAbortCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAbortCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamCloseCode;
+extern const int s_writableStreamInternalsWritableStreamCloseCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamAddWriteRequestCode;
+extern const int s_writableStreamInternalsWritableStreamAddWriteRequestCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAddWriteRequestCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAddWriteRequestCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCode;
+extern const int s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode;
+extern const int s_writableStreamInternalsWritableStreamDealWithRejectionCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDealWithRejectionCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDealWithRejectionCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamFinishErroringCode;
+extern const int s_writableStreamInternalsWritableStreamFinishErroringCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishErroringCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishErroringCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode;
+extern const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode;
+extern const int s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteCode;
+extern const int s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCode;
+extern const int s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCode;
+extern const int s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCode;
+extern const int s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode;
+extern const int s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode;
+extern const int s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamStartErroringCode;
+extern const int s_writableStreamInternalsWritableStreamStartErroringCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamStartErroringCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamStartErroringCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamUpdateBackpressureCode;
+extern const int s_writableStreamInternalsWritableStreamUpdateBackpressureCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamUpdateBackpressureCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterReleaseCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeConstructorKind;
+extern const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode;
+extern const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructorKind;
+extern const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode;
+extern const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructorKind;
+extern const char* const s_writableStreamInternalsIsCloseSentinelCode;
+extern const int s_writableStreamInternalsIsCloseSentinelCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsIsCloseSentinelCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsIsCloseSentinelCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerCloseCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeConstructorKind;
+extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode;
+extern const int s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeLength;
+extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructAbility;
+extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructorKind;
+
+#define WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_DATA(macro) \
+ macro(isWritableStream, writableStreamInternalsIsWritableStream, 1) \
+ macro(isWritableStreamDefaultWriter, writableStreamInternalsIsWritableStreamDefaultWriter, 1) \
+ macro(acquireWritableStreamDefaultWriter, writableStreamInternalsAcquireWritableStreamDefaultWriter, 1) \
+ macro(createWritableStream, writableStreamInternalsCreateWritableStream, 6) \
+ macro(createInternalWritableStreamFromUnderlyingSink, writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSink, 2) \
+ macro(initializeWritableStreamSlots, writableStreamInternalsInitializeWritableStreamSlots, 2) \
+ macro(writableStreamCloseForBindings, writableStreamInternalsWritableStreamCloseForBindings, 1) \
+ macro(writableStreamAbortForBindings, writableStreamInternalsWritableStreamAbortForBindings, 2) \
+ macro(isWritableStreamLocked, writableStreamInternalsIsWritableStreamLocked, 1) \
+ macro(setUpWritableStreamDefaultWriter, writableStreamInternalsSetUpWritableStreamDefaultWriter, 2) \
+ macro(writableStreamAbort, writableStreamInternalsWritableStreamAbort, 2) \
+ macro(writableStreamClose, writableStreamInternalsWritableStreamClose, 1) \
+ macro(writableStreamAddWriteRequest, writableStreamInternalsWritableStreamAddWriteRequest, 1) \
+ macro(writableStreamCloseQueuedOrInFlight, writableStreamInternalsWritableStreamCloseQueuedOrInFlight, 1) \
+ macro(writableStreamDealWithRejection, writableStreamInternalsWritableStreamDealWithRejection, 2) \
+ macro(writableStreamFinishErroring, writableStreamInternalsWritableStreamFinishErroring, 1) \
+ macro(writableStreamFinishInFlightClose, writableStreamInternalsWritableStreamFinishInFlightClose, 1) \
+ macro(writableStreamFinishInFlightCloseWithError, writableStreamInternalsWritableStreamFinishInFlightCloseWithError, 2) \
+ macro(writableStreamFinishInFlightWrite, writableStreamInternalsWritableStreamFinishInFlightWrite, 1) \
+ macro(writableStreamFinishInFlightWriteWithError, writableStreamInternalsWritableStreamFinishInFlightWriteWithError, 2) \
+ macro(writableStreamHasOperationMarkedInFlight, writableStreamInternalsWritableStreamHasOperationMarkedInFlight, 1) \
+ macro(writableStreamMarkCloseRequestInFlight, writableStreamInternalsWritableStreamMarkCloseRequestInFlight, 1) \
+ macro(writableStreamMarkFirstWriteRequestInFlight, writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlight, 1) \
+ macro(writableStreamRejectCloseAndClosedPromiseIfNeeded, writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeeded, 1) \
+ macro(writableStreamStartErroring, writableStreamInternalsWritableStreamStartErroring, 2) \
+ macro(writableStreamUpdateBackpressure, writableStreamInternalsWritableStreamUpdateBackpressure, 2) \
+ macro(writableStreamDefaultWriterAbort, writableStreamInternalsWritableStreamDefaultWriterAbort, 2) \
+ macro(writableStreamDefaultWriterClose, writableStreamInternalsWritableStreamDefaultWriterClose, 1) \
+ macro(writableStreamDefaultWriterCloseWithErrorPropagation, writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagation, 1) \
+ macro(writableStreamDefaultWriterEnsureClosedPromiseRejected, writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejected, 2) \
+ macro(writableStreamDefaultWriterEnsureReadyPromiseRejected, writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejected, 2) \
+ macro(writableStreamDefaultWriterGetDesiredSize, writableStreamInternalsWritableStreamDefaultWriterGetDesiredSize, 1) \
+ macro(writableStreamDefaultWriterRelease, writableStreamInternalsWritableStreamDefaultWriterRelease, 1) \
+ macro(writableStreamDefaultWriterWrite, writableStreamInternalsWritableStreamDefaultWriterWrite, 2) \
+ macro(setUpWritableStreamDefaultController, writableStreamInternalsSetUpWritableStreamDefaultController, 8) \
+ macro(setUpWritableStreamDefaultControllerFromUnderlyingSink, writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSink, 5) \
+ macro(writableStreamDefaultControllerAdvanceQueueIfNeeded, writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeeded, 1) \
+ macro(isCloseSentinel, writableStreamInternalsIsCloseSentinel, 0) \
+ macro(writableStreamDefaultControllerClearAlgorithms, writableStreamInternalsWritableStreamDefaultControllerClearAlgorithms, 1) \
+ macro(writableStreamDefaultControllerClose, writableStreamInternalsWritableStreamDefaultControllerClose, 1) \
+ macro(writableStreamDefaultControllerError, writableStreamInternalsWritableStreamDefaultControllerError, 2) \
+ macro(writableStreamDefaultControllerErrorIfNeeded, writableStreamInternalsWritableStreamDefaultControllerErrorIfNeeded, 2) \
+ macro(writableStreamDefaultControllerGetBackpressure, writableStreamInternalsWritableStreamDefaultControllerGetBackpressure, 1) \
+ macro(writableStreamDefaultControllerGetChunkSize, writableStreamInternalsWritableStreamDefaultControllerGetChunkSize, 2) \
+ macro(writableStreamDefaultControllerGetDesiredSize, writableStreamInternalsWritableStreamDefaultControllerGetDesiredSize, 1) \
+ macro(writableStreamDefaultControllerProcessClose, writableStreamInternalsWritableStreamDefaultControllerProcessClose, 1) \
+ macro(writableStreamDefaultControllerProcessWrite, writableStreamInternalsWritableStreamDefaultControllerProcessWrite, 2) \
+ macro(writableStreamDefaultControllerWrite, writableStreamInternalsWritableStreamDefaultControllerWrite, 3) \
+
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ISWRITABLESTREAM 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ISWRITABLESTREAMDEFAULTWRITER 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ACQUIREWRITABLESTREAMDEFAULTWRITER 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_CREATEWRITABLESTREAM 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_CREATEINTERNALWRITABLESTREAMFROMUNDERLYINGSINK 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_INITIALIZEWRITABLESTREAMSLOTS 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMCLOSEFORBINDINGS 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMABORTFORBINDINGS 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ISWRITABLESTREAMLOCKED 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_SETUPWRITABLESTREAMDEFAULTWRITER 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMABORT 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMCLOSE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMADDWRITEREQUEST 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMCLOSEQUEUEDORINFLIGHT 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEALWITHREJECTION 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHERRORING 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHINFLIGHTCLOSE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHINFLIGHTCLOSEWITHERROR 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHINFLIGHTWRITE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHINFLIGHTWRITEWITHERROR 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMHASOPERATIONMARKEDINFLIGHT 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMMARKCLOSEREQUESTINFLIGHT 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMMARKFIRSTWRITEREQUESTINFLIGHT 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMREJECTCLOSEANDCLOSEDPROMISEIFNEEDED 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMSTARTERRORING 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMUPDATEBACKPRESSURE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERABORT 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERCLOSE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERCLOSEWITHERRORPROPAGATION 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERENSURECLOSEDPROMISEREJECTED 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERENSUREREADYPROMISEREJECTED 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERGETDESIREDSIZE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERRELEASE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERWRITE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_SETUPWRITABLESTREAMDEFAULTCONTROLLER 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_SETUPWRITABLESTREAMDEFAULTCONTROLLERFROMUNDERLYINGSINK 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERADVANCEQUEUEIFNEEDED 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ISCLOSESENTINEL 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERCLEARALGORITHMS 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERCLOSE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERERROR 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERERRORIFNEEDED 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERGETBACKPRESSURE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERGETCHUNKSIZE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERGETDESIREDSIZE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERPROCESSCLOSE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERPROCESSWRITE 1
+#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERWRITE 1
+
+#define WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_CODE(macro) \
+ macro(writableStreamInternalsIsWritableStreamCode, isWritableStream, ASCIILiteral(), s_writableStreamInternalsIsWritableStreamCodeLength) \
+ macro(writableStreamInternalsIsWritableStreamDefaultWriterCode, isWritableStreamDefaultWriter, ASCIILiteral(), s_writableStreamInternalsIsWritableStreamDefaultWriterCodeLength) \
+ macro(writableStreamInternalsAcquireWritableStreamDefaultWriterCode, acquireWritableStreamDefaultWriter, ASCIILiteral(), s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeLength) \
+ macro(writableStreamInternalsCreateWritableStreamCode, createWritableStream, ASCIILiteral(), s_writableStreamInternalsCreateWritableStreamCodeLength) \
+ macro(writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode, createInternalWritableStreamFromUnderlyingSink, ASCIILiteral(), s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength) \
+ macro(writableStreamInternalsInitializeWritableStreamSlotsCode, initializeWritableStreamSlots, ASCIILiteral(), s_writableStreamInternalsInitializeWritableStreamSlotsCodeLength) \
+ macro(writableStreamInternalsWritableStreamCloseForBindingsCode, writableStreamCloseForBindings, ASCIILiteral(), s_writableStreamInternalsWritableStreamCloseForBindingsCodeLength) \
+ macro(writableStreamInternalsWritableStreamAbortForBindingsCode, writableStreamAbortForBindings, ASCIILiteral(), s_writableStreamInternalsWritableStreamAbortForBindingsCodeLength) \
+ macro(writableStreamInternalsIsWritableStreamLockedCode, isWritableStreamLocked, ASCIILiteral(), s_writableStreamInternalsIsWritableStreamLockedCodeLength) \
+ macro(writableStreamInternalsSetUpWritableStreamDefaultWriterCode, setUpWritableStreamDefaultWriter, ASCIILiteral(), s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeLength) \
+ macro(writableStreamInternalsWritableStreamAbortCode, writableStreamAbort, ASCIILiteral(), s_writableStreamInternalsWritableStreamAbortCodeLength) \
+ macro(writableStreamInternalsWritableStreamCloseCode, writableStreamClose, ASCIILiteral(), s_writableStreamInternalsWritableStreamCloseCodeLength) \
+ macro(writableStreamInternalsWritableStreamAddWriteRequestCode, writableStreamAddWriteRequest, ASCIILiteral(), s_writableStreamInternalsWritableStreamAddWriteRequestCodeLength) \
+ macro(writableStreamInternalsWritableStreamCloseQueuedOrInFlightCode, writableStreamCloseQueuedOrInFlight, ASCIILiteral(), s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeLength) \
+ macro(writableStreamInternalsWritableStreamDealWithRejectionCode, writableStreamDealWithRejection, ASCIILiteral(), s_writableStreamInternalsWritableStreamDealWithRejectionCodeLength) \
+ macro(writableStreamInternalsWritableStreamFinishErroringCode, writableStreamFinishErroring, ASCIILiteral(), s_writableStreamInternalsWritableStreamFinishErroringCodeLength) \
+ macro(writableStreamInternalsWritableStreamFinishInFlightCloseCode, writableStreamFinishInFlightClose, ASCIILiteral(), s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength) \
+ macro(writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode, writableStreamFinishInFlightCloseWithError, ASCIILiteral(), s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeLength) \
+ macro(writableStreamInternalsWritableStreamFinishInFlightWriteCode, writableStreamFinishInFlightWrite, ASCIILiteral(), s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeLength) \
+ macro(writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCode, writableStreamFinishInFlightWriteWithError, ASCIILiteral(), s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeLength) \
+ macro(writableStreamInternalsWritableStreamHasOperationMarkedInFlightCode, writableStreamHasOperationMarkedInFlight, ASCIILiteral(), s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeLength) \
+ macro(writableStreamInternalsWritableStreamMarkCloseRequestInFlightCode, writableStreamMarkCloseRequestInFlight, ASCIILiteral(), s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeLength) \
+ macro(writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode, writableStreamMarkFirstWriteRequestInFlight, ASCIILiteral(), s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeLength) \
+ macro(writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode, writableStreamRejectCloseAndClosedPromiseIfNeeded, ASCIILiteral(), s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength) \
+ macro(writableStreamInternalsWritableStreamStartErroringCode, writableStreamStartErroring, ASCIILiteral(), s_writableStreamInternalsWritableStreamStartErroringCodeLength) \
+ macro(writableStreamInternalsWritableStreamUpdateBackpressureCode, writableStreamUpdateBackpressure, ASCIILiteral(), s_writableStreamInternalsWritableStreamUpdateBackpressureCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultWriterAbortCode, writableStreamDefaultWriterAbort, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultWriterCloseCode, writableStreamDefaultWriterClose, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode, writableStreamDefaultWriterCloseWithErrorPropagation, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode, writableStreamDefaultWriterEnsureClosedPromiseRejected, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode, writableStreamDefaultWriterEnsureReadyPromiseRejected, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode, writableStreamDefaultWriterGetDesiredSize, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultWriterReleaseCode, writableStreamDefaultWriterRelease, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultWriterWriteCode, writableStreamDefaultWriterWrite, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeLength) \
+ macro(writableStreamInternalsSetUpWritableStreamDefaultControllerCode, setUpWritableStreamDefaultController, ASCIILiteral(), s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeLength) \
+ macro(writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode, setUpWritableStreamDefaultControllerFromUnderlyingSink, ASCIILiteral(), s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode, writableStreamDefaultControllerAdvanceQueueIfNeeded, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeLength) \
+ macro(writableStreamInternalsIsCloseSentinelCode, isCloseSentinel, ASCIILiteral(), s_writableStreamInternalsIsCloseSentinelCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCode, writableStreamDefaultControllerClearAlgorithms, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultControllerCloseCode, writableStreamDefaultControllerClose, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultControllerErrorCode, writableStreamDefaultControllerError, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCode, writableStreamDefaultControllerErrorIfNeeded, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCode, writableStreamDefaultControllerGetBackpressure, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCode, writableStreamDefaultControllerGetChunkSize, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCode, writableStreamDefaultControllerGetDesiredSize, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultControllerProcessCloseCode, writableStreamDefaultControllerProcessClose, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode, writableStreamDefaultControllerProcessWrite, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeLength) \
+ macro(writableStreamInternalsWritableStreamDefaultControllerWriteCode, writableStreamDefaultControllerWrite, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeLength) \
+
+#define WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \
+ macro(acquireWritableStreamDefaultWriter) \
+ macro(createInternalWritableStreamFromUnderlyingSink) \
+ macro(createWritableStream) \
+ macro(initializeWritableStreamSlots) \
+ macro(isCloseSentinel) \
+ macro(isWritableStream) \
+ macro(isWritableStreamDefaultWriter) \
+ macro(isWritableStreamLocked) \
+ macro(setUpWritableStreamDefaultController) \
+ macro(setUpWritableStreamDefaultControllerFromUnderlyingSink) \
+ macro(setUpWritableStreamDefaultWriter) \
+ macro(writableStreamAbort) \
+ macro(writableStreamAbortForBindings) \
+ macro(writableStreamAddWriteRequest) \
+ macro(writableStreamClose) \
+ macro(writableStreamCloseForBindings) \
+ macro(writableStreamCloseQueuedOrInFlight) \
+ macro(writableStreamDealWithRejection) \
+ macro(writableStreamDefaultControllerAdvanceQueueIfNeeded) \
+ macro(writableStreamDefaultControllerClearAlgorithms) \
+ macro(writableStreamDefaultControllerClose) \
+ macro(writableStreamDefaultControllerError) \
+ macro(writableStreamDefaultControllerErrorIfNeeded) \
+ macro(writableStreamDefaultControllerGetBackpressure) \
+ macro(writableStreamDefaultControllerGetChunkSize) \
+ macro(writableStreamDefaultControllerGetDesiredSize) \
+ macro(writableStreamDefaultControllerProcessClose) \
+ macro(writableStreamDefaultControllerProcessWrite) \
+ macro(writableStreamDefaultControllerWrite) \
+ macro(writableStreamDefaultWriterAbort) \
+ macro(writableStreamDefaultWriterClose) \
+ macro(writableStreamDefaultWriterCloseWithErrorPropagation) \
+ macro(writableStreamDefaultWriterEnsureClosedPromiseRejected) \
+ macro(writableStreamDefaultWriterEnsureReadyPromiseRejected) \
+ macro(writableStreamDefaultWriterGetDesiredSize) \
+ macro(writableStreamDefaultWriterRelease) \
+ macro(writableStreamDefaultWriterWrite) \
+ macro(writableStreamFinishErroring) \
+ macro(writableStreamFinishInFlightClose) \
+ macro(writableStreamFinishInFlightCloseWithError) \
+ macro(writableStreamFinishInFlightWrite) \
+ macro(writableStreamFinishInFlightWriteWithError) \
+ macro(writableStreamHasOperationMarkedInFlight) \
+ macro(writableStreamMarkCloseRequestInFlight) \
+ macro(writableStreamMarkFirstWriteRequestInFlight) \
+ macro(writableStreamRejectCloseAndClosedPromiseIfNeeded) \
+ macro(writableStreamStartErroring) \
+ macro(writableStreamUpdateBackpressure) \
+
+#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \
+ JSC::FunctionExecutable* codeName##Generator(JSC::VM&);
+
+WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR)
+#undef DECLARE_BUILTIN_GENERATOR
+
+class WritableStreamInternalsBuiltinsWrapper : private JSC::WeakHandleOwner {
+public:
+ explicit WritableStreamInternalsBuiltinsWrapper(JSC::VM& vm)
+ : m_vm(vm)
+ WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_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_WRITABLESTREAMINTERNALS_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_WRITABLESTREAMINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES)
+#undef EXPOSE_BUILTIN_EXECUTABLES
+
+ WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR)
+
+ void exportNames();
+
+private:
+ JSC::VM& m_vm;
+
+ WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_NAMES)
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(name, functionName, overriddenName, length) \
+ JSC::SourceCode m_##name##Source;\
+ JSC::Weak<JSC::UnlinkedFunctionExecutable> m_##name##Executable;
+ WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+
+};
+
+#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \
+inline JSC::UnlinkedFunctionExecutable* WritableStreamInternalsBuiltinsWrapper::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::UnlinkedFunctionExecutable>(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_WRITABLESTREAMINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES)
+#undef DEFINE_BUILTIN_EXECUTABLES
+
+inline void WritableStreamInternalsBuiltinsWrapper::exportNames()
+{
+#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName());
+ WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME)
+#undef EXPORT_FUNCTION_NAME
+}
+
+class WritableStreamInternalsBuiltinFunctions {
+public:
+ explicit WritableStreamInternalsBuiltinFunctions(JSC::VM& vm) : m_vm(vm) { }
+
+ void init(JSC::JSGlobalObject&);
+ template<typename Visitor> void visit(Visitor&);
+
+public:
+ JSC::VM& m_vm;
+
+#define DECLARE_BUILTIN_SOURCE_MEMBERS(functionName) \
+ JSC::WriteBarrier<JSC::JSFunction> m_##functionName##Function;
+ WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS)
+#undef DECLARE_BUILTIN_SOURCE_MEMBERS
+};
+
+inline void WritableStreamInternalsBuiltinFunctions::init(JSC::JSGlobalObject& globalObject)
+{
+#define EXPORT_FUNCTION(codeName, functionName, overriddenName, length)\
+ m_##functionName##Function.set(m_vm, &globalObject, JSC::JSFunction::create(m_vm, codeName##Generator(m_vm), &globalObject));
+ WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_CODE(EXPORT_FUNCTION)
+#undef EXPORT_FUNCTION
+}
+
+template<typename Visitor>
+inline void WritableStreamInternalsBuiltinFunctions::visit(Visitor& visitor)
+{
+#define VISIT_FUNCTION(name) visitor.append(m_##name##Function);
+ WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION)
+#undef VISIT_FUNCTION
+}
+
+template void WritableStreamInternalsBuiltinFunctions::visit(JSC::AbstractSlotVisitor&);
+template void WritableStreamInternalsBuiltinFunctions::visit(JSC::SlotVisitor&);
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
index 9498d6b14..7d531c7e9 100644
--- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp
+++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
@@ -112,6 +112,26 @@ namespace JSCastingHelpers = JSC::JSCastingHelpers;
using JSBuffer = WebCore::JSBuffer;
#include <dlfcn.h>
+#include "IDLTypes.h"
+
+#include "JSAbortAlgorithm.h"
+#include "JSDOMAttribute.h"
+#include "JSByteLengthQueuingStrategy.h"
+#include "JSCountQueuingStrategy.h"
+#include "JSReadableByteStreamController.h"
+#include "JSReadableStream.h"
+#include "JSReadableStreamBYOBReader.h"
+#include "JSReadableStreamBYOBRequest.h"
+#include "JSReadableStreamDefaultController.h"
+#include "JSReadableStreamDefaultReader.h"
+#include "JSTransformStream.h"
+#include "JSTransformStreamDefaultController.h"
+#include "JSWritableStream.h"
+#include "JSWritableStreamDefaultController.h"
+#include "JSWritableStreamDefaultWriter.h"
+#include "JavaScriptCore/BuiltinNames.h"
+#include "StructuredClone.h"
+
// #include <iostream>
static bool has_loaded_jsc = false;
@@ -307,6 +327,13 @@ GlobalObject::GlobalObject(JSC::VM& vm, JSC::Structure* structure)
m_scriptExecutionContext = new WebCore::ScriptExecutionContext(&vm, this);
}
+GlobalObject::~GlobalObject() = default;
+
+void GlobalObject::destroy(JSCell* cell)
+{
+ static_cast<GlobalObject*>(cell)->GlobalObject::~GlobalObject();
+}
+
WebCore::ScriptExecutionContext* GlobalObject::scriptExecutionContext()
{
return m_scriptExecutionContext;
@@ -827,6 +854,23 @@ static JSC_DEFINE_HOST_FUNCTION(functionReportError,
return JSC::JSValue::encode(JSC::jsUndefined());
}
+JSC_DEFINE_HOST_FUNCTION(functionNoop, (JSC::JSGlobalObject*, JSC::CallFrame*))
+{
+ return JSC::JSValue::encode(JSC::jsUndefined());
+}
+
+JSC_DEFINE_CUSTOM_GETTER(noop_getter, (JSGlobalObject*, EncodedJSValue, PropertyName))
+{
+ return JSC::JSValue::encode(JSC::jsUndefined());
+}
+
+JSC_DEFINE_CUSTOM_SETTER(noop_setter,
+ (JSC::JSGlobalObject*, JSC::EncodedJSValue,
+ JSC::EncodedJSValue, JSC::PropertyName))
+{
+ return true;
+}
+
// we're trying out a new way to do this lazy loading
static JSC_DECLARE_HOST_FUNCTION(functionLazyLoad);
static JSC_DEFINE_HOST_FUNCTION(functionLazyLoad,
@@ -843,6 +887,7 @@ JSC:
}
default: {
static NeverDestroyed<const String> sqliteString(MAKE_STATIC_STRING_IMPL("sqlite"));
+ static NeverDestroyed<const String> noopString(MAKE_STATIC_STRING_IMPL("noop"));
JSC::JSValue moduleName = callFrame->argument(0);
auto string = moduleName.toWTFString(globalObject);
if (string.isNull()) {
@@ -856,6 +901,14 @@ JSC:
return JSC::JSValue::encode(JSSQLStatementConstructor::create(vm, globalObject, JSSQLStatementConstructor::createStructure(vm, globalObject, globalObject->m_functionPrototype.get())));
}
+ if (UNLIKELY(string == noopString)) {
+ auto* obj = constructEmptyObject(globalObject);
+ obj->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "getterSetter"_s)), JSC::CustomGetterSetter::create(vm, noop_getter, noop_setter), 0);
+ Zig::JSFFIFunction* function = Zig::JSFFIFunction::create(vm, reinterpret_cast<Zig::GlobalObject*>(globalObject), 0, String(), functionNoop, JSC::NoIntrinsic);
+ obj->putDirect(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "function"_s)), function, JSC::PropertyAttribute::Function | 0);
+ return JSC::JSValue::encode(obj);
+ }
+
return JSC::JSValue::encode(JSC::jsUndefined());
break;
@@ -863,56 +916,277 @@ JSC:
}
}
-// This is not a publicly exposed API currently.
-// This is used by the bundler to make Response, Request, FetchEvent,
-// and any other objects available globally.
-void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm)
+static inline JSValue jsServiceWorkerGlobalScope_ByteLengthQueuingStrategyConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
{
- auto clientData = WebCore::clientData(vm);
- size_t constructor_count = 0;
- JSC__JSValue const* constructors = Zig__getAPIConstructors(&constructor_count, this);
- WTF::Vector<GlobalPropertyInfo> extraStaticGlobals;
- extraStaticGlobals.reserveCapacity((size_t)count + constructor_count + 3 + 11);
- int i = 0;
- for (; i < constructor_count; i++) {
- auto* object = JSC::jsDynamicCast<JSC::JSCallbackConstructor*>(JSC::JSValue::decode(constructors[i]).asCell()->getObject());
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSByteLengthQueuingStrategy::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo { JSC::Identifier::fromString(vm, object->get(this, vm.propertyNames->name).toWTFString(this)),
- JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 });
- }
- int j = 0;
- for (; j < count - 1; j++) {
- auto jsClass = globals[j];
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ByteLengthQueuingStrategyConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ByteLengthQueuingStrategyConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
- JSC::JSCallbackObject<JSNonFinalObject>* object = JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
- jsClass, nullptr);
- if (JSObject* prototype = object->classRef()->prototype(this))
- object->setPrototypeDirect(vm, prototype);
+static inline JSValue jsServiceWorkerGlobalScope_CountQueuingStrategyConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSCountQueuingStrategy::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo { JSC::Identifier::fromString(vm, jsClass->className()),
- JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 });
- }
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_CountQueuingStrategyConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_CountQueuingStrategyConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
- // The last one must be "process.env"
- // Runtime-support is for if they change
- dot_env_class_ref = globals[j];
+static inline JSValue jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSReadableByteStreamController::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
- // // The last one must be "process.env"
- // // Runtime-support is for if they change
- // {
- // auto jsClass = globals[i];
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
- // JSC::JSCallbackObject<JSNonFinalObject> *object =
- // JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
- // jsClass, nullptr);
- // if (JSObject *prototype = jsClass->prototype(this)) object->setPrototypeDirect(vm,
- // prototype);
+static inline JSValue jsServiceWorkerGlobalScope_ReadableStreamConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSReadableStream::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
- // process->putDirect(this->vm, JSC::Identifier::fromString(this->vm, "env"),
- // JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0);
- // }
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableStreamConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableStreamConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSReadableStreamBYOBReader::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSReadableStreamBYOBRequest::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSReadableStreamDefaultController::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSReadableStreamDefaultReader::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsServiceWorkerGlobalScope_TransformStreamConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSTransformStream::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_TransformStreamConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_TransformStreamConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSTransformStreamDefaultController::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsServiceWorkerGlobalScope_WritableStreamConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSWritableStream::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_WritableStreamConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_WritableStreamConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSWritableStreamDefaultController::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSWritableStreamDefaultWriter::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+JSC_DECLARE_HOST_FUNCTION(makeThisTypeErrorForBuiltins);
+JSC_DECLARE_HOST_FUNCTION(makeGetterTypeErrorForBuiltins);
+JSC_DECLARE_HOST_FUNCTION(makeDOMExceptionForBuiltins);
+JSC_DECLARE_HOST_FUNCTION(createWritableStreamFromInternal);
+JSC_DECLARE_HOST_FUNCTION(getInternalWritableStream);
+JSC_DECLARE_HOST_FUNCTION(whenSignalAborted);
+JSC_DECLARE_HOST_FUNCTION(isAbortSignal);
+JSC_DEFINE_HOST_FUNCTION(makeThisTypeErrorForBuiltins, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ ASSERT(callFrame);
+ ASSERT(callFrame->argumentCount() == 2);
+ VM& vm = globalObject->vm();
+ DeferTermination deferScope(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+
+ auto interfaceName = callFrame->uncheckedArgument(0).getString(globalObject);
+ scope.assertNoException();
+ auto functionName = callFrame->uncheckedArgument(1).getString(globalObject);
+ scope.assertNoException();
+ return JSValue::encode(createTypeError(globalObject, makeThisTypeErrorMessage(interfaceName.utf8().data(), functionName.utf8().data())));
+}
+
+JSC_DEFINE_HOST_FUNCTION(makeGetterTypeErrorForBuiltins, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ ASSERT(callFrame);
+ ASSERT(callFrame->argumentCount() == 2);
+ VM& vm = globalObject->vm();
+ DeferTermination deferScope(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+
+ auto interfaceName = callFrame->uncheckedArgument(0).getString(globalObject);
+ scope.assertNoException();
+ auto attributeName = callFrame->uncheckedArgument(1).getString(globalObject);
+ scope.assertNoException();
+
+ auto error = static_cast<ErrorInstance*>(createTypeError(globalObject, JSC::makeDOMAttributeGetterTypeErrorMessage(interfaceName.utf8().data(), attributeName)));
+ error->setNativeGetterTypeError();
+ return JSValue::encode(error);
+}
+
+JSC_DEFINE_HOST_FUNCTION(makeDOMExceptionForBuiltins, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ ASSERT(callFrame);
+ ASSERT(callFrame->argumentCount() == 2);
+
+ auto& vm = globalObject->vm();
+ DeferTermination deferScope(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+
+ auto codeValue = callFrame->uncheckedArgument(0).getString(globalObject);
+ scope.assertNoException();
+
+ auto message = callFrame->uncheckedArgument(1).getString(globalObject);
+ scope.assertNoException();
+
+ ExceptionCode code { TypeError };
+ if (codeValue == "AbortError")
+ code = AbortError;
+ auto value = createDOMException(globalObject, code, message);
+
+ EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+
+ return JSValue::encode(value);
+}
+
+JSC_DEFINE_HOST_FUNCTION(getInternalWritableStream, (JSGlobalObject*, CallFrame* callFrame))
+{
+ ASSERT(callFrame);
+ ASSERT(callFrame->argumentCount() == 1);
+
+ auto* writableStream = jsDynamicCast<JSWritableStream*>(callFrame->uncheckedArgument(0));
+ if (UNLIKELY(!writableStream))
+ return JSValue::encode(jsUndefined());
+ return JSValue::encode(writableStream->wrapped().internalWritableStream());
+}
+
+JSC_DEFINE_HOST_FUNCTION(createWritableStreamFromInternal, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ ASSERT(callFrame);
+ ASSERT(callFrame->argumentCount() == 1);
+ ASSERT(callFrame->uncheckedArgument(0).isObject());
+
+ auto* jsDOMGlobalObject = JSC::jsCast<JSDOMGlobalObject*>(globalObject);
+ auto internalWritableStream = InternalWritableStream::fromObject(*jsDOMGlobalObject, *callFrame->uncheckedArgument(0).toObject(globalObject));
+ return JSValue::encode(toJSNewlyCreated(globalObject, jsDOMGlobalObject, WritableStream::create(WTFMove(internalWritableStream))));
+}
+
+JSC_DEFINE_HOST_FUNCTION(whenSignalAborted, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ ASSERT(callFrame);
+ ASSERT(callFrame->argumentCount() == 2);
+
+ auto& vm = globalObject->vm();
+ auto* abortSignal = jsDynamicCast<JSAbortSignal*>(callFrame->uncheckedArgument(0));
+ if (UNLIKELY(!abortSignal))
+ return JSValue::encode(JSValue(JSC::JSValue::JSFalse));
+
+ Ref<AbortAlgorithm> abortAlgorithm = JSAbortAlgorithm::create(vm, callFrame->uncheckedArgument(1).getObject());
+
+ bool result = AbortSignal::whenSignalAborted(abortSignal->wrapped(), WTFMove(abortAlgorithm));
+ return JSValue::encode(result ? JSValue(JSC::JSValue::JSTrue) : JSValue(JSC::JSValue::JSFalse));
+}
+
+JSC_DEFINE_HOST_FUNCTION(isAbortSignal, (JSGlobalObject*, CallFrame* callFrame))
+{
+ ASSERT(callFrame->argumentCount() == 1);
+ return JSValue::encode(jsBoolean(callFrame->uncheckedArgument(0).inherits<JSAbortSignal>()));
+}
+
+void GlobalObject::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+ addBuiltinGlobals(vm);
+
+ RELEASE_ASSERT(classInfo());
+}
+
+void GlobalObject::addBuiltinGlobals(JSC::VM& vm)
+{
+ m_builtinInternalFunctions.initialize(*this);
+
+ auto clientData = WebCore::clientData(vm);
+ auto& builtinNames = WebCore::builtinNames(vm);
+
+ WTF::Vector<GlobalPropertyInfo> extraStaticGlobals;
+ extraStaticGlobals.reserveCapacity(26);
JSC::Identifier queueMicrotaskIdentifier = JSC::Identifier::fromString(vm, "queueMicrotask"_s);
extraStaticGlobals.uncheckedAppend(
@@ -977,17 +1251,26 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm
BunLazyString, functionLazyLoad),
JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::Function | 0 });
- this->addStaticGlobals(extraStaticGlobals.data(), extraStaticGlobals.size());
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.makeThisTypeErrorPrivateName(), JSFunction::create(vm, this, 2, String(), makeThisTypeErrorForBuiltins), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.makeGetterTypeErrorPrivateName(), JSFunction::create(vm, this, 2, String(), makeGetterTypeErrorForBuiltins), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.makeDOMExceptionPrivateName(), JSFunction::create(vm, this, 2, String(), makeDOMExceptionForBuiltins), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.whenSignalAbortedPrivateName(), JSFunction::create(vm, this, 2, String(), whenSignalAborted), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.cloneArrayBufferPrivateName(), JSFunction::create(vm, this, 3, String(), cloneArrayBuffer), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.structuredCloneForStreamPrivateName(), JSFunction::create(vm, this, 1, String(), structuredCloneForStream), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(vm.propertyNames->builtinNames().ArrayBufferPrivateName(), arrayBufferConstructor(), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.streamClosedPrivateName(), jsNumber(1), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.streamClosingPrivateName(), jsNumber(2), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.streamErroredPrivateName(), jsNumber(3), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.streamReadablePrivateName(), jsNumber(4), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.streamWaitingPrivateName(), jsNumber(5), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.streamWritablePrivateName(), jsNumber(6), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.isAbortSignalPrivateName(), JSFunction::create(vm, this, 1, String(), isAbortSignal), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.getInternalWritableStreamPrivateName(), JSFunction::create(vm, this, 1, String(), getInternalWritableStream), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
+ extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo(builtinNames.createWritableStreamFromInternalPrivateName(), JSFunction::create(vm, this, 1, String(), createWritableStreamFromInternal), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly));
- m_NapiClassStructure.initLater(
- [](LazyClassStructure::Initializer& init) {
- init.setStructure(Zig::NapiClass::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()));
- });
+ this->addStaticGlobals(extraStaticGlobals.data(), extraStaticGlobals.size());
- m_JSFFIFunctionStructure.initLater(
- [](LazyClassStructure::Initializer& init) {
- init.setStructure(Zig::JSFFIFunction::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()));
- });
+ extraStaticGlobals.releaseBuffer();
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "process"_s), JSC::CustomGetterSetter::create(vm, property_lazyProcessGetter, property_lazyProcessSetter),
JSC::PropertyAttribute::CustomAccessor | 0);
@@ -1025,6 +1308,99 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "Buffer"_s), JSC::CustomGetterSetter::create(vm, JSBuffer_getter, nullptr),
JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TransformStreamPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamConstructor, nullptr), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TransformStreamPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamConstructor, nullptr), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TransformStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructor, nullptr), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TransformStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructor, nullptr), attributesForStructure(static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableByteStreamControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamBYOBReaderPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamBYOBRequestPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamDefaultReaderPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WritableStreamPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WritableStreamDefaultControllerPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WritableStreamDefaultWriterPrivateName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructor, nullptr), attributesForStructure(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().AbortSignalPrivateName(), CustomGetterSetter::create(vm, JSDOMAbortSignal_getter, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().TransformStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_TransformStreamDefaultControllerConstructor, nullptr), static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontEnum));
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableByteStreamControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamBYOBReaderPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBReaderConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamBYOBRequestPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamBYOBRequestConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultControllerConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().ReadableStreamDefaultReaderPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ReadableStreamDefaultReaderConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WritableStreamPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WritableStreamDefaultControllerPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultControllerConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().WritableStreamDefaultWriterPublicName(), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_WritableStreamDefaultWriterConstructor, nullptr), JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "ByteLengthQueuingStrategy"_s), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_ByteLengthQueuingStrategyConstructor, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+ putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "CountQueuingStrategy"_s), CustomGetterSetter::create(vm, jsServiceWorkerGlobalScope_CountQueuingStrategyConstructor, nullptr), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
+}
+
+// This is not a publicly exposed API currently.
+// This is used by the bundler to make Response, Request, FetchEvent,
+// and any other objects available globally.
+void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm)
+{
+ auto clientData = WebCore::clientData(vm);
+ size_t constructor_count = 0;
+ JSC__JSValue const* constructors = Zig__getAPIConstructors(&constructor_count, this);
+ WTF::Vector<GlobalPropertyInfo> extraStaticGlobals;
+ extraStaticGlobals.reserveCapacity((size_t)count + constructor_count + 3 + 1);
+ int i = 0;
+ for (; i < constructor_count; i++) {
+ auto* object = JSC::jsDynamicCast<JSC::JSCallbackConstructor*>(JSC::JSValue::decode(constructors[i]).asCell()->getObject());
+
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { JSC::Identifier::fromString(vm, object->get(this, vm.propertyNames->name).toWTFString(this)),
+ JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 });
+ }
+ int j = 0;
+ for (; j < count - 1; j++) {
+ auto jsClass = globals[j];
+
+ JSC::JSCallbackObject<JSNonFinalObject>* object = JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
+ jsClass, nullptr);
+ if (JSObject* prototype = object->classRef()->prototype(this))
+ object->setPrototypeDirect(vm, prototype);
+
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { JSC::Identifier::fromString(vm, jsClass->className()),
+ JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 });
+ }
+
+ // The last one must be "process.env"
+ // Runtime-support is for if they change
+ dot_env_class_ref = globals[j];
+
+ // // The last one must be "process.env"
+ // // Runtime-support is for if they change
+ // {
+ // auto jsClass = globals[i];
+
+ // JSC::JSCallbackObject<JSNonFinalObject> *object =
+ // JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
+ // jsClass, nullptr);
+ // if (JSObject *prototype = jsClass->prototype(this)) object->setPrototypeDirect(vm,
+ // prototype);
+
+ // process->putDirect(this->vm, JSC::Identifier::fromString(this->vm, "env"),
+ // JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0);
+ // }
+
+ this->addStaticGlobals(extraStaticGlobals.data(), extraStaticGlobals.size());
+
+ m_NapiClassStructure.initLater(
+ [](LazyClassStructure::Initializer& init) {
+ init.setStructure(Zig::NapiClass::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()));
+ });
+
+ m_JSFFIFunctionStructure.initLater(
+ [](LazyClassStructure::Initializer& init) {
+ init.setStructure(Zig::JSFFIFunction::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()));
+ });
+
// putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "SQL"_s), JSC::CustomGetterSetter::create(vm, JSSQLStatement_getter, nullptr),
// JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly);
@@ -1050,14 +1426,14 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor)
for (auto& structure : thisObject->m_structures.values())
visitor.append(structure);
- // for (auto& guarded : thisObject->m_guardedObjects)
- // guarded->visitAggregate(visitor);
+ for (auto& guarded : thisObject->m_guardedObjects)
+ guarded->visitAggregate(visitor);
}
for (auto& constructor : thisObject->constructors().array())
visitor.append(constructor);
- // thisObject->m_builtinInternalFunctions.visit(visitor);
+ thisObject->m_builtinInternalFunctions.visit(visitor);
thisObject->m_JSFFIFunctionStructure.visit(visitor);
ScriptExecutionContext* context = thisObject->scriptExecutionContext();
visitor.addOpaqueRoot(context);
diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.h b/src/javascript/jsc/bindings/ZigGlobalObject.h
index 70740a2c4..933764be9 100644
--- a/src/javascript/jsc/bindings/ZigGlobalObject.h
+++ b/src/javascript/jsc/bindings/ZigGlobalObject.h
@@ -12,6 +12,7 @@ class LazyClassStructure;
namespace WebCore {
class ScriptExecutionContext;
+class DOMGuardedObject;
}
#include "root.h"
@@ -34,6 +35,7 @@ class ScriptExecutionContext;
namespace Zig {
using JSDOMStructureMap = HashMap<const JSC::ClassInfo*, JSC::WriteBarrier<JSC::Structure>>;
+using DOMGuardedObjectSet = HashSet<WebCore::DOMGuardedObject*>;
class GlobalObject : public JSC::JSGlobalObject {
using Base = JSC::JSGlobalObject;
@@ -41,21 +43,22 @@ class GlobalObject : public JSC::JSGlobalObject {
public:
static const JSC::ClassInfo s_info;
static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable;
- static constexpr bool needsDestruction = false;
template<typename, SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
{
if constexpr (mode == JSC::SubspaceAccess::Concurrently)
return nullptr;
- return WebCore::subspaceForImpl<GlobalObject, WebCore::UseCustomHeapCellType::No>(
+ return WebCore::subspaceForImpl<GlobalObject, WebCore::UseCustomHeapCellType::Yes>(
vm,
- [](auto& spaces) { return spaces.m_clientSubspaceForGlobalObject.get(); },
- [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForGlobalObject = WTFMove(space); },
- [](auto& spaces) { return spaces.m_subspaceForGlobalObject.get(); },
- [](auto& spaces, auto&& space) { spaces.m_subspaceForGlobalObject = WTFMove(space); });
+ [](auto& spaces) { return spaces.m_clientSubspaceForWorkerGlobalScope.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForWorkerGlobalScope = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForWorkerGlobalScope.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForWorkerGlobalScope = WTFMove(space); },
+ [](auto& server) -> JSC::HeapCellType& { return server.m_heapCellTypeForJSWorkerGlobalScope; });
}
~GlobalObject();
+ static void destroy(JSC::JSCell*);
static constexpr const JSC::ClassInfo* info() { return &s_info; }
@@ -67,6 +70,19 @@ public:
// Make binding code generation easier.
GlobalObject* globalObject() { return this; }
+ DOMGuardedObjectSet& guardedObjects() WTF_REQUIRES_LOCK(m_gcLock) { return m_guardedObjects; }
+
+ const DOMGuardedObjectSet& guardedObjects() const WTF_IGNORES_THREAD_SAFETY_ANALYSIS
+ {
+ ASSERT(!Thread::mayBeGCThread());
+ return m_guardedObjects;
+ }
+ DOMGuardedObjectSet& guardedObjects(NoLockingNecessaryTag) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
+ {
+ ASSERT(!vm().heap.mutatorShouldBeFenced());
+ return m_guardedObjects;
+ }
+
static GlobalObject* create(JSC::VM& vm, JSC::Structure* structure)
{
GlobalObject* ptr = new (NotNull, JSC::allocateCell<GlobalObject>(vm)) GlobalObject(vm, structure);
@@ -106,6 +122,8 @@ public:
Lock& gcLock() WTF_RETURNS_LOCK(m_gcLock) { return m_gcLock; }
+ void clearDOMGuardedObjects();
+
static void reportUncaughtExceptionAtEventLoop(JSGlobalObject*, JSC::Exception*);
static JSGlobalObject* deriveShadowRealmGlobalObject(JSGlobalObject* globalObject);
static void queueMicrotaskToEventLoop(JSC::JSGlobalObject& global, Ref<JSC::Microtask>&& task);
@@ -133,6 +151,7 @@ public:
private:
void addBuiltinGlobals(JSC::VM&);
+ void finishCreation(JSC::VM&);
friend void WebCore::JSBuiltinInternalFunctions::initialize(Zig::GlobalObject&);
WebCore::JSBuiltinInternalFunctions m_builtinInternalFunctions;
GlobalObject(JSC::VM& vm, JSC::Structure* structure);
@@ -144,6 +163,7 @@ private:
Ref<WebCore::DOMWrapperWorld> m_world;
LazyClassStructure m_JSFFIFunctionStructure;
LazyClassStructure m_NapiClassStructure;
+ DOMGuardedObjectSet m_guardedObjects WTF_GUARDED_BY_LOCK(m_gcLock);
};
class JSMicrotaskCallback : public RefCounted<JSMicrotaskCallback> {
diff --git a/src/javascript/jsc/bindings/builtins/js/ByteLengthQueuingStrategy.js b/src/javascript/jsc/bindings/builtins/js/ByteLengthQueuingStrategy.js
new file mode 100644
index 000000000..e8f5b1cfc
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ByteLengthQueuingStrategy.js
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia S.L.
+ *
+ * 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. ``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
+ * 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.
+ */
+
+@getter
+function highWaterMark()
+{
+ "use strict";
+
+ const highWaterMark = @getByIdDirectPrivate(this, "highWaterMark");
+ if (highWaterMark === @undefined)
+ @throwTypeError("ByteLengthQueuingStrategy.highWaterMark getter called on incompatible |this| value.");
+
+ return highWaterMark;
+}
+
+function size(chunk)
+{
+ "use strict";
+
+ return chunk.byteLength;
+}
+
+function initializeByteLengthQueuingStrategy(parameters)
+{
+ "use strict";
+
+ @putByIdDirectPrivate(this, "highWaterMark", @extractHighWaterMarkFromQueuingStrategyInit(parameters));
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/CountQueuingStrategy.js b/src/javascript/jsc/bindings/builtins/js/CountQueuingStrategy.js
new file mode 100644
index 000000000..3cd9cffc2
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/CountQueuingStrategy.js
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2015 Canon Inc.
+ *
+ * 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. ``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
+ * 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.
+ */
+
+@getter
+function highWaterMark()
+{
+ "use strict";
+
+ const highWaterMark = @getByIdDirectPrivate(this, "highWaterMark");
+ if (highWaterMark === @undefined)
+ @throwTypeError("CountQueuingStrategy.highWaterMark getter called on incompatible |this| value.");
+
+ return highWaterMark;
+}
+
+function size()
+{
+ "use strict";
+
+ return 1;
+}
+
+function initializeCountQueuingStrategy(parameters)
+{
+ "use strict";
+
+ @putByIdDirectPrivate(this, "highWaterMark", @extractHighWaterMarkFromQueuingStrategyInit(parameters));
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/ReadableByteStreamController.js b/src/javascript/jsc/bindings/builtins/js/ReadableByteStreamController.js
new file mode 100644
index 000000000..fac5c864c
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableByteStreamController.js
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2016 Canon Inc.
+ *
+ * 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. ``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
+ * 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.
+ */
+
+function initializeReadableByteStreamController(stream, underlyingByteSource, highWaterMark)
+{
+ "use strict";
+
+ if (arguments.length !== 4 && arguments[3] !== @isReadableStream)
+ @throwTypeError("ReadableByteStreamController constructor should not be called directly");
+
+ return @privateInitializeReadableByteStreamController.@call(this, stream, underlyingByteSource, highWaterMark);
+}
+
+function enqueue(chunk)
+{
+ "use strict";
+
+ if (!@isReadableByteStreamController(this))
+ throw @makeThisTypeError("ReadableByteStreamController", "enqueue");
+
+ if (@getByIdDirectPrivate(this, "closeRequested"))
+ @throwTypeError("ReadableByteStreamController is requested to close");
+
+ if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, "controlledReadableStream"), "state") !== @streamReadable)
+ @throwTypeError("ReadableStream is not readable");
+
+ if (!@isObject(chunk) || !@ArrayBuffer.@isView(chunk))
+ @throwTypeError("Provided chunk is not a TypedArray");
+
+ return @readableByteStreamControllerEnqueue(this, chunk);
+}
+
+function error(error)
+{
+ "use strict";
+
+ if (!@isReadableByteStreamController(this))
+ throw @makeThisTypeError("ReadableByteStreamController", "error");
+
+ if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, "controlledReadableStream"), "state") !== @streamReadable)
+ @throwTypeError("ReadableStream is not readable");
+
+ @readableByteStreamControllerError(this, error);
+}
+
+function close()
+{
+ "use strict";
+
+ if (!@isReadableByteStreamController(this))
+ throw @makeThisTypeError("ReadableByteStreamController", "close");
+
+ if (@getByIdDirectPrivate(this, "closeRequested"))
+ @throwTypeError("Close has already been requested");
+
+ if (@getByIdDirectPrivate(@getByIdDirectPrivate(this, "controlledReadableStream"), "state") !== @streamReadable)
+ @throwTypeError("ReadableStream is not readable");
+
+ @readableByteStreamControllerClose(this);
+}
+
+@getter
+function byobRequest()
+{
+ "use strict";
+
+ if (!@isReadableByteStreamController(this))
+ throw @makeGetterTypeError("ReadableByteStreamController", "byobRequest");
+
+ if (@getByIdDirectPrivate(this, "byobRequest") === @undefined && @getByIdDirectPrivate(this, "pendingPullIntos").length) {
+ const firstDescriptor = @getByIdDirectPrivate(this, "pendingPullIntos")[0];
+ const view = new @Uint8Array(firstDescriptor.buffer,
+ firstDescriptor.byteOffset + firstDescriptor.bytesFilled,
+ firstDescriptor.byteLength - firstDescriptor.bytesFilled);
+ @putByIdDirectPrivate(this, "byobRequest", new @ReadableStreamBYOBRequest(this, view, @isReadableStream));
+ }
+
+ return @getByIdDirectPrivate(this, "byobRequest");
+}
+
+@getter
+function desiredSize()
+{
+ "use strict";
+
+ if (!@isReadableByteStreamController(this))
+ throw @makeGetterTypeError("ReadableByteStreamController", "desiredSize");
+
+ return @readableByteStreamControllerGetDesiredSize(this);
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/ReadableByteStreamInternals.js b/src/javascript/jsc/bindings/builtins/js/ReadableByteStreamInternals.js
new file mode 100644
index 000000000..38f6b6f17
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableByteStreamInternals.js
@@ -0,0 +1,673 @@
+/*
+ * Copyright (C) 2016 Canon Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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
+ * 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.
+ */
+// @internal
+
+function privateInitializeReadableByteStreamController(stream, underlyingByteSource, highWaterMark)
+{
+ "use strict";
+
+ if (!@isReadableStream(stream))
+ @throwTypeError("ReadableByteStreamController needs a ReadableStream");
+
+ // readableStreamController is initialized with null value.
+ if (@getByIdDirectPrivate(stream, "readableStreamController") !== null)
+ @throwTypeError("ReadableStream already has a controller");
+
+ @putByIdDirectPrivate(this, "controlledReadableStream", stream);
+ @putByIdDirectPrivate(this, "underlyingByteSource", underlyingByteSource);
+ @putByIdDirectPrivate(this, "pullAgain", false);
+ @putByIdDirectPrivate(this, "pulling", false);
+ @readableByteStreamControllerClearPendingPullIntos(this);
+ @putByIdDirectPrivate(this, "queue", @newQueue());
+ @putByIdDirectPrivate(this, "started", false);
+ @putByIdDirectPrivate(this, "closeRequested", false);
+
+ let hwm = @toNumber(highWaterMark);
+ if (@isNaN(hwm) || hwm < 0)
+ @throwRangeError("highWaterMark value is negative or not a number");
+ @putByIdDirectPrivate(this, "strategyHWM", hwm);
+
+ let autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
+ if (autoAllocateChunkSize !== @undefined) {
+ autoAllocateChunkSize = @toNumber(autoAllocateChunkSize);
+ if (autoAllocateChunkSize <= 0 || autoAllocateChunkSize === @Infinity || autoAllocateChunkSize === -@Infinity)
+ @throwRangeError("autoAllocateChunkSize value is negative or equal to positive or negative infinity");
+ }
+ @putByIdDirectPrivate(this, "autoAllocateChunkSize", autoAllocateChunkSize);
+ @putByIdDirectPrivate(this, "pendingPullIntos", []);
+
+ const controller = this;
+ const startResult = @promiseInvokeOrNoopNoCatch(underlyingByteSource, "start", [this]).@then(() => {
+ @putByIdDirectPrivate(controller, "started", true);
+ @assert(!@getByIdDirectPrivate(controller, "pulling"));
+ @assert(!@getByIdDirectPrivate(controller, "pullAgain"));
+ @readableByteStreamControllerCallPullIfNeeded(controller);
+ }, (error) => {
+ if (@getByIdDirectPrivate(stream, "state") === @streamReadable)
+ @readableByteStreamControllerError(controller, error);
+ });
+
+ @putByIdDirectPrivate(this, "cancel", @readableByteStreamControllerCancel);
+ @putByIdDirectPrivate(this, "pull", @readableByteStreamControllerPull);
+
+ return this;
+}
+
+function privateInitializeReadableStreamBYOBRequest(controller, view)
+{
+ "use strict";
+
+ @putByIdDirectPrivate(this, "associatedReadableByteStreamController", controller);
+ @putByIdDirectPrivate(this, "view", view);
+}
+
+function isReadableByteStreamController(controller)
+{
+ "use strict";
+
+ // Same test mechanism as in isReadableStreamDefaultController (ReadableStreamInternals.js).
+ // See corresponding function for explanations.
+ return @isObject(controller) && !!@getByIdDirectPrivate(controller, "underlyingByteSource");
+}
+
+function isReadableStreamBYOBRequest(byobRequest)
+{
+ "use strict";
+
+ // Same test mechanism as in isReadableStreamDefaultController (ReadableStreamInternals.js).
+ // See corresponding function for explanations.
+ return @isObject(byobRequest) && !!@getByIdDirectPrivate(byobRequest, "associatedReadableByteStreamController");
+}
+
+function isReadableStreamBYOBReader(reader)
+{
+ "use strict";
+
+ // Spec tells to return true only if reader has a readIntoRequests internal slot.
+ // However, since it is a private slot, it cannot be checked using hasOwnProperty().
+ // Since readIntoRequests is initialized with an empty array, the following test is ok.
+ return @isObject(reader) && !!@getByIdDirectPrivate(reader, "readIntoRequests");
+}
+
+function readableByteStreamControllerCancel(controller, reason)
+{
+ "use strict";
+
+ var pendingPullIntos = @getByIdDirectPrivate(controller, "pendingPullIntos");
+ if (pendingPullIntos.length > 0)
+ pendingPullIntos[0].bytesFilled = 0;
+ @putByIdDirectPrivate(controller, "queue", @newQueue());
+ return @promiseInvokeOrNoop(@getByIdDirectPrivate(controller, "underlyingByteSource"), "cancel", [reason]);
+}
+
+function readableByteStreamControllerError(controller, e)
+{
+ "use strict";
+
+ @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === @streamReadable);
+ @readableByteStreamControllerClearPendingPullIntos(controller);
+ @putByIdDirectPrivate(controller, "queue", @newQueue());
+ @readableStreamError(@getByIdDirectPrivate(controller, "controlledReadableStream"), e);
+}
+
+function readableByteStreamControllerClose(controller)
+{
+ "use strict";
+
+ @assert(!@getByIdDirectPrivate(controller, "closeRequested"));
+ @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === @streamReadable);
+
+ if (@getByIdDirectPrivate(controller, "queue").size > 0) {
+ @putByIdDirectPrivate(controller, "closeRequested", true);
+ return;
+ }
+
+ var pendingPullIntos = @getByIdDirectPrivate(controller, "pendingPullIntos");
+ if (pendingPullIntos.length > 0) {
+ if (pendingPullIntos[0].bytesFilled > 0) {
+ const e = @makeTypeError("Close requested while there remain pending bytes");
+ @readableByteStreamControllerError(controller, e);
+ throw e;
+ }
+ }
+
+ @readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
+}
+
+function readableByteStreamControllerClearPendingPullIntos(controller)
+{
+ "use strict";
+
+ @readableByteStreamControllerInvalidateBYOBRequest(controller);
+ @putByIdDirectPrivate(controller, "pendingPullIntos", []);
+}
+
+function readableByteStreamControllerGetDesiredSize(controller)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+ const state = @getByIdDirectPrivate(stream, "state");
+
+ if (state === @streamErrored)
+ return null;
+ if (state === @streamClosed)
+ return 0;
+
+ return @getByIdDirectPrivate(controller, "strategyHWM") - @getByIdDirectPrivate(controller, "queue").size;
+}
+
+function readableStreamHasBYOBReader(stream)
+{
+ "use strict";
+
+ const reader = @getByIdDirectPrivate(stream, "reader");
+ return reader !== @undefined && @isReadableStreamBYOBReader(reader);
+}
+
+function readableStreamHasDefaultReader(stream)
+{
+ "use strict";
+
+ const reader = @getByIdDirectPrivate(stream, "reader");
+ return reader !== @undefined && @isReadableStreamDefaultReader(reader);
+}
+
+function readableByteStreamControllerHandleQueueDrain(controller) {
+
+ "use strict";
+
+ @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === @streamReadable);
+ if (!@getByIdDirectPrivate(controller, "queue").size && @getByIdDirectPrivate(controller, "closeRequested"))
+ @readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
+ else
+ @readableByteStreamControllerCallPullIfNeeded(controller);
+}
+
+function readableByteStreamControllerPull(controller)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+ @assert(@readableStreamHasDefaultReader(stream));
+
+ if (@getByIdDirectPrivate(controller, "queue").size > 0) {
+ @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests").length === 0);
+ const entry = @getByIdDirectPrivate(controller, "queue").content.@shift();
+ @getByIdDirectPrivate(controller, "queue").size -= entry.byteLength;
+ @readableByteStreamControllerHandleQueueDrain(controller);
+ let view;
+ try {
+ view = new @Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
+ } catch (error) {
+ return @Promise.@reject(error);
+ }
+ return @createFulfilledPromise({ value: view, done: false });
+ }
+
+ if (@getByIdDirectPrivate(controller, "autoAllocateChunkSize") !== @undefined) {
+ let buffer;
+ try {
+ buffer = new @ArrayBuffer(@getByIdDirectPrivate(controller, "autoAllocateChunkSize"));
+ } catch (error) {
+ return @Promise.@reject(error);
+ }
+ const pullIntoDescriptor = {
+ buffer,
+ byteOffset: 0,
+ byteLength: @getByIdDirectPrivate(controller, "autoAllocateChunkSize"),
+ bytesFilled: 0,
+ elementSize: 1,
+ ctor: @Uint8Array,
+ readerType: 'default'
+ };
+ @arrayPush(@getByIdDirectPrivate(controller, "pendingPullIntos"), pullIntoDescriptor);
+ }
+
+ const promise = @readableStreamAddReadRequest(stream);
+ @readableByteStreamControllerCallPullIfNeeded(controller);
+ return promise;
+}
+
+function readableByteStreamControllerShouldCallPull(controller)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+
+ if (@getByIdDirectPrivate(stream, "state") !== @streamReadable)
+ return false;
+ if (@getByIdDirectPrivate(controller, "closeRequested"))
+ return false;
+ if (!@getByIdDirectPrivate(controller, "started"))
+ return false;
+ if (@readableStreamHasDefaultReader(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests").length > 0)
+ return true;
+ if (@readableStreamHasBYOBReader(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readIntoRequests").length > 0)
+ return true;
+ if (@readableByteStreamControllerGetDesiredSize(controller) > 0)
+ return true;
+ return false;
+}
+
+function readableByteStreamControllerCallPullIfNeeded(controller)
+{
+ "use strict";
+
+ if (!@readableByteStreamControllerShouldCallPull(controller))
+ return;
+
+ if (@getByIdDirectPrivate(controller, "pulling")) {
+ @putByIdDirectPrivate(controller, "pullAgain", true);
+ return;
+ }
+
+ @assert(!@getByIdDirectPrivate(controller, "pullAgain"));
+ @putByIdDirectPrivate(controller, "pulling", true);
+ @promiseInvokeOrNoop(@getByIdDirectPrivate(controller, "underlyingByteSource"), "pull", [controller]).@then(() => {
+ @putByIdDirectPrivate(controller, "pulling", false);
+ if (@getByIdDirectPrivate(controller, "pullAgain")) {
+ @putByIdDirectPrivate(controller, "pullAgain", false);
+ @readableByteStreamControllerCallPullIfNeeded(controller);
+ }
+ }, (error) => {
+ if (@getByIdDirectPrivate(@getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === @streamReadable)
+ @readableByteStreamControllerError(controller, error);
+ });
+}
+
+function transferBufferToCurrentRealm(buffer)
+{
+ "use strict";
+
+ // FIXME: Determine what should be done here exactly (what is already existing in current
+ // codebase and what has to be added). According to spec, Transfer operation should be
+ // performed in order to transfer buffer to current realm. For the moment, simply return
+ // received buffer.
+ return buffer;
+}
+
+function readableByteStreamControllerEnqueue(controller, chunk)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+ @assert(!@getByIdDirectPrivate(controller, "closeRequested"));
+ @assert(@getByIdDirectPrivate(stream, "state") === @streamReadable);
+ const buffer = chunk.buffer;
+ const byteOffset = chunk.byteOffset;
+ const byteLength = chunk.byteLength;
+ const transferredBuffer = @transferBufferToCurrentRealm(buffer);
+
+ if (@readableStreamHasDefaultReader(stream)) {
+ if (!@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests").length)
+ @readableByteStreamControllerEnqueueChunk(controller, transferredBuffer, byteOffset, byteLength);
+ else {
+ @assert(!@getByIdDirectPrivate(controller, "queue").content.length);
+ let transferredView = new @Uint8Array(transferredBuffer, byteOffset, byteLength);
+ @readableStreamFulfillReadRequest(stream, transferredView, false);
+ }
+ return;
+ }
+
+ if (@readableStreamHasBYOBReader(stream)) {
+ @readableByteStreamControllerEnqueueChunk(controller, transferredBuffer, byteOffset, byteLength);
+ @readableByteStreamControllerProcessPullDescriptors(controller);
+ return;
+ }
+
+ @assert(!@isReadableStreamLocked(stream));
+ @readableByteStreamControllerEnqueueChunk(controller, transferredBuffer, byteOffset, byteLength);
+}
+
+// Spec name: readableByteStreamControllerEnqueueChunkToQueue.
+function readableByteStreamControllerEnqueueChunk(controller, buffer, byteOffset, byteLength)
+{
+ "use strict";
+
+ @arrayPush(@getByIdDirectPrivate(controller, "queue").content, {
+ buffer: buffer,
+ byteOffset: byteOffset,
+ byteLength: byteLength
+ });
+ @getByIdDirectPrivate(controller, "queue").size += byteLength;
+}
+
+function readableByteStreamControllerRespondWithNewView(controller, view)
+{
+ "use strict";
+
+ @assert(@getByIdDirectPrivate(controller, "pendingPullIntos").length > 0);
+
+ let firstDescriptor = @getByIdDirectPrivate(controller, "pendingPullIntos")[0];
+
+ if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset)
+ @throwRangeError("Invalid value for view.byteOffset");
+
+ if (firstDescriptor.byteLength !== view.byteLength)
+ @throwRangeError("Invalid value for view.byteLength");
+
+ firstDescriptor.buffer = view.buffer;
+ @readableByteStreamControllerRespondInternal(controller, view.byteLength);
+}
+
+function readableByteStreamControllerRespond(controller, bytesWritten)
+{
+ "use strict";
+
+ bytesWritten = @toNumber(bytesWritten);
+
+ if (@isNaN(bytesWritten) || bytesWritten === @Infinity || bytesWritten < 0 )
+ @throwRangeError("bytesWritten has an incorrect value");
+
+ @assert(@getByIdDirectPrivate(controller, "pendingPullIntos").length > 0);
+
+ @readableByteStreamControllerRespondInternal(controller, bytesWritten);
+}
+
+function readableByteStreamControllerRespondInternal(controller, bytesWritten)
+{
+ "use strict";
+
+ let firstDescriptor = @getByIdDirectPrivate(controller, "pendingPullIntos")[0];
+ let stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+
+ if (@getByIdDirectPrivate(stream, "state") === @streamClosed) {
+ if (bytesWritten !== 0)
+ @throwTypeError("bytesWritten is different from 0 even though stream is closed");
+ @readableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
+ } else {
+ @assert(@getByIdDirectPrivate(stream, "state") === @streamReadable);
+ @readableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
+ }
+}
+
+function readableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor)
+{
+ "use strict";
+
+ if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength)
+ @throwRangeError("bytesWritten value is too great");
+
+ @assert(@getByIdDirectPrivate(controller, "pendingPullIntos").length === 0 || @getByIdDirectPrivate(controller, "pendingPullIntos")[0] === pullIntoDescriptor);
+ @readableByteStreamControllerInvalidateBYOBRequest(controller);
+ pullIntoDescriptor.bytesFilled += bytesWritten;
+
+ if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize)
+ return;
+
+ @readableByteStreamControllerShiftPendingDescriptor(controller);
+ const remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
+
+ if (remainderSize > 0) {
+ const end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
+ const remainder = @cloneArrayBuffer(pullIntoDescriptor.buffer, end - remainderSize, remainderSize);
+ @readableByteStreamControllerEnqueueChunk(controller, remainder, 0, remainder.byteLength);
+ }
+
+ pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);
+ pullIntoDescriptor.bytesFilled -= remainderSize;
+ @readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, "controlledReadableStream"), pullIntoDescriptor);
+ @readableByteStreamControllerProcessPullDescriptors(controller);
+}
+
+function readableByteStreamControllerRespondInClosedState(controller, firstDescriptor)
+{
+ "use strict";
+
+ firstDescriptor.buffer = @transferBufferToCurrentRealm(firstDescriptor.buffer);
+ @assert(firstDescriptor.bytesFilled === 0);
+
+ if (@readableStreamHasBYOBReader(@getByIdDirectPrivate(controller, "controlledReadableStream"))) {
+ while (@getByIdDirectPrivate(@getByIdDirectPrivate(@getByIdDirectPrivate(controller, "controlledReadableStream"), "reader"), "readIntoRequests").length > 0) {
+ let pullIntoDescriptor = @readableByteStreamControllerShiftPendingDescriptor(controller);
+ @readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, "controlledReadableStream"), pullIntoDescriptor);
+ }
+ }
+}
+
+// Spec name: readableByteStreamControllerProcessPullIntoDescriptorsUsingQueue (shortened for readability).
+function readableByteStreamControllerProcessPullDescriptors(controller)
+{
+ "use strict";
+
+ @assert(!@getByIdDirectPrivate(controller, "closeRequested"));
+ while (@getByIdDirectPrivate(controller, "pendingPullIntos").length > 0) {
+ if (@getByIdDirectPrivate(controller, "queue").size === 0)
+ return;
+ let pullIntoDescriptor = @getByIdDirectPrivate(controller, "pendingPullIntos")[0];
+ if (@readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor)) {
+ @readableByteStreamControllerShiftPendingDescriptor(controller);
+ @readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(controller, "controlledReadableStream"), pullIntoDescriptor);
+ }
+ }
+}
+
+// Spec name: readableByteStreamControllerFillPullIntoDescriptorFromQueue (shortened for readability).
+function readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor)
+{
+ "use strict";
+
+ const currentAlignedBytes = pullIntoDescriptor.bytesFilled - (pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize);
+ const maxBytesToCopy = @getByIdDirectPrivate(controller, "queue").size < pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled ?
+ @getByIdDirectPrivate(controller, "queue").size : pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled;
+ const maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
+ const maxAlignedBytes = maxBytesFilled - (maxBytesFilled % pullIntoDescriptor.elementSize);
+ let totalBytesToCopyRemaining = maxBytesToCopy;
+ let ready = false;
+
+ if (maxAlignedBytes > currentAlignedBytes) {
+ totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
+ ready = true;
+ }
+
+ while (totalBytesToCopyRemaining > 0) {
+ let headOfQueue = @getByIdDirectPrivate(controller, "queue").content[0];
+ const bytesToCopy = totalBytesToCopyRemaining < headOfQueue.byteLength ? totalBytesToCopyRemaining : headOfQueue.byteLength;
+ // Copy appropriate part of pullIntoDescriptor.buffer to headOfQueue.buffer.
+ // Remark: this implementation is not completely aligned on the definition of CopyDataBlockBytes
+ // operation of ECMAScript (the case of Shared Data Block is not considered here, but it doesn't seem to be an issue).
+ const destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
+ // FIXME: As indicated in comments of bug 172717, access to set is not safe. However, using prototype.@set.@call does
+ // not work (@set is undefined). A safe way to do that is needed.
+ new @Uint8Array(pullIntoDescriptor.buffer).set(new @Uint8Array(headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy), destStart);
+
+ if (headOfQueue.byteLength === bytesToCopy)
+ @getByIdDirectPrivate(controller, "queue").content.@shift();
+ else {
+ headOfQueue.byteOffset += bytesToCopy;
+ headOfQueue.byteLength -= bytesToCopy;
+ }
+
+ @getByIdDirectPrivate(controller, "queue").size -= bytesToCopy;
+ @assert(@getByIdDirectPrivate(controller, "pendingPullIntos").length === 0 || @getByIdDirectPrivate(controller, "pendingPullIntos")[0] === pullIntoDescriptor);
+ @readableByteStreamControllerInvalidateBYOBRequest(controller);
+ pullIntoDescriptor.bytesFilled += bytesToCopy;
+ totalBytesToCopyRemaining -= bytesToCopy;
+ }
+
+ if (!ready) {
+ @assert(@getByIdDirectPrivate(controller, "queue").size === 0);
+ @assert(pullIntoDescriptor.bytesFilled > 0);
+ @assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize);
+ }
+
+ return ready;
+}
+
+// Spec name: readableByteStreamControllerShiftPendingPullInto (renamed for consistency).
+function readableByteStreamControllerShiftPendingDescriptor(controller)
+{
+ "use strict";
+
+ let descriptor = @getByIdDirectPrivate(controller, "pendingPullIntos").@shift();
+ @readableByteStreamControllerInvalidateBYOBRequest(controller);
+ return descriptor;
+}
+
+function readableByteStreamControllerInvalidateBYOBRequest(controller)
+{
+ "use strict";
+
+ if (@getByIdDirectPrivate(controller, "byobRequest") === @undefined)
+ return;
+ const byobRequest = @getByIdDirectPrivate(controller, "byobRequest");
+ @putByIdDirectPrivate(byobRequest, "associatedReadableByteStreamController", @undefined);
+ @putByIdDirectPrivate(byobRequest, "view", @undefined);
+ @putByIdDirectPrivate(controller, "byobRequest", @undefined);
+}
+
+// Spec name: readableByteStreamControllerCommitPullIntoDescriptor (shortened for readability).
+function readableByteStreamControllerCommitDescriptor(stream, pullIntoDescriptor)
+{
+ "use strict";
+
+ @assert(@getByIdDirectPrivate(stream, "state") !== @streamErrored);
+ let done = false;
+ if (@getByIdDirectPrivate(stream, "state") === @streamClosed) {
+ @assert(!pullIntoDescriptor.bytesFilled);
+ done = true;
+ }
+ let filledView = @readableByteStreamControllerConvertDescriptor(pullIntoDescriptor);
+ if (pullIntoDescriptor.readerType === "default")
+ @readableStreamFulfillReadRequest(stream, filledView, done);
+ else {
+ @assert(pullIntoDescriptor.readerType === "byob");
+ @readableStreamFulfillReadIntoRequest(stream, filledView, done);
+ }
+}
+
+// Spec name: readableByteStreamControllerConvertPullIntoDescriptor (shortened for readability).
+function readableByteStreamControllerConvertDescriptor(pullIntoDescriptor)
+{
+ "use strict";
+
+ @assert(pullIntoDescriptor.bytesFilled <= pullIntoDescriptor.byteLength);
+ @assert(pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize === 0);
+
+ return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, pullIntoDescriptor.bytesFilled / pullIntoDescriptor.elementSize);
+}
+
+function readableStreamFulfillReadIntoRequest(stream, chunk, done)
+{
+ "use strict";
+ const readIntoRequest = @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readIntoRequests").@shift();
+ @fulfillPromise(readIntoRequest, { value: chunk, done: done });
+}
+
+function readableStreamBYOBReaderRead(reader, view)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(reader, "ownerReadableStream");
+ @assert(!!stream);
+
+ @putByIdDirectPrivate(stream, "disturbed", true);
+ if (@getByIdDirectPrivate(stream, "state") === @streamErrored)
+ return @Promise.@reject(@getByIdDirectPrivate(stream, "storedError"));
+
+ return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(stream, "readableStreamController"), view);
+}
+
+function readableByteStreamControllerPullInto(controller, view)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+ let elementSize = 1;
+ // Spec describes that in the case where view is a TypedArray, elementSize
+ // should be set to the size of an element (e.g. 2 for UInt16Array). For
+ // DataView, BYTES_PER_ELEMENT is undefined, contrary to the same property
+ // for TypedArrays.
+ // FIXME: Getting BYTES_PER_ELEMENT like this is not safe (property is read-only
+ // but can be modified if the prototype is redefined). A safe way of getting
+ // it would be to determine which type of ArrayBufferView view is an instance
+ // of based on typed arrays private variables. However, this is not possible due
+ // to bug 167697, which prevents access to typed arrays through their private
+ // names unless public name has already been met before.
+ if (view.BYTES_PER_ELEMENT !== @undefined)
+ elementSize = view.BYTES_PER_ELEMENT;
+
+ // FIXME: Getting constructor like this is not safe. A safe way of getting
+ // it would be to determine which type of ArrayBufferView view is an instance
+ // of, and to assign appropriate constructor based on this (e.g. ctor =
+ // @Uint8Array). However, this is not possible due to bug 167697, which
+ // prevents access to typed arrays through their private names unless public
+ // name has already been met before.
+ const ctor = view.constructor;
+
+ const pullIntoDescriptor = {
+ buffer: view.buffer,
+ byteOffset: view.byteOffset,
+ byteLength: view.byteLength,
+ bytesFilled: 0,
+ elementSize,
+ ctor,
+ readerType: 'byob'
+ };
+
+ if (@getByIdDirectPrivate(controller, "pendingPullIntos").length) {
+ pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);
+ @arrayPush(@getByIdDirectPrivate(controller, "pendingPullIntos"), pullIntoDescriptor);
+ return @readableStreamAddReadIntoRequest(stream);
+ }
+
+ if (@getByIdDirectPrivate(stream, "state") === @streamClosed) {
+ const emptyView = new ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0);
+ return @createFulfilledPromise({ value: emptyView, done: true });
+ }
+
+ if (@getByIdDirectPrivate(controller, "queue").size > 0) {
+ if (@readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor)) {
+ const filledView = @readableByteStreamControllerConvertDescriptor(pullIntoDescriptor);
+ @readableByteStreamControllerHandleQueueDrain(controller);
+ return @createFulfilledPromise({ value: filledView, done: false });
+ }
+ if (@getByIdDirectPrivate(controller, "closeRequested")) {
+ const e = @makeTypeError("Closing stream has been requested");
+ @readableByteStreamControllerError(controller, e);
+ return @Promise.@reject(e);
+ }
+ }
+
+ pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);
+ @arrayPush(@getByIdDirectPrivate(controller, "pendingPullIntos"), pullIntoDescriptor);
+ const promise = @readableStreamAddReadIntoRequest(stream);
+ @readableByteStreamControllerCallPullIfNeeded(controller);
+ return promise;
+}
+
+function readableStreamAddReadIntoRequest(stream)
+{
+ "use strict";
+
+ @assert(@isReadableStreamBYOBReader(@getByIdDirectPrivate(stream, "reader")));
+ @assert(@getByIdDirectPrivate(stream, "state") === @streamReadable || @getByIdDirectPrivate(stream, "state") === @streamClosed);
+
+ const readRequest = @newPromise();
+ @arrayPush(@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readIntoRequests"), readRequest);
+
+ return readRequest;
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/ReadableStream.js b/src/javascript/jsc/bindings/builtins/js/ReadableStream.js
new file mode 100644
index 000000000..177bb75e9
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableStream.js
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia.
+ *
+ * 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. ``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
+ * 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.
+ */
+
+function initializeReadableStream(underlyingSource, strategy)
+{
+ "use strict";
+
+ if (underlyingSource === @undefined)
+ underlyingSource = { };
+ if (strategy === @undefined)
+ strategy = { };
+
+ if (!@isObject(underlyingSource))
+ @throwTypeError("ReadableStream constructor takes an object as first argument");
+
+ if (strategy !== @undefined && !@isObject(strategy))
+ @throwTypeError("ReadableStream constructor takes an object as second argument, if any");
+
+ @putByIdDirectPrivate(this, "state", @streamReadable);
+
+ @putByIdDirectPrivate(this, "reader", @undefined);
+
+ @putByIdDirectPrivate(this, "storedError", @undefined);
+
+ @putByIdDirectPrivate(this, "disturbed", false);
+
+ // Initialized with null value to enable distinction with undefined case.
+ @putByIdDirectPrivate(this, "readableStreamController", null);
+
+
+ // FIXME: We should introduce https://streams.spec.whatwg.org/#create-readable-stream.
+ // For now, we emulate this with underlyingSource with private properties.
+ if (@getByIdDirectPrivate(underlyingSource, "pull") !== @undefined) {
+
+ const size = @getByIdDirectPrivate(strategy, "size");
+ const highWaterMark = @getByIdDirectPrivate(strategy, "highWaterMark");
+ @setupReadableStreamDefaultController(this, underlyingSource, size, highWaterMark !== @undefined ? highWaterMark : 1, @getByIdDirectPrivate(underlyingSource, "start"), @getByIdDirectPrivate(underlyingSource, "pull"), @getByIdDirectPrivate(underlyingSource, "cancel"));
+
+ return this;
+ }
+
+ const type = underlyingSource.type;
+ const typeString = @toString(type);
+
+ if (typeString === "bytes") {
+ // if (!@readableByteStreamAPIEnabled())
+ // @throwTypeError("ReadableByteStreamController is not implemented");
+
+ if (strategy.highWaterMark === @undefined)
+ strategy.highWaterMark = 0;
+ if (strategy.size !== @undefined)
+ @throwRangeError("Strategy for a ReadableByteStreamController cannot have a size");
+
+ let readableByteStreamControllerConstructor = @ReadableByteStreamController;
+
+ @putByIdDirectPrivate(this, "readableStreamController", new @ReadableByteStreamController(this, underlyingSource, strategy.highWaterMark, @isReadableStream));
+ } else if (type === @undefined) {
+ if (strategy.highWaterMark === @undefined)
+ strategy.highWaterMark = 1;
+
+ @setupReadableStreamDefaultController(this, underlyingSource, strategy.size, strategy.highWaterMark, underlyingSource.start, underlyingSource.pull, underlyingSource.cancel);
+ } else
+ @throwRangeError("Invalid type for underlying source");
+
+ return this;
+}
+
+function cancel(reason)
+{
+ "use strict";
+
+ if (!@isReadableStream(this))
+ return @Promise.@reject(@makeThisTypeError("ReadableStream", "cancel"));
+
+ if (@isReadableStreamLocked(this))
+ return @Promise.@reject(@makeTypeError("ReadableStream is locked"));
+
+ return @readableStreamCancel(this, reason);
+}
+
+function getReader(options)
+{
+ "use strict";
+
+ if (!@isReadableStream(this))
+ throw @makeThisTypeError("ReadableStream", "getReader");
+
+ const mode = @toDictionary(options, { }, "ReadableStream.getReader takes an object as first argument").mode;
+ if (mode === @undefined)
+ return new @ReadableStreamDefaultReader(this);
+
+ // String conversion is required by spec, hence double equals.
+ if (mode == 'byob')
+ return new @ReadableStreamBYOBReader(this);
+
+ @throwTypeError("Invalid mode is specified");
+}
+
+function pipeThrough(streams, options)
+{
+ "use strict";
+
+ const transforms = streams;
+
+ const readable = transforms["readable"];
+ if (!@isReadableStream(readable))
+ throw @makeTypeError("readable should be ReadableStream");
+
+ const writable = transforms["writable"];
+ const internalWritable = @getInternalWritableStream(writable);
+ if (!@isWritableStream(internalWritable))
+ throw @makeTypeError("writable should be WritableStream");
+
+ let preventClose = false;
+ let preventAbort = false;
+ let preventCancel = false;
+ let signal;
+ if (!@isUndefinedOrNull(options)) {
+ if (!@isObject(options))
+ throw @makeTypeError("options must be an object");
+
+ preventAbort = !!options["preventAbort"];
+ preventCancel = !!options["preventCancel"];
+ preventClose = !!options["preventClose"];
+
+ signal = options["signal"];
+ if (signal !== @undefined && !@isAbortSignal(signal))
+ throw @makeTypeError("options.signal must be AbortSignal");
+ }
+
+ if (!@isReadableStream(this))
+ throw @makeThisTypeError("ReadableStream", "pipeThrough");
+
+ if (@isReadableStreamLocked(this))
+ throw @makeTypeError("ReadableStream is locked");
+
+ if (@isWritableStreamLocked(internalWritable))
+ throw @makeTypeError("WritableStream is locked");
+
+ @readableStreamPipeToWritableStream(this, internalWritable, preventClose, preventAbort, preventCancel, signal);
+
+ return readable;
+}
+
+function pipeTo(destination)
+{
+ "use strict";
+
+ // FIXME: https://bugs.webkit.org/show_bug.cgi?id=159869.
+ // Built-in generator should be able to parse function signature to compute the function length correctly.
+ let options = arguments[1];
+
+ let preventClose = false;
+ let preventAbort = false;
+ let preventCancel = false;
+ let signal;
+ if (!@isUndefinedOrNull(options)) {
+ if (!@isObject(options))
+ return @Promise.@reject(@makeTypeError("options must be an object"));
+
+ try {
+ preventAbort = !!options["preventAbort"];
+ preventCancel = !!options["preventCancel"];
+ preventClose = !!options["preventClose"];
+
+ signal = options["signal"];
+ } catch(e) {
+ return @Promise.@reject(e);
+ }
+
+ if (signal !== @undefined && !@isAbortSignal(signal))
+ return @Promise.@reject(@makeTypeError("options.signal must be AbortSignal"));
+ }
+
+ const internalDestination = @getInternalWritableStream(destination);
+ if (!@isWritableStream(internalDestination))
+ return @Promise.@reject(@makeTypeError("ReadableStream pipeTo requires a WritableStream"));
+
+ if (!@isReadableStream(this))
+ return @Promise.@reject(@makeThisTypeError("ReadableStream", "pipeTo"));
+
+ if (@isReadableStreamLocked(this))
+ return @Promise.@reject(@makeTypeError("ReadableStream is locked"));
+
+ if (@isWritableStreamLocked(internalDestination))
+ return @Promise.@reject(@makeTypeError("WritableStream is locked"));
+
+ return @readableStreamPipeToWritableStream(this, internalDestination, preventClose, preventAbort, preventCancel, signal);
+}
+
+function tee()
+{
+ "use strict";
+
+ if (!@isReadableStream(this))
+ throw @makeThisTypeError("ReadableStream", "tee");
+
+ return @readableStreamTee(this, false);
+}
+
+@getter
+function locked()
+{
+ "use strict";
+
+ if (!@isReadableStream(this))
+ throw @makeGetterTypeError("ReadableStream", "locked");
+
+ return @isReadableStreamLocked(this);
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/ReadableStreamBYOBReader.js b/src/javascript/jsc/bindings/builtins/js/ReadableStreamBYOBReader.js
new file mode 100644
index 000000000..f4bc203c8
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableStreamBYOBReader.js
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2017 Canon Inc.
+ *
+ * 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 CANON 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 CANON INC. AND 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.
+ */
+
+function initializeReadableStreamBYOBReader(stream)
+{
+ "use strict";
+
+ if (!@isReadableStream(stream))
+ @throwTypeError("ReadableStreamBYOBReader needs a ReadableStream");
+ if (!@isReadableByteStreamController(@getByIdDirectPrivate(stream, "readableStreamController")))
+ @throwTypeError("ReadableStreamBYOBReader needs a ReadableByteStreamController");
+ if (@isReadableStreamLocked(stream))
+ @throwTypeError("ReadableStream is locked");
+
+ @readableStreamReaderGenericInitialize(this, stream);
+ @putByIdDirectPrivate(this, "readIntoRequests", []);
+
+ return this;
+}
+
+function cancel(reason)
+{
+ "use strict";
+
+ if (!@isReadableStreamBYOBReader(this))
+ return @Promise.@reject(@makeThisTypeError("ReadableStreamBYOBReader", "cancel"));
+
+ if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
+ return @Promise.@reject(@makeTypeError("cancel() called on a reader owned by no readable stream"));
+
+ return @readableStreamReaderGenericCancel(this, reason);
+}
+
+function read(view)
+{
+ "use strict";
+
+ if (!@isReadableStreamBYOBReader(this))
+ return @Promise.@reject(@makeThisTypeError("ReadableStreamBYOBReader", "read"));
+
+ if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
+ return @Promise.@reject(@makeTypeError("read() called on a reader owned by no readable stream"));
+
+ if (!@isObject(view))
+ return @Promise.@reject(@makeTypeError("Provided view is not an object"));
+
+ if (!@ArrayBuffer.@isView(view))
+ return @Promise.@reject(@makeTypeError("Provided view is not an ArrayBufferView"));
+
+ if (view.byteLength === 0)
+ return @Promise.@reject(@makeTypeError("Provided view cannot have a 0 byteLength"));
+
+ return @readableStreamBYOBReaderRead(this, view);
+}
+
+function releaseLock()
+{
+ "use strict";
+
+ if (!@isReadableStreamBYOBReader(this))
+ throw @makeThisTypeError("ReadableStreamBYOBReader", "releaseLock");
+
+ if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
+ return;
+
+ if (@getByIdDirectPrivate(this, "readIntoRequests").length)
+ @throwTypeError("There are still pending read requests, cannot release the lock");
+
+ @readableStreamReaderGenericRelease(this);
+}
+
+@getter
+function closed()
+{
+ "use strict";
+
+ if (!@isReadableStreamBYOBReader(this))
+ return @Promise.@reject(@makeGetterTypeError("ReadableStreamBYOBReader", "closed"));
+
+ return @getByIdDirectPrivate(this, "closedPromiseCapability").@promise;
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/ReadableStreamBYOBRequest.js b/src/javascript/jsc/bindings/builtins/js/ReadableStreamBYOBRequest.js
new file mode 100644
index 000000000..d97667165
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableStreamBYOBRequest.js
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2017 Canon Inc.
+ *
+ * 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. ``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
+ * 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.
+ */
+
+function initializeReadableStreamBYOBRequest(controller, view)
+{
+ "use strict";
+
+ if (arguments.length !== 3 && arguments[2] !== @isReadableStream)
+ @throwTypeError("ReadableStreamBYOBRequest constructor should not be called directly");
+
+ return @privateInitializeReadableStreamBYOBRequest.@call(this, controller, view);
+}
+
+function respond(bytesWritten)
+{
+ "use strict";
+
+ if (!@isReadableStreamBYOBRequest(this))
+ throw @makeThisTypeError("ReadableStreamBYOBRequest", "respond");
+
+ if (@getByIdDirectPrivate(this, "associatedReadableByteStreamController") === @undefined)
+ @throwTypeError("ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined");
+
+ return @readableByteStreamControllerRespond(@getByIdDirectPrivate(this, "associatedReadableByteStreamController"), bytesWritten);
+}
+
+function respondWithNewView(view)
+{
+ "use strict";
+
+ if (!@isReadableStreamBYOBRequest(this))
+ throw @makeThisTypeError("ReadableStreamBYOBRequest", "respond");
+
+ if (@getByIdDirectPrivate(this, "associatedReadableByteStreamController") === @undefined)
+ @throwTypeError("ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined");
+
+ if (!@isObject(view))
+ @throwTypeError("Provided view is not an object");
+
+ if (!@ArrayBuffer.@isView(view))
+ @throwTypeError("Provided view is not an ArrayBufferView");
+
+ return @readableByteStreamControllerRespondWithNewView(@getByIdDirectPrivate(this, "associatedReadableByteStreamController"), view);
+}
+
+@getter
+function view()
+{
+ "use strict";
+
+ if (!@isReadableStreamBYOBRequest(this))
+ throw @makeGetterTypeError("ReadableStreamBYOBRequest", "view");
+
+ return @getByIdDirectPrivate(this, "view");
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/ReadableStreamDefaultController.js b/src/javascript/jsc/bindings/builtins/js/ReadableStreamDefaultController.js
new file mode 100644
index 000000000..07fc65cb1
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableStreamDefaultController.js
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2015 Canon Inc.
+ *
+ * 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. ``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
+ * 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.
+ */
+
+function initializeReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark)
+{
+ "use strict";
+
+ if (arguments.length !== 5 && arguments[4] !== @isReadableStream)
+ @throwTypeError("ReadableStreamDefaultController constructor should not be called directly");
+
+ return @privateInitializeReadableStreamDefaultController.@call(this, stream, underlyingSource, size, highWaterMark);
+}
+
+function enqueue(chunk)
+{
+ "use strict";
+
+ if (!@isReadableStreamDefaultController(this))
+ throw @makeThisTypeError("ReadableStreamDefaultController", "enqueue");
+
+ if (!@readableStreamDefaultControllerCanCloseOrEnqueue(this))
+ @throwTypeError("ReadableStreamDefaultController is not in a state where chunk can be enqueued");
+
+ return @readableStreamDefaultControllerEnqueue(this, chunk);
+}
+
+function error(error)
+{
+ "use strict";
+
+ if (!@isReadableStreamDefaultController(this))
+ throw @makeThisTypeError("ReadableStreamDefaultController", "error");
+
+ @readableStreamDefaultControllerError(this, error);
+}
+
+function close()
+{
+ "use strict";
+
+ if (!@isReadableStreamDefaultController(this))
+ throw @makeThisTypeError("ReadableStreamDefaultController", "close");
+
+ if (!@readableStreamDefaultControllerCanCloseOrEnqueue(this))
+ @throwTypeError("ReadableStreamDefaultController is not in a state where it can be closed");
+
+ @readableStreamDefaultControllerClose(this);
+}
+
+@getter
+function desiredSize()
+{
+ "use strict";
+
+ if (!@isReadableStreamDefaultController(this))
+ throw @makeGetterTypeError("ReadableStreamDefaultController", "desiredSize");
+
+ return @readableStreamDefaultControllerGetDesiredSize(this);
+}
+
diff --git a/src/javascript/jsc/bindings/builtins/js/ReadableStreamDefaultReader.js b/src/javascript/jsc/bindings/builtins/js/ReadableStreamDefaultReader.js
new file mode 100644
index 000000000..b270dce85
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableStreamDefaultReader.js
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2015 Canon Inc.
+ *
+ * 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. ``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
+ * 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.
+ */
+
+function initializeReadableStreamDefaultReader(stream)
+{
+ "use strict";
+
+ if (!@isReadableStream(stream))
+ @throwTypeError("ReadableStreamDefaultReader needs a ReadableStream");
+ if (@isReadableStreamLocked(stream))
+ @throwTypeError("ReadableStream is locked");
+
+ @readableStreamReaderGenericInitialize(this, stream);
+ @putByIdDirectPrivate(this, "readRequests", []);
+
+ return this;
+}
+
+function cancel(reason)
+{
+ "use strict";
+
+ if (!@isReadableStreamDefaultReader(this))
+ return @Promise.@reject(@makeThisTypeError("ReadableStreamDefaultReader", "cancel"));
+
+ if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
+ return @Promise.@reject(@makeTypeError("cancel() called on a reader owned by no readable stream"));
+
+ return @readableStreamReaderGenericCancel(this, reason);
+}
+
+function read()
+{
+ "use strict";
+
+ if (!@isReadableStreamDefaultReader(this))
+ return @Promise.@reject(@makeThisTypeError("ReadableStreamDefaultReader", "read"));
+ if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
+ return @Promise.@reject(@makeTypeError("read() called on a reader owned by no readable stream"));
+
+ return @readableStreamDefaultReaderRead(this);
+}
+
+function releaseLock()
+{
+ "use strict";
+
+ if (!@isReadableStreamDefaultReader(this))
+ throw @makeThisTypeError("ReadableStreamDefaultReader", "releaseLock");
+
+ if (!@getByIdDirectPrivate(this, "ownerReadableStream"))
+ return;
+
+ if (@getByIdDirectPrivate(this, "readRequests").length)
+ @throwTypeError("There are still pending read requests, cannot release the lock");
+
+ @readableStreamReaderGenericRelease(this);
+}
+
+@getter
+function closed()
+{
+ "use strict";
+
+ if (!@isReadableStreamDefaultReader(this))
+ return @Promise.@reject(@makeGetterTypeError("ReadableStreamDefaultReader", "closed"));
+
+ return @getByIdDirectPrivate(this, "closedPromiseCapability").@promise;
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/ReadableStreamInternals.js b/src/javascript/jsc/bindings/builtins/js/ReadableStreamInternals.js
new file mode 100644
index 000000000..cb0b76229
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableStreamInternals.js
@@ -0,0 +1,814 @@
+/*
+ * Copyright (C) 2015 Canon Inc. All rights reserved.
+ * Copyright (C) 2015 Igalia.
+ *
+ * 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. ``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
+ * 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.
+ */
+
+// @internal
+
+function readableStreamReaderGenericInitialize(reader, stream)
+{
+ "use strict";
+
+ @putByIdDirectPrivate(reader, "ownerReadableStream", stream);
+ @putByIdDirectPrivate(stream, "reader", reader);
+ if (@getByIdDirectPrivate(stream, "state") === @streamReadable)
+ @putByIdDirectPrivate(reader, "closedPromiseCapability", @newPromiseCapability(@Promise));
+ else if (@getByIdDirectPrivate(stream, "state") === @streamClosed)
+ @putByIdDirectPrivate(reader, "closedPromiseCapability", { @promise: @Promise.@resolve() });
+ else {
+ @assert(@getByIdDirectPrivate(stream, "state") === @streamErrored);
+ @putByIdDirectPrivate(reader, "closedPromiseCapability", { @promise: @newHandledRejectedPromise(@getByIdDirectPrivate(stream, "storedError")) });
+ }
+}
+
+function privateInitializeReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark)
+{
+ "use strict";
+
+ if (!@isReadableStream(stream))
+ @throwTypeError("ReadableStreamDefaultController needs a ReadableStream");
+
+ // readableStreamController is initialized with null value.
+ if (@getByIdDirectPrivate(stream, "readableStreamController") !== null)
+ @throwTypeError("ReadableStream already has a controller");
+
+
+
+ @putByIdDirectPrivate(this, "controlledReadableStream", stream);
+ @putByIdDirectPrivate(this, "underlyingSource", underlyingSource);
+ @putByIdDirectPrivate(this, "queue", @newQueue());
+ @putByIdDirectPrivate(this, "started", false);
+ @putByIdDirectPrivate(this, "closeRequested", false);
+ @putByIdDirectPrivate(this, "pullAgain", false);
+ @putByIdDirectPrivate(this, "pulling", false);
+ @putByIdDirectPrivate(this, "strategy", @validateAndNormalizeQueuingStrategy(size, highWaterMark));
+
+
+
+ return this;
+}
+
+// https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller, starting from step 6.
+// The other part is implemented in privateInitializeReadableStreamDefaultController.
+function setupReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark, startMethod, pullMethod, cancelMethod)
+{
+ "use strict";
+
+ const controller = new @ReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark, @isReadableStream);
+ const startAlgorithm = () => @promiseInvokeOrNoopMethodNoCatch(underlyingSource, startMethod, [controller]);
+ const pullAlgorithm = () => @promiseInvokeOrNoopMethod(underlyingSource, pullMethod, [controller]);
+ const cancelAlgorithm = (reason) => @promiseInvokeOrNoopMethod(underlyingSource, cancelMethod, [reason]);
+
+ @putByIdDirectPrivate(controller, "pullAlgorithm", pullAlgorithm);
+ @putByIdDirectPrivate(controller, "cancelAlgorithm", cancelAlgorithm);
+ @putByIdDirectPrivate(controller, "pull", @readableStreamDefaultControllerPull);
+ @putByIdDirectPrivate(controller, "cancel", @readableStreamDefaultControllerCancel);
+ @putByIdDirectPrivate(stream, "readableStreamController", controller);
+
+ startAlgorithm().@then(() => {
+ @putByIdDirectPrivate(controller, "started", true);
+ @assert(!@getByIdDirectPrivate(controller, "pulling"));
+ @assert(!@getByIdDirectPrivate(controller, "pullAgain"));
+ @readableStreamDefaultControllerCallPullIfNeeded(controller);
+
+ }, (error) => {
+ @readableStreamDefaultControllerError(controller, error);
+ });
+}
+
+function readableStreamDefaultControllerError(controller, error)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+ if (@getByIdDirectPrivate(stream, "state") !== @streamReadable)
+ return;
+ @putByIdDirectPrivate(controller, "queue", @newQueue());
+ @readableStreamError(stream, error);
+}
+
+function readableStreamPipeTo(stream, sink)
+{
+ "use strict";
+ @assert(@isReadableStream(stream));
+
+ const reader = new @ReadableStreamDefaultReader(stream);
+
+ @getByIdDirectPrivate(reader, "closedPromiseCapability").@promise.@then(() => { }, (e) => { sink.error(e); });
+
+ function doPipe() {
+ @readableStreamDefaultReaderRead(reader).@then(function(result) {
+ if (result.done) {
+ sink.close();
+ return;
+ }
+ try {
+ sink.enqueue(result.value);
+ } catch (e) {
+ sink.error("ReadableStream chunk enqueueing in the sink failed");
+ return;
+ }
+ doPipe();
+ }, function(e) {
+ sink.error(e);
+ });
+ }
+ doPipe();
+}
+
+function acquireReadableStreamDefaultReader(stream)
+{
+ return new @ReadableStreamDefaultReader(stream);
+}
+
+// FIXME: Replace readableStreamPipeTo by below function.
+// This method implements the latest https://streams.spec.whatwg.org/#readable-stream-pipe-to.
+function readableStreamPipeToWritableStream(source, destination, preventClose, preventAbort, preventCancel, signal)
+{
+ @assert(@isReadableStream(source));
+ @assert(@isWritableStream(destination));
+ @assert(!@isReadableStreamLocked(source));
+ @assert(!@isWritableStreamLocked(destination));
+ @assert(signal === @undefined || @isAbortSignal(signal));
+
+ if (@getByIdDirectPrivate(source, "underlyingByteSource") !== @undefined)
+ return @Promise.@reject("Piping of readable by strean is not supported");
+
+ let pipeState = { source : source, destination : destination, preventAbort : preventAbort, preventCancel : preventCancel, preventClose : preventClose, signal : signal };
+
+ pipeState.reader = @acquireReadableStreamDefaultReader(source);
+ pipeState.writer = @acquireWritableStreamDefaultWriter(destination);
+
+ @putByIdDirectPrivate(source, "disturbed", true);
+
+ pipeState.finalized = false;
+ pipeState.shuttingDown = false;
+ pipeState.promiseCapability = @newPromiseCapability(@Promise);
+ pipeState.pendingReadPromiseCapability = @newPromiseCapability(@Promise);
+ pipeState.pendingReadPromiseCapability.@resolve.@call();
+ pipeState.pendingWritePromise = @Promise.@resolve();
+
+ if (signal !== @undefined) {
+ const algorithm = () => {
+ if (pipeState.finalized)
+ return;
+
+ const error = @makeDOMException("AbortError", "abort pipeTo from signal");
+
+ @pipeToShutdownWithAction(pipeState, () => {
+ const shouldAbortDestination = !pipeState.preventAbort && @getByIdDirectPrivate(pipeState.destination, "state") === "writable";
+ const promiseDestination = shouldAbortDestination ? @writableStreamAbort(pipeState.destination, error) : @Promise.@resolve();
+
+ const shouldAbortSource = !pipeState.preventCancel && @getByIdDirectPrivate(pipeState.source, "state") === @streamReadable;
+ const promiseSource = shouldAbortSource ? @readableStreamCancel(pipeState.source, error) : @Promise.@resolve();
+
+ let promiseCapability = @newPromiseCapability(@Promise);
+ let shouldWait = true;
+ let handleResolvedPromise = () => {
+ if (shouldWait) {
+ shouldWait = false;
+ return;
+ }
+ promiseCapability.@resolve.@call();
+ }
+ let handleRejectedPromise = (e) => {
+ promiseCapability.@reject.@call(@undefined, e);
+ }
+ promiseDestination.@then(handleResolvedPromise, handleRejectedPromise);
+ promiseSource.@then(handleResolvedPromise, handleRejectedPromise);
+ return promiseCapability.@promise;
+ }, error);
+ };
+ if (@whenSignalAborted(signal, algorithm))
+ return pipeState.promiseCapability.@promise;
+ }
+
+ @pipeToErrorsMustBePropagatedForward(pipeState);
+ @pipeToErrorsMustBePropagatedBackward(pipeState);
+ @pipeToClosingMustBePropagatedForward(pipeState);
+ @pipeToClosingMustBePropagatedBackward(pipeState);
+
+ @pipeToLoop(pipeState);
+
+ return pipeState.promiseCapability.@promise;
+}
+
+function pipeToLoop(pipeState)
+{
+ if (pipeState.shuttingDown)
+ return;
+
+ @pipeToDoReadWrite(pipeState).@then((result) => {
+ if (result)
+ @pipeToLoop(pipeState);
+ });
+}
+
+function pipeToDoReadWrite(pipeState)
+{
+ @assert(!pipeState.shuttingDown);
+
+ pipeState.pendingReadPromiseCapability = @newPromiseCapability(@Promise);
+ @getByIdDirectPrivate(pipeState.writer, "readyPromise").@promise.@then(() => {
+ if (pipeState.shuttingDown) {
+ pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);
+ return;
+ }
+
+ @readableStreamDefaultReaderRead(pipeState.reader).@then((result) => {
+ const canWrite = !result.done && @getByIdDirectPrivate(pipeState.writer, "stream") !== @undefined;
+ pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, canWrite);
+ if (!canWrite)
+ return;
+
+ pipeState.pendingWritePromise = @writableStreamDefaultWriterWrite(pipeState.writer, result.value);
+ }, (e) => {
+ pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);
+ });
+ }, (e) => {
+ pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);
+ });
+ return pipeState.pendingReadPromiseCapability.@promise;
+}
+
+function pipeToErrorsMustBePropagatedForward(pipeState)
+{
+ const action = () => {
+ pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);
+ const error = @getByIdDirectPrivate(pipeState.source, "storedError");
+ if (!pipeState.preventAbort) {
+ @pipeToShutdownWithAction(pipeState, () => @writableStreamAbort(pipeState.destination, error), error);
+ return;
+ }
+ @pipeToShutdown(pipeState, error);
+ };
+
+ if (@getByIdDirectPrivate(pipeState.source, "state") === @streamErrored) {
+ action();
+ return;
+ }
+
+ @getByIdDirectPrivate(pipeState.reader, "closedPromiseCapability").@promise.@then(@undefined, action);
+}
+
+function pipeToErrorsMustBePropagatedBackward(pipeState)
+{
+ const action = () => {
+ const error = @getByIdDirectPrivate(pipeState.destination, "storedError");
+ if (!pipeState.preventCancel) {
+ @pipeToShutdownWithAction(pipeState, () => @readableStreamCancel(pipeState.source, error), error);
+ return;
+ }
+ @pipeToShutdown(pipeState, error);
+ };
+ if (@getByIdDirectPrivate(pipeState.destination, "state") === "errored") {
+ action();
+ return;
+ }
+ @getByIdDirectPrivate(pipeState.writer, "closedPromise").@promise.@then(@undefined, action);
+}
+
+function pipeToClosingMustBePropagatedForward(pipeState)
+{
+ const action = () => {
+ pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);
+ const error = @getByIdDirectPrivate(pipeState.source, "storedError");
+ if (!pipeState.preventClose) {
+ @pipeToShutdownWithAction(pipeState, () => @writableStreamDefaultWriterCloseWithErrorPropagation(pipeState.writer));
+ return;
+ }
+ @pipeToShutdown(pipeState);
+ };
+ if (@getByIdDirectPrivate(pipeState.source, "state") === @streamClosed) {
+ action();
+ return;
+ }
+ @getByIdDirectPrivate(pipeState.reader, "closedPromiseCapability").@promise.@then(action, @undefined);
+}
+
+function pipeToClosingMustBePropagatedBackward(pipeState)
+{
+ if (!@writableStreamCloseQueuedOrInFlight(pipeState.destination) && @getByIdDirectPrivate(pipeState.destination, "state") !== "closed")
+ return;
+
+ // @assert no chunks have been read/written
+
+ const error = @makeTypeError("closing is propagated backward");
+ if (!pipeState.preventCancel) {
+ @pipeToShutdownWithAction(pipeState, () => @readableStreamCancel(pipeState.source, error), error);
+ return;
+ }
+ @pipeToShutdown(pipeState, error);
+}
+
+function pipeToShutdownWithAction(pipeState, action)
+{
+ if (pipeState.shuttingDown)
+ return;
+
+ pipeState.shuttingDown = true;
+
+ const hasError = arguments.length > 2;
+ const error = arguments[2];
+ const finalize = () => {
+ const promise = action();
+ promise.@then(() => {
+ if (hasError)
+ @pipeToFinalize(pipeState, error);
+ else
+ @pipeToFinalize(pipeState);
+ }, (e) => {
+ @pipeToFinalize(pipeState, e);
+ });
+ };
+
+ if (@getByIdDirectPrivate(pipeState.destination, "state") === "writable" && !@writableStreamCloseQueuedOrInFlight(pipeState.destination)) {
+ pipeState.pendingReadPromiseCapability.@promise.@then(() => {
+ pipeState.pendingWritePromise.@then(finalize, finalize);
+ }, (e) => @pipeToFinalize(pipeState, e));
+ return;
+ }
+
+ finalize();
+}
+
+function pipeToShutdown(pipeState)
+{
+ if (pipeState.shuttingDown)
+ return;
+
+ pipeState.shuttingDown = true;
+
+ const hasError = arguments.length > 1;
+ const error = arguments[1];
+ const finalize = () => {
+ if (hasError)
+ @pipeToFinalize(pipeState, error);
+ else
+ @pipeToFinalize(pipeState);
+ };
+
+ if (@getByIdDirectPrivate(pipeState.destination, "state") === "writable" && !@writableStreamCloseQueuedOrInFlight(pipeState.destination)) {
+ pipeState.pendingReadPromiseCapability.@promise.@then(() => {
+ pipeState.pendingWritePromise.@then(finalize, finalize);
+ }, (e) => @pipeToFinalize(pipeState, e));
+ return;
+ }
+ finalize();
+}
+
+function pipeToFinalize(pipeState)
+{
+ @writableStreamDefaultWriterRelease(pipeState.writer);
+ @readableStreamReaderGenericRelease(pipeState.reader);
+
+ // Instead of removing the abort algorithm as per spec, we make it a no-op which is equivalent.
+ pipeState.finalized = true;
+
+ if (arguments.length > 1)
+ pipeState.promiseCapability.@reject.@call(@undefined, arguments[1]);
+ else
+ pipeState.promiseCapability.@resolve.@call();
+}
+
+function readableStreamTee(stream, shouldClone)
+{
+ "use strict";
+
+ @assert(@isReadableStream(stream));
+ @assert(typeof(shouldClone) === "boolean");
+
+ const reader = new @ReadableStreamDefaultReader(stream);
+
+ const teeState = {
+ closedOrErrored: false,
+ canceled1: false,
+ canceled2: false,
+ reason1: @undefined,
+ reason2: @undefined,
+ };
+
+ teeState.cancelPromiseCapability = @newPromiseCapability(@Promise);
+
+ const pullFunction = @readableStreamTeePullFunction(teeState, reader, shouldClone);
+
+ const branch1Source = { };
+ @putByIdDirectPrivate(branch1Source, "pull", pullFunction);
+ @putByIdDirectPrivate(branch1Source, "cancel", @readableStreamTeeBranch1CancelFunction(teeState, stream));
+
+ const branch2Source = { };
+ @putByIdDirectPrivate(branch2Source, "pull", pullFunction);
+ @putByIdDirectPrivate(branch2Source, "cancel", @readableStreamTeeBranch2CancelFunction(teeState, stream));
+
+ const branch1 = new @ReadableStream(branch1Source);
+ const branch2 = new @ReadableStream(branch2Source);
+
+ @getByIdDirectPrivate(reader, "closedPromiseCapability").@promise.@then(@undefined, function(e) {
+ if (teeState.closedOrErrored)
+ return;
+ @readableStreamDefaultControllerError(branch1.@readableStreamController, e);
+ @readableStreamDefaultControllerError(branch2.@readableStreamController, e);
+ teeState.closedOrErrored = true;
+ if (!teeState.canceled1 || !teeState.canceled2)
+ teeState.cancelPromiseCapability.@resolve.@call();
+ });
+
+ // Additional fields compared to the spec, as they are needed within pull/cancel functions.
+ teeState.branch1 = branch1;
+ teeState.branch2 = branch2;
+
+ return [branch1, branch2];
+}
+
+function readableStreamTeePullFunction(teeState, reader, shouldClone)
+{
+ "use strict";
+
+ return function() {
+ @Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(reader), function(result) {
+ @assert(@isObject(result));
+ @assert(typeof result.done === "boolean");
+ if (result.done && !teeState.closedOrErrored) {
+ if (!teeState.canceled1)
+ @readableStreamDefaultControllerClose(teeState.branch1.@readableStreamController);
+ if (!teeState.canceled2)
+ @readableStreamDefaultControllerClose(teeState.branch2.@readableStreamController);
+ teeState.closedOrErrored = true;
+ if (!teeState.canceled1 || !teeState.canceled2)
+ teeState.cancelPromiseCapability.@resolve.@call();
+ }
+ if (teeState.closedOrErrored)
+ return;
+ if (!teeState.canceled1)
+ @readableStreamDefaultControllerEnqueue(teeState.branch1.@readableStreamController, result.value);
+ if (!teeState.canceled2)
+ @readableStreamDefaultControllerEnqueue(teeState.branch2.@readableStreamController, shouldClone ? @structuredCloneForStream(result.value) : result.value);
+ });
+ }
+}
+
+function readableStreamTeeBranch1CancelFunction(teeState, stream)
+{
+ "use strict";
+
+ return function(r) {
+ teeState.canceled1 = true;
+ teeState.reason1 = r;
+ if (teeState.canceled2) {
+ @readableStreamCancel(stream, [teeState.reason1, teeState.reason2]).@then(
+ teeState.cancelPromiseCapability.@resolve,
+ teeState.cancelPromiseCapability.@reject);
+ }
+ return teeState.cancelPromiseCapability.@promise;
+ }
+}
+
+function readableStreamTeeBranch2CancelFunction(teeState, stream)
+{
+ "use strict";
+
+ return function(r) {
+ teeState.canceled2 = true;
+ teeState.reason2 = r;
+ if (teeState.canceled1) {
+ @readableStreamCancel(stream, [teeState.reason1, teeState.reason2]).@then(
+ teeState.cancelPromiseCapability.@resolve,
+ teeState.cancelPromiseCapability.@reject);
+ }
+ return teeState.cancelPromiseCapability.@promise;
+ }
+}
+
+function isReadableStream(stream)
+{
+ "use strict";
+
+ // Spec tells to return true only if stream has a readableStreamController internal slot.
+ // However, since it is a private slot, it cannot be checked using hasOwnProperty().
+ // Therefore, readableStreamController is initialized with null value.
+ return @isObject(stream) && @getByIdDirectPrivate(stream, "readableStreamController") !== @undefined;
+}
+
+function isReadableStreamDefaultReader(reader)
+{
+ "use strict";
+
+ // Spec tells to return true only if reader has a readRequests internal slot.
+ // However, since it is a private slot, it cannot be checked using hasOwnProperty().
+ // Since readRequests is initialized with an empty array, the following test is ok.
+ return @isObject(reader) && !!@getByIdDirectPrivate(reader, "readRequests");
+}
+
+function isReadableStreamDefaultController(controller)
+{
+ "use strict";
+
+ // Spec tells to return true only if controller has an underlyingSource internal slot.
+ // However, since it is a private slot, it cannot be checked using hasOwnProperty().
+ // underlyingSource is obtained in ReadableStream constructor: if undefined, it is set
+ // to an empty object. Therefore, following test is ok.
+ return @isObject(controller) && !!@getByIdDirectPrivate(controller, "underlyingSource");
+}
+
+function readableStreamError(stream, error)
+{
+ "use strict";
+
+ @assert(@isReadableStream(stream));
+ @assert(@getByIdDirectPrivate(stream, "state") === @streamReadable);
+ @putByIdDirectPrivate(stream, "state", @streamErrored);
+ @putByIdDirectPrivate(stream, "storedError", error);
+
+ if (!@getByIdDirectPrivate(stream, "reader"))
+ return;
+
+ const reader = @getByIdDirectPrivate(stream, "reader");
+
+ if (@isReadableStreamDefaultReader(reader)) {
+ const requests = @getByIdDirectPrivate(reader, "readRequests");
+ @putByIdDirectPrivate(reader, "readRequests", []);
+ for (let index = 0, length = requests.length; index < length; ++index)
+ @rejectPromise(requests[index], error);
+ } else {
+ @assert(@isReadableStreamBYOBReader(reader));
+ const requests = @getByIdDirectPrivate(reader, "readIntoRequests");
+ @putByIdDirectPrivate(reader, "readIntoRequests", []);
+ for (let index = 0, length = requests.length; index < length; ++index)
+ @rejectPromise(requests[index], error);
+ }
+
+ @getByIdDirectPrivate(reader, "closedPromiseCapability").@reject.@call(@undefined, error);
+ const promise = @getByIdDirectPrivate(reader, "closedPromiseCapability").@promise;
+ @markPromiseAsHandled(promise);
+}
+
+function readableStreamDefaultControllerShouldCallPull(controller)
+{
+ const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+
+ if (!@readableStreamDefaultControllerCanCloseOrEnqueue(controller))
+ return false;
+ if (!@getByIdDirectPrivate(controller, "started"))
+ return false;
+ if ((!@isReadableStreamLocked(stream) || !@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests").length) && @readableStreamDefaultControllerGetDesiredSize(controller) <= 0)
+ return false;
+ const desiredSize = @readableStreamDefaultControllerGetDesiredSize(controller);
+ @assert(desiredSize !== null);
+ return desiredSize > 0;
+}
+
+function readableStreamDefaultControllerCallPullIfNeeded(controller)
+{
+ "use strict";
+
+ // FIXME: use @readableStreamDefaultControllerShouldCallPull
+ const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+
+ if (!@readableStreamDefaultControllerCanCloseOrEnqueue(controller))
+ return;
+ if (!@getByIdDirectPrivate(controller, "started"))
+ return;
+ if ((!@isReadableStreamLocked(stream) || !@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests").length) && @readableStreamDefaultControllerGetDesiredSize(controller) <= 0)
+ return;
+
+ if (@getByIdDirectPrivate(controller, "pulling")) {
+ @putByIdDirectPrivate(controller, "pullAgain", true);
+ return;
+ }
+
+ @assert(!@getByIdDirectPrivate(controller, "pullAgain"));
+ @putByIdDirectPrivate(controller, "pulling", true);
+
+ @getByIdDirectPrivate(controller, "pullAlgorithm").@call(@undefined).@then(function() {
+ @putByIdDirectPrivate(controller, "pulling", false);
+ if (@getByIdDirectPrivate(controller, "pullAgain")) {
+ @putByIdDirectPrivate(controller, "pullAgain", false);
+ @readableStreamDefaultControllerCallPullIfNeeded(controller);
+ }
+ }, function(error) {
+ @readableStreamDefaultControllerError(controller, error);
+ });
+}
+
+function isReadableStreamLocked(stream)
+{
+ "use strict";
+
+ @assert(@isReadableStream(stream));
+ return !!@getByIdDirectPrivate(stream, "reader");
+}
+
+function readableStreamDefaultControllerGetDesiredSize(controller)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+ const state = @getByIdDirectPrivate(stream, "state");
+
+ if (state === @streamErrored)
+ return null;
+ if (state === @streamClosed)
+ return 0;
+
+ return @getByIdDirectPrivate(controller, "strategy").highWaterMark - @getByIdDirectPrivate(controller, "queue").size;
+}
+
+
+function readableStreamReaderGenericCancel(reader, reason)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(reader, "ownerReadableStream");
+ @assert(!!stream);
+ return @readableStreamCancel(stream, reason);
+}
+
+function readableStreamCancel(stream, reason)
+{
+ "use strict";
+
+ @putByIdDirectPrivate(stream, "disturbed", true);
+ const state = @getByIdDirectPrivate(stream, "state");
+ if (state === @streamClosed)
+ return @Promise.@resolve();
+ if (state === @streamErrored)
+ return @Promise.@reject(@getByIdDirectPrivate(stream, "storedError"));
+ @readableStreamClose(stream);
+ return @getByIdDirectPrivate(stream, "readableStreamController").@cancel(@getByIdDirectPrivate(stream, "readableStreamController"), reason).@then(function() { });
+}
+
+function readableStreamDefaultControllerCancel(controller, reason)
+{
+ "use strict";
+
+ @putByIdDirectPrivate(controller, "queue", @newQueue());
+ return @getByIdDirectPrivate(controller, "cancelAlgorithm").@call(@undefined, reason);
+}
+
+function readableStreamDefaultControllerPull(controller)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+ if (@getByIdDirectPrivate(controller, "queue").content.length) {
+ const chunk = @dequeueValue(@getByIdDirectPrivate(controller, "queue"));
+ if (@getByIdDirectPrivate(controller, "closeRequested") && @getByIdDirectPrivate(controller, "queue").content.length === 0)
+ @readableStreamClose(stream);
+ else
+ @readableStreamDefaultControllerCallPullIfNeeded(controller);
+
+ return @createFulfilledPromise({ value: chunk, done: false });
+ }
+ const pendingPromise = @readableStreamAddReadRequest(stream);
+ @readableStreamDefaultControllerCallPullIfNeeded(controller);
+ return pendingPromise;
+}
+
+function readableStreamDefaultControllerClose(controller)
+{
+ "use strict";
+
+ @assert(@readableStreamDefaultControllerCanCloseOrEnqueue(controller));
+ @putByIdDirectPrivate(controller, "closeRequested", true);
+ if (@getByIdDirectPrivate(controller, "queue").content.length === 0)
+ @readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
+}
+
+function readableStreamClose(stream)
+{
+ "use strict";
+
+ @assert(@getByIdDirectPrivate(stream, "state") === @streamReadable);
+ @putByIdDirectPrivate(stream, "state", @streamClosed);
+ const reader = @getByIdDirectPrivate(stream, "reader");
+
+ if (!reader)
+ return;
+
+ if (@isReadableStreamDefaultReader(reader)) {
+ const requests = @getByIdDirectPrivate(reader, "readRequests");
+ @putByIdDirectPrivate(reader, "readRequests", []);
+ for (let index = 0, length = requests.length; index < length; ++index)
+ @fulfillPromise(requests[index], { value: @undefined, done: true });
+ }
+
+ @getByIdDirectPrivate(reader, "closedPromiseCapability").@resolve.@call();
+}
+
+function readableStreamFulfillReadRequest(stream, chunk, done)
+{
+ "use strict";
+ const readRequest = @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests").@shift();
+ @fulfillPromise(readRequest, { value: chunk, done: done });
+}
+
+function readableStreamDefaultControllerEnqueue(controller, chunk)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+ @assert(@readableStreamDefaultControllerCanCloseOrEnqueue(controller));
+
+ if (@isReadableStreamLocked(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests").length) {
+ @readableStreamFulfillReadRequest(stream, chunk, false);
+ @readableStreamDefaultControllerCallPullIfNeeded(controller);
+ return;
+ }
+
+ try {
+ let chunkSize = 1;
+ if (@getByIdDirectPrivate(controller, "strategy").size !== @undefined)
+ chunkSize = @getByIdDirectPrivate(controller, "strategy").size(chunk);
+ @enqueueValueWithSize(@getByIdDirectPrivate(controller, "queue"), chunk, chunkSize);
+ }
+ catch(error) {
+ @readableStreamDefaultControllerError(controller, error);
+ throw error;
+ }
+ @readableStreamDefaultControllerCallPullIfNeeded(controller);
+}
+
+function readableStreamDefaultReaderRead(reader)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(reader, "ownerReadableStream");
+ @assert(!!stream);
+ const state = @getByIdDirectPrivate(stream, "state");
+
+ @putByIdDirectPrivate(stream, "disturbed", true);
+ if (state === @streamClosed)
+ return @createFulfilledPromise({ value: @undefined, done: true });
+ if (state === @streamErrored)
+ return @Promise.@reject(@getByIdDirectPrivate(stream, "storedError"));
+ @assert(state === @streamReadable);
+
+ return @getByIdDirectPrivate(stream, "readableStreamController").@pull(@getByIdDirectPrivate(stream, "readableStreamController"));
+}
+
+function readableStreamAddReadRequest(stream)
+{
+ "use strict";
+
+ @assert(@isReadableStreamDefaultReader(@getByIdDirectPrivate(stream, "reader")));
+ @assert(@getByIdDirectPrivate(stream, "state") == @streamReadable);
+
+ const readRequest = @newPromise();
+ @arrayPush(@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests"), readRequest);
+
+ return readRequest;
+}
+
+function isReadableStreamDisturbed(stream)
+{
+ "use strict";
+
+ @assert(@isReadableStream(stream));
+ return @getByIdDirectPrivate(stream, "disturbed");
+}
+
+function readableStreamReaderGenericRelease(reader)
+{
+ "use strict";
+
+ @assert(!!@getByIdDirectPrivate(reader, "ownerReadableStream"));
+ @assert(@getByIdDirectPrivate(@getByIdDirectPrivate(reader, "ownerReadableStream"), "reader") === reader);
+
+ if (@getByIdDirectPrivate(@getByIdDirectPrivate(reader, "ownerReadableStream"), "state") === @streamReadable)
+ @getByIdDirectPrivate(reader, "closedPromiseCapability").@reject.@call(@undefined, @makeTypeError("releasing lock of reader whose stream is still in readable state"));
+ else
+ @putByIdDirectPrivate(reader, "closedPromiseCapability", { @promise: @newHandledRejectedPromise(@makeTypeError("reader released lock")) });
+
+ const promise = @getByIdDirectPrivate(reader, "closedPromiseCapability").@promise;
+ @markPromiseAsHandled(promise);
+ @putByIdDirectPrivate(@getByIdDirectPrivate(reader, "ownerReadableStream"), "reader", @undefined);
+ @putByIdDirectPrivate(reader, "ownerReadableStream", @undefined);
+}
+
+function readableStreamDefaultControllerCanCloseOrEnqueue(controller)
+{
+ "use strict";
+
+ return !@getByIdDirectPrivate(controller, "closeRequested") && @getByIdDirectPrivate(@getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === @streamReadable;
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/StreamInternals.js b/src/javascript/jsc/bindings/builtins/js/StreamInternals.js
new file mode 100644
index 000000000..bf1200ec9
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/StreamInternals.js
@@ -0,0 +1,218 @@
+/*
+ * Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia.
+ *
+ * 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. ``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
+ * 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.
+ */
+
+// @internal
+
+function markPromiseAsHandled(promise)
+{
+ "use strict";
+
+ @assert(@isPromise(promise));
+ @putPromiseInternalField(promise, @promiseFieldFlags, @getPromiseInternalField(promise, @promiseFieldFlags) | @promiseFlagsIsHandled);
+}
+
+function shieldingPromiseResolve(result)
+{
+ "use strict";
+
+ const promise = @Promise.@resolve(result);
+ if (promise.@then === @undefined)
+ promise.@then = @Promise.prototype.@then;
+ return promise;
+}
+
+function promiseInvokeOrNoopMethodNoCatch(object, method, args)
+{
+ "use strict";
+
+ if (method === @undefined)
+ return @Promise.@resolve();
+ return @shieldingPromiseResolve(method.@apply(object, args));
+}
+
+function promiseInvokeOrNoopNoCatch(object, key, args)
+{
+ "use strict";
+
+ return @promiseInvokeOrNoopMethodNoCatch(object, object[key], args);
+}
+
+function promiseInvokeOrNoopMethod(object, method, args)
+{
+ "use strict";
+
+ try {
+ return @promiseInvokeOrNoopMethodNoCatch(object, method, args);
+ }
+ catch(error) {
+ return @Promise.@reject(error);
+ }
+}
+
+function promiseInvokeOrNoop(object, key, args)
+{
+ "use strict";
+
+ try {
+ return @promiseInvokeOrNoopNoCatch(object, key, args);
+ }
+ catch(error) {
+ return @Promise.@reject(error);
+ }
+}
+
+function promiseInvokeOrFallbackOrNoop(object, key1, args1, key2, args2)
+{
+ "use strict";
+
+ try {
+ const method = object[key1];
+ if (method === @undefined)
+ return @promiseInvokeOrNoopNoCatch(object, key2, args2);
+ return @shieldingPromiseResolve(method.@apply(object, args1));
+ }
+ catch(error) {
+ return @Promise.@reject(error);
+ }
+}
+
+function validateAndNormalizeQueuingStrategy(size, highWaterMark)
+{
+ "use strict";
+
+ if (size !== @undefined && typeof size !== "function")
+ @throwTypeError("size parameter must be a function");
+
+ const normalizedStrategy = {
+ size: size,
+ highWaterMark: @toNumber(highWaterMark)
+ };
+
+ if (@isNaN(normalizedStrategy.highWaterMark) || normalizedStrategy.highWaterMark < 0)
+ @throwRangeError("highWaterMark value is negative or not a number");
+
+ return normalizedStrategy;
+}
+
+function newQueue()
+{
+ "use strict";
+
+ return { content: [], size: 0 };
+}
+
+function dequeueValue(queue)
+{
+ "use strict";
+
+ const record = queue.content.@shift();
+ queue.size -= record.size;
+ // As described by spec, below case may occur due to rounding errors.
+ if (queue.size < 0)
+ queue.size = 0;
+ return record.value;
+}
+
+function enqueueValueWithSize(queue, value, size)
+{
+ "use strict";
+
+ size = @toNumber(size);
+ if (!@isFinite(size) || size < 0)
+ @throwRangeError("size has an incorrect value");
+ @arrayPush(queue.content, { value, size });
+ queue.size += size;
+}
+
+function peekQueueValue(queue)
+{
+ "use strict";
+
+ @assert(queue.content.length > 0);
+
+ return queue.content[0].value;
+}
+
+function resetQueue(queue)
+{
+ "use strict";
+
+ @assert("content" in queue);
+ @assert("size" in queue);
+ queue.content = [];
+ queue.size = 0;
+}
+
+function extractSizeAlgorithm(strategy)
+{
+ if (!("size" in strategy))
+ return () => 1;
+ const sizeAlgorithm = strategy["size"];
+ if (typeof sizeAlgorithm !== "function")
+ @throwTypeError("strategy.size must be a function");
+
+ return (chunk) => { return sizeAlgorithm(chunk); };
+}
+
+function extractHighWaterMark(strategy, defaultHWM)
+{
+ if (!("highWaterMark" in strategy))
+ return defaultHWM;
+ const highWaterMark = strategy["highWaterMark"];
+ if (@isNaN(highWaterMark) || highWaterMark < 0)
+ @throwRangeError("highWaterMark value is negative or not a number");
+
+ return @toNumber(highWaterMark);
+}
+
+function extractHighWaterMarkFromQueuingStrategyInit(init)
+{
+ "use strict";
+
+ if (!@isObject(init))
+ @throwTypeError("QueuingStrategyInit argument must be an object.");
+ const {highWaterMark} = init;
+ if (highWaterMark === @undefined)
+ @throwTypeError("QueuingStrategyInit.highWaterMark member is required.");
+
+ return @toNumber(highWaterMark);
+}
+
+function createFulfilledPromise(value)
+{
+ const promise = @newPromise();
+ @fulfillPromise(promise, value);
+ return promise;
+}
+
+function toDictionary(value, defaultValue, errorMessage)
+{
+ if (value === @undefined || value === null)
+ return defaultValue;
+ if (!@isObject(value))
+ @throwTypeError(errorMessage);
+ return value;
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/TransformStream.js b/src/javascript/jsc/bindings/builtins/js/TransformStream.js
new file mode 100644
index 000000000..8d82d87d8
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/TransformStream.js
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+function initializeTransformStream()
+{
+ "use strict";
+
+ let transformer = arguments[0];
+
+ // This is the path for CreateTransformStream.
+ if (@isObject(transformer) && @getByIdDirectPrivate(transformer, "TransformStream"))
+ return this;
+
+ let writableStrategy = arguments[1];
+ let readableStrategy = arguments[2];
+
+ if (transformer === @undefined)
+ transformer = null;
+
+ if (readableStrategy === @undefined)
+ readableStrategy = { };
+
+ if (writableStrategy === @undefined)
+ writableStrategy = { };
+
+ let transformerDict = { };
+ if (transformer !== null) {
+ if ("start" in transformer) {
+ transformerDict["start"] = transformer["start"];
+ if (typeof transformerDict["start"] !== "function")
+ @throwTypeError("transformer.start should be a function");
+ }
+ if ("transform" in transformer) {
+ transformerDict["transform"] = transformer["transform"];
+ if (typeof transformerDict["transform"] !== "function")
+ @throwTypeError("transformer.transform should be a function");
+ }
+ if ("flush" in transformer) {
+ transformerDict["flush"] = transformer["flush"];
+ if (typeof transformerDict["flush"] !== "function")
+ @throwTypeError("transformer.flush should be a function");
+ }
+
+ if ("readableType" in transformer)
+ @throwRangeError("TransformStream transformer has a readableType");
+ if ("writableType" in transformer)
+ @throwRangeError("TransformStream transformer has a writableType");
+ }
+
+ const readableHighWaterMark = @extractHighWaterMark(readableStrategy, 0);
+ const readableSizeAlgorithm = @extractSizeAlgorithm(readableStrategy);
+
+ const writableHighWaterMark = @extractHighWaterMark(writableStrategy, 1);
+ const writableSizeAlgorithm = @extractSizeAlgorithm(writableStrategy);
+
+ const startPromiseCapability = @newPromiseCapability(@Promise);
+ @initializeTransformStream(this, startPromiseCapability.@promise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
+ @setUpTransformStreamDefaultControllerFromTransformer(this, transformer, transformerDict);
+
+ if ("start" in transformerDict) {
+ const controller = @getByIdDirectPrivate(this, "controller");
+ const startAlgorithm = () => @promiseInvokeOrNoopMethodNoCatch(transformer, transformerDict["start"], [controller]);
+ startAlgorithm().@then(() => {
+ // FIXME: We probably need to resolve start promise with the result of the start algorithm.
+ startPromiseCapability.@resolve.@call();
+ }, (error) => {
+ startPromiseCapability.@reject.@call(@undefined, error);
+ });
+ } else
+ startPromiseCapability.@resolve.@call();
+
+ return this;
+}
+
+@getter
+function readable()
+{
+ "use strict";
+
+ if (!@isTransformStream(this))
+ throw @makeThisTypeError("TransformStream", "readable");
+
+ return @getByIdDirectPrivate(this, "readable");
+}
+
+function writable()
+{
+ "use strict";
+
+ if (!@isTransformStream(this))
+ throw @makeThisTypeError("TransformStream", "writable");
+
+ return @getByIdDirectPrivate(this, "writable");
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/TransformStreamDefaultController.js b/src/javascript/jsc/bindings/builtins/js/TransformStreamDefaultController.js
new file mode 100644
index 000000000..5ed7d0dfa
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/TransformStreamDefaultController.js
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+function initializeTransformStreamDefaultController()
+{
+ "use strict";
+
+ return this;
+}
+
+@getter
+function desiredSize()
+{
+ "use strict";
+
+ if (!@isTransformStreamDefaultController(this))
+ throw @makeThisTypeError("TransformStreamDefaultController", "enqueue");
+
+ const stream = @getByIdDirectPrivate(this, "stream");
+ const readable = @getByIdDirectPrivate(stream, "readable");
+ const readableController = @getByIdDirectPrivate(readable, "readableStreamController");
+
+ return @readableStreamDefaultControllerGetDesiredSize(readableController);
+}
+
+function enqueue(chunk)
+{
+ "use strict";
+
+ if (!@isTransformStreamDefaultController(this))
+ throw @makeThisTypeError("TransformStreamDefaultController", "enqueue");
+
+ @transformStreamDefaultControllerEnqueue(this, chunk);
+}
+
+function error(e)
+{
+ "use strict";
+
+ if (!@isTransformStreamDefaultController(this))
+ throw @makeThisTypeError("TransformStreamDefaultController", "error");
+
+ @transformStreamDefaultControllerError(this, e);
+}
+
+function terminate()
+{
+ "use strict";
+
+ if (!@isTransformStreamDefaultController(this))
+ throw @makeThisTypeError("TransformStreamDefaultController", "terminate");
+
+ @transformStreamDefaultControllerTerminate(this);
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/TransformStreamInternals.js b/src/javascript/jsc/bindings/builtins/js/TransformStreamInternals.js
new file mode 100644
index 000000000..4263e3991
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/TransformStreamInternals.js
@@ -0,0 +1,350 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// @internal
+
+function isTransformStream(stream)
+{
+ "use strict";
+
+ return @isObject(stream) && !!@getByIdDirectPrivate(stream, "readable");
+}
+
+function isTransformStreamDefaultController(controller)
+{
+ "use strict";
+
+ return @isObject(controller) && !!@getByIdDirectPrivate(controller, "transformAlgorithm");
+}
+
+function createTransformStream(startAlgorithm, transformAlgorithm, flushAlgorithm, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm)
+{
+ if (writableHighWaterMark === @undefined)
+ writableHighWaterMark = 1;
+ if (writableSizeAlgorithm === @undefined)
+ writableSizeAlgorithm = () => 1;
+ if (readableHighWaterMark === @undefined)
+ readableHighWaterMark = 0;
+ if (readableSizeAlgorithm === @undefined)
+ readableSizeAlgorithm = () => 1;
+ @assert(writableHighWaterMark >= 0);
+ @assert(readableHighWaterMark >= 0);
+
+ const transform = {};
+ @putByIdDirectPrivate(transform, "TransformStream", true);
+
+ const stream = new @TransformStream(transform);
+ const startPromiseCapability = @newPromiseCapability(@Promise);
+ @initializeTransformStream(stream, startPromiseCapability.@promise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
+
+ const controller = new @TransformStreamDefaultController();
+ @setUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm);
+
+ startAlgorithm().@then(() => {
+ startPromiseCapability.@resolve.@call();
+ }, (error) => {
+ startPromiseCapability.@reject.@call(@undefined, error);
+ });
+
+ return stream;
+}
+
+function initializeTransformStream(stream, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm)
+{
+ "use strict";
+
+ const startAlgorithm = () => { return startPromise; };
+ const writeAlgorithm = (chunk) => { return @transformStreamDefaultSinkWriteAlgorithm(stream, chunk); }
+ const abortAlgorithm = (reason) => { return @transformStreamDefaultSinkAbortAlgorithm(stream, reason); }
+ const closeAlgorithm = () => { return @transformStreamDefaultSinkCloseAlgorithm(stream); }
+ const writable = @createWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, writableHighWaterMark, writableSizeAlgorithm);
+
+ const pullAlgorithm = () => { return @transformStreamDefaultSourcePullAlgorithm(stream); };
+ const cancelAlgorithm = (reason) => {
+ @transformStreamErrorWritableAndUnblockWrite(stream, reason);
+ return @Promise.@resolve();
+ };
+ const underlyingSource = { };
+ @putByIdDirectPrivate(underlyingSource, "start", startAlgorithm);
+ @putByIdDirectPrivate(underlyingSource, "pull", pullAlgorithm);
+ @putByIdDirectPrivate(underlyingSource, "cancel", cancelAlgorithm);
+ const options = { };
+ @putByIdDirectPrivate(options, "size", readableSizeAlgorithm);
+ @putByIdDirectPrivate(options, "highWaterMark", readableHighWaterMark);
+ const readable = new @ReadableStream(underlyingSource, options);
+
+ // The writable to expose to JS through writable getter.
+ @putByIdDirectPrivate(stream, "writable", writable);
+ // The writable to use for the actual transform algorithms.
+ @putByIdDirectPrivate(stream, "internalWritable", @getInternalWritableStream(writable));
+
+ @putByIdDirectPrivate(stream, "readable", readable);
+ @putByIdDirectPrivate(stream, "backpressure", @undefined);
+ @putByIdDirectPrivate(stream, "backpressureChangePromise", @undefined);
+
+ @transformStreamSetBackpressure(stream, true);
+ @putByIdDirectPrivate(stream, "controller", @undefined);
+}
+
+function transformStreamError(stream, e)
+{
+ "use strict";
+
+ const readable = @getByIdDirectPrivate(stream, "readable");
+ const readableController = @getByIdDirectPrivate(readable, "readableStreamController");
+ @readableStreamDefaultControllerError(readableController, e);
+
+ @transformStreamErrorWritableAndUnblockWrite(stream, e);
+}
+
+function transformStreamErrorWritableAndUnblockWrite(stream, e)
+{
+ "use strict";
+
+ @transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(stream, "controller"));
+
+ const writable = @getByIdDirectPrivate(stream, "internalWritable");
+ @writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(writable, "controller"), e);
+
+ if (@getByIdDirectPrivate(stream, "backpressure"))
+ @transformStreamSetBackpressure(stream, false);
+}
+
+function transformStreamSetBackpressure(stream, backpressure)
+{
+ "use strict";
+
+ @assert(@getByIdDirectPrivate(stream, "backpressure") !== backpressure);
+
+ const backpressureChangePromise = @getByIdDirectPrivate(stream, "backpressureChangePromise");
+ if (backpressureChangePromise !== @undefined)
+ backpressureChangePromise.@resolve.@call();
+
+ @putByIdDirectPrivate(stream, "backpressureChangePromise", @newPromiseCapability(@Promise));
+ @putByIdDirectPrivate(stream, "backpressure", backpressure);
+}
+
+function setUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm)
+{
+ "use strict";
+
+ @assert(@isTransformStream(stream));
+ @assert(@getByIdDirectPrivate(stream, "controller") === @undefined);
+
+ @putByIdDirectPrivate(controller, "stream", stream);
+ @putByIdDirectPrivate(stream, "controller", controller);
+ @putByIdDirectPrivate(controller, "transformAlgorithm", transformAlgorithm);
+ @putByIdDirectPrivate(controller, "flushAlgorithm", flushAlgorithm);
+}
+
+
+function setUpTransformStreamDefaultControllerFromTransformer(stream, transformer, transformerDict)
+{
+ "use strict";
+
+ const controller = new @TransformStreamDefaultController();
+ let transformAlgorithm = (chunk) => {
+ try {
+ @transformStreamDefaultControllerEnqueue(controller, chunk);
+ } catch (e) {
+ return @Promise.@reject(e);
+ }
+ return @Promise.@resolve();
+ };
+ let flushAlgorithm = () => { return @Promise.@resolve(); };
+
+ if ("transform" in transformerDict)
+ transformAlgorithm = (chunk) => {
+ return @promiseInvokeOrNoopMethod(transformer, transformerDict["transform"], [chunk, controller]);
+ };
+
+ if ("flush" in transformerDict) {
+ flushAlgorithm = () => {
+ return @promiseInvokeOrNoopMethod(transformer, transformerDict["flush"], [controller]);
+ };
+ }
+
+ @setUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm);
+}
+
+function transformStreamDefaultControllerClearAlgorithms(controller)
+{
+ "use strict";
+
+ // We set transformAlgorithm to true to allow GC but keep the isTransformStreamDefaultController check.
+ @putByIdDirectPrivate(controller, "transformAlgorithm", true);
+ @putByIdDirectPrivate(controller, "flushAlgorithm", @undefined);
+}
+
+function transformStreamDefaultControllerEnqueue(controller, chunk)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(controller, "stream");
+ const readable = @getByIdDirectPrivate(stream, "readable");
+ const readableController = @getByIdDirectPrivate(readable, "readableStreamController");
+
+ @assert(readableController !== @undefined);
+ if (!@readableStreamDefaultControllerCanCloseOrEnqueue(readableController))
+ @throwTypeError("TransformStream.readable cannot close or enqueue");
+
+ try {
+ @readableStreamDefaultControllerEnqueue(readableController, chunk);
+ } catch (e) {
+ @transformStreamErrorWritableAndUnblockWrite(stream, e);
+ throw @getByIdDirectPrivate(readable, "storedError");
+ }
+
+ const backpressure = !@readableStreamDefaultControllerShouldCallPull(readableController);
+ if (backpressure !== @getByIdDirectPrivate(stream, "backpressure")) {
+ @assert(backpressure);
+ @transformStreamSetBackpressure(stream, true);
+ }
+}
+
+function transformStreamDefaultControllerError(controller, e)
+{
+ "use strict";
+
+ @transformStreamError(@getByIdDirectPrivate(controller, "stream"), e);
+}
+
+function transformStreamDefaultControllerPerformTransform(controller, chunk)
+{
+ "use strict";
+
+ const promiseCapability = @newPromiseCapability(@Promise);
+
+ const transformPromise = @getByIdDirectPrivate(controller, "transformAlgorithm").@call(@undefined, chunk);
+ transformPromise.@then(() => {
+ promiseCapability.@resolve();
+ }, (r) => {
+ @transformStreamError(@getByIdDirectPrivate(controller, "stream"), r);
+ promiseCapability.@reject.@call(@undefined, r);
+ });
+ return promiseCapability.@promise;
+}
+
+function transformStreamDefaultControllerTerminate(controller)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(controller, "stream");
+ const readable = @getByIdDirectPrivate(stream, "readable");
+ const readableController = @getByIdDirectPrivate(readable, "readableStreamController");
+
+ // FIXME: Update readableStreamDefaultControllerClose to make this check.
+ if (@readableStreamDefaultControllerCanCloseOrEnqueue(readableController))
+ @readableStreamDefaultControllerClose(readableController);
+ const error = @makeTypeError("the stream has been terminated");
+ @transformStreamErrorWritableAndUnblockWrite(stream, error);
+}
+
+function transformStreamDefaultSinkWriteAlgorithm(stream, chunk)
+{
+ "use strict";
+
+ const writable = @getByIdDirectPrivate(stream, "internalWritable");
+
+ @assert(@getByIdDirectPrivate(writable, "state") === "writable");
+
+ const controller = @getByIdDirectPrivate(stream, "controller");
+
+ if (@getByIdDirectPrivate(stream, "backpressure")) {
+ const promiseCapability = @newPromiseCapability(@Promise);
+
+ const backpressureChangePromise = @getByIdDirectPrivate(stream, "backpressureChangePromise");
+ @assert(backpressureChangePromise !== @undefined);
+ backpressureChangePromise.@promise.@then(() => {
+ const state = @getByIdDirectPrivate(writable, "state");
+ if (state === "erroring") {
+ promiseCapability.@reject.@call(@undefined, @getByIdDirectPrivate(writable, "storedError"));
+ return;
+ }
+
+ @assert(state === "writable");
+ @transformStreamDefaultControllerPerformTransform(controller, chunk).@then(() => {
+ promiseCapability.@resolve();
+ }, (e) => {
+ promiseCapability.@reject.@call(@undefined, e);
+ });
+ }, (e) => {
+ promiseCapability.@reject.@call(@undefined, e);
+ });
+
+ return promiseCapability.@promise;
+ }
+ return @transformStreamDefaultControllerPerformTransform(controller, chunk);
+}
+
+function transformStreamDefaultSinkAbortAlgorithm(stream, reason)
+{
+ "use strict";
+
+ @transformStreamError(stream, reason);
+ return @Promise.@resolve();
+}
+
+function transformStreamDefaultSinkCloseAlgorithm(stream)
+{
+ "use strict";
+ const readable = @getByIdDirectPrivate(stream, "readable");
+ const controller = @getByIdDirectPrivate(stream, "controller");
+ const readableController = @getByIdDirectPrivate(readable, "readableStreamController");
+
+ const flushAlgorithm = @getByIdDirectPrivate(controller, "flushAlgorithm");
+ @assert(flushAlgorithm !== @undefined);
+ const flushPromise = @getByIdDirectPrivate(controller, "flushAlgorithm").@call();
+ @transformStreamDefaultControllerClearAlgorithms(controller);
+
+ const promiseCapability = @newPromiseCapability(@Promise);
+ flushPromise.@then(() => {
+ if (@getByIdDirectPrivate(readable, "state") === @streamErrored) {
+ promiseCapability.@reject.@call(@undefined, @getByIdDirectPrivate(readable, "storedError"));
+ return;
+ }
+
+ // FIXME: Update readableStreamDefaultControllerClose to make this check.
+ if (@readableStreamDefaultControllerCanCloseOrEnqueue(readableController))
+ @readableStreamDefaultControllerClose(readableController);
+ promiseCapability.@resolve();
+ }, (r) => {
+ @transformStreamError(@getByIdDirectPrivate(controller, "stream"), r);
+ promiseCapability.@reject.@call(@undefined, @getByIdDirectPrivate(readable, "storedError"));
+ });
+ return promiseCapability.@promise;
+}
+
+function transformStreamDefaultSourcePullAlgorithm(stream)
+{
+ "use strict";
+
+ @assert(@getByIdDirectPrivate(stream, "backpressure"));
+ @assert(@getByIdDirectPrivate(stream, "backpressureChangePromise") !== @undefined);
+
+ @transformStreamSetBackpressure(stream, false);
+
+ return @getByIdDirectPrivate(stream, "backpressureChangePromise").@promise;
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/WritableStreamDefaultController.js b/src/javascript/jsc/bindings/builtins/js/WritableStreamDefaultController.js
new file mode 100644
index 000000000..8c42212e0
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/WritableStreamDefaultController.js
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+function initializeWritableStreamDefaultController()
+{
+ "use strict";
+
+ @putByIdDirectPrivate(this, "queue", @newQueue());
+ @putByIdDirectPrivate(this, "abortSteps", (reason) => {
+ const result = @getByIdDirectPrivate(this, "abortAlgorithm").@call(@undefined, reason);
+ @writableStreamDefaultControllerClearAlgorithms(this);
+ return result;
+ });
+
+ @putByIdDirectPrivate(this, "errorSteps", () => {
+ @resetQueue(@getByIdDirectPrivate(this, "queue"));
+ });
+
+ return this;
+}
+
+function error(e)
+{
+ "use strict";
+
+ if (@getByIdDirectPrivate(this, "abortSteps") === @undefined)
+ throw @makeThisTypeError("WritableStreamDefaultController", "error");
+
+ const stream = @getByIdDirectPrivate(this, "stream");
+ if (@getByIdDirectPrivate(stream, "state") !== "writable")
+ return;
+ @writableStreamDefaultControllerError(this, e);
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/WritableStreamDefaultWriter.js b/src/javascript/jsc/bindings/builtins/js/WritableStreamDefaultWriter.js
new file mode 100644
index 000000000..69a953fc3
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/WritableStreamDefaultWriter.js
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+function initializeWritableStreamDefaultWriter(stream)
+{
+ "use strict";
+
+ // stream can be a WritableStream if WritableStreamDefaultWriter constructor is called directly from JS
+ // or an InternalWritableStream in other code paths.
+ const internalStream = @getInternalWritableStream(stream);
+ if (internalStream)
+ stream = internalStream;
+
+ if (!@isWritableStream(stream))
+ @throwTypeError("WritableStreamDefaultWriter constructor takes a WritableStream");
+
+ @setUpWritableStreamDefaultWriter(this, stream);
+ return this;
+}
+
+@getter
+function closed()
+{
+ "use strict";
+
+ if (!@isWritableStreamDefaultWriter(this))
+ return @Promise.@reject(@makeGetterTypeError("WritableStreamDefaultWriter", "closed"));
+
+ return @getByIdDirectPrivate(this, "closedPromise").@promise;
+}
+
+@getter
+function desiredSize()
+{
+ "use strict";
+
+ if (!@isWritableStreamDefaultWriter(this))
+ throw @makeThisTypeError("WritableStreamDefaultWriter", "desiredSize");
+
+ if (@getByIdDirectPrivate(this, "stream") === @undefined)
+ @throwTypeError("WritableStreamDefaultWriter has no stream");
+
+ return @writableStreamDefaultWriterGetDesiredSize(this);
+}
+
+@getter
+function ready()
+{
+ "use strict";
+
+ if (!@isWritableStreamDefaultWriter(this))
+ return @Promise.@reject(@makeThisTypeError("WritableStreamDefaultWriter", "ready"));
+
+ return @getByIdDirectPrivate(this, "readyPromise").@promise;
+}
+
+function abort(reason)
+{
+ "use strict";
+
+ if (!@isWritableStreamDefaultWriter(this))
+ return @Promise.@reject(@makeThisTypeError("WritableStreamDefaultWriter", "abort"));
+
+ if (@getByIdDirectPrivate(this, "stream") === @undefined)
+ return @Promise.@reject(@makeTypeError("WritableStreamDefaultWriter has no stream"));
+
+ return @writableStreamDefaultWriterAbort(this, reason);
+}
+
+function close()
+{
+ "use strict";
+
+ if (!@isWritableStreamDefaultWriter(this))
+ return @Promise.@reject(@makeThisTypeError("WritableStreamDefaultWriter", "close"));
+
+ const stream = @getByIdDirectPrivate(this, "stream");
+ if (stream === @undefined)
+ return @Promise.@reject(@makeTypeError("WritableStreamDefaultWriter has no stream"));
+
+ if (@writableStreamCloseQueuedOrInFlight(stream))
+ return @Promise.@reject(@makeTypeError("WritableStreamDefaultWriter is being closed"));
+
+ return @writableStreamDefaultWriterClose(this);
+}
+
+function releaseLock()
+{
+ "use strict";
+
+ if (!@isWritableStreamDefaultWriter(this))
+ throw @makeThisTypeError("WritableStreamDefaultWriter", "releaseLock");
+
+ const stream = @getByIdDirectPrivate(this, "stream");
+ if (stream === @undefined)
+ return;
+
+ @assert(@getByIdDirectPrivate(stream, "writer") !== @undefined);
+ @writableStreamDefaultWriterRelease(this);
+}
+
+function write(chunk)
+{
+ "use strict";
+
+ if (!@isWritableStreamDefaultWriter(this))
+ return @Promise.@reject(@makeThisTypeError("WritableStreamDefaultWriter", "write"));
+
+ if (@getByIdDirectPrivate(this, "stream") === @undefined)
+ return @Promise.@reject(@makeTypeError("WritableStreamDefaultWriter has no stream"));
+
+ return @writableStreamDefaultWriterWrite(this, chunk);
+}
diff --git a/src/javascript/jsc/bindings/builtins/js/WritableStreamInternals.js b/src/javascript/jsc/bindings/builtins/js/WritableStreamInternals.js
new file mode 100644
index 000000000..406b9ea48
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/WritableStreamInternals.js
@@ -0,0 +1,781 @@
+/*
+ * Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia
+ *
+ * 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. ``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
+ * 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.
+ */
+
+// @internal
+
+function isWritableStream(stream)
+{
+ "use strict";
+
+ return @isObject(stream) && !!@getByIdDirectPrivate(stream, "underlyingSink");
+}
+
+function isWritableStreamDefaultWriter(writer)
+{
+ "use strict";
+
+ return @isObject(writer) && !!@getByIdDirectPrivate(writer, "closedPromise");
+}
+
+function acquireWritableStreamDefaultWriter(stream)
+{
+ return new @WritableStreamDefaultWriter(stream);
+}
+
+// https://streams.spec.whatwg.org/#create-writable-stream
+function createWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm)
+{
+ @assert(typeof highWaterMark === "number" && !@isNaN(highWaterMark) && highWaterMark >= 0);
+
+ const internalStream = { };
+ @initializeWritableStreamSlots(internalStream, { });
+ const controller = new @WritableStreamDefaultController();
+
+ @setUpWritableStreamDefaultController(internalStream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
+
+ return @createWritableStreamFromInternal(internalStream);
+}
+
+function createInternalWritableStreamFromUnderlyingSink(underlyingSink, strategy)
+{
+ "use strict";
+
+ const stream = { };
+
+ if (underlyingSink === @undefined)
+ underlyingSink = { };
+
+ if (strategy === @undefined)
+ strategy = { };
+
+ if (!@isObject(underlyingSink))
+ @throwTypeError("WritableStream constructor takes an object as first argument");
+
+ if ("type" in underlyingSink)
+ @throwRangeError("Invalid type is specified");
+
+ const sizeAlgorithm = @extractSizeAlgorithm(strategy);
+ const highWaterMark = @extractHighWaterMark(strategy, 1);
+
+ const underlyingSinkDict = { };
+ if ("start" in underlyingSink) {
+ underlyingSinkDict["start"] = underlyingSink["start"];
+ if (typeof underlyingSinkDict["start"] !== "function")
+ @throwTypeError("underlyingSink.start should be a function");
+ }
+ if ("write" in underlyingSink) {
+ underlyingSinkDict["write"] = underlyingSink["write"];
+ if (typeof underlyingSinkDict["write"] !== "function")
+ @throwTypeError("underlyingSink.write should be a function");
+ }
+ if ("close" in underlyingSink) {
+ underlyingSinkDict["close"] = underlyingSink["close"];
+ if (typeof underlyingSinkDict["close"] !== "function")
+ @throwTypeError("underlyingSink.close should be a function");
+ }
+ if ("abort" in underlyingSink) {
+ underlyingSinkDict["abort"] = underlyingSink["abort"];
+ if (typeof underlyingSinkDict["abort"] !== "function")
+ @throwTypeError("underlyingSink.abort should be a function");
+ }
+
+ @initializeWritableStreamSlots(stream, underlyingSink);
+ @setUpWritableStreamDefaultControllerFromUnderlyingSink(stream, underlyingSink, underlyingSinkDict, highWaterMark, sizeAlgorithm);
+
+ return stream;
+}
+
+function initializeWritableStreamSlots(stream, underlyingSink)
+{
+ @putByIdDirectPrivate(stream, "state", "writable");
+ @putByIdDirectPrivate(stream, "storedError", @undefined);
+ @putByIdDirectPrivate(stream, "writer", @undefined);
+ @putByIdDirectPrivate(stream, "controller", @undefined);
+ @putByIdDirectPrivate(stream, "inFlightWriteRequest", @undefined);
+ @putByIdDirectPrivate(stream, "closeRequest", @undefined);
+ @putByIdDirectPrivate(stream, "inFlightCloseRequest", @undefined);
+ @putByIdDirectPrivate(stream, "pendingAbortRequest", @undefined);
+ @putByIdDirectPrivate(stream, "writeRequests", []);
+ @putByIdDirectPrivate(stream, "backpressure", false);
+ @putByIdDirectPrivate(stream, "underlyingSink", underlyingSink);
+}
+
+function writableStreamCloseForBindings(stream)
+{
+ if (@isWritableStreamLocked(stream))
+ return @Promise.@reject(@makeTypeError("WritableStream.close method can only be used on non locked WritableStream"));
+
+ if (@writableStreamCloseQueuedOrInFlight(stream))
+ return @Promise.@reject(@makeTypeError("WritableStream.close method can only be used on a being close WritableStream"));
+
+ return @writableStreamClose(stream);
+}
+
+function writableStreamAbortForBindings(stream, reason)
+{
+ if (@isWritableStreamLocked(stream))
+ return @Promise.@reject(@makeTypeError("WritableStream.abort method can only be used on non locked WritableStream"));
+
+ return @writableStreamAbort(stream, reason);
+}
+
+function isWritableStreamLocked(stream)
+{
+ return @getByIdDirectPrivate(stream, "writer") !== @undefined;
+}
+
+function setUpWritableStreamDefaultWriter(writer, stream)
+{
+ if (@isWritableStreamLocked(stream))
+ @throwTypeError("WritableStream is locked");
+
+ @putByIdDirectPrivate(writer, "stream", stream);
+ @putByIdDirectPrivate(stream, "writer", writer);
+
+ const readyPromiseCapability = @newPromiseCapability(@Promise);
+ const closedPromiseCapability = @newPromiseCapability(@Promise);
+ @putByIdDirectPrivate(writer, "readyPromise", readyPromiseCapability);
+ @putByIdDirectPrivate(writer, "closedPromise", closedPromiseCapability);
+
+ const state = @getByIdDirectPrivate(stream, "state");
+ if (state === "writable") {
+ if (@writableStreamCloseQueuedOrInFlight(stream) || !@getByIdDirectPrivate(stream, "backpressure"))
+ readyPromiseCapability.@resolve.@call();
+ } else if (state === "erroring") {
+ readyPromiseCapability.@reject.@call(@undefined, @getByIdDirectPrivate(stream, "storedError"));
+ @markPromiseAsHandled(readyPromiseCapability.@promise);
+ } else if (state === "closed") {
+ readyPromiseCapability.@resolve.@call();
+ closedPromiseCapability.@resolve.@call();
+ } else {
+ @assert(state === "errored");
+ const storedError = @getByIdDirectPrivate(stream, "storedError");
+ readyPromiseCapability.@reject.@call(@undefined, storedError);
+ @markPromiseAsHandled(readyPromiseCapability.@promise);
+ closedPromiseCapability.@reject.@call(@undefined, storedError);
+ @markPromiseAsHandled(closedPromiseCapability.@promise);
+ }
+}
+
+function writableStreamAbort(stream, reason)
+{
+ const state = @getByIdDirectPrivate(stream, "state");
+ if (state === "closed" || state === "errored")
+ return @Promise.@resolve();
+
+ const pendingAbortRequest = @getByIdDirectPrivate(stream, "pendingAbortRequest");
+ if (pendingAbortRequest !== @undefined)
+ return pendingAbortRequest.promise.@promise;
+
+ @assert(state === "writable" || state === "erroring");
+ let wasAlreadyErroring = false;
+ if (state === "erroring") {
+ wasAlreadyErroring = true;
+ reason = @undefined;
+ }
+
+ const abortPromiseCapability = @newPromiseCapability(@Promise);
+ @putByIdDirectPrivate(stream, "pendingAbortRequest", { promise : abortPromiseCapability, reason : reason, wasAlreadyErroring : wasAlreadyErroring });
+
+ if (!wasAlreadyErroring)
+ @writableStreamStartErroring(stream, reason);
+ return abortPromiseCapability.@promise;
+}
+
+function writableStreamClose(stream)
+{
+ const state = @getByIdDirectPrivate(stream, "state");
+ if (state === "closed" || state === "errored")
+ return @Promise.@reject(@makeTypeError("Cannot close a writable stream that is closed or errored"));
+
+ @assert(state === "writable" || state === "erroring");
+ @assert(!@writableStreamCloseQueuedOrInFlight(stream));
+
+ const closePromiseCapability = @newPromiseCapability(@Promise);
+ @putByIdDirectPrivate(stream, "closeRequest", closePromiseCapability);
+
+ const writer = @getByIdDirectPrivate(stream, "writer");
+ if (writer !== @undefined && @getByIdDirectPrivate(stream, "backpressure") && state === "writable")
+ @getByIdDirectPrivate(writer, "readyPromise").@resolve.@call();
+
+ @writableStreamDefaultControllerClose(@getByIdDirectPrivate(stream, "controller"));
+
+ return closePromiseCapability.@promise;
+}
+
+function writableStreamAddWriteRequest(stream)
+{
+ @assert(@isWritableStreamLocked(stream))
+ @assert(@getByIdDirectPrivate(stream, "state") === "writable");
+
+ const writePromiseCapability = @newPromiseCapability(@Promise);
+ const writeRequests = @getByIdDirectPrivate(stream, "writeRequests");
+ @arrayPush(writeRequests, writePromiseCapability);
+ return writePromiseCapability.@promise;
+}
+
+function writableStreamCloseQueuedOrInFlight(stream)
+{
+ return @getByIdDirectPrivate(stream, "closeRequest") !== @undefined || @getByIdDirectPrivate(stream, "inFlightCloseRequest") !== @undefined;
+}
+
+function writableStreamDealWithRejection(stream, error)
+{
+ const state = @getByIdDirectPrivate(stream, "state");
+ if (state === "writable") {
+ @writableStreamStartErroring(stream, error);
+ return;
+ }
+
+ @assert(state === "erroring");
+ @writableStreamFinishErroring(stream);
+}
+
+function writableStreamFinishErroring(stream)
+{
+ @assert(@getByIdDirectPrivate(stream, "state") === "erroring");
+ @assert(!@writableStreamHasOperationMarkedInFlight(stream));
+
+ @putByIdDirectPrivate(stream, "state", "errored");
+
+ const controller = @getByIdDirectPrivate(stream, "controller");
+ @getByIdDirectPrivate(controller, "errorSteps").@call();
+
+ const storedError = @getByIdDirectPrivate(stream, "storedError");
+ const requests = @getByIdDirectPrivate(stream, "writeRequests");
+ for (let index = 0, length = requests.length; index < length; ++index)
+ requests[index].@reject.@call(@undefined, storedError);
+
+ @putByIdDirectPrivate(stream, "writeRequests", []);
+
+ const abortRequest = @getByIdDirectPrivate(stream, "pendingAbortRequest");
+ if (abortRequest === @undefined) {
+ @writableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
+ return;
+ }
+
+ @putByIdDirectPrivate(stream, "pendingAbortRequest", @undefined);
+ if (abortRequest.wasAlreadyErroring) {
+ abortRequest.promise.@reject.@call(@undefined, storedError);
+ @writableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
+ return;
+ }
+
+ @getByIdDirectPrivate(controller, "abortSteps").@call(@undefined, abortRequest.reason).@then(() => {
+ abortRequest.promise.@resolve.@call();
+ @writableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
+ }, (reason) => {
+ abortRequest.promise.@reject.@call(@undefined, reason);
+ @writableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
+ });
+}
+
+function writableStreamFinishInFlightClose(stream)
+{
+ const inFlightCloseRequest = @getByIdDirectPrivate(stream, "inFlightCloseRequest");
+ inFlightCloseRequest.@resolve.@call();
+
+ @putByIdDirectPrivate(stream, "inFlightCloseRequest", @undefined);
+
+ const state = @getByIdDirectPrivate(stream, "state");
+ @assert(state === "writable" || state === "erroring");
+
+ if (state === "erroring") {
+ @putByIdDirectPrivate(stream, "storedError", @undefined);
+ const abortRequest = @getByIdDirectPrivate(stream, "pendingAbortRequest");
+ if (abortRequest !== @undefined) {
+ abortRequest.promise.@resolve.@call();
+ @putByIdDirectPrivate(stream, "pendingAbortRequest", @undefined);
+ }
+ }
+
+ @putByIdDirectPrivate(stream, "state", "closed");
+
+ const writer = @getByIdDirectPrivate(stream, "writer");
+ if (writer !== @undefined)
+ @getByIdDirectPrivate(writer, "closedPromise").@resolve.@call();
+
+ @assert(@getByIdDirectPrivate(stream, "pendingAbortRequest") === @undefined);
+ @assert(@getByIdDirectPrivate(stream, "storedError") === @undefined);
+}
+
+function writableStreamFinishInFlightCloseWithError(stream, error)
+{
+ const inFlightCloseRequest = @getByIdDirectPrivate(stream, "inFlightCloseRequest");
+ @assert(inFlightCloseRequest !== @undefined);
+ inFlightCloseRequest.@reject.@call(@undefined, error);
+
+ @putByIdDirectPrivate(stream, "inFlightCloseRequest", @undefined);
+
+ const state = @getByIdDirectPrivate(stream, "state");
+ @assert(state === "writable" || state === "erroring");
+
+ const abortRequest = @getByIdDirectPrivate(stream, "pendingAbortRequest");
+ if (abortRequest !== @undefined) {
+ abortRequest.promise.@reject.@call(@undefined, error);
+ @putByIdDirectPrivate(stream, "pendingAbortRequest", @undefined);
+ }
+
+ @writableStreamDealWithRejection(stream, error);
+}
+
+function writableStreamFinishInFlightWrite(stream)
+{
+ const inFlightWriteRequest = @getByIdDirectPrivate(stream, "inFlightWriteRequest");
+ @assert(inFlightWriteRequest !== @undefined);
+ inFlightWriteRequest.@resolve.@call();
+
+ @putByIdDirectPrivate(stream, "inFlightWriteRequest", @undefined);
+}
+
+function writableStreamFinishInFlightWriteWithError(stream, error)
+{
+ const inFlightWriteRequest = @getByIdDirectPrivate(stream, "inFlightWriteRequest");
+ @assert(inFlightWriteRequest !== @undefined);
+ inFlightWriteRequest.@reject.@call(@undefined, error);
+
+ @putByIdDirectPrivate(stream, "inFlightWriteRequest", @undefined);
+
+ const state = @getByIdDirectPrivate(stream, "state");
+ @assert(state === "writable" || state === "erroring");
+
+ @writableStreamDealWithRejection(stream, error);
+}
+
+function writableStreamHasOperationMarkedInFlight(stream)
+{
+ return @getByIdDirectPrivate(stream, "inFlightWriteRequest") !== @undefined || @getByIdDirectPrivate(stream, "inFlightCloseRequest") !== @undefined;
+}
+
+function writableStreamMarkCloseRequestInFlight(stream)
+{
+ const closeRequest = @getByIdDirectPrivate(stream, "closeRequest");
+ @assert(@getByIdDirectPrivate(stream, "inFlightCloseRequest") === @undefined);
+ @assert(closeRequest !== @undefined);
+
+ @putByIdDirectPrivate(stream, "inFlightCloseRequest", closeRequest);
+ @putByIdDirectPrivate(stream, "closeRequest", @undefined);
+}
+
+function writableStreamMarkFirstWriteRequestInFlight(stream)
+{
+ const writeRequests = @getByIdDirectPrivate(stream, "writeRequests");
+ @assert(@getByIdDirectPrivate(stream, "inFlightWriteRequest") === @undefined);
+ @assert(writeRequests.length > 0);
+
+ const writeRequest = writeRequests.@shift();
+ @putByIdDirectPrivate(stream, "inFlightWriteRequest", writeRequest);
+}
+
+function writableStreamRejectCloseAndClosedPromiseIfNeeded(stream)
+{
+ @assert(@getByIdDirectPrivate(stream, "state") === "errored");
+
+ const storedError = @getByIdDirectPrivate(stream, "storedError");
+
+ const closeRequest = @getByIdDirectPrivate(stream, "closeRequest");
+ if (closeRequest !== @undefined) {
+ @assert(@getByIdDirectPrivate(stream, "inFlightCloseRequest") === @undefined);
+ closeRequest.@reject.@call(@undefined, storedError);
+ @putByIdDirectPrivate(stream, "closeRequest", @undefined);
+ }
+
+ const writer = @getByIdDirectPrivate(stream, "writer");
+ if (writer !== @undefined) {
+ const closedPromise = @getByIdDirectPrivate(writer, "closedPromise");
+ closedPromise.@reject.@call(@undefined, storedError);
+ @markPromiseAsHandled(closedPromise.@promise);
+ }
+}
+
+function writableStreamStartErroring(stream, reason)
+{
+ @assert(@getByIdDirectPrivate(stream, "storedError") === @undefined);
+ @assert(@getByIdDirectPrivate(stream, "state") === "writable");
+
+ const controller = @getByIdDirectPrivate(stream, "controller");
+ @assert(controller !== @undefined);
+
+ @putByIdDirectPrivate(stream, "state", "erroring");
+ @putByIdDirectPrivate(stream, "storedError", reason);
+
+ const writer = @getByIdDirectPrivate(stream, "writer");
+ if (writer !== @undefined)
+ @writableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason);
+
+ if (!@writableStreamHasOperationMarkedInFlight(stream) && @getByIdDirectPrivate(controller, "started"))
+ @writableStreamFinishErroring(stream);
+}
+
+function writableStreamUpdateBackpressure(stream, backpressure)
+{
+ @assert(@getByIdDirectPrivate(stream, "state") === "writable");
+ @assert(!@writableStreamCloseQueuedOrInFlight(stream));
+
+ const writer = @getByIdDirectPrivate(stream, "writer");
+ if (writer !== @undefined && backpressure !== @getByIdDirectPrivate(stream, "backpressure")) {
+ if (backpressure)
+ @putByIdDirectPrivate(writer, "readyPromise", @newPromiseCapability(@Promise));
+ else
+ @getByIdDirectPrivate(writer, "readyPromise").@resolve.@call();
+ }
+ @putByIdDirectPrivate(stream, "backpressure", backpressure);
+}
+
+function writableStreamDefaultWriterAbort(writer, reason)
+{
+ const stream = @getByIdDirectPrivate(writer, "stream");
+ @assert(stream !== @undefined);
+ return @writableStreamAbort(stream, reason);
+}
+
+function writableStreamDefaultWriterClose(writer)
+{
+ const stream = @getByIdDirectPrivate(writer, "stream");
+ @assert(stream !== @undefined);
+ return @writableStreamClose(stream);
+}
+
+function writableStreamDefaultWriterCloseWithErrorPropagation(writer)
+{
+ const stream = @getByIdDirectPrivate(writer, "stream");
+ @assert(stream !== @undefined);
+
+ const state = @getByIdDirectPrivate(stream, "state");
+
+ if (@writableStreamCloseQueuedOrInFlight(stream) || state === "closed")
+ return @Promise.@resolve();
+
+ if (state === "errored")
+ return @Promise.@reject(@getByIdDirectPrivate(stream, "storedError"));
+
+ @assert(state === "writable" || state === "erroring");
+ return @writableStreamDefaultWriterClose(writer);
+}
+
+function writableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error)
+{
+ let closedPromiseCapability = @getByIdDirectPrivate(writer, "closedPromise");
+ let closedPromise = closedPromiseCapability.@promise;
+
+ if ((@getPromiseInternalField(closedPromise, @promiseFieldFlags) & @promiseStateMask) !== @promiseStatePending) {
+ closedPromiseCapability = @newPromiseCapability(@Promise);
+ closedPromise = closedPromiseCapability.@promise;
+ @putByIdDirectPrivate(writer, "closedPromise", closedPromiseCapability);
+ }
+
+ closedPromiseCapability.@reject.@call(@undefined, error);
+ @markPromiseAsHandled(closedPromise);
+}
+
+function writableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error)
+{
+ let readyPromiseCapability = @getByIdDirectPrivate(writer, "readyPromise");
+ let readyPromise = readyPromiseCapability.@promise;
+
+ if ((@getPromiseInternalField(readyPromise, @promiseFieldFlags) & @promiseStateMask) !== @promiseStatePending) {
+ readyPromiseCapability = @newPromiseCapability(@Promise);
+ readyPromise = readyPromiseCapability.@promise;
+ @putByIdDirectPrivate(writer, "readyPromise", readyPromiseCapability);
+ }
+
+ readyPromiseCapability.@reject.@call(@undefined, error);
+ @markPromiseAsHandled(readyPromise);
+}
+
+function writableStreamDefaultWriterGetDesiredSize(writer)
+{
+ const stream = @getByIdDirectPrivate(writer, "stream");
+ @assert(stream !== @undefined);
+
+ const state = @getByIdDirectPrivate(stream, "state");
+
+ if (state === "errored" || state === "erroring")
+ return null;
+
+ if (state === "closed")
+ return 0;
+
+ return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(stream, "controller"));
+}
+
+function writableStreamDefaultWriterRelease(writer)
+{
+ const stream = @getByIdDirectPrivate(writer, "stream");
+ @assert(stream !== @undefined);
+ @assert(@getByIdDirectPrivate(stream, "writer") === writer);
+
+ const releasedError = @makeTypeError("writableStreamDefaultWriterRelease");
+
+ @writableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError);
+ @writableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError);
+
+ @putByIdDirectPrivate(stream, "writer", @undefined);
+ @putByIdDirectPrivate(writer, "stream", @undefined);
+}
+
+function writableStreamDefaultWriterWrite(writer, chunk)
+{
+ const stream = @getByIdDirectPrivate(writer, "stream");
+ @assert(stream !== @undefined);
+
+ const controller = @getByIdDirectPrivate(stream, "controller");
+ @assert(controller !== @undefined);
+ const chunkSize = @writableStreamDefaultControllerGetChunkSize(controller, chunk);
+
+ if (stream !== @getByIdDirectPrivate(writer, "stream"))
+ return @Promise.@reject(@makeTypeError("writer is not stream's writer"));
+
+ const state = @getByIdDirectPrivate(stream, "state");
+ if (state === "errored")
+ return @Promise.@reject(@getByIdDirectPrivate(stream, "storedError"));
+
+ if (@writableStreamCloseQueuedOrInFlight(stream) || state === "closed")
+ return @Promise.@reject(@makeTypeError("stream is closing or closed"));
+
+ if (@writableStreamCloseQueuedOrInFlight(stream) || state === "closed")
+ return @Promise.@reject(@makeTypeError("stream is closing or closed"));
+
+ if (state === "erroring")
+ return @Promise.@reject(@getByIdDirectPrivate(stream, "storedError"));
+
+ @assert(state === "writable");
+
+ const promise = @writableStreamAddWriteRequest(stream);
+ @writableStreamDefaultControllerWrite(controller, chunk, chunkSize);
+ return promise;
+}
+
+function setUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm)
+{
+ @assert(@isWritableStream(stream));
+ @assert(@getByIdDirectPrivate(stream, "controller") === @undefined);
+
+ @putByIdDirectPrivate(controller, "stream", stream);
+ @putByIdDirectPrivate(stream, "controller", controller);
+
+ @resetQueue(@getByIdDirectPrivate(controller, "queue"));
+
+ @putByIdDirectPrivate(controller, "started", false);
+ @putByIdDirectPrivate(controller, "strategySizeAlgorithm", sizeAlgorithm);
+ @putByIdDirectPrivate(controller, "strategyHWM", highWaterMark);
+ @putByIdDirectPrivate(controller, "writeAlgorithm", writeAlgorithm);
+ @putByIdDirectPrivate(controller, "closeAlgorithm", closeAlgorithm);
+ @putByIdDirectPrivate(controller, "abortAlgorithm", abortAlgorithm);
+
+ const backpressure = @writableStreamDefaultControllerGetBackpressure(controller);
+ @writableStreamUpdateBackpressure(stream, backpressure);
+
+ @Promise.@resolve(startAlgorithm.@call()).@then(() => {
+ const state = @getByIdDirectPrivate(stream, "state");
+ @assert(state === "writable" || state === "erroring");
+ @putByIdDirectPrivate(controller, "started", true);
+ @writableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
+ }, (error) => {
+ const state = @getByIdDirectPrivate(stream, "state");
+ @assert(state === "writable" || state === "erroring");
+ @putByIdDirectPrivate(controller, "started", true);
+ @writableStreamDealWithRejection(stream, error);
+ });
+}
+
+function setUpWritableStreamDefaultControllerFromUnderlyingSink(stream, underlyingSink, underlyingSinkDict, highWaterMark, sizeAlgorithm)
+{
+ const controller = new @WritableStreamDefaultController();
+
+ let startAlgorithm = () => { };
+ let writeAlgorithm = () => { return @Promise.@resolve(); };
+ let closeAlgorithm = () => { return @Promise.@resolve(); };
+ let abortAlgorithm = () => { return @Promise.@resolve(); };
+
+ if ("start" in underlyingSinkDict) {
+ const startMethod = underlyingSinkDict["start"];
+ startAlgorithm = () => @promiseInvokeOrNoopMethodNoCatch(underlyingSink, startMethod, [controller]);
+ }
+ if ("write" in underlyingSinkDict) {
+ const writeMethod = underlyingSinkDict["write"];
+ writeAlgorithm = (chunk) => @promiseInvokeOrNoopMethod(underlyingSink, writeMethod, [chunk, controller]);
+ }
+ if ("close" in underlyingSinkDict) {
+ const closeMethod = underlyingSinkDict["close"];
+ closeAlgorithm = () => @promiseInvokeOrNoopMethod(underlyingSink, closeMethod, []);
+ }
+ if ("abort" in underlyingSinkDict) {
+ const abortMethod = underlyingSinkDict["abort"];
+ abortAlgorithm = (reason) => @promiseInvokeOrNoopMethod(underlyingSink, abortMethod, [reason]);
+ }
+
+ @setUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
+}
+
+function writableStreamDefaultControllerAdvanceQueueIfNeeded(controller)
+{
+ const stream = @getByIdDirectPrivate(controller, "stream");
+
+ if (!@getByIdDirectPrivate(controller, "started"))
+ return;
+
+ @assert(stream !== @undefined);
+ if (@getByIdDirectPrivate(stream, "inFlightWriteRequest") !== @undefined)
+ return;
+
+ const state = @getByIdDirectPrivate(stream, "state");
+ @assert(state !== "closed" || state !== "errored");
+ if (state === "erroring") {
+ @writableStreamFinishErroring(stream);
+ return;
+ }
+
+ if (@getByIdDirectPrivate(controller, "queue").content.length === 0)
+ return;
+
+ const value = @peekQueueValue(@getByIdDirectPrivate(controller, "queue"));
+ if (value === @isCloseSentinel)
+ @writableStreamDefaultControllerProcessClose(controller);
+ else
+ @writableStreamDefaultControllerProcessWrite(controller, value);
+}
+
+function isCloseSentinel()
+{
+}
+
+function writableStreamDefaultControllerClearAlgorithms(controller)
+{
+ @putByIdDirectPrivate(controller, "writeAlgorithm", @undefined);
+ @putByIdDirectPrivate(controller, "closeAlgorithm", @undefined);
+ @putByIdDirectPrivate(controller, "abortAlgorithm", @undefined);
+ @putByIdDirectPrivate(controller, "strategySizeAlgorithm", @undefined);
+}
+
+function writableStreamDefaultControllerClose(controller)
+{
+ @enqueueValueWithSize(@getByIdDirectPrivate(controller, "queue"), @isCloseSentinel, 0);
+ @writableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
+}
+
+function writableStreamDefaultControllerError(controller, error)
+{
+ const stream = @getByIdDirectPrivate(controller, "stream");
+ @assert(stream !== @undefined);
+ @assert(@getByIdDirectPrivate(stream, "state") === "writable");
+
+ @writableStreamDefaultControllerClearAlgorithms(controller);
+ @writableStreamStartErroring(stream, error);
+}
+
+function writableStreamDefaultControllerErrorIfNeeded(controller, error)
+{
+ const stream = @getByIdDirectPrivate(controller, "stream");
+ if (@getByIdDirectPrivate(stream, "state") === "writable")
+ @writableStreamDefaultControllerError(controller, error);
+}
+
+function writableStreamDefaultControllerGetBackpressure(controller)
+{
+ const desiredSize = @writableStreamDefaultControllerGetDesiredSize(controller);
+ return desiredSize <= 0;
+}
+
+function writableStreamDefaultControllerGetChunkSize(controller, chunk)
+{
+ try {
+ return @getByIdDirectPrivate(controller, "strategySizeAlgorithm").@call(@undefined, chunk);
+ } catch (e) {
+ @writableStreamDefaultControllerErrorIfNeeded(controller, e);
+ return 1;
+ }
+}
+
+function writableStreamDefaultControllerGetDesiredSize(controller)
+{
+ return @getByIdDirectPrivate(controller, "strategyHWM") - @getByIdDirectPrivate(controller, "queue").size;
+}
+
+function writableStreamDefaultControllerProcessClose(controller)
+{
+ const stream = @getByIdDirectPrivate(controller, "stream");
+
+ @writableStreamMarkCloseRequestInFlight(stream);
+ @dequeueValue(@getByIdDirectPrivate(controller, "queue"));
+
+ @assert(@getByIdDirectPrivate(controller, "queue").content.length === 0);
+
+ const sinkClosePromise = @getByIdDirectPrivate(controller, "closeAlgorithm").@call();
+ @writableStreamDefaultControllerClearAlgorithms(controller);
+
+ sinkClosePromise.@then(() => {
+ @writableStreamFinishInFlightClose(stream);
+ }, (reason) => {
+ @writableStreamFinishInFlightCloseWithError(stream, reason);
+ });
+}
+
+function writableStreamDefaultControllerProcessWrite(controller, chunk)
+{
+ const stream = @getByIdDirectPrivate(controller, "stream");
+
+ @writableStreamMarkFirstWriteRequestInFlight(stream);
+
+ const sinkWritePromise = @getByIdDirectPrivate(controller, "writeAlgorithm").@call(@undefined, chunk);
+
+ sinkWritePromise.@then(() => {
+ @writableStreamFinishInFlightWrite(stream);
+ const state = @getByIdDirectPrivate(stream, "state");
+ @assert(state === "writable" || state === "erroring");
+
+ @dequeueValue(@getByIdDirectPrivate(controller, "queue"));
+ if (!@writableStreamCloseQueuedOrInFlight(stream) && state === "writable") {
+ const backpressure = @writableStreamDefaultControllerGetBackpressure(controller);
+ @writableStreamUpdateBackpressure(stream, backpressure);
+ }
+ @writableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
+ }, (reason) => {
+ const state = @getByIdDirectPrivate(stream, "state");
+ if (state === "writable")
+ @writableStreamDefaultControllerClearAlgorithms(controller);
+
+ @writableStreamFinishInFlightWriteWithError(stream, reason);
+ });
+}
+
+function writableStreamDefaultControllerWrite(controller, chunk, chunkSize)
+{
+ try {
+ @enqueueValueWithSize(@getByIdDirectPrivate(controller, "queue"), chunk, chunkSize);
+
+ const stream = @getByIdDirectPrivate(controller, "stream");
+
+ const state = @getByIdDirectPrivate(stream, "state");
+ if (!@writableStreamCloseQueuedOrInFlight(stream) && state === "writable") {
+ const backpressure = @writableStreamDefaultControllerGetBackpressure(controller);
+ @writableStreamUpdateBackpressure(stream, backpressure);
+ }
+ @writableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
+ } catch (e) {
+ @writableStreamDefaultControllerErrorIfNeeded(controller, e);
+ }
+}
diff --git a/src/javascript/jsc/bindings/headers.zig b/src/javascript/jsc/bindings/headers.zig
index 3b74bd4cd..e69de29bb 100644
--- a/src/javascript/jsc/bindings/headers.zig
+++ b/src/javascript/jsc/bindings/headers.zig
@@ -1,474 +0,0 @@
-// GENERATED FILE - do not modify!
-const bindings = @import("../../../jsc.zig");
-
-pub const struct_JSC__StringPrototype = bindings.StringPrototype;
-pub const struct_JSC__SetIteratorPrototype = bindings.SetIteratorPrototype;
-pub const struct_JSC__RegExpPrototype = bindings.RegExpPrototype;
-pub const struct_JSC__ObjectPrototype = bindings.ObjectPrototype;
-pub const struct_JSC__MapIteratorPrototype = bindings.MapIteratorPrototype;
-pub const struct_JSC__JSPromisePrototype = bindings.JSPromisePrototype;
-pub const struct_JSC__IteratorPrototype = bindings.IteratorPrototype;
-pub const struct_JSC__GeneratorPrototype = bindings.GeneratorPrototype;
-pub const struct_JSC__GeneratorFunctionPrototype = bindings.GeneratorFunctionPrototype;
-pub const struct_JSC__FunctionPrototype = bindings.FunctionPrototype;
-pub const struct_JSC__BigIntPrototype = bindings.BigIntPrototype;
-pub const struct_JSC__AsyncIteratorPrototype = bindings.AsyncIteratorPrototype;
-pub const struct_JSC__AsyncGeneratorPrototype = bindings.AsyncGeneratorPrototype;
-pub const struct_JSC__AsyncGeneratorFunctionPrototype = bindings.AsyncGeneratorFunctionPrototype;
-pub const struct_JSC__AsyncFunctionPrototype = bindings.AsyncFunctionPrototype;
-pub const struct_JSC__ArrayPrototype = bindings.ArrayPrototype;
-pub const struct_JSC__ArrayIteratorPrototype = bindings.ArrayIteratorPrototype;
-pub const bWTF__URL = bindings.URL;
-pub const bWTF__StringView = bindings.StringView;
-pub const bWTF__StringImpl = bindings.StringImpl;
-pub const bWTF__String = bindings.String;
-pub const bWTF__ExternalStringImpl = bindings.ExternalStringImpl;
-pub const bJSC__VM = bindings.VM;
-pub const bJSC__ThrowScope = bindings.ThrowScope;
-pub const bJSC__SourceOrigin = bindings.SourceOrigin;
-pub const bJSC__SourceCode = bindings.SourceCode;
-pub const bJSC__PropertyName = bindings.PropertyName;
-pub const bJSC__JSString = bindings.JSString;
-pub const bJSC__JSPromise = bindings.JSPromise;
-pub const bJSC__JSObject = bindings.JSObject;
-pub const bJSC__JSModuleRecord = bindings.JSModuleRecord;
-pub const bJSC__JSModuleLoader = bindings.JSModuleLoader;
-pub const bJSC__JSLock = bindings.JSLock;
-pub const bJSC__JSInternalPromise = bindings.JSInternalPromise;
-pub const bJSC__JSGlobalObject = bindings.JSGlobalObject;
-pub const bJSC__JSFunction = bindings.JSFunction;
-pub const bJSC__JSCell = bindings.JSCell;
-pub const bJSC__Identifier = bindings.Identifier;
-pub const bJSC__Exception = bindings.Exception;
-pub const bJSC__CatchScope = bindings.CatchScope;
-pub const bJSC__CallFrame = bindings.CallFrame;
-pub const bInspector__ScriptArguments = bindings.ScriptArguments;
-pub const JSC__JSValue = bindings.JSValue;
-
-// Inlined types
-pub const ZigString = bindings.ZigString;
-pub const ZigException = bindings.ZigException;
-pub const ResolvedSource = bindings.ResolvedSource;
-pub const ZigStackTrace = bindings.ZigStackTrace;
-pub const ReturnableException = bindings.ReturnableException;
-pub const struct_Zig__JSMicrotaskCallback = bindings.Microtask;
-pub const bZig__JSMicrotaskCallback = struct_Zig__JSMicrotaskCallback;
-pub const SystemError = bindings.SystemError;
-const JSClassRef = bindings.C.JSClassRef;
-pub const JSC__CatchScope = bindings.CatchScope;
-pub const Bun__Readable = bindings.NodeReadableStream;
-pub const Bun__Writable = bindings.NodeWritableStream;
-pub const Bun__ArrayBuffer = bindings.ArrayBuffer;
-pub const struct_WebCore__DOMURL = bindings.DOMURL;
-pub const struct_WebCore__FetchHeaders = bindings.FetchHeaders;
-pub const StringPointer = @import("../../../api/schema.zig").Api.StringPointer;
-// GENERATED CODE - DO NOT MODIFY BY HAND
-
-pub const ptrdiff_t = c_long;
-pub const wchar_t = c_int;
-pub const __uint16_t = c_ushort;
-pub const __int32_t = c_int;
-pub const __uint32_t = c_uint;
-pub const __int64_t = c_longlong;
-pub const __uint64_t = c_ulonglong;
-pub const __mbstate_t = extern union {
- __mbstate8: [128]u8,
- _mbstateL: c_longlong,
-};
-
-pub const JSC__GeneratorPrototype = struct_JSC__GeneratorPrototype;
-
-pub const JSC__ArrayIteratorPrototype = struct_JSC__ArrayIteratorPrototype;
-
-pub const JSC__JSPromisePrototype = struct_JSC__JSPromisePrototype;
-pub const JSC__PropertyName = bJSC__PropertyName;
-pub const JSC__JSObject = bJSC__JSObject;
-pub const WTF__ExternalStringImpl = bWTF__ExternalStringImpl;
-
-pub const JSC__AsyncIteratorPrototype = struct_JSC__AsyncIteratorPrototype;
-pub const JSC__JSModuleLoader = bJSC__JSModuleLoader;
-
-pub const JSC__AsyncGeneratorPrototype = struct_JSC__AsyncGeneratorPrototype;
-
-pub const JSC__AsyncGeneratorFunctionPrototype = struct_JSC__AsyncGeneratorFunctionPrototype;
-pub const JSC__Identifier = bJSC__Identifier;
-
-pub const JSC__ArrayPrototype = struct_JSC__ArrayPrototype;
-
-pub const Zig__JSMicrotaskCallback = struct_Zig__JSMicrotaskCallback;
-pub const JSC__JSPromise = bJSC__JSPromise;
-
-pub const JSC__SetIteratorPrototype = struct_JSC__SetIteratorPrototype;
-pub const JSC__JSCell = bJSC__JSCell;
-pub const JSC__SourceOrigin = bJSC__SourceOrigin;
-pub const JSC__JSModuleRecord = bJSC__JSModuleRecord;
-pub const WTF__String = bWTF__String;
-pub const WTF__URL = bWTF__URL;
-
-pub const JSC__IteratorPrototype = struct_JSC__IteratorPrototype;
-pub const JSC__JSInternalPromise = bJSC__JSInternalPromise;
-
-pub const JSC__MapIteratorPrototype = struct_JSC__MapIteratorPrototype;
-
-pub const JSC__RegExpPrototype = struct_JSC__RegExpPrototype;
-pub const JSC__CallFrame = bJSC__CallFrame;
-
-pub const WebCore__FetchHeaders = struct_WebCore__FetchHeaders;
-pub const WTF__StringView = bWTF__StringView;
-pub const JSC__ThrowScope = bJSC__ThrowScope;
-pub const WTF__StringImpl = bWTF__StringImpl;
-pub const JSC__VM = bJSC__VM;
-pub const JSC__JSGlobalObject = bJSC__JSGlobalObject;
-pub const JSC__JSFunction = bJSC__JSFunction;
-
-pub const JSC__AsyncFunctionPrototype = struct_JSC__AsyncFunctionPrototype;
-pub const JSC__SourceCode = bJSC__SourceCode;
-
-pub const JSC__BigIntPrototype = struct_JSC__BigIntPrototype;
-
-pub const JSC__GeneratorFunctionPrototype = struct_JSC__GeneratorFunctionPrototype;
-
-pub const WebCore__DOMURL = struct_WebCore__DOMURL;
-
-pub const JSC__FunctionPrototype = struct_JSC__FunctionPrototype;
-pub const Inspector__ScriptArguments = bInspector__ScriptArguments;
-pub const JSC__Exception = bJSC__Exception;
-pub const JSC__JSString = bJSC__JSString;
-
-pub const JSC__ObjectPrototype = struct_JSC__ObjectPrototype;
-
-pub const JSC__StringPrototype = struct_JSC__StringPrototype;
-pub extern fn JSC__JSObject__create(arg0: [*c]JSC__JSGlobalObject, arg1: usize, arg2: ?*anyopaque, ArgFn3: ?fn (?*anyopaque, [*c]JSC__JSObject, [*c]JSC__JSGlobalObject) callconv(.C) void) JSC__JSValue;
-pub extern fn JSC__JSObject__getArrayLength(arg0: [*c]JSC__JSObject) usize;
-pub extern fn JSC__JSObject__getDirect(arg0: [*c]JSC__JSObject, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]const ZigString) JSC__JSValue;
-pub extern fn JSC__JSObject__getIndex(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: u32) JSC__JSValue;
-pub extern fn JSC__JSObject__putRecord(arg0: [*c]JSC__JSObject, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]ZigString, arg3: [*c]ZigString, arg4: usize) void;
-pub extern fn ZigString__external(arg0: [*c]const ZigString, arg1: [*c]JSC__JSGlobalObject, arg2: ?*anyopaque, ArgFn3: ?fn (?*anyopaque, ?*anyopaque, usize) callconv(.C) void) JSC__JSValue;
-pub extern fn ZigString__to16BitValue(arg0: [*c]const ZigString, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toErrorInstance(arg0: [*c]const ZigString, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toExternalU16(arg0: [*c]const u16, arg1: usize, arg2: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toExternalValue(arg0: [*c]const ZigString, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toExternalValueWithCallback(arg0: [*c]const ZigString, arg1: [*c]JSC__JSGlobalObject, ArgFn2: ?fn (?*anyopaque, ?*anyopaque, usize) callconv(.C) void) JSC__JSValue;
-pub extern fn ZigString__toValue(arg0: [*c]const ZigString, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn ZigString__toValueGC(arg0: [*c]const ZigString, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn WebCore__DOMURL__cast_(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM) ?*WebCore__DOMURL;
-pub extern fn WebCore__DOMURL__href_(arg0: ?*WebCore__DOMURL, arg1: [*c]ZigString) void;
-pub extern fn WebCore__DOMURL__pathname_(arg0: ?*WebCore__DOMURL, arg1: [*c]ZigString) void;
-pub extern fn WebCore__FetchHeaders__append(arg0: ?*WebCore__FetchHeaders, arg1: [*c]const ZigString, arg2: [*c]const ZigString) void;
-pub extern fn WebCore__FetchHeaders__cast_(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM) ?*WebCore__FetchHeaders;
-pub extern fn WebCore__FetchHeaders__clone(arg0: ?*WebCore__FetchHeaders, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn WebCore__FetchHeaders__cloneThis(arg0: ?*WebCore__FetchHeaders) ?*WebCore__FetchHeaders;
-pub extern fn WebCore__FetchHeaders__copyTo(arg0: ?*WebCore__FetchHeaders, arg1: [*c]StringPointer, arg2: [*c]StringPointer, arg3: [*c]u8) void;
-pub extern fn WebCore__FetchHeaders__count(arg0: ?*WebCore__FetchHeaders, arg1: [*c]u32, arg2: [*c]u32) void;
-pub extern fn WebCore__FetchHeaders__createEmpty(...) ?*WebCore__FetchHeaders;
-pub extern fn WebCore__FetchHeaders__createFromJS(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) ?*WebCore__FetchHeaders;
-pub extern fn WebCore__FetchHeaders__createFromPicoHeaders_(arg0: [*c]JSC__JSGlobalObject, arg1: ?*const anyopaque) ?*WebCore__FetchHeaders;
-pub extern fn WebCore__FetchHeaders__createFromUWS(arg0: [*c]JSC__JSGlobalObject, arg1: ?*anyopaque) ?*WebCore__FetchHeaders;
-pub extern fn WebCore__FetchHeaders__createValue(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]StringPointer, arg2: [*c]StringPointer, arg3: [*c]const ZigString, arg4: u32) JSC__JSValue;
-pub extern fn WebCore__FetchHeaders__deref(arg0: ?*WebCore__FetchHeaders) void;
-pub extern fn WebCore__FetchHeaders__get_(arg0: ?*WebCore__FetchHeaders, arg1: [*c]const ZigString, arg2: [*c]ZigString) void;
-pub extern fn WebCore__FetchHeaders__has(arg0: ?*WebCore__FetchHeaders, arg1: [*c]const ZigString) bool;
-pub extern fn WebCore__FetchHeaders__put_(arg0: ?*WebCore__FetchHeaders, arg1: [*c]const ZigString, arg2: [*c]const ZigString) void;
-pub extern fn WebCore__FetchHeaders__remove(arg0: ?*WebCore__FetchHeaders, arg1: [*c]const ZigString) void;
-pub extern fn WebCore__FetchHeaders__toJS(arg0: ?*WebCore__FetchHeaders, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn WebCore__FetchHeaders__toUWSResponse(arg0: ?*WebCore__FetchHeaders, arg1: bool, arg2: ?*anyopaque) void;
-pub extern fn SystemError__toErrorInstance(arg0: [*c]const SystemError, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSCell__getObject(arg0: [*c]JSC__JSCell) [*c]JSC__JSObject;
-pub extern fn JSC__JSCell__getString(arg0: [*c]JSC__JSCell, arg1: [*c]JSC__JSGlobalObject) bWTF__String;
-pub extern fn JSC__JSCell__getType(arg0: [*c]JSC__JSCell) u8;
-pub extern fn JSC__JSString__createFromOwnedString(arg0: [*c]JSC__VM, arg1: [*c]const WTF__String) [*c]JSC__JSString;
-pub extern fn JSC__JSString__createFromString(arg0: [*c]JSC__VM, arg1: [*c]const WTF__String) [*c]JSC__JSString;
-pub extern fn JSC__JSString__eql(arg0: [*c]const JSC__JSString, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__JSString) bool;
-pub extern fn JSC__JSString__is8Bit(arg0: [*c]const JSC__JSString) bool;
-pub extern fn JSC__JSString__length(arg0: [*c]const JSC__JSString) usize;
-pub extern fn JSC__JSString__toObject(arg0: [*c]JSC__JSString, arg1: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject;
-pub extern fn JSC__JSString__value(arg0: [*c]JSC__JSString, arg1: [*c]JSC__JSGlobalObject) bWTF__String;
-pub extern fn Inspector__ScriptArguments__argumentAt(arg0: [*c]Inspector__ScriptArguments, arg1: usize) JSC__JSValue;
-pub extern fn Inspector__ScriptArguments__argumentCount(arg0: [*c]Inspector__ScriptArguments) usize;
-pub extern fn Inspector__ScriptArguments__getFirstArgumentAsString(arg0: [*c]Inspector__ScriptArguments) bWTF__String;
-pub extern fn Inspector__ScriptArguments__isEqual(arg0: [*c]Inspector__ScriptArguments, arg1: [*c]Inspector__ScriptArguments) bool;
-pub extern fn Inspector__ScriptArguments__release(arg0: [*c]Inspector__ScriptArguments) void;
-pub extern fn JSC__JSModuleLoader__checkSyntax(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const JSC__SourceCode, arg2: bool) bool;
-pub extern fn JSC__JSModuleLoader__evaluate(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const u8, arg2: usize, arg3: [*c]const u8, arg4: usize, JSValue5: JSC__JSValue, arg6: [*c]JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__JSModuleLoader__importModule(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const JSC__Identifier) [*c]JSC__JSInternalPromise;
-pub extern fn JSC__JSModuleLoader__linkAndEvaluateModule(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const JSC__Identifier) JSC__JSValue;
-pub extern fn JSC__JSModuleLoader__loadAndEvaluateModule(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const ZigString) [*c]JSC__JSInternalPromise;
-pub extern fn JSC__JSModuleLoader__loadAndEvaluateModuleEntryPoint(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const JSC__SourceCode) [*c]JSC__JSInternalPromise;
-pub extern fn JSC__JSModuleRecord__sourceCode(arg0: [*c]JSC__JSModuleRecord) bJSC__SourceCode;
-pub extern fn JSC__JSPromise__asValue(arg0: [*c]JSC__JSPromise, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSPromise__create(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSPromise;
-pub extern fn JSC__JSPromise__isHandled(arg0: [*c]const JSC__JSPromise, arg1: [*c]JSC__VM) bool;
-pub extern fn JSC__JSPromise__reject(arg0: [*c]JSC__JSPromise, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSPromise__rejectAsHandled(arg0: [*c]JSC__JSPromise, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSPromise__rejectAsHandledException(arg0: [*c]JSC__JSPromise, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__Exception) void;
-pub extern fn JSC__JSPromise__rejectedPromise(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) [*c]JSC__JSPromise;
-pub extern fn JSC__JSPromise__rejectedPromiseValue(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__JSPromise__rejectWithCaughtException(arg0: [*c]JSC__JSPromise, arg1: [*c]JSC__JSGlobalObject, arg2: bJSC__ThrowScope) void;
-pub extern fn JSC__JSPromise__resolve(arg0: [*c]JSC__JSPromise, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSPromise__resolvedPromise(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) [*c]JSC__JSPromise;
-pub extern fn JSC__JSPromise__resolvedPromiseValue(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__JSPromise__result(arg0: [*c]const JSC__JSPromise, arg1: [*c]JSC__VM) JSC__JSValue;
-pub extern fn JSC__JSPromise__status(arg0: [*c]const JSC__JSPromise, arg1: [*c]JSC__VM) u32;
-pub extern fn JSC__JSInternalPromise__create(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSInternalPromise;
-pub extern fn JSC__JSInternalPromise__isHandled(arg0: [*c]const JSC__JSInternalPromise, arg1: [*c]JSC__VM) bool;
-pub extern fn JSC__JSInternalPromise__reject(arg0: [*c]JSC__JSInternalPromise, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSInternalPromise__rejectAsHandled(arg0: [*c]JSC__JSInternalPromise, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSInternalPromise__rejectAsHandledException(arg0: [*c]JSC__JSInternalPromise, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__Exception) void;
-pub extern fn JSC__JSInternalPromise__rejectedPromise(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) [*c]JSC__JSInternalPromise;
-pub extern fn JSC__JSInternalPromise__rejectWithCaughtException(arg0: [*c]JSC__JSInternalPromise, arg1: [*c]JSC__JSGlobalObject, arg2: bJSC__ThrowScope) void;
-pub extern fn JSC__JSInternalPromise__resolve(arg0: [*c]JSC__JSInternalPromise, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void;
-pub extern fn JSC__JSInternalPromise__resolvedPromise(arg0: [*c]JSC__JSGlobalObject, JSValue1: JSC__JSValue) [*c]JSC__JSInternalPromise;
-pub extern fn JSC__JSInternalPromise__result(arg0: [*c]const JSC__JSInternalPromise, arg1: [*c]JSC__VM) JSC__JSValue;
-pub extern fn JSC__JSInternalPromise__status(arg0: [*c]const JSC__JSInternalPromise, arg1: [*c]JSC__VM) u32;
-pub extern fn JSC__SourceOrigin__fromURL(arg0: [*c]const WTF__URL) bJSC__SourceOrigin;
-pub extern fn JSC__SourceCode__fromString(arg0: [*c]JSC__SourceCode, arg1: [*c]const WTF__String, arg2: [*c]const JSC__SourceOrigin, arg3: [*c]WTF__String, SourceType4: u8) void;
-pub extern fn JSC__JSFunction__calculatedDisplayName(arg0: [*c]JSC__JSFunction, arg1: [*c]JSC__VM) bWTF__String;
-pub extern fn JSC__JSFunction__callWithArguments(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__JSValue, arg3: usize, arg4: *?*JSC__Exception, arg5: [*c]const u8) JSC__JSValue;
-pub extern fn JSC__JSFunction__callWithArgumentsAndThis(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: [*c]JSC__JSGlobalObject, arg3: [*c]JSC__JSValue, arg4: usize, arg5: *?*JSC__Exception, arg6: [*c]const u8) JSC__JSValue;
-pub extern fn JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: *?*JSC__Exception, arg3: [*c]const u8) JSC__JSValue;
-pub extern fn JSC__JSFunction__callWithThis(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue, arg3: *?*JSC__Exception, arg4: [*c]const u8) JSC__JSValue;
-pub extern fn JSC__JSFunction__constructWithArguments(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__JSValue, arg3: usize, arg4: *?*JSC__Exception, arg5: [*c]const u8) JSC__JSValue;
-pub extern fn JSC__JSFunction__constructWithArgumentsAndNewTarget(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: [*c]JSC__JSGlobalObject, arg3: [*c]JSC__JSValue, arg4: usize, arg5: *?*JSC__Exception, arg6: [*c]const u8) JSC__JSValue;
-pub extern fn JSC__JSFunction__constructWithNewTarget(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue, arg3: *?*JSC__Exception, arg4: [*c]const u8) JSC__JSValue;
-pub extern fn JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: *?*JSC__Exception, arg3: [*c]const u8) JSC__JSValue;
-pub extern fn JSC__JSFunction__createFromNative(arg0: [*c]JSC__JSGlobalObject, arg1: u16, arg2: [*c]const WTF__String, arg3: ?*anyopaque, ArgFn4: ?fn (?*anyopaque, [*c]JSC__JSGlobalObject, [*c]JSC__CallFrame) callconv(.C) JSC__JSValue) [*c]JSC__JSFunction;
-pub extern fn JSC__JSFunction__displayName(arg0: [*c]JSC__JSFunction, arg1: [*c]JSC__VM) bWTF__String;
-pub extern fn JSC__JSFunction__getName(arg0: [*c]JSC__JSFunction, arg1: [*c]JSC__VM) bWTF__String;
-pub extern fn JSC__JSGlobalObject__arrayIteratorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__ArrayIteratorPrototype;
-pub extern fn JSC__JSGlobalObject__arrayPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__ArrayPrototype;
-pub extern fn JSC__JSGlobalObject__asyncFunctionPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__AsyncFunctionPrototype;
-pub extern fn JSC__JSGlobalObject__asyncGeneratorFunctionPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__AsyncGeneratorFunctionPrototype;
-pub extern fn JSC__JSGlobalObject__asyncGeneratorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__AsyncGeneratorPrototype;
-pub extern fn JSC__JSGlobalObject__asyncIteratorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__AsyncIteratorPrototype;
-pub extern fn JSC__JSGlobalObject__bigIntPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__BigIntPrototype;
-pub extern fn JSC__JSGlobalObject__booleanPrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject;
-pub extern fn JSC__JSGlobalObject__createAggregateError(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]*anyopaque, arg2: u16, arg3: [*c]const ZigString) JSC__JSValue;
-pub extern fn JSC__JSGlobalObject__datePrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject;
-pub extern fn JSC__JSGlobalObject__deleteModuleRegistryEntry(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]ZigString) void;
-pub extern fn JSC__JSGlobalObject__errorPrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject;
-pub extern fn JSC__JSGlobalObject__functionPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__FunctionPrototype;
-pub extern fn JSC__JSGlobalObject__generateHeapSnapshot(arg0: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSGlobalObject__generatorFunctionPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__GeneratorFunctionPrototype;
-pub extern fn JSC__JSGlobalObject__generatorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__GeneratorPrototype;
-pub extern fn JSC__JSGlobalObject__getCachedObject(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const ZigString) JSC__JSValue;
-pub extern fn JSC__JSGlobalObject__iteratorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__IteratorPrototype;
-pub extern fn JSC__JSGlobalObject__jsSetPrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject;
-pub extern fn JSC__JSGlobalObject__mapIteratorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__MapIteratorPrototype;
-pub extern fn JSC__JSGlobalObject__mapPrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject;
-pub extern fn JSC__JSGlobalObject__numberPrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject;
-pub extern fn JSC__JSGlobalObject__objectPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__ObjectPrototype;
-pub extern fn JSC__JSGlobalObject__promisePrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__JSPromisePrototype;
-pub extern fn JSC__JSGlobalObject__putCachedObject(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const ZigString, JSValue2: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__JSGlobalObject__regExpPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__RegExpPrototype;
-pub extern fn JSC__JSGlobalObject__setIteratorPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__SetIteratorPrototype;
-pub extern fn JSC__JSGlobalObject__stringPrototype(arg0: [*c]JSC__JSGlobalObject) ?*JSC__StringPrototype;
-pub extern fn JSC__JSGlobalObject__symbolPrototype(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject;
-pub extern fn JSC__JSGlobalObject__vm(arg0: [*c]JSC__JSGlobalObject) [*c]JSC__VM;
-pub extern fn WTF__URL__encodedPassword(arg0: [*c]WTF__URL) bWTF__StringView;
-pub extern fn WTF__URL__encodedUser(arg0: [*c]WTF__URL) bWTF__StringView;
-pub extern fn WTF__URL__fileSystemPath(arg0: [*c]WTF__URL) bWTF__String;
-pub extern fn WTF__URL__fragmentIdentifier(arg0: [*c]WTF__URL) bWTF__StringView;
-pub extern fn WTF__URL__fragmentIdentifierWithLeadingNumberSign(arg0: [*c]WTF__URL) bWTF__StringView;
-pub extern fn WTF__URL__fromFileSystemPath(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void;
-pub extern fn WTF__URL__fromString(arg0: bWTF__String, arg1: bWTF__String) bWTF__URL;
-pub extern fn WTF__URL__host(arg0: [*c]WTF__URL) bWTF__StringView;
-pub extern fn WTF__URL__hostAndPort(arg0: [*c]WTF__URL) bWTF__String;
-pub extern fn WTF__URL__isEmpty(arg0: [*c]const WTF__URL) bool;
-pub extern fn WTF__URL__isValid(arg0: [*c]const WTF__URL) bool;
-pub extern fn WTF__URL__lastPathComponent(arg0: [*c]WTF__URL) bWTF__StringView;
-pub extern fn WTF__URL__password(arg0: [*c]WTF__URL) bWTF__String;
-pub extern fn WTF__URL__path(arg0: [*c]WTF__URL) bWTF__StringView;
-pub extern fn WTF__URL__protocol(arg0: [*c]WTF__URL) bWTF__StringView;
-pub extern fn WTF__URL__protocolHostAndPort(arg0: [*c]WTF__URL) bWTF__String;
-pub extern fn WTF__URL__query(arg0: [*c]WTF__URL) bWTF__StringView;
-pub extern fn WTF__URL__queryWithLeadingQuestionMark(arg0: [*c]WTF__URL) bWTF__StringView;
-pub extern fn WTF__URL__setHost(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void;
-pub extern fn WTF__URL__setHostAndPort(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void;
-pub extern fn WTF__URL__setPassword(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void;
-pub extern fn WTF__URL__setPath(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void;
-pub extern fn WTF__URL__setProtocol(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void;
-pub extern fn WTF__URL__setQuery(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void;
-pub extern fn WTF__URL__setUser(arg0: [*c]WTF__URL, arg1: bWTF__StringView) void;
-pub extern fn WTF__URL__stringWithoutFragmentIdentifier(arg0: [*c]WTF__URL) bWTF__String;
-pub extern fn WTF__URL__stringWithoutQueryOrFragmentIdentifier(arg0: [*c]WTF__URL) bWTF__StringView;
-pub extern fn WTF__URL__truncatedForUseAsBase(arg0: [*c]WTF__URL) bWTF__URL;
-pub extern fn WTF__URL__user(arg0: [*c]WTF__URL) bWTF__String;
-pub extern fn WTF__String__characters16(arg0: [*c]WTF__String) [*c]const u16;
-pub extern fn WTF__String__characters8(arg0: [*c]WTF__String) [*c]const u8;
-pub extern fn WTF__String__createFromExternalString(arg0: bWTF__ExternalStringImpl) bWTF__String;
-pub extern fn WTF__String__createWithoutCopyingFromPtr(arg0: [*c]WTF__String, arg1: [*c]const u8, arg2: usize) void;
-pub extern fn WTF__String__eqlSlice(arg0: [*c]WTF__String, arg1: [*c]const u8, arg2: usize) bool;
-pub extern fn WTF__String__eqlString(arg0: [*c]WTF__String, arg1: [*c]const WTF__String) bool;
-pub extern fn WTF__String__impl(arg0: [*c]WTF__String) [*c]const WTF__StringImpl;
-pub extern fn WTF__String__is16Bit(arg0: [*c]WTF__String) bool;
-pub extern fn WTF__String__is8Bit(arg0: [*c]WTF__String) bool;
-pub extern fn WTF__String__isEmpty(arg0: [*c]WTF__String) bool;
-pub extern fn WTF__String__isExternal(arg0: [*c]WTF__String) bool;
-pub extern fn WTF__String__isStatic(arg0: [*c]WTF__String) bool;
-pub extern fn WTF__String__length(arg0: [*c]WTF__String) usize;
-pub extern fn JSC__JSValue___then(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: ?*anyopaque, ArgFn3: ?fn ([*c]JSC__JSGlobalObject, ?*anyopaque, JSC__JSValue, usize) callconv(.C) void, ArgFn4: ?fn ([*c]JSC__JSGlobalObject, ?*anyopaque, JSC__JSValue, usize) callconv(.C) void) void;
-pub extern fn JSC__JSValue__asArrayBuffer_(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]Bun__ArrayBuffer) bool;
-pub extern fn JSC__JSValue__asCell(JSValue0: JSC__JSValue) [*c]JSC__JSCell;
-pub extern fn JSC__JSValue__asInternalPromise(JSValue0: JSC__JSValue) [*c]JSC__JSInternalPromise;
-pub extern fn JSC__JSValue__asNumber(JSValue0: JSC__JSValue) f64;
-pub extern fn JSC__JSValue__asObject(JSValue0: JSC__JSValue) bJSC__JSObject;
-pub extern fn JSC__JSValue__asPromise(JSValue0: JSC__JSValue) [*c]JSC__JSPromise;
-pub extern fn JSC__JSValue__asString(JSValue0: JSC__JSValue) [*c]JSC__JSString;
-pub extern fn JSC__JSValue__createEmptyObject(arg0: [*c]JSC__JSGlobalObject, arg1: usize) JSC__JSValue;
-pub extern fn JSC__JSValue__createInternalPromise(arg0: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__createObject2(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]const ZigString, arg2: [*c]const ZigString, JSValue3: JSC__JSValue, JSValue4: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__JSValue__createRangeError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__createStringArray(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]ZigString, arg2: usize, arg3: bool) JSC__JSValue;
-pub extern fn JSC__JSValue__createTypeError(arg0: [*c]const ZigString, arg1: [*c]const ZigString, arg2: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__eqlCell(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSCell) bool;
-pub extern fn JSC__JSValue__eqlValue(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__forEach(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: ?*anyopaque, ArgFn3: ?fn ([*c]JSC__VM, [*c]JSC__JSGlobalObject, ?*anyopaque, JSC__JSValue) callconv(.C) void) void;
-pub extern fn JSC__JSValue__fromEntries(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]ZigString, arg2: [*c]ZigString, arg3: usize, arg4: bool) JSC__JSValue;
-pub extern fn JSC__JSValue__fromInt64NoTruncate(arg0: [*c]JSC__JSGlobalObject, arg1: i64) JSC__JSValue;
-pub extern fn JSC__JSValue__fromUInt64NoTruncate(arg0: [*c]JSC__JSGlobalObject, arg1: u64) JSC__JSValue;
-pub extern fn JSC__JSValue__getClassName(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]ZigString) void;
-pub extern fn JSC__JSValue__getErrorsProperty(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__getIfPropertyExistsImpl(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]const u8, arg3: u32) JSC__JSValue;
-pub extern fn JSC__JSValue__getLengthOfArray(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) u32;
-pub extern fn JSC__JSValue__getNameProperty(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]ZigString) void;
-pub extern fn JSC__JSValue__getPrototype(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__getReadableStreamState(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM) [*c]Bun__Readable;
-pub extern fn JSC__JSValue__getSymbolDescription(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]ZigString) void;
-pub extern fn JSC__JSValue__getWritableStreamState(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM) [*c]Bun__Writable;
-pub extern fn JSC__JSValue__isAggregateError(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) bool;
-pub extern fn JSC__JSValue__isAnyInt(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isBigInt(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isBigInt32(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isBoolean(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isCallable(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM) bool;
-pub extern fn JSC__JSValue__isCell(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isClass(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) bool;
-pub extern fn JSC__JSValue__isCustomGetterSetter(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isError(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isException(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM) bool;
-pub extern fn JSC__JSValue__isGetterSetter(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isHeapBigInt(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isInt32(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isInt32AsAnyInt(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isIterable(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) bool;
-pub extern fn JSC__JSValue__isNumber(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isObject(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isPrimitive(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isSameValue(JSValue0: JSC__JSValue, JSValue1: JSC__JSValue, arg2: [*c]JSC__JSGlobalObject) bool;
-pub extern fn JSC__JSValue__isString(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isSymbol(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__isTerminationException(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM) bool;
-pub extern fn JSC__JSValue__isUInt32AsAnyInt(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__jsBoolean(arg0: bool) JSC__JSValue;
-pub extern fn JSC__JSValue__jsDoubleNumber(arg0: f64) JSC__JSValue;
-pub extern fn JSC__JSValue__jsNull(...) JSC__JSValue;
-pub extern fn JSC__JSValue__jsNumberFromChar(arg0: u8) JSC__JSValue;
-pub extern fn JSC__JSValue__jsNumberFromDouble(arg0: f64) JSC__JSValue;
-pub extern fn JSC__JSValue__jsNumberFromInt32(arg0: i32) JSC__JSValue;
-pub extern fn JSC__JSValue__jsNumberFromInt64(arg0: i64) JSC__JSValue;
-pub extern fn JSC__JSValue__jsNumberFromU16(arg0: u16) JSC__JSValue;
-pub extern fn JSC__JSValue__jsNumberFromUint64(arg0: u64) JSC__JSValue;
-pub extern fn JSC__JSValue__jsonStringify(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: u32, arg3: [*c]ZigString) void;
-pub extern fn JSC__JSValue__jsTDZValue(...) JSC__JSValue;
-pub extern fn JSC__JSValue__jsType(JSValue0: JSC__JSValue) u8;
-pub extern fn JSC__JSValue__jsUndefined(...) JSC__JSValue;
-pub extern fn JSC__JSValue__makeWithNameAndPrototype(arg0: [*c]JSC__JSGlobalObject, arg1: ?*anyopaque, arg2: ?*anyopaque, arg3: [*c]const ZigString) JSC__JSValue;
-pub extern fn JSC__JSValue__parseJSON(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__put(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]const ZigString, JSValue3: JSC__JSValue) void;
-pub extern fn JSC__JSValue__putRecord(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]ZigString, arg3: [*c]ZigString, arg4: usize) void;
-pub extern fn JSC__JSValue__symbolFor(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]ZigString) JSC__JSValue;
-pub extern fn JSC__JSValue__symbolKeyFor(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]ZigString) bool;
-pub extern fn JSC__JSValue__toBoolean(JSValue0: JSC__JSValue) bool;
-pub extern fn JSC__JSValue__toInt32(JSValue0: JSC__JSValue) i32;
-pub extern fn JSC__JSValue__toInt64(JSValue0: JSC__JSValue) i64;
-pub extern fn JSC__JSValue__toObject(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) [*c]JSC__JSObject;
-pub extern fn JSC__JSValue__toPropertyKey(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) bJSC__Identifier;
-pub extern fn JSC__JSValue__toPropertyKeyValue(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn JSC__JSValue__toString(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) [*c]JSC__JSString;
-pub extern fn JSC__JSValue__toStringOrNull(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) [*c]JSC__JSString;
-pub extern fn JSC__JSValue__toUInt64NoTruncate(JSValue0: JSC__JSValue) u64;
-pub extern fn JSC__JSValue__toWTFString(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) bWTF__String;
-pub extern fn JSC__JSValue__toZigException(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]ZigException) void;
-pub extern fn JSC__JSValue__toZigString(JSValue0: JSC__JSValue, arg1: [*c]ZigString, arg2: [*c]JSC__JSGlobalObject) void;
-pub extern fn JSC__PropertyName__eqlToIdentifier(arg0: [*c]JSC__PropertyName, arg1: [*c]const JSC__Identifier) bool;
-pub extern fn JSC__PropertyName__eqlToPropertyName(arg0: [*c]JSC__PropertyName, arg1: [*c]const JSC__PropertyName) bool;
-pub extern fn JSC__PropertyName__publicName(arg0: [*c]JSC__PropertyName) [*c]const WTF__StringImpl;
-pub extern fn JSC__PropertyName__uid(arg0: [*c]JSC__PropertyName) [*c]const WTF__StringImpl;
-pub extern fn JSC__Exception__create(arg0: [*c]JSC__JSGlobalObject, arg1: [*c]JSC__JSObject, StackCaptureAction2: u8) [*c]JSC__Exception;
-pub extern fn JSC__Exception__getStackTrace(arg0: [*c]JSC__Exception, arg1: [*c]ZigStackTrace) void;
-pub extern fn JSC__Exception__value(arg0: [*c]JSC__Exception) JSC__JSValue;
-pub extern fn JSC__VM__clearExecutionTimeLimit(arg0: [*c]JSC__VM) void;
-pub extern fn JSC__VM__create(HeapType0: u8) [*c]JSC__VM;
-pub extern fn JSC__VM__deferGC(arg0: [*c]JSC__VM, arg1: ?*anyopaque, ArgFn2: ?fn (?*anyopaque) callconv(.C) void) void;
-pub extern fn JSC__VM__deinit(arg0: [*c]JSC__VM, arg1: [*c]JSC__JSGlobalObject) void;
-pub extern fn JSC__VM__deleteAllCode(arg0: [*c]JSC__VM, arg1: [*c]JSC__JSGlobalObject) void;
-pub extern fn JSC__VM__doWork(arg0: [*c]JSC__VM) void;
-pub extern fn JSC__VM__drainMicrotasks(arg0: [*c]JSC__VM) void;
-pub extern fn JSC__VM__executionForbidden(arg0: [*c]JSC__VM) bool;
-pub extern fn JSC__VM__holdAPILock(arg0: [*c]JSC__VM, arg1: ?*anyopaque, ArgFn2: ?fn (?*anyopaque) callconv(.C) void) void;
-pub extern fn JSC__VM__isEntered(arg0: [*c]JSC__VM) bool;
-pub extern fn JSC__VM__isJITEnabled(...) bool;
-pub extern fn JSC__VM__runGC(arg0: [*c]JSC__VM, arg1: bool) JSC__JSValue;
-pub extern fn JSC__VM__setExecutionForbidden(arg0: [*c]JSC__VM, arg1: bool) void;
-pub extern fn JSC__VM__setExecutionTimeLimit(arg0: [*c]JSC__VM, arg1: f64) void;
-pub extern fn JSC__VM__shrinkFootprint(arg0: [*c]JSC__VM) void;
-pub extern fn JSC__VM__throwError(arg0: [*c]JSC__VM, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__ThrowScope, arg3: [*c]const u8, arg4: usize) bool;
-pub extern fn JSC__VM__whenIdle(arg0: [*c]JSC__VM, ArgFn1: ?fn (...) callconv(.C) void) void;
-pub extern fn JSC__ThrowScope__clearException(arg0: [*c]JSC__ThrowScope) void;
-pub extern fn JSC__ThrowScope__declare(arg0: [*c]JSC__VM, arg1: [*c]u8, arg2: [*c]u8, arg3: usize) bJSC__ThrowScope;
-pub extern fn JSC__ThrowScope__exception(arg0: [*c]JSC__ThrowScope) [*c]JSC__Exception;
-pub extern fn JSC__ThrowScope__release(arg0: [*c]JSC__ThrowScope) void;
-pub extern fn JSC__CatchScope__clearException(arg0: [*c]JSC__CatchScope) void;
-pub extern fn JSC__CatchScope__declare(arg0: [*c]JSC__VM, arg1: [*c]u8, arg2: [*c]u8, arg3: usize) bJSC__CatchScope;
-pub extern fn JSC__CatchScope__exception(arg0: [*c]JSC__CatchScope) [*c]JSC__Exception;
-pub extern fn JSC__CallFrame__argument(arg0: [*c]const JSC__CallFrame, arg1: u16) JSC__JSValue;
-pub extern fn JSC__CallFrame__argumentsCount(arg0: [*c]const JSC__CallFrame) usize;
-pub extern fn JSC__CallFrame__jsCallee(arg0: [*c]const JSC__CallFrame) [*c]JSC__JSObject;
-pub extern fn JSC__CallFrame__newTarget(arg0: [*c]const JSC__CallFrame) JSC__JSValue;
-pub extern fn JSC__CallFrame__setNewTarget(arg0: [*c]JSC__CallFrame, JSValue1: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__CallFrame__setThisValue(arg0: [*c]JSC__CallFrame, JSValue1: JSC__JSValue) JSC__JSValue;
-pub extern fn JSC__CallFrame__thisValue(arg0: [*c]const JSC__CallFrame) JSC__JSValue;
-pub extern fn JSC__CallFrame__uncheckedArgument(arg0: [*c]const JSC__CallFrame, arg1: u16) JSC__JSValue;
-pub extern fn JSC__Identifier__deinit(arg0: [*c]const JSC__Identifier) void;
-pub extern fn JSC__Identifier__eqlIdent(arg0: [*c]const JSC__Identifier, arg1: [*c]const JSC__Identifier) bool;
-pub extern fn JSC__Identifier__eqlStringImpl(arg0: [*c]const JSC__Identifier, arg1: [*c]const WTF__StringImpl) bool;
-pub extern fn JSC__Identifier__eqlUTF8(arg0: [*c]const JSC__Identifier, arg1: [*c]const u8, arg2: usize) bool;
-pub extern fn JSC__Identifier__fromSlice(arg0: [*c]JSC__VM, arg1: [*c]const u8, arg2: usize) bJSC__Identifier;
-pub extern fn JSC__Identifier__fromString(arg0: [*c]JSC__VM, arg1: [*c]const WTF__String) bJSC__Identifier;
-pub extern fn JSC__Identifier__isEmpty(arg0: [*c]const JSC__Identifier) bool;
-pub extern fn JSC__Identifier__isNull(arg0: [*c]const JSC__Identifier) bool;
-pub extern fn JSC__Identifier__isPrivateName(arg0: [*c]const JSC__Identifier) bool;
-pub extern fn JSC__Identifier__isSymbol(arg0: [*c]const JSC__Identifier) bool;
-pub extern fn JSC__Identifier__length(arg0: [*c]const JSC__Identifier) usize;
-pub extern fn JSC__Identifier__neqlIdent(arg0: [*c]const JSC__Identifier, arg1: [*c]const JSC__Identifier) bool;
-pub extern fn JSC__Identifier__neqlStringImpl(arg0: [*c]const JSC__Identifier, arg1: [*c]const WTF__StringImpl) bool;
-pub extern fn JSC__Identifier__toString(arg0: [*c]const JSC__Identifier) bWTF__String;
-pub extern fn WTF__StringImpl__characters16(arg0: [*c]const WTF__StringImpl) [*c]const u16;
-pub extern fn WTF__StringImpl__characters8(arg0: [*c]const WTF__StringImpl) [*c]const u8;
-pub extern fn WTF__StringImpl__is16Bit(arg0: [*c]const WTF__StringImpl) bool;
-pub extern fn WTF__StringImpl__is8Bit(arg0: [*c]const WTF__StringImpl) bool;
-pub extern fn WTF__StringImpl__isEmpty(arg0: [*c]const WTF__StringImpl) bool;
-pub extern fn WTF__StringImpl__isExternal(arg0: [*c]const WTF__StringImpl) bool;
-pub extern fn WTF__StringImpl__isStatic(arg0: [*c]const WTF__StringImpl) bool;
-pub extern fn WTF__StringImpl__length(arg0: [*c]const WTF__StringImpl) usize;
-pub extern fn WTF__ExternalStringImpl__characters16(arg0: [*c]const WTF__ExternalStringImpl) [*c]const u16;
-pub extern fn WTF__ExternalStringImpl__characters8(arg0: [*c]const WTF__ExternalStringImpl) [*c]const u8;
-pub extern fn WTF__ExternalStringImpl__create(arg0: [*c]const u8, arg1: usize, ArgFn2: ?fn (?*anyopaque, [*c]u8, usize) callconv(.C) void) bWTF__ExternalStringImpl;
-pub extern fn WTF__ExternalStringImpl__is16Bit(arg0: [*c]const WTF__ExternalStringImpl) bool;
-pub extern fn WTF__ExternalStringImpl__is8Bit(arg0: [*c]const WTF__ExternalStringImpl) bool;
-pub extern fn WTF__ExternalStringImpl__isEmpty(arg0: [*c]const WTF__ExternalStringImpl) bool;
-pub extern fn WTF__ExternalStringImpl__length(arg0: [*c]const WTF__ExternalStringImpl) usize;
-pub extern fn WTF__StringView__characters16(arg0: [*c]const WTF__StringView) [*c]const u16;
-pub extern fn WTF__StringView__characters8(arg0: [*c]const WTF__StringView) [*c]const u8;
-pub extern fn WTF__StringView__from8Bit(arg0: [*c]WTF__StringView, arg1: [*c]const u8, arg2: usize) void;
-pub extern fn WTF__StringView__is16Bit(arg0: [*c]const WTF__StringView) bool;
-pub extern fn WTF__StringView__is8Bit(arg0: [*c]const WTF__StringView) bool;
-pub extern fn WTF__StringView__isEmpty(arg0: [*c]const WTF__StringView) bool;
-pub extern fn WTF__StringView__length(arg0: [*c]const WTF__StringView) usize;
-pub extern fn Zig__GlobalObject__create(arg0: [*c]JSClassRef, arg1: i32, arg2: ?*anyopaque) [*c]JSC__JSGlobalObject;
-pub extern fn Zig__GlobalObject__getModuleRegistryMap(arg0: [*c]JSC__JSGlobalObject) ?*anyopaque;
-pub extern fn Zig__GlobalObject__resetModuleRegistryMap(arg0: [*c]JSC__JSGlobalObject, arg1: ?*anyopaque) bool;
-pub extern fn Bun__Readable__create(arg0: [*c]Bun__Readable, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn Bun__Writable__create(arg0: [*c]Bun__Writable, arg1: [*c]JSC__JSGlobalObject) JSC__JSValue;
-pub extern fn Bun__Path__create(arg0: [*c]JSC__JSGlobalObject, arg1: bool) JSC__JSValue;
-pub extern fn ZigException__fromException(arg0: [*c]JSC__Exception) ZigException;
diff --git a/src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h b/src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h
index c4ab49dd2..c965f6731 100644
--- a/src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h
+++ b/src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h
@@ -24,8 +24,6 @@ public:
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForJSSQLStatementConstructor;
/* --- bun --- */
- std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForGlobalObject;
-
std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDOMException;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDOMFormData;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDOMFormDataIterator;
@@ -217,22 +215,22 @@ public:
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSpeechSynthesisUtterance;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSpeechSynthesisVoice;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForStorageManager;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForByteLengthQueuingStrategy;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCountQueuingStrategy;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableByteStreamController;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStream;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStreamBYOBReader;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStreamBYOBRequest;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStreamDefaultController;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStreamDefaultReader;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStreamSink;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStreamSource;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTransformStream;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTransformStreamDefaultController;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWritableStream;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWritableStreamDefaultController;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWritableStreamDefaultWriter;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWritableStreamSink;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForByteLengthQueuingStrategy;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCountQueuingStrategy;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableByteStreamController;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStream;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStreamBYOBReader;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStreamBYOBRequest;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStreamDefaultController;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStreamDefaultReader;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStreamSink;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForReadableStreamSource;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTransformStream;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTransformStreamDefaultController;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWritableStream;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWritableStreamDefaultController;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWritableStreamDefaultWriter;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWritableStreamSink;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWebLock;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWebLockManager;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForAnalyserNode;
@@ -843,7 +841,7 @@ public:
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWebXRTest;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDedicatedWorkerGlobalScope;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWorker;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWorkerGlobalScope;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWorkerGlobalScope;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForWorkerLocation;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExtendableEvent;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExtendableMessageEvent;
diff --git a/src/javascript/jsc/bindings/webcore/DOMConstructors.h b/src/javascript/jsc/bindings/webcore/DOMConstructors.h
index b6bc299b7..b0219fffc 100644
--- a/src/javascript/jsc/bindings/webcore/DOMConstructors.h
+++ b/src/javascript/jsc/bindings/webcore/DOMConstructors.h
@@ -287,6 +287,7 @@ enum class DOMConstructorID : uint16_t {
CryptoKey,
SubtleCrypto,
CSSConditionRule,
+ CSSContainerRule,
CSSCounterStyleRule,
CSSFontFaceRule,
CSSFontPaletteValuesRule,
@@ -333,6 +334,15 @@ enum class DOMConstructorID : uint16_t {
CSSUnparsedValue,
StylePropertyMap,
StylePropertyMapReadOnly,
+ CSSColor,
+ CSSColorValue,
+ CSSHSL,
+ CSSHWB,
+ CSSLCH,
+ CSSLab,
+ CSSOKLCH,
+ CSSOKLab,
+ CSSRGB,
CSSMathInvert,
CSSMathMax,
CSSMathMin,
@@ -844,13 +854,15 @@ enum class DOMConstructorID : uint16_t {
XPathResult,
XSLTProcessor,
- // Bun extras
- Buffer
+ // --bun--
+ Buffer,
};
+static constexpr unsigned numberOfDOMConstructorsBase = 846;
+
static constexpr unsigned bunExtraConstructors = 1;
-static constexpr unsigned numberOfDOMConstructors = 836 + bunExtraConstructors;
+static constexpr unsigned numberOfDOMConstructors = numberOfDOMConstructorsBase + bunExtraConstructors;
class DOMConstructors {
WTF_MAKE_NONCOPYABLE(DOMConstructors);
diff --git a/src/javascript/jsc/bindings/webcore/DOMIsoSubspaces.h b/src/javascript/jsc/bindings/webcore/DOMIsoSubspaces.h
index f950020f7..7d0c1cb3f 100644
--- a/src/javascript/jsc/bindings/webcore/DOMIsoSubspaces.h
+++ b/src/javascript/jsc/bindings/webcore/DOMIsoSubspaces.h
@@ -98,8 +98,7 @@ public:
// std::unique_ptr<IsoSubspace> m_subspaceForFileSystemDirectoryReader;
// std::unique_ptr<IsoSubspace> m_subspaceForFileSystemEntry;
// std::unique_ptr<IsoSubspace> m_subspaceForFileSystemFileEntry;
- std::unique_ptr<IsoSubspace>
- m_subspaceForFetchHeaders;
+ std::unique_ptr<IsoSubspace> m_subspaceForFetchHeaders;
std::unique_ptr<IsoSubspace> m_subspaceForFetchHeadersIterator;
// std::unique_ptr<IsoSubspace> m_subspaceForFetchRequest;
// std::unique_ptr<IsoSubspace> m_subspaceForFetchResponse;
@@ -206,22 +205,22 @@ public:
// std::unique_ptr<IsoSubspace> m_subspaceForSpeechSynthesisUtterance;
// std::unique_ptr<IsoSubspace> m_subspaceForSpeechSynthesisVoice;
// std::unique_ptr<IsoSubspace> m_subspaceForStorageManager;
- // std::unique_ptr<IsoSubspace> m_subspaceForByteLengthQueuingStrategy;
- // std::unique_ptr<IsoSubspace> m_subspaceForCountQueuingStrategy;
- // std::unique_ptr<IsoSubspace> m_subspaceForReadableByteStreamController;
- // std::unique_ptr<IsoSubspace> m_subspaceForReadableStream;
- // std::unique_ptr<IsoSubspace> m_subspaceForReadableStreamBYOBReader;
- // std::unique_ptr<IsoSubspace> m_subspaceForReadableStreamBYOBRequest;
- // std::unique_ptr<IsoSubspace> m_subspaceForReadableStreamDefaultController;
- // std::unique_ptr<IsoSubspace> m_subspaceForReadableStreamDefaultReader;
- // std::unique_ptr<IsoSubspace> m_subspaceForReadableStreamSink;
- // std::unique_ptr<IsoSubspace> m_subspaceForReadableStreamSource;
- // std::unique_ptr<IsoSubspace> m_subspaceForTransformStream;
- // std::unique_ptr<IsoSubspace> m_subspaceForTransformStreamDefaultController;
- // std::unique_ptr<IsoSubspace> m_subspaceForWritableStream;
- // std::unique_ptr<IsoSubspace> m_subspaceForWritableStreamDefaultController;
- // std::unique_ptr<IsoSubspace> m_subspaceForWritableStreamDefaultWriter;
- // std::unique_ptr<IsoSubspace> m_subspaceForWritableStreamSink;
+ std::unique_ptr<IsoSubspace> m_subspaceForByteLengthQueuingStrategy;
+ std::unique_ptr<IsoSubspace> m_subspaceForCountQueuingStrategy;
+ std::unique_ptr<IsoSubspace> m_subspaceForReadableByteStreamController;
+ std::unique_ptr<IsoSubspace> m_subspaceForReadableStream;
+ std::unique_ptr<IsoSubspace> m_subspaceForReadableStreamBYOBReader;
+ std::unique_ptr<IsoSubspace> m_subspaceForReadableStreamBYOBRequest;
+ std::unique_ptr<IsoSubspace> m_subspaceForReadableStreamDefaultController;
+ std::unique_ptr<IsoSubspace> m_subspaceForReadableStreamDefaultReader;
+ std::unique_ptr<IsoSubspace> m_subspaceForReadableStreamSink;
+ std::unique_ptr<IsoSubspace> m_subspaceForReadableStreamSource;
+ std::unique_ptr<IsoSubspace> m_subspaceForTransformStream;
+ std::unique_ptr<IsoSubspace> m_subspaceForTransformStreamDefaultController;
+ std::unique_ptr<IsoSubspace> m_subspaceForWritableStream;
+ std::unique_ptr<IsoSubspace> m_subspaceForWritableStreamDefaultController;
+ std::unique_ptr<IsoSubspace> m_subspaceForWritableStreamDefaultWriter;
+ std::unique_ptr<IsoSubspace> m_subspaceForWritableStreamSink;
// std::unique_ptr<IsoSubspace> m_subspaceForWebLock;
// std::unique_ptr<IsoSubspace> m_subspaceForWebLockManager;
// std::unique_ptr<IsoSubspace> m_subspaceForAnalyserNode;
@@ -872,7 +871,7 @@ public:
std::unique_ptr<IsoSubspace> m_subspaceForEventListener;
std::unique_ptr<IsoSubspace> m_subspaceForEventTarget;
- std::unique_ptr<IsoSubspace> m_subspaceForGlobalObject;
+ std::unique_ptr<IsoSubspace> m_subspaceForZigGlobalObject;
std::unique_ptr<IsoSubspace> m_subspaceForExposedToWorkerAndWindow;
std::unique_ptr<IsoSubspace> m_subspaceForURLSearchParams;
diff --git a/src/javascript/jsc/bindings/webcore/DOMPromiseProxy.h b/src/javascript/jsc/bindings/webcore/DOMPromiseProxy.h
new file mode 100644
index 000000000..2b8706e76
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/DOMPromiseProxy.h
@@ -0,0 +1,350 @@
+/*
+ * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "ExceptionOr.h"
+#include "JSDOMGlobalObject.h"
+#include "JSDOMPromiseDeferred.h"
+#include <wtf/Function.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+template<typename IDLType>
+class DOMPromiseProxy {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ using Value = typename IDLType::StorageType;
+
+ DOMPromiseProxy() = default;
+ ~DOMPromiseProxy() = default;
+
+ JSC::JSValue promise(JSC::JSGlobalObject&, JSDOMGlobalObject&);
+
+ void clear();
+
+ bool isFulfilled() const;
+
+ void resolve(typename IDLType::StorageType);
+ void resolveWithNewlyCreated(typename IDLType::StorageType);
+ void reject(Exception, RejectAsHandled = RejectAsHandled::No);
+
+private:
+ JSC::JSValue resolvePromise(JSC::JSGlobalObject&, JSDOMGlobalObject&, const Function<void(DeferredPromise&)>&);
+
+ std::optional<ExceptionOr<Value>> m_valueOrException;
+ Vector<Ref<DeferredPromise>, 1> m_deferredPromises;
+};
+
+template<>
+class DOMPromiseProxy<IDLUndefined> {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ DOMPromiseProxy() = default;
+ ~DOMPromiseProxy() = default;
+
+ JSC::JSValue promise(JSC::JSGlobalObject&, JSDOMGlobalObject&);
+
+ void clear();
+
+ bool isFulfilled() const;
+
+ void resolve();
+ void reject(Exception, RejectAsHandled = RejectAsHandled::No);
+
+private:
+ std::optional<ExceptionOr<void>> m_valueOrException;
+ Vector<Ref<DeferredPromise>, 1> m_deferredPromises;
+};
+
+// Instead of storing the value of the resolution directly, DOMPromiseProxyWithResolveCallback
+// allows the owner to specify callback to be called when the resolved value is needed. This is
+// needed to avoid reference cycles when the resolved value is the owner, such as is the case with
+// FontFace and FontFaceSet.
+template<typename IDLType>
+class DOMPromiseProxyWithResolveCallback {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ using ResolveCallback = Function<typename IDLType::ParameterType()>;
+
+ template <typename Class, typename BaseClass>
+ DOMPromiseProxyWithResolveCallback(Class&, typename IDLType::ParameterType (BaseClass::*)());
+ DOMPromiseProxyWithResolveCallback(ResolveCallback&&);
+ ~DOMPromiseProxyWithResolveCallback() = default;
+
+ JSC::JSValue promise(JSC::JSGlobalObject&, JSDOMGlobalObject&);
+
+ void clear();
+
+ bool isFulfilled() const;
+
+ void resolve(typename IDLType::ParameterType);
+ void resolveWithNewlyCreated(typename IDLType::ParameterType);
+ void reject(Exception, RejectAsHandled = RejectAsHandled::No);
+
+private:
+ ResolveCallback m_resolveCallback;
+ std::optional<ExceptionOr<void>> m_valueOrException;
+ Vector<Ref<DeferredPromise>, 1> m_deferredPromises;
+};
+
+// MARK: - DOMPromiseProxy<IDLType> generic implementation
+
+template<typename IDLType>
+inline JSC::JSValue DOMPromiseProxy<IDLType>::resolvePromise(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject, const Function<void(DeferredPromise&)>& resolvePromiseCallback)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ for (auto& deferredPromise : m_deferredPromises) {
+ if (deferredPromise->globalObject() == &globalObject)
+ return deferredPromise->promise();
+ }
+
+ // DeferredPromise can fail construction during worker abrupt termination.
+ auto deferredPromise = DeferredPromise::create(globalObject, DeferredPromise::Mode::RetainPromiseOnResolve);
+ if (!deferredPromise)
+ return JSC::jsUndefined();
+
+ if (m_valueOrException) {
+ if (m_valueOrException->hasException())
+ deferredPromise->reject(m_valueOrException->exception());
+ else
+ resolvePromiseCallback(*deferredPromise);
+ }
+
+ auto result = deferredPromise->promise();
+ m_deferredPromises.append(deferredPromise.releaseNonNull());
+ return result;
+}
+
+template<typename IDLType>
+inline JSC::JSValue DOMPromiseProxy<IDLType>::promise(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject)
+{
+ return resolvePromise(lexicalGlobalObject, globalObject, [this](auto& deferredPromise) {
+ deferredPromise.template resolve<IDLType>(m_valueOrException->returnValue());
+ });
+}
+
+template<>
+inline JSC::JSValue DOMPromiseProxy<IDLAny>::promise(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject)
+{
+ return resolvePromise(lexicalGlobalObject, globalObject, [this](auto& deferredPromise) {
+ deferredPromise.resolveWithJSValue(m_valueOrException->returnValue().get());
+ });
+}
+
+template<typename IDLType>
+inline void DOMPromiseProxy<IDLType>::clear()
+{
+ m_valueOrException = std::nullopt;
+ m_deferredPromises.clear();
+}
+
+template<typename IDLType>
+inline bool DOMPromiseProxy<IDLType>::isFulfilled() const
+{
+ return m_valueOrException.has_value();
+}
+
+template<typename IDLType>
+inline void DOMPromiseProxy<IDLType>::resolve(typename IDLType::StorageType value)
+{
+ ASSERT(!m_valueOrException);
+
+ m_valueOrException = ExceptionOr<Value> { std::forward<typename IDLType::StorageType>(value) };
+ for (auto& deferredPromise : m_deferredPromises)
+ deferredPromise->template resolve<IDLType>(m_valueOrException->returnValue());
+}
+
+template<>
+inline void DOMPromiseProxy<IDLAny>::resolve(typename IDLAny::StorageType value)
+{
+ ASSERT(!m_valueOrException);
+
+ m_valueOrException = ExceptionOr<Value> { std::forward<typename IDLAny::StorageType>(value) };
+ for (auto& deferredPromise : m_deferredPromises)
+ deferredPromise->resolveWithJSValue(m_valueOrException->returnValue().get());
+}
+
+template<typename IDLType>
+inline void DOMPromiseProxy<IDLType>::resolveWithNewlyCreated(typename IDLType::StorageType value)
+{
+ ASSERT(!m_valueOrException);
+
+ m_valueOrException = ExceptionOr<Value> { std::forward<typename IDLType::StorageType>(value) };
+ for (auto& deferredPromise : m_deferredPromises)
+ deferredPromise->template resolveWithNewlyCreated<IDLType>(m_valueOrException->returnValue());
+}
+
+template<typename IDLType>
+inline void DOMPromiseProxy<IDLType>::reject(Exception exception, RejectAsHandled rejectAsHandled)
+{
+ ASSERT(!m_valueOrException);
+
+ m_valueOrException = ExceptionOr<Value> { WTFMove(exception) };
+ for (auto& deferredPromise : m_deferredPromises)
+ deferredPromise->reject(m_valueOrException->exception(), rejectAsHandled);
+}
+
+
+// MARK: - DOMPromiseProxy<IDLUndefined> specialization
+
+inline JSC::JSValue DOMPromiseProxy<IDLUndefined>::promise(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ for (auto& deferredPromise : m_deferredPromises) {
+ if (deferredPromise->globalObject() == &globalObject)
+ return deferredPromise->promise();
+ }
+
+ // DeferredPromise can fail construction during worker abrupt termination.
+ auto deferredPromise = DeferredPromise::create(globalObject, DeferredPromise::Mode::RetainPromiseOnResolve);
+ if (!deferredPromise)
+ return JSC::jsUndefined();
+
+ if (m_valueOrException) {
+ if (m_valueOrException->hasException())
+ deferredPromise->reject(m_valueOrException->exception());
+ else
+ deferredPromise->resolve();
+ }
+
+ auto result = deferredPromise->promise();
+ m_deferredPromises.append(deferredPromise.releaseNonNull());
+ return result;
+}
+
+inline void DOMPromiseProxy<IDLUndefined>::clear()
+{
+ m_valueOrException = std::nullopt;
+ m_deferredPromises.clear();
+}
+
+inline bool DOMPromiseProxy<IDLUndefined>::isFulfilled() const
+{
+ return m_valueOrException.has_value();
+}
+
+inline void DOMPromiseProxy<IDLUndefined>::resolve()
+{
+ ASSERT(!m_valueOrException);
+ m_valueOrException = ExceptionOr<void> { };
+ for (auto& deferredPromise : m_deferredPromises)
+ deferredPromise->resolve();
+}
+
+inline void DOMPromiseProxy<IDLUndefined>::reject(Exception exception, RejectAsHandled rejectAsHandled)
+{
+ ASSERT(!m_valueOrException);
+ m_valueOrException = ExceptionOr<void> { WTFMove(exception) };
+ for (auto& deferredPromise : m_deferredPromises)
+ deferredPromise->reject(m_valueOrException->exception(), rejectAsHandled);
+}
+
+// MARK: - DOMPromiseProxyWithResolveCallback<IDLType> implementation
+
+template<typename IDLType>
+template <typename Class, typename BaseClass>
+inline DOMPromiseProxyWithResolveCallback<IDLType>::DOMPromiseProxyWithResolveCallback(Class& object, typename IDLType::ParameterType (BaseClass::*function)())
+ : m_resolveCallback(std::bind(function, &object))
+{
+}
+
+template<typename IDLType>
+inline DOMPromiseProxyWithResolveCallback<IDLType>::DOMPromiseProxyWithResolveCallback(ResolveCallback&& function)
+ : m_resolveCallback(WTFMove(function))
+{
+}
+
+template<typename IDLType>
+inline JSC::JSValue DOMPromiseProxyWithResolveCallback<IDLType>::promise(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ for (auto& deferredPromise : m_deferredPromises) {
+ if (deferredPromise->globalObject() == &globalObject)
+ return deferredPromise->promise();
+ }
+
+ // DeferredPromise can fail construction during worker abrupt termination.
+ auto deferredPromise = DeferredPromise::create(globalObject, DeferredPromise::Mode::RetainPromiseOnResolve);
+ if (!deferredPromise)
+ return JSC::jsUndefined();
+
+ if (m_valueOrException) {
+ if (m_valueOrException->hasException())
+ deferredPromise->reject(m_valueOrException->exception());
+ else
+ deferredPromise->template resolve<IDLType>(m_resolveCallback());
+ }
+
+ auto result = deferredPromise->promise();
+ m_deferredPromises.append(deferredPromise.releaseNonNull());
+ return result;
+}
+
+template<typename IDLType>
+inline void DOMPromiseProxyWithResolveCallback<IDLType>::clear()
+{
+ m_valueOrException = std::nullopt;
+ m_deferredPromises.clear();
+}
+
+template<typename IDLType>
+inline bool DOMPromiseProxyWithResolveCallback<IDLType>::isFulfilled() const
+{
+ return m_valueOrException.has_value();
+}
+
+template<typename IDLType>
+inline void DOMPromiseProxyWithResolveCallback<IDLType>::resolve(typename IDLType::ParameterType value)
+{
+ ASSERT(!m_valueOrException);
+
+ m_valueOrException = ExceptionOr<void> { };
+ for (auto& deferredPromise : m_deferredPromises)
+ deferredPromise->template resolve<IDLType>(value);
+}
+
+template<typename IDLType>
+inline void DOMPromiseProxyWithResolveCallback<IDLType>::resolveWithNewlyCreated(typename IDLType::ParameterType value)
+{
+ ASSERT(!m_valueOrException);
+
+ m_valueOrException = ExceptionOr<void> { };
+ for (auto& deferredPromise : m_deferredPromises)
+ deferredPromise->template resolveWithNewlyCreated<IDLType>(value);
+}
+
+template<typename IDLType>
+inline void DOMPromiseProxyWithResolveCallback<IDLType>::reject(Exception exception, RejectAsHandled rejectAsHandled)
+{
+ ASSERT(!m_valueOrException);
+
+ m_valueOrException = ExceptionOr<void> { WTFMove(exception) };
+ for (auto& deferredPromise : m_deferredPromises)
+ deferredPromise->reject(m_valueOrException->exception(), rejectAsHandled);
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/InternalWritableStream.cpp b/src/javascript/jsc/bindings/webcore/InternalWritableStream.cpp
new file mode 100644
index 000000000..d3988c908
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/InternalWritableStream.cpp
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. ``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 CANON INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "InternalWritableStream.h"
+
+#include "Exception.h"
+#include "WebCoreJSClientData.h"
+
+namespace WebCore {
+
+static ExceptionOr<JSC::JSValue> invokeWritableStreamFunction(JSC::JSGlobalObject& globalObject, const JSC::Identifier& identifier, const JSC::MarkedArgumentBuffer& arguments)
+{
+ JSC::VM& vm = globalObject.vm();
+ JSC::JSLockHolder lock(vm);
+
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+
+ auto function = globalObject.get(&globalObject, identifier);
+ ASSERT(function.isCallable());
+ scope.assertNoExceptionExceptTermination();
+
+ auto callData = JSC::getCallData(function);
+
+ auto result = call(&globalObject, function, callData, JSC::jsUndefined(), arguments);
+ RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
+
+ return result;
+}
+
+ExceptionOr<Ref<InternalWritableStream>> InternalWritableStream::createFromUnderlyingSink(JSDOMGlobalObject& globalObject, JSC::JSValue underlyingSink, JSC::JSValue strategy)
+{
+ auto* clientData = static_cast<JSVMClientData*>(globalObject.vm().clientData);
+ auto& privateName = clientData->builtinFunctions().writableStreamInternalsBuiltins().createInternalWritableStreamFromUnderlyingSinkPrivateName();
+
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(underlyingSink);
+ arguments.append(strategy);
+ ASSERT(!arguments.hasOverflowed());
+
+ auto result = invokeWritableStreamFunction(globalObject, privateName, arguments);
+ if (UNLIKELY(result.hasException()))
+ return result.releaseException();
+
+ ASSERT(result.returnValue().isObject());
+ return adoptRef(*new InternalWritableStream(globalObject, *result.returnValue().toObject(&globalObject)));
+}
+
+Ref<InternalWritableStream> InternalWritableStream::fromObject(JSDOMGlobalObject& globalObject, JSC::JSObject& object)
+{
+ return adoptRef(*new InternalWritableStream(globalObject, object));
+}
+
+bool InternalWritableStream::locked() const
+{
+ auto* globalObject = this->globalObject();
+ if (!globalObject)
+ return false;
+
+ auto scope = DECLARE_CATCH_SCOPE(globalObject->vm());
+
+ auto* clientData = static_cast<JSVMClientData*>(globalObject->vm().clientData);
+ auto& privateName = clientData->builtinFunctions().writableStreamInternalsBuiltins().isWritableStreamLockedPrivateName();
+
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(guardedObject());
+ ASSERT(!arguments.hasOverflowed());
+
+ auto result = invokeWritableStreamFunction(*globalObject, privateName, arguments);
+ if (scope.exception())
+ scope.clearException();
+
+ return result.hasException() ? false : result.returnValue().isTrue();
+}
+
+void InternalWritableStream::lock()
+{
+ auto* globalObject = this->globalObject();
+ if (!globalObject)
+ return;
+
+ auto scope = DECLARE_CATCH_SCOPE(globalObject->vm());
+
+ auto* clientData = static_cast<JSVMClientData*>(globalObject->vm().clientData);
+ auto& privateName = clientData->builtinFunctions().writableStreamInternalsBuiltins().acquireWritableStreamDefaultWriterPrivateName();
+
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(guardedObject());
+ ASSERT(!arguments.hasOverflowed());
+
+ invokeWritableStreamFunction(*globalObject, privateName, arguments);
+ if (UNLIKELY(scope.exception()))
+ scope.clearException();
+}
+
+JSC::JSValue InternalWritableStream::abort(JSC::JSGlobalObject& globalObject, JSC::JSValue reason)
+{
+ auto* clientData = static_cast<JSVMClientData*>(globalObject.vm().clientData);
+ auto& privateName = clientData->builtinFunctions().writableStreamInternalsBuiltins().writableStreamAbortForBindingsPrivateName();
+
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(guardedObject());
+ arguments.append(reason);
+ ASSERT(!arguments.hasOverflowed());
+
+ auto result = invokeWritableStreamFunction(globalObject, privateName, arguments);
+ if (result.hasException())
+ return { };
+
+ return result.returnValue();
+}
+
+JSC::JSValue InternalWritableStream::close(JSC::JSGlobalObject& globalObject)
+{
+ auto* clientData = static_cast<JSVMClientData*>(globalObject.vm().clientData);
+ auto& privateName = clientData->builtinFunctions().writableStreamInternalsBuiltins().writableStreamCloseForBindingsPrivateName();
+
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(guardedObject());
+ ASSERT(!arguments.hasOverflowed());
+
+ auto result = invokeWritableStreamFunction(globalObject, privateName, arguments);
+ if (result.hasException())
+ return { };
+
+ return result.returnValue();
+}
+
+JSC::JSValue InternalWritableStream::getWriter(JSC::JSGlobalObject& globalObject)
+{
+ auto* clientData = static_cast<JSVMClientData*>(globalObject.vm().clientData);
+ auto& privateName = clientData->builtinFunctions().writableStreamInternalsBuiltins().acquireWritableStreamDefaultWriterPrivateName();
+
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(guardedObject());
+ ASSERT(!arguments.hasOverflowed());
+
+ auto result = invokeWritableStreamFunction(globalObject, privateName, arguments);
+ if (result.hasException())
+ return { };
+
+ return result.returnValue();
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/InternalWritableStream.h b/src/javascript/jsc/bindings/webcore/InternalWritableStream.h
new file mode 100644
index 000000000..a768f959d
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/InternalWritableStream.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2020-2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. ``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 CANON INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "ExceptionOr.h"
+#include "JSDOMGuardedObject.h"
+#include <JavaScriptCore/JSObject.h>
+
+namespace WebCore {
+class InternalWritableStream final : public DOMGuarded<JSC::JSObject> {
+public:
+ static ExceptionOr<Ref<InternalWritableStream>> createFromUnderlyingSink(JSDOMGlobalObject&, JSC::JSValue underlyingSink, JSC::JSValue strategy);
+ static Ref<InternalWritableStream> fromObject(JSDOMGlobalObject&, JSC::JSObject&);
+
+ operator JSC::JSValue() const { return guarded(); }
+
+ bool locked() const;
+ void lock();
+ JSC::JSValue abort(JSC::JSGlobalObject&, JSC::JSValue);
+ JSC::JSValue close(JSC::JSGlobalObject&);
+ JSC::JSValue getWriter(JSC::JSGlobalObject&);
+
+private:
+ InternalWritableStream(JSDOMGlobalObject& globalObject, JSC::JSObject& jsObject)
+ : DOMGuarded<JSC::JSObject>(globalObject, jsObject)
+ {
+ }
+};
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSByteLengthQueuingStrategy.cpp b/src/javascript/jsc/bindings/webcore/JSByteLengthQueuingStrategy.cpp
new file mode 100644
index 000000000..d0e02a447
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSByteLengthQueuingStrategy.cpp
@@ -0,0 +1,182 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSByteLengthQueuingStrategy.h"
+
+#include "ByteLengthQueuingStrategyBuiltins.h"
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMBuiltinConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsByteLengthQueuingStrategyConstructor);
+
+class JSByteLengthQueuingStrategyPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSByteLengthQueuingStrategyPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSByteLengthQueuingStrategyPrototype* ptr = new (NotNull, JSC::allocateCell<JSByteLengthQueuingStrategyPrototype>(vm)) JSByteLengthQueuingStrategyPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSByteLengthQueuingStrategyPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSByteLengthQueuingStrategyPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSByteLengthQueuingStrategyPrototype, JSByteLengthQueuingStrategyPrototype::Base);
+
+using JSByteLengthQueuingStrategyDOMConstructor = JSDOMBuiltinConstructor<JSByteLengthQueuingStrategy>;
+
+template<> const ClassInfo JSByteLengthQueuingStrategyDOMConstructor::s_info = { "ByteLengthQueuingStrategy"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSByteLengthQueuingStrategyDOMConstructor) };
+
+template<> JSValue JSByteLengthQueuingStrategyDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSByteLengthQueuingStrategyDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "ByteLengthQueuingStrategy"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSByteLengthQueuingStrategy::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+template<> FunctionExecutable* JSByteLengthQueuingStrategyDOMConstructor::initializeExecutable(VM& vm)
+{
+ return byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeGenerator(vm);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSByteLengthQueuingStrategyPrototypeTableValues[] =
+{
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsByteLengthQueuingStrategyConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "highWaterMark"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(byteLengthQueuingStrategyHighWaterMarkCodeGenerator), (intptr_t) (0) } },
+ { "size"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(byteLengthQueuingStrategySizeCodeGenerator), (intptr_t) (0) } },
+};
+
+const ClassInfo JSByteLengthQueuingStrategyPrototype::s_info = { "ByteLengthQueuingStrategy"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSByteLengthQueuingStrategyPrototype) };
+
+void JSByteLengthQueuingStrategyPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSByteLengthQueuingStrategy::info(), JSByteLengthQueuingStrategyPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSByteLengthQueuingStrategy::s_info = { "ByteLengthQueuingStrategy"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSByteLengthQueuingStrategy) };
+
+JSByteLengthQueuingStrategy::JSByteLengthQueuingStrategy(Structure* structure, JSDOMGlobalObject& globalObject)
+ : JSDOMObject(structure, globalObject) { }
+
+void JSByteLengthQueuingStrategy::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+}
+
+JSObject* JSByteLengthQueuingStrategy::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSByteLengthQueuingStrategyPrototype::create(vm, &globalObject, JSByteLengthQueuingStrategyPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSByteLengthQueuingStrategy::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSByteLengthQueuingStrategy>(vm, globalObject);
+}
+
+JSValue JSByteLengthQueuingStrategy::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSByteLengthQueuingStrategyDOMConstructor, DOMConstructorID::ByteLengthQueuingStrategy>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSByteLengthQueuingStrategy::destroy(JSC::JSCell* cell)
+{
+ JSByteLengthQueuingStrategy* thisObject = static_cast<JSByteLengthQueuingStrategy*>(cell);
+ thisObject->JSByteLengthQueuingStrategy::~JSByteLengthQueuingStrategy();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsByteLengthQueuingStrategyConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSByteLengthQueuingStrategyPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSByteLengthQueuingStrategy::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+JSC::GCClient::IsoSubspace* JSByteLengthQueuingStrategy::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSByteLengthQueuingStrategy, UseCustomHeapCellType::No>(vm,
+ [] (auto& spaces) { return spaces.m_clientSubspaceForByteLengthQueuingStrategy.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForByteLengthQueuingStrategy = WTFMove(space); },
+ [] (auto& spaces) { return spaces.m_subspaceForByteLengthQueuingStrategy.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_subspaceForByteLengthQueuingStrategy = WTFMove(space); }
+ );
+}
+
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSByteLengthQueuingStrategy.dep b/src/javascript/jsc/bindings/webcore/JSByteLengthQueuingStrategy.dep
new file mode 100644
index 000000000..0b697d758
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSByteLengthQueuingStrategy.dep
@@ -0,0 +1 @@
+JSByteLengthQueuingStrategy.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSByteLengthQueuingStrategy.h b/src/javascript/jsc/bindings/webcore/JSByteLengthQueuingStrategy.h
new file mode 100644
index 000000000..75d528814
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSByteLengthQueuingStrategy.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+
+namespace WebCore {
+
+class JSByteLengthQueuingStrategy : public JSDOMObject {
+public:
+ using Base = JSDOMObject;
+ static JSByteLengthQueuingStrategy* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+ {
+ JSByteLengthQueuingStrategy* ptr = new (NotNull, JSC::allocateCell<JSByteLengthQueuingStrategy>(globalObject->vm())) JSByteLengthQueuingStrategy(structure, *globalObject);
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+protected:
+ JSByteLengthQueuingStrategy(JSC::Structure*, JSDOMGlobalObject&);
+
+ void finishCreation(JSC::VM&);
+};
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSCountQueuingStrategy.cpp b/src/javascript/jsc/bindings/webcore/JSCountQueuingStrategy.cpp
new file mode 100644
index 000000000..286897c2d
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSCountQueuingStrategy.cpp
@@ -0,0 +1,182 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSCountQueuingStrategy.h"
+
+#include "CountQueuingStrategyBuiltins.h"
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMBuiltinConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsCountQueuingStrategyConstructor);
+
+class JSCountQueuingStrategyPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSCountQueuingStrategyPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSCountQueuingStrategyPrototype* ptr = new (NotNull, JSC::allocateCell<JSCountQueuingStrategyPrototype>(vm)) JSCountQueuingStrategyPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSCountQueuingStrategyPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSCountQueuingStrategyPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSCountQueuingStrategyPrototype, JSCountQueuingStrategyPrototype::Base);
+
+using JSCountQueuingStrategyDOMConstructor = JSDOMBuiltinConstructor<JSCountQueuingStrategy>;
+
+template<> const ClassInfo JSCountQueuingStrategyDOMConstructor::s_info = { "CountQueuingStrategy"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCountQueuingStrategyDOMConstructor) };
+
+template<> JSValue JSCountQueuingStrategyDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSCountQueuingStrategyDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "CountQueuingStrategy"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSCountQueuingStrategy::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+template<> FunctionExecutable* JSCountQueuingStrategyDOMConstructor::initializeExecutable(VM& vm)
+{
+ return countQueuingStrategyInitializeCountQueuingStrategyCodeGenerator(vm);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSCountQueuingStrategyPrototypeTableValues[] =
+{
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCountQueuingStrategyConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "highWaterMark"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(countQueuingStrategyHighWaterMarkCodeGenerator), (intptr_t) (0) } },
+ { "size"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(countQueuingStrategySizeCodeGenerator), (intptr_t) (0) } },
+};
+
+const ClassInfo JSCountQueuingStrategyPrototype::s_info = { "CountQueuingStrategy"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCountQueuingStrategyPrototype) };
+
+void JSCountQueuingStrategyPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSCountQueuingStrategy::info(), JSCountQueuingStrategyPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSCountQueuingStrategy::s_info = { "CountQueuingStrategy"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCountQueuingStrategy) };
+
+JSCountQueuingStrategy::JSCountQueuingStrategy(Structure* structure, JSDOMGlobalObject& globalObject)
+ : JSDOMObject(structure, globalObject) { }
+
+void JSCountQueuingStrategy::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+}
+
+JSObject* JSCountQueuingStrategy::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSCountQueuingStrategyPrototype::create(vm, &globalObject, JSCountQueuingStrategyPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSCountQueuingStrategy::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSCountQueuingStrategy>(vm, globalObject);
+}
+
+JSValue JSCountQueuingStrategy::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSCountQueuingStrategyDOMConstructor, DOMConstructorID::CountQueuingStrategy>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSCountQueuingStrategy::destroy(JSC::JSCell* cell)
+{
+ JSCountQueuingStrategy* thisObject = static_cast<JSCountQueuingStrategy*>(cell);
+ thisObject->JSCountQueuingStrategy::~JSCountQueuingStrategy();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsCountQueuingStrategyConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSCountQueuingStrategyPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSCountQueuingStrategy::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+JSC::GCClient::IsoSubspace* JSCountQueuingStrategy::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSCountQueuingStrategy, UseCustomHeapCellType::No>(vm,
+ [] (auto& spaces) { return spaces.m_clientSubspaceForCountQueuingStrategy.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForCountQueuingStrategy = WTFMove(space); },
+ [] (auto& spaces) { return spaces.m_subspaceForCountQueuingStrategy.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_subspaceForCountQueuingStrategy = WTFMove(space); }
+ );
+}
+
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSCountQueuingStrategy.dep b/src/javascript/jsc/bindings/webcore/JSCountQueuingStrategy.dep
new file mode 100644
index 000000000..413363a34
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSCountQueuingStrategy.dep
@@ -0,0 +1 @@
+JSCountQueuingStrategy.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSCountQueuingStrategy.h b/src/javascript/jsc/bindings/webcore/JSCountQueuingStrategy.h
new file mode 100644
index 000000000..0cd89d4fc
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSCountQueuingStrategy.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+
+namespace WebCore {
+
+class JSCountQueuingStrategy : public JSDOMObject {
+public:
+ using Base = JSDOMObject;
+ static JSCountQueuingStrategy* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+ {
+ JSCountQueuingStrategy* ptr = new (NotNull, JSC::allocateCell<JSCountQueuingStrategy>(globalObject->vm())) JSCountQueuingStrategy(structure, *globalObject);
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+protected:
+ JSCountQueuingStrategy(JSC::Structure*, JSDOMGlobalObject&);
+
+ void finishCreation(JSC::VM&);
+};
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMBinding.h b/src/javascript/jsc/bindings/webcore/JSDOMBinding.h
new file mode 100644
index 000000000..cb9a3a1c6
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMBinding.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2003-2006, 2008-2009, 2013, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
+ * Copyright (C) 2009 Google, Inc. All rights reserved.
+ * Copyright (C) 2012 Ericsson AB. All rights reserved.
+ * Copyright (C) 2013 Michael Pruett <michael@68k.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+// FIXME: Remove this header.
+
+#include "ExceptionOr.h"
+#include "JSDOMWrapperCache.h"
+#include <JavaScriptCore/AuxiliaryBarrierInlines.h>
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/JSArray.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/JSCellInlines.h>
+#include <JavaScriptCore/JSObjectInlines.h>
+#include <JavaScriptCore/Lookup.h>
+#include <JavaScriptCore/ObjectConstructor.h>
+#include <JavaScriptCore/SlotVisitorInlines.h>
+#include <JavaScriptCore/StructureInlines.h>
+#include <JavaScriptCore/WriteBarrier.h>
+#include <cstddef>
+#include <wtf/Forward.h>
+#include <wtf/GetPtr.h>
+#include <wtf/Vector.h>
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMBuiltinConstructor.h b/src/javascript/jsc/bindings/webcore/JSDOMBuiltinConstructor.h
new file mode 100644
index 000000000..733a880f3
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMBuiltinConstructor.h
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2015, 2016 Canon Inc. All rights reserved.
+ * Copyright (C) 2016-2021 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+#include "JSDOMBuiltinConstructorBase.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMWrapperCache.h"
+
+namespace WebCore {
+
+template<typename JSClass> class JSDOMBuiltinConstructor final : public JSDOMBuiltinConstructorBase {
+public:
+ using Base = JSDOMBuiltinConstructorBase;
+
+ static JSDOMBuiltinConstructor* create(JSC::VM&, JSC::Structure*, JSDOMGlobalObject&);
+ static JSC::Structure* createStructure(JSC::VM&, JSC::JSGlobalObject&, JSC::JSValue prototype);
+
+ DECLARE_INFO;
+
+ // Usually defined for each specialization class.
+ static JSC::JSValue prototypeForStructure(JSC::VM&, const JSDOMGlobalObject&);
+
+ static JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES construct(JSC::JSGlobalObject*, JSC::CallFrame*);
+
+private:
+ JSDOMBuiltinConstructor(JSC::VM& vm, JSC::Structure* structure)
+ : Base(vm, structure, construct)
+ {
+ }
+
+ void finishCreation(JSC::VM&, JSDOMGlobalObject&);
+
+ JSC::Structure* getDOMStructureForJSObject(JSC::JSGlobalObject*, JSC::JSObject* newTarget);
+
+ // Usually defined for each specialization class.
+ void initializeProperties(JSC::VM&, JSDOMGlobalObject&) {}
+ // Must be defined for each specialization class.
+ JSC::FunctionExecutable* initializeExecutable(JSC::VM&);
+};
+
+template<typename JSClass> inline JSDOMBuiltinConstructor<JSClass>* JSDOMBuiltinConstructor<JSClass>::create(JSC::VM& vm, JSC::Structure* structure, JSDOMGlobalObject& globalObject)
+{
+ JSDOMBuiltinConstructor* constructor = new (NotNull, JSC::allocateCell<JSDOMBuiltinConstructor>(vm)) JSDOMBuiltinConstructor(vm, structure);
+ constructor->finishCreation(vm, globalObject);
+ return constructor;
+}
+
+template<typename JSClass> inline JSC::Structure* JSDOMBuiltinConstructor<JSClass>::createStructure(JSC::VM& vm, JSC::JSGlobalObject& globalObject, JSC::JSValue prototype)
+{
+ return JSC::Structure::create(vm, &globalObject, prototype, JSC::TypeInfo(JSC::InternalFunctionType, StructureFlags), info());
+}
+
+template<typename JSClass> inline void JSDOMBuiltinConstructor<JSClass>::finishCreation(JSC::VM& vm, JSDOMGlobalObject& globalObject)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+ setInitializeFunction(vm, *JSC::JSFunction::create(vm, initializeExecutable(vm), &globalObject));
+ initializeProperties(vm, globalObject);
+}
+
+template<typename JSClass> inline JSC::Structure* JSDOMBuiltinConstructor<JSClass>::getDOMStructureForJSObject(JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSObject* newTarget)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+
+ if (LIKELY(newTarget == this))
+ return getDOMStructure<JSClass>(vm, *globalObject());
+
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ auto* newTargetGlobalObject = JSC::getFunctionRealm(lexicalGlobalObject, newTarget);
+ RETURN_IF_EXCEPTION(scope, nullptr);
+ auto* baseStructure = getDOMStructure<JSClass>(vm, *JSC::jsCast<JSDOMGlobalObject*>(newTargetGlobalObject));
+ RELEASE_AND_RETURN(scope, JSC::InternalFunction::createSubclassStructure(lexicalGlobalObject, newTarget, baseStructure));
+}
+
+template<typename JSClass> inline JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSDOMBuiltinConstructor<JSClass>::construct(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
+{
+ ASSERT(callFrame);
+ auto* castedThis = JSC::jsCast<JSDOMBuiltinConstructor*>(callFrame->jsCallee());
+ auto* structure = castedThis->getDOMStructureForJSObject(lexicalGlobalObject, asObject(callFrame->newTarget()));
+ if (UNLIKELY(!structure))
+ return {};
+
+ auto* jsObject = JSClass::create(structure, castedThis->globalObject());
+ JSC::call(lexicalGlobalObject, castedThis->initializeFunction(), jsObject, JSC::ArgList(callFrame), "This error should never occur: initialize function is guaranteed to be callable."_s);
+ return JSC::JSValue::encode(jsObject);
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMBuiltinConstructorBase.cpp b/src/javascript/jsc/bindings/webcore/JSDOMBuiltinConstructorBase.cpp
new file mode 100644
index 000000000..98058f5f4
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMBuiltinConstructorBase.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2004-2022 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
+ * Copyright (C) 2013 Michael Pruett <michael@68k.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "JSDOMBuiltinConstructorBase.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/JSCInlines.h>
+
+namespace WebCore {
+using namespace JSC;
+
+template<typename Visitor>
+void JSDOMBuiltinConstructorBase::visitChildrenImpl(JSC::JSCell* cell, Visitor& visitor)
+{
+ auto* thisObject = jsCast<JSDOMBuiltinConstructorBase*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+ visitor.append(thisObject->m_initializeFunction);
+}
+
+DEFINE_VISIT_CHILDREN(JSDOMBuiltinConstructorBase);
+
+JSC::GCClient::IsoSubspace* JSDOMBuiltinConstructorBase::subspaceForImpl(JSC::VM& vm)
+{
+ return &static_cast<JSVMClientData*>(vm.clientData)->domBuiltinConstructorSpace();
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMBuiltinConstructorBase.h b/src/javascript/jsc/bindings/webcore/JSDOMBuiltinConstructorBase.h
new file mode 100644
index 000000000..9593d99c1
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMBuiltinConstructorBase.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2015, 2016 Canon Inc. All rights reserved.
+ * Copyright (C) 2016-2022 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+#include "JSDOMConstructorBase.h"
+
+namespace WebCore {
+
+class JSDOMBuiltinConstructorBase : public JSDOMConstructorBase {
+public:
+ using Base = JSDOMConstructorBase;
+
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ static_assert(sizeof(CellType) == sizeof(JSDOMBuiltinConstructorBase));
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(CellType, JSDOMBuiltinConstructorBase);
+ static_assert(CellType::destroy == JSC::JSCell::destroy, "JSDOMBuiltinConstructor<JSClass> is not destructible actually");
+ return subspaceForImpl(vm);
+ }
+
+protected:
+ JSDOMBuiltinConstructorBase(JSC::VM& vm, JSC::Structure* structure, JSC::NativeFunction functionForConstruct)
+ : Base(vm, structure, functionForConstruct)
+ {
+ }
+
+ DECLARE_VISIT_CHILDREN;
+
+ JSC::JSFunction* initializeFunction();
+ void setInitializeFunction(JSC::VM&, JSC::JSFunction&);
+
+private:
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM&);
+
+ JSC::WriteBarrier<JSC::JSFunction> m_initializeFunction;
+};
+
+inline JSC::JSFunction* JSDOMBuiltinConstructorBase::initializeFunction()
+{
+ return m_initializeFunction.get();
+}
+
+inline void JSDOMBuiltinConstructorBase::setInitializeFunction(JSC::VM& vm, JSC::JSFunction& function)
+{
+ m_initializeFunction.set(vm, this, &function);
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMConvertPromise.h b/src/javascript/jsc/bindings/webcore/JSDOMConvertPromise.h
index 29324f11b..e01a99884 100644
--- a/src/javascript/jsc/bindings/webcore/JSDOMConvertPromise.h
+++ b/src/javascript/jsc/bindings/webcore/JSDOMConvertPromise.h
@@ -28,7 +28,7 @@
#include "IDLTypes.h"
#include "JSDOMConvertBase.h"
#include "JSDOMPromise.h"
-#include "WorkerGlobalScope.h"
+// #include "WorkerGlobalScope.h"
namespace WebCore {
@@ -50,14 +50,14 @@ template<typename T> struct Converter<IDLPromise<T>> : DefaultConverter<IDLPromi
auto* promise = JSC::JSPromise::resolvedPromise(globalObject, value);
if (scope.exception()) {
auto* scriptExecutionContext = globalObject->scriptExecutionContext();
- if (is<WorkerGlobalScope>(scriptExecutionContext)) {
- auto* scriptController = downcast<WorkerGlobalScope>(*scriptExecutionContext).script();
- bool terminatorCausedException = vm.isTerminationException(scope.exception());
- if (terminatorCausedException || (scriptController && scriptController->isTerminatingExecution())) {
- scriptController->forbidExecution();
- return nullptr;
- }
- }
+ // if (is<WorkerGlobalScope>(scriptExecutionContext)) {
+ // auto* scriptController = downcast<WorkerGlobalScope>(*scriptExecutionContext).script();
+ // bool terminatorCausedException = vm.isTerminationException(scope.exception());
+ // if (terminatorCausedException || (scriptController && scriptController->isTerminatingExecution())) {
+ // scriptController->forbidExecution();
+ // return nullptr;
+ // }
+ // }
exceptionThrower(lexicalGlobalObject, scope);
return nullptr;
}
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMGuardedObject.cpp b/src/javascript/jsc/bindings/webcore/JSDOMGuardedObject.cpp
new file mode 100644
index 000000000..76fc86415
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMGuardedObject.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSDOMGuardedObject.h"
+
+
+namespace WebCore {
+using namespace JSC;
+
+DOMGuardedObject::DOMGuardedObject(JSDOMGlobalObject& globalObject, JSCell& guarded)
+ : ActiveDOMCallback(globalObject.scriptExecutionContext())
+ , m_guarded(&guarded)
+ , m_globalObject(&globalObject)
+{
+ globalObject.vm().writeBarrier(&globalObject, &guarded);
+ if (globalObject.vm().heap.mutatorShouldBeFenced()) {
+ Locker locker { globalObject.gcLock() };
+ globalObject.guardedObjects().add(this);
+ return;
+ }
+ globalObject.guardedObjects(NoLockingNecessary).add(this);
+}
+
+DOMGuardedObject::~DOMGuardedObject()
+{
+ clear();
+}
+
+void DOMGuardedObject::clear()
+{
+ ASSERT(!m_guarded || m_globalObject);
+ removeFromGlobalObject();
+ m_guarded.clear();
+ m_globalObject.clear();
+}
+
+void DOMGuardedObject::removeFromGlobalObject()
+{
+ if (!m_guarded || !m_globalObject)
+ return;
+
+ if (m_globalObject->vm().heap.mutatorShouldBeFenced()) {
+ Locker locker { m_globalObject->gcLock() };
+ m_globalObject->guardedObjects().remove(this);
+ } else
+ m_globalObject->guardedObjects(NoLockingNecessary).remove(this);
+}
+
+void DOMGuardedObject::contextDestroyed()
+{
+ ActiveDOMCallback::contextDestroyed();
+ clear();
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMGuardedObject.h b/src/javascript/jsc/bindings/webcore/JSDOMGuardedObject.h
new file mode 100644
index 000000000..cf0887c32
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMGuardedObject.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "ActiveDOMCallback.h"
+#include "JSDOMGlobalObject.h"
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/JSCell.h>
+#include <JavaScriptCore/SlotVisitorInlines.h>
+#include <JavaScriptCore/StrongInlines.h>
+
+namespace WebCore {
+
+class WEBCORE_EXPORT DOMGuardedObject : public RefCounted<DOMGuardedObject>, public ActiveDOMCallback {
+public:
+ ~DOMGuardedObject();
+
+ bool isSuspended() const { return !m_guarded || !canInvokeCallback(); } // The wrapper world has gone away or active DOM objects have been suspended.
+
+ template<typename Visitor> void visitAggregate(Visitor& visitor) { visitor.append(m_guarded); }
+
+ JSC::JSValue guardedObject() const { return m_guarded.get(); }
+ JSDOMGlobalObject* globalObject() const { return m_globalObject.get(); }
+
+ void clear();
+
+protected:
+ DOMGuardedObject(JSDOMGlobalObject&, JSC::JSCell&);
+
+ void contextDestroyed();
+ bool isEmpty() const { return !m_guarded; }
+
+ JSC::Weak<JSC::JSCell> m_guarded;
+ JSC::Weak<JSDOMGlobalObject> m_globalObject;
+
+private:
+ void removeFromGlobalObject();
+};
+
+template<typename T> class DOMGuarded : public DOMGuardedObject {
+protected:
+ DOMGuarded(JSDOMGlobalObject& globalObject, T& guarded)
+ : DOMGuardedObject(globalObject, guarded)
+ {
+ }
+ T* guarded() const { return JSC::jsDynamicCast<T*>(guardedObject()); }
+};
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMOperationReturningPromise.h b/src/javascript/jsc/bindings/webcore/JSDOMOperationReturningPromise.h
new file mode 100644
index 000000000..c4d1513ad
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMOperationReturningPromise.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
+ * Copyright (C) 2003-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2007 Samuel Weinig <sam@webkit.org>
+ * Copyright (C) 2009 Google, Inc. All rights reserved.
+ * Copyright (C) 2012 Ericsson AB. All rights reserved.
+ * Copyright (C) 2013 Michael Pruett <michael@68k.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+#include "JSDOMOperation.h"
+#include "JSDOMPromiseDeferred.h"
+
+namespace WebCore {
+
+template<typename JSClass>
+class IDLOperationReturningPromise {
+public:
+ using ClassParameter = JSClass*;
+ using Operation = JSC::EncodedJSValue(JSC::JSGlobalObject*, JSC::CallFrame*, ClassParameter, Ref<DeferredPromise>&&);
+ using StaticOperation = JSC::EncodedJSValue(JSC::JSGlobalObject*, JSC::CallFrame*, Ref<DeferredPromise>&&);
+
+ template<Operation operation, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::RejectPromise>
+ static JSC::EncodedJSValue call(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char* operationName)
+ {
+ return JSC::JSValue::encode(callPromiseFunction(lexicalGlobalObject, callFrame, [&operationName] (JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, Ref<DeferredPromise>&& promise) {
+ auto* thisObject = IDLOperation<JSClass>::cast(lexicalGlobalObject, callFrame);
+ if constexpr (shouldThrow != CastedThisErrorBehavior::Assert) {
+ if (UNLIKELY(!thisObject))
+ return rejectPromiseWithThisTypeError(promise.get(), JSClass::info()->className, operationName);
+ } else
+ ASSERT(thisObject);
+
+ ASSERT_GC_OBJECT_INHERITS(thisObject, JSClass::info());
+
+ // FIXME: We should refactor the binding generated code to use references for lexicalGlobalObject and thisObject.
+ return operation(&lexicalGlobalObject, &callFrame, thisObject, WTFMove(promise));
+ }));
+ }
+
+ // This function is a special case for custom operations want to handle the creation of the promise themselves.
+ // It is triggered via the extended attribute [ReturnsOwnPromise].
+ template<typename IDLOperation<JSClass>::Operation operation, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::RejectPromise>
+ static JSC::EncodedJSValue callReturningOwnPromise(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char* operationName)
+ {
+ auto* thisObject = IDLOperation<JSClass>::cast(lexicalGlobalObject, callFrame);
+ if constexpr (shouldThrow != CastedThisErrorBehavior::Assert) {
+ if (UNLIKELY(!thisObject))
+ return rejectPromiseWithThisTypeError(lexicalGlobalObject, JSClass::info()->className, operationName);
+ } else
+ ASSERT(thisObject);
+
+ ASSERT_GC_OBJECT_INHERITS(thisObject, JSClass::info());
+
+ // FIXME: We should refactor the binding generated code to use references for lexicalGlobalObject and thisObject.
+ return operation(&lexicalGlobalObject, &callFrame, thisObject);
+ }
+
+ template<StaticOperation operation, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::RejectPromise>
+ static JSC::EncodedJSValue callStatic(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char*)
+ {
+ return JSC::JSValue::encode(callPromiseFunction(lexicalGlobalObject, callFrame, [] (JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, Ref<DeferredPromise>&& promise) {
+ // FIXME: We should refactor the binding generated code to use references for lexicalGlobalObject.
+ return operation(&lexicalGlobalObject, &callFrame, WTFMove(promise));
+ }));
+ }
+
+ // This function is a special case for custom operations want to handle the creation of the promise themselves.
+ // It is triggered via the extended attribute [ReturnsOwnPromise].
+ template<typename IDLOperation<JSClass>::StaticOperation operation, CastedThisErrorBehavior shouldThrow = CastedThisErrorBehavior::RejectPromise>
+ static JSC::EncodedJSValue callStaticReturningOwnPromise(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, const char*)
+ {
+ // FIXME: We should refactor the binding generated code to use references for lexicalGlobalObject.
+ return operation(&lexicalGlobalObject, &callFrame);
+ }
+};
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMPromise.cpp b/src/javascript/jsc/bindings/webcore/JSDOMPromise.cpp
new file mode 100644
index 000000000..db1597552
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMPromise.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSDOMPromise.h"
+
+// #include "DOMWindow.h"
+// #include "JSDOMWindow.h"
+#include <JavaScriptCore/BuiltinNames.h>
+#include <JavaScriptCore/CatchScope.h>
+#include <JavaScriptCore/Exception.h>
+#include <JavaScriptCore/JSNativeStdFunction.h>
+#include <JavaScriptCore/JSPromiseConstructor.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+auto DOMPromise::whenSettled(std::function<void()>&& callback) -> IsCallbackRegistered
+{
+ return whenPromiseIsSettled(globalObject(), promise(), WTFMove(callback));
+}
+
+auto DOMPromise::whenPromiseIsSettled(JSDOMGlobalObject* globalObject, JSC::JSObject* promise, Function<void()>&& callback) -> IsCallbackRegistered
+{
+ auto& lexicalGlobalObject = *globalObject;
+ auto& vm = lexicalGlobalObject.vm();
+ JSLockHolder lock(vm);
+ auto* handler = JSC::JSNativeStdFunction::create(vm, globalObject, 1, String {}, [callback = WTFMove(callback)](JSGlobalObject*, CallFrame*) mutable {
+ callback();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ });
+
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ const JSC::Identifier& privateName = vm.propertyNames->builtinNames().thenPrivateName();
+ auto thenFunction = promise->get(&lexicalGlobalObject, privateName);
+
+ EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+ if (scope.exception())
+ return IsCallbackRegistered::No;
+
+ ASSERT(thenFunction.isCallable());
+
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(handler);
+ arguments.append(handler);
+
+ auto callData = JSC::getCallData(thenFunction);
+ ASSERT(callData.type != JSC::CallData::Type::None);
+ call(&lexicalGlobalObject, thenFunction, callData, promise, arguments);
+
+ EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+ return scope.exception() ? IsCallbackRegistered::No : IsCallbackRegistered::Yes;
+}
+
+JSC::JSValue DOMPromise::result() const
+{
+ return promise()->result(m_globalObject->vm());
+}
+
+DOMPromise::Status DOMPromise::status() const
+{
+ switch (promise()->status(m_globalObject->vm())) {
+ case JSC::JSPromise::Status::Pending:
+ return Status::Pending;
+ case JSC::JSPromise::Status::Fulfilled:
+ return Status::Fulfilled;
+ case JSC::JSPromise::Status::Rejected:
+ return Status::Rejected;
+ };
+ ASSERT_NOT_REACHED();
+ return Status::Rejected;
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMPromise.h b/src/javascript/jsc/bindings/webcore/JSDOMPromise.h
new file mode 100644
index 000000000..97ebafa74
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMPromise.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017 Yusuke Suzuki <utatane.tea@gmail.com>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "JSDOMGuardedObject.h"
+#include <JavaScriptCore/JSPromise.h>
+
+namespace WebCore {
+
+class DOMPromise : public DOMGuarded<JSC::JSPromise> {
+public:
+ static Ref<DOMPromise> create(JSDOMGlobalObject& globalObject, JSC::JSPromise& promise)
+ {
+ return adoptRef(*new DOMPromise(globalObject, promise));
+ }
+
+ JSC::JSPromise* promise() const
+ {
+ ASSERT(!isSuspended());
+ return guarded();
+ }
+
+ enum class IsCallbackRegistered { No, Yes };
+ IsCallbackRegistered whenSettled(std::function<void()>&&);
+ JSC::JSValue result() const;
+
+ enum class Status { Pending, Fulfilled, Rejected };
+ Status status() const;
+
+ static IsCallbackRegistered whenPromiseIsSettled(JSDOMGlobalObject*, JSC::JSObject* promise, Function<void()>&&);
+
+private:
+ DOMPromise(JSDOMGlobalObject& globalObject, JSC::JSPromise& promise)
+ : DOMGuarded<JSC::JSPromise>(globalObject, promise)
+ {
+ }
+};
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMPromiseDeferred.cpp b/src/javascript/jsc/bindings/webcore/JSDOMPromiseDeferred.cpp
new file mode 100644
index 000000000..da1f9bdd2
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMPromiseDeferred.cpp
@@ -0,0 +1,300 @@
+/*
+ * Copyright (C) 2013-2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSDOMPromiseDeferred.h"
+
+// #include "DOMWindow.h"
+// #include "EventLoop.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMPromise.h"
+// #include "JSDOMWindow.h"
+// #include "ScriptController.h"
+// #include "WorkerGlobalScope.h"
+#include <JavaScriptCore/BuiltinNames.h>
+#include <JavaScriptCore/Exception.h>
+#include <JavaScriptCore/JSONObject.h>
+#include <JavaScriptCore/JSPromiseConstructor.h>
+#include <JavaScriptCore/Strong.h>
+
+namespace WebCore {
+using namespace JSC;
+
+JSC::JSValue DeferredPromise::promise() const
+{
+ if (isEmpty())
+ return jsUndefined();
+
+ ASSERT(deferred());
+ return deferred();
+}
+
+void DeferredPromise::callFunction(JSGlobalObject& lexicalGlobalObject, ResolveMode mode, JSValue resolution)
+{
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ // if (activeDOMObjectsAreSuspended()) {
+ // JSC::Strong<JSC::Unknown, ShouldStrongDestructorGrabLock::Yes> strongResolution(lexicalGlobalObject.vm(), resolution);
+ // ASSERT(scriptExecutionContext()->eventLoop().isSuspended());
+ // scriptExecutionContext()->eventLoop().queueTask(TaskSource::Networking, [this, protectedThis = Ref { *this }, mode, strongResolution = WTFMove(strongResolution)]() mutable {
+ // if (shouldIgnoreRequestToFulfill())
+ // return;
+
+ // JSC::JSGlobalObject* lexicalGlobalObject = globalObject();
+ // JSC::JSLockHolder locker(lexicalGlobalObject);
+ // callFunction(*globalObject(), mode, strongResolution.get());
+ // });
+ // return;
+ // }
+
+ // FIXME: We could have error since any JS call can throw stack-overflow errors.
+ // https://bugs.webkit.org/show_bug.cgi?id=203402
+ switch (mode) {
+ case ResolveMode::Resolve:
+ deferred()->resolve(&lexicalGlobalObject, resolution);
+ break;
+ case ResolveMode::Reject:
+ deferred()->reject(&lexicalGlobalObject, resolution);
+ break;
+ case ResolveMode::RejectAsHandled:
+ deferred()->rejectAsHandled(&lexicalGlobalObject, resolution);
+ break;
+ }
+
+ if (m_mode == Mode::ClearPromiseOnResolve)
+ clear();
+}
+
+void DeferredPromise::whenSettled(Function<void()>&& callback)
+{
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ // if (activeDOMObjectsAreSuspended()) {
+ // scriptExecutionContext()->eventLoop().queueTask(TaskSource::Networking, [this, protectedThis = Ref { *this }, callback = WTFMove(callback)]() mutable {
+ // whenSettled(WTFMove(callback));
+ // });
+ // return;
+ // }
+
+ DOMPromise::whenPromiseIsSettled(globalObject(), deferred(), WTFMove(callback));
+}
+
+void DeferredPromise::reject(RejectAsHandled rejectAsHandled)
+{
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ ASSERT(deferred());
+ ASSERT(m_globalObject);
+ auto& lexicalGlobalObject = *m_globalObject;
+ JSC::JSLockHolder locker(&lexicalGlobalObject);
+ reject(lexicalGlobalObject, JSC::jsUndefined(), rejectAsHandled);
+}
+
+void DeferredPromise::reject(std::nullptr_t, RejectAsHandled rejectAsHandled)
+{
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ ASSERT(deferred());
+ ASSERT(m_globalObject);
+ auto& lexicalGlobalObject = *m_globalObject;
+ JSC::JSLockHolder locker(&lexicalGlobalObject);
+ reject(lexicalGlobalObject, JSC::jsNull(), rejectAsHandled);
+}
+
+void DeferredPromise::reject(Exception exception, RejectAsHandled rejectAsHandled)
+{
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ Ref protectedThis(*this);
+ ASSERT(deferred());
+ ASSERT(m_globalObject);
+ auto& lexicalGlobalObject = *m_globalObject;
+ JSC::VM& vm = lexicalGlobalObject.vm();
+ JSC::JSLockHolder locker(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+
+ if (exception.code() == ExistingExceptionError) {
+ EXCEPTION_ASSERT(scope.exception());
+ auto error = scope.exception()->value();
+ bool isTerminating = handleTerminationExceptionIfNeeded(scope, lexicalGlobalObject);
+ scope.clearException();
+
+ if (!isTerminating)
+ reject<IDLAny>(error, rejectAsHandled);
+ return;
+ }
+
+ auto error = createDOMException(lexicalGlobalObject, WTFMove(exception));
+ if (UNLIKELY(scope.exception())) {
+ handleUncaughtException(scope, lexicalGlobalObject);
+ return;
+ }
+
+ reject(lexicalGlobalObject, error, rejectAsHandled);
+ if (UNLIKELY(scope.exception()))
+ handleUncaughtException(scope, lexicalGlobalObject);
+}
+
+void DeferredPromise::reject(ExceptionCode ec, const String& message, RejectAsHandled rejectAsHandled)
+{
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ Ref protectedThis(*this);
+ ASSERT(deferred());
+ ASSERT(m_globalObject);
+ auto& lexicalGlobalObject = *m_globalObject;
+ JSC::VM& vm = lexicalGlobalObject.vm();
+ JSC::JSLockHolder locker(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+
+ if (ec == ExistingExceptionError) {
+ EXCEPTION_ASSERT(scope.exception());
+ auto error = scope.exception()->value();
+ bool isTerminating = handleTerminationExceptionIfNeeded(scope, lexicalGlobalObject);
+ scope.clearException();
+
+ if (!isTerminating)
+ reject<IDLAny>(error, rejectAsHandled);
+ return;
+ }
+
+ auto error = createDOMException(&lexicalGlobalObject, ec, message);
+ if (UNLIKELY(scope.exception())) {
+ handleUncaughtException(scope, lexicalGlobalObject);
+ return;
+ }
+
+ reject(lexicalGlobalObject, error, rejectAsHandled);
+ if (UNLIKELY(scope.exception()))
+ handleUncaughtException(scope, lexicalGlobalObject);
+}
+
+void DeferredPromise::reject(const JSC::PrivateName& privateName, RejectAsHandled rejectAsHandled)
+{
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ ASSERT(deferred());
+ ASSERT(m_globalObject);
+ JSC::JSGlobalObject* lexicalGlobalObject = m_globalObject.get();
+ JSC::JSLockHolder locker(lexicalGlobalObject);
+ reject(*lexicalGlobalObject, JSC::Symbol::create(lexicalGlobalObject->vm(), privateName.uid()), rejectAsHandled);
+}
+
+void rejectPromiseWithExceptionIfAny(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject, JSPromise& promise, JSC::CatchScope& catchScope)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ if (LIKELY(!catchScope.exception()))
+ return;
+
+ JSValue error = catchScope.exception()->value();
+ catchScope.clearException();
+
+ DeferredPromise::create(globalObject, promise)->reject<IDLAny>(error);
+}
+
+JSC::EncodedJSValue createRejectedPromiseWithTypeError(JSC::JSGlobalObject& lexicalGlobalObject, const String& errorMessage, RejectedPromiseWithTypeErrorCause cause)
+{
+ auto& globalObject = lexicalGlobalObject;
+ auto& vm = lexicalGlobalObject.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto promiseConstructor = globalObject.promiseConstructor();
+ auto rejectFunction = promiseConstructor->get(&lexicalGlobalObject, vm.propertyNames->builtinNames().rejectPrivateName());
+ RETURN_IF_EXCEPTION(scope, {});
+ auto* rejectionValue = static_cast<ErrorInstance*>(createTypeError(&lexicalGlobalObject, errorMessage));
+ if (cause == RejectedPromiseWithTypeErrorCause::NativeGetter)
+ rejectionValue->setNativeGetterTypeError();
+
+ auto callData = JSC::getCallData(rejectFunction);
+ ASSERT(callData.type != CallData::Type::None);
+
+ MarkedArgumentBuffer arguments;
+ arguments.append(rejectionValue);
+ ASSERT(!arguments.hasOverflowed());
+
+ RELEASE_AND_RETURN(scope, JSValue::encode(call(&lexicalGlobalObject, rejectFunction, callData, promiseConstructor, arguments)));
+}
+
+static inline JSC::JSValue parseAsJSON(JSC::JSGlobalObject* lexicalGlobalObject, const String& data)
+{
+ JSC::JSLockHolder lock(lexicalGlobalObject);
+ return JSC::JSONParse(lexicalGlobalObject, data);
+}
+
+void fulfillPromiseWithJSON(Ref<DeferredPromise>&& promise, const String& data)
+{
+ JSC::JSValue value = parseAsJSON(promise->globalObject(), data);
+ if (!value)
+ promise->reject(SyntaxError);
+ else
+ promise->resolve<IDLAny>(value);
+}
+
+void fulfillPromiseWithArrayBuffer(Ref<DeferredPromise>&& promise, ArrayBuffer* arrayBuffer)
+{
+ if (!arrayBuffer) {
+ promise->reject<IDLAny>(createOutOfMemoryError(promise->globalObject()));
+ return;
+ }
+ promise->resolve<IDLInterface<ArrayBuffer>>(*arrayBuffer);
+}
+
+void fulfillPromiseWithArrayBuffer(Ref<DeferredPromise>&& promise, const void* data, size_t length)
+{
+ fulfillPromiseWithArrayBuffer(WTFMove(promise), ArrayBuffer::tryCreate(data, length).get());
+}
+
+bool DeferredPromise::handleTerminationExceptionIfNeeded(CatchScope& scope, JSDOMGlobalObject& lexicalGlobalObject)
+{
+ auto* exception = scope.exception();
+ VM& vm = scope.vm();
+
+ auto& scriptExecutionContext = *lexicalGlobalObject.scriptExecutionContext();
+ // if (is<WorkerGlobalScope>(scriptExecutionContext)) {
+ // auto* scriptController = downcast<WorkerGlobalScope>(scriptExecutionContext).script();
+ // bool terminatorCausedException = vm.isTerminationException(exception);
+ // if (terminatorCausedException || (scriptController && scriptController->isTerminatingExecution())) {
+ // scriptController->forbidExecution();
+ // return true;
+ // }
+ // }
+ return false;
+}
+
+void DeferredPromise::handleUncaughtException(CatchScope& scope, JSDOMGlobalObject& lexicalGlobalObject)
+{
+ auto* exception = scope.exception();
+ handleTerminationExceptionIfNeeded(scope, lexicalGlobalObject);
+ reportException(&lexicalGlobalObject, exception);
+};
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMPromiseDeferred.h b/src/javascript/jsc/bindings/webcore/JSDOMPromiseDeferred.h
new file mode 100644
index 000000000..ba65dfa1c
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMPromiseDeferred.h
@@ -0,0 +1,376 @@
+/*
+ * Copyright (C) 2013-2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "ExceptionOr.h"
+#include "JSDOMConvert.h"
+#include "JSDOMGuardedObject.h"
+#include "ScriptExecutionContext.h"
+#include <JavaScriptCore/CatchScope.h>
+#include <JavaScriptCore/JSPromise.h>
+
+namespace WebCore {
+
+class JSDOMWindow;
+enum class RejectAsHandled : uint8_t { No,
+ Yes };
+
+class DeferredPromise : public DOMGuarded<JSC::JSPromise> {
+public:
+ enum class Mode {
+ ClearPromiseOnResolve,
+ RetainPromiseOnResolve
+ };
+
+ static RefPtr<DeferredPromise> create(JSDOMGlobalObject& globalObject, Mode mode = Mode::ClearPromiseOnResolve)
+ {
+ JSC::VM& vm = JSC::getVM(&globalObject);
+ auto* promise = JSC::JSPromise::create(vm, globalObject.promiseStructure());
+ ASSERT(promise);
+ return adoptRef(new DeferredPromise(globalObject, *promise, mode));
+ }
+
+ static Ref<DeferredPromise> create(JSDOMGlobalObject& globalObject, JSC::JSPromise& deferred, Mode mode = Mode::ClearPromiseOnResolve)
+ {
+ return adoptRef(*new DeferredPromise(globalObject, deferred, mode));
+ }
+
+ template<class IDLType>
+ void resolve(typename IDLType::ParameterType value)
+ {
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ ASSERT(deferred());
+ ASSERT(globalObject());
+ JSC::JSGlobalObject* lexicalGlobalObject = globalObject();
+ JSC::JSLockHolder locker(lexicalGlobalObject);
+ resolve(*lexicalGlobalObject, toJS<IDLType>(*lexicalGlobalObject, *globalObject(), std::forward<typename IDLType::ParameterType>(value)));
+ }
+
+ void resolveWithJSValue(JSC::JSValue resolution)
+ {
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ ASSERT(deferred());
+ ASSERT(globalObject());
+ JSC::JSGlobalObject* lexicalGlobalObject = globalObject();
+ JSC::JSLockHolder locker(lexicalGlobalObject);
+ resolve(*lexicalGlobalObject, resolution);
+ }
+
+ void resolve()
+ {
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ ASSERT(deferred());
+ ASSERT(globalObject());
+ JSC::JSGlobalObject* lexicalGlobalObject = globalObject();
+ JSC::JSLockHolder locker(lexicalGlobalObject);
+ resolve(*lexicalGlobalObject, JSC::jsUndefined());
+ }
+
+ template<class IDLType>
+ void resolveWithNewlyCreated(typename IDLType::ParameterType value)
+ {
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ ASSERT(deferred());
+ ASSERT(globalObject());
+ JSC::JSGlobalObject* lexicalGlobalObject = globalObject();
+ JSC::JSLockHolder locker(lexicalGlobalObject);
+ resolve(*lexicalGlobalObject, toJSNewlyCreated<IDLType>(*lexicalGlobalObject, *globalObject(), std::forward<typename IDLType::ParameterType>(value)));
+ }
+
+ template<class IDLType>
+ void resolveCallbackValueWithNewlyCreated(const Function<typename IDLType::InnerParameterType(ScriptExecutionContext&)>& createValue)
+ {
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ ASSERT(deferred());
+ ASSERT(globalObject());
+ auto* lexicalGlobalObject = globalObject();
+ JSC::JSLockHolder locker(lexicalGlobalObject);
+ resolve(*lexicalGlobalObject, toJSNewlyCreated<IDLType>(*lexicalGlobalObject, *globalObject(), createValue(*globalObject()->scriptExecutionContext())));
+ }
+
+ template<class IDLType>
+ void reject(typename IDLType::ParameterType value, RejectAsHandled rejectAsHandled = RejectAsHandled::No)
+ {
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ ASSERT(deferred());
+ ASSERT(globalObject());
+ JSC::JSGlobalObject* lexicalGlobalObject = globalObject();
+ JSC::JSLockHolder locker(lexicalGlobalObject);
+ reject(*lexicalGlobalObject, toJS<IDLType>(*lexicalGlobalObject, *globalObject(), std::forward<typename IDLType::ParameterType>(value)), rejectAsHandled);
+ }
+
+ void reject(RejectAsHandled = RejectAsHandled::No);
+ void reject(std::nullptr_t, RejectAsHandled = RejectAsHandled::No);
+ WEBCORE_EXPORT void reject(Exception, RejectAsHandled = RejectAsHandled::No);
+ WEBCORE_EXPORT void reject(ExceptionCode, const String& = {}, RejectAsHandled = RejectAsHandled::No);
+ void reject(const JSC::PrivateName&, RejectAsHandled = RejectAsHandled::No);
+
+ template<typename Callback>
+ void resolveWithCallback(Callback callback)
+ {
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ ASSERT(deferred());
+ ASSERT(globalObject());
+ auto* lexicalGlobalObject = globalObject();
+ JSC::VM& vm = lexicalGlobalObject->vm();
+ JSC::JSLockHolder locker(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+ resolve(*lexicalGlobalObject, callback(*globalObject()));
+ if (UNLIKELY(scope.exception()))
+ handleUncaughtException(scope, *lexicalGlobalObject);
+ }
+
+ template<typename Callback>
+ void rejectWithCallback(Callback callback, RejectAsHandled rejectAsHandled = RejectAsHandled::No)
+ {
+ if (shouldIgnoreRequestToFulfill())
+ return;
+
+ ASSERT(deferred());
+ ASSERT(globalObject());
+ auto* lexicalGlobalObject = globalObject();
+ JSC::VM& vm = lexicalGlobalObject->vm();
+ JSC::JSLockHolder locker(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+ reject(*lexicalGlobalObject, callback(*globalObject()), rejectAsHandled);
+ if (UNLIKELY(scope.exception()))
+ handleUncaughtException(scope, *lexicalGlobalObject);
+ }
+
+ JSC::JSValue promise() const;
+
+ void whenSettled(Function<void()>&&);
+
+private:
+ DeferredPromise(JSDOMGlobalObject& globalObject, JSC::JSPromise& deferred, Mode mode)
+ : DOMGuarded<JSC::JSPromise>(globalObject, deferred)
+ , m_mode(mode)
+ {
+ }
+
+ bool shouldIgnoreRequestToFulfill() const { return isEmpty(); }
+
+ JSC::JSPromise* deferred() const { return guarded(); }
+
+ enum class ResolveMode { Resolve,
+ Reject,
+ RejectAsHandled };
+ WEBCORE_EXPORT void callFunction(JSC::JSGlobalObject&, ResolveMode, JSC::JSValue resolution);
+
+ void resolve(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue resolution) { callFunction(lexicalGlobalObject, ResolveMode::Resolve, resolution); }
+ void reject(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue resolution, RejectAsHandled rejectAsHandled)
+ {
+ callFunction(lexicalGlobalObject, rejectAsHandled == RejectAsHandled::Yes ? ResolveMode::RejectAsHandled : ResolveMode::Reject, resolution);
+ }
+
+ bool handleTerminationExceptionIfNeeded(JSC::CatchScope&, JSDOMGlobalObject& lexicalGlobalObject);
+ void handleUncaughtException(JSC::CatchScope&, JSDOMGlobalObject& lexicalGlobalObject);
+
+ Mode m_mode;
+};
+
+class DOMPromiseDeferredBase {
+ WTF_MAKE_FAST_ALLOCATED;
+
+public:
+ DOMPromiseDeferredBase(Ref<DeferredPromise>&& genericPromise)
+ : m_promise(WTFMove(genericPromise))
+ {
+ }
+
+ DOMPromiseDeferredBase(DOMPromiseDeferredBase&& promise)
+ : m_promise(WTFMove(promise.m_promise))
+ {
+ }
+
+ DOMPromiseDeferredBase(const DOMPromiseDeferredBase& other)
+ : m_promise(other.m_promise.copyRef())
+ {
+ }
+
+ DOMPromiseDeferredBase& operator=(const DOMPromiseDeferredBase& other)
+ {
+ m_promise = other.m_promise.copyRef();
+ return *this;
+ }
+
+ DOMPromiseDeferredBase& operator=(DOMPromiseDeferredBase&& other)
+ {
+ m_promise = WTFMove(other.m_promise);
+ return *this;
+ }
+
+ void reject(RejectAsHandled rejectAsHandled = RejectAsHandled::No)
+ {
+ m_promise->reject(rejectAsHandled);
+ }
+
+ template<typename... ErrorType>
+ void reject(ErrorType&&... error)
+ {
+ m_promise->reject(std::forward<ErrorType>(error)...);
+ }
+
+ template<typename IDLType>
+ void rejectType(typename IDLType::ParameterType value, RejectAsHandled rejectAsHandled = RejectAsHandled::No)
+ {
+ m_promise->reject<IDLType>(std::forward<typename IDLType::ParameterType>(value), rejectAsHandled);
+ }
+
+ JSC::JSValue promise() const { return m_promise->promise(); };
+
+ void whenSettled(Function<void()>&& function)
+ {
+ m_promise->whenSettled(WTFMove(function));
+ }
+
+protected:
+ Ref<DeferredPromise> m_promise;
+};
+
+template<typename IDLType>
+class DOMPromiseDeferred : public DOMPromiseDeferredBase {
+public:
+ using DOMPromiseDeferredBase::DOMPromiseDeferredBase;
+ using DOMPromiseDeferredBase::operator=;
+ using DOMPromiseDeferredBase::promise;
+ using DOMPromiseDeferredBase::reject;
+
+ void resolve(typename IDLType::ParameterType value)
+ {
+ m_promise->resolve<IDLType>(std::forward<typename IDLType::ParameterType>(value));
+ }
+
+ template<typename U>
+ void settle(ExceptionOr<U>&& result)
+ {
+ if (result.hasException()) {
+ reject(result.releaseException());
+ return;
+ }
+ resolve(result.releaseReturnValue());
+ }
+};
+
+template<> class DOMPromiseDeferred<void> : public DOMPromiseDeferredBase {
+public:
+ using DOMPromiseDeferredBase::DOMPromiseDeferredBase;
+ using DOMPromiseDeferredBase::operator=;
+ using DOMPromiseDeferredBase::promise;
+ using DOMPromiseDeferredBase::reject;
+
+ void resolve()
+ {
+ m_promise->resolve();
+ }
+
+ void settle(ExceptionOr<void>&& result)
+ {
+ if (result.hasException()) {
+ reject(result.releaseException());
+ return;
+ }
+ resolve();
+ }
+};
+
+void fulfillPromiseWithJSON(Ref<DeferredPromise>&&, const String&);
+void fulfillPromiseWithArrayBuffer(Ref<DeferredPromise>&&, ArrayBuffer*);
+void fulfillPromiseWithArrayBuffer(Ref<DeferredPromise>&&, const void*, size_t);
+WEBCORE_EXPORT void rejectPromiseWithExceptionIfAny(JSC::JSGlobalObject&, JSDOMGlobalObject&, JSC::JSPromise&, JSC::CatchScope&);
+
+enum class RejectedPromiseWithTypeErrorCause { NativeGetter,
+ InvalidThis };
+JSC::EncodedJSValue createRejectedPromiseWithTypeError(JSC::JSGlobalObject&, const String&, RejectedPromiseWithTypeErrorCause);
+
+using PromiseFunction = void(JSC::JSGlobalObject&, JSC::CallFrame&, Ref<DeferredPromise>&&);
+
+template<PromiseFunction promiseFunction>
+inline JSC::JSValue callPromiseFunction(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame)
+{
+ JSC::VM& vm = JSC::getVM(&lexicalGlobalObject);
+ auto catchScope = DECLARE_CATCH_SCOPE(vm);
+
+ auto& globalObject = *JSC::jsSecureCast<JSDOMGlobalObject*>(&lexicalGlobalObject);
+ auto* promise = JSC::JSPromise::create(vm, globalObject.promiseStructure());
+ ASSERT(promise);
+
+ promiseFunction(lexicalGlobalObject, callFrame, DeferredPromise::create(globalObject, *promise));
+
+ rejectPromiseWithExceptionIfAny(lexicalGlobalObject, globalObject, *promise, catchScope);
+ // FIXME: We could have error since any JS call can throw stack-overflow errors.
+ // https://bugs.webkit.org/show_bug.cgi?id=203402
+ RETURN_IF_EXCEPTION(catchScope, JSC::jsUndefined());
+ return promise;
+}
+
+template<typename PromiseFunctor>
+inline JSC::JSValue callPromiseFunction(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, PromiseFunctor functor)
+{
+ JSC::VM& vm = JSC::getVM(&lexicalGlobalObject);
+ auto catchScope = DECLARE_CATCH_SCOPE(vm);
+
+ auto& globalObject = *JSC::jsSecureCast<JSDOMGlobalObject*>(&lexicalGlobalObject);
+ auto* promise = JSC::JSPromise::create(vm, globalObject.promiseStructure());
+ ASSERT(promise);
+
+ functor(lexicalGlobalObject, callFrame, DeferredPromise::create(globalObject, *promise));
+
+ rejectPromiseWithExceptionIfAny(lexicalGlobalObject, globalObject, *promise, catchScope);
+ // FIXME: We could have error since any JS call can throw stack-overflow errors.
+ // https://bugs.webkit.org/show_bug.cgi?id=203402
+ RETURN_IF_EXCEPTION(catchScope, JSC::jsUndefined());
+ return promise;
+}
+
+using BindingPromiseFunction = JSC::EncodedJSValue(JSC::JSGlobalObject*, JSC::CallFrame*, Ref<DeferredPromise>&&);
+template<BindingPromiseFunction bindingFunction>
+inline void bindingPromiseFunctionAdapter(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame, Ref<DeferredPromise>&& promise)
+{
+ bindingFunction(&lexicalGlobalObject, &callFrame, WTFMove(promise));
+}
+
+template<BindingPromiseFunction bindingPromiseFunction>
+inline JSC::JSValue callPromiseFunction(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame& callFrame)
+{
+ return callPromiseFunction<bindingPromiseFunctionAdapter<bindingPromiseFunction>>(lexicalGlobalObject, callFrame);
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSDOMWindow.h b/src/javascript/jsc/bindings/webcore/JSDOMWindow.h
new file mode 100644
index 000000000..472956eba
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMWindow.h
@@ -0,0 +1 @@
+// this is a stub header file \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableByteStreamController.cpp b/src/javascript/jsc/bindings/webcore/JSReadableByteStreamController.cpp
new file mode 100644
index 000000000..7f151188f
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableByteStreamController.cpp
@@ -0,0 +1,185 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSReadableByteStreamController.h"
+
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMBuiltinConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+#include "ReadableByteStreamControllerBuiltins.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsReadableByteStreamControllerConstructor);
+
+class JSReadableByteStreamControllerPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSReadableByteStreamControllerPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSReadableByteStreamControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableByteStreamControllerPrototype>(vm)) JSReadableByteStreamControllerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableByteStreamControllerPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSReadableByteStreamControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableByteStreamControllerPrototype, JSReadableByteStreamControllerPrototype::Base);
+
+using JSReadableByteStreamControllerDOMConstructor = JSDOMBuiltinConstructor<JSReadableByteStreamController>;
+
+template<> const ClassInfo JSReadableByteStreamControllerDOMConstructor::s_info = { "ReadableByteStreamController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableByteStreamControllerDOMConstructor) };
+
+template<> JSValue JSReadableByteStreamControllerDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSReadableByteStreamControllerDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(3), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "ReadableByteStreamController"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSReadableByteStreamController::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+template<> FunctionExecutable* JSReadableByteStreamControllerDOMConstructor::initializeExecutable(VM& vm)
+{
+ return readableByteStreamControllerInitializeReadableByteStreamControllerCodeGenerator(vm);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSReadableByteStreamControllerPrototypeTableValues[] =
+{
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadableByteStreamControllerConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "byobRequest"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableByteStreamControllerByobRequestCodeGenerator), (intptr_t) (0) } },
+ { "desiredSize"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableByteStreamControllerDesiredSizeCodeGenerator), (intptr_t) (0) } },
+ { "enqueue"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableByteStreamControllerEnqueueCodeGenerator), (intptr_t) (0) } },
+ { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableByteStreamControllerCloseCodeGenerator), (intptr_t) (0) } },
+ { "error"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableByteStreamControllerErrorCodeGenerator), (intptr_t) (0) } },
+};
+
+const ClassInfo JSReadableByteStreamControllerPrototype::s_info = { "ReadableByteStreamController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableByteStreamControllerPrototype) };
+
+void JSReadableByteStreamControllerPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSReadableByteStreamController::info(), JSReadableByteStreamControllerPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSReadableByteStreamController::s_info = { "ReadableByteStreamController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableByteStreamController) };
+
+JSReadableByteStreamController::JSReadableByteStreamController(Structure* structure, JSDOMGlobalObject& globalObject)
+ : JSDOMObject(structure, globalObject) { }
+
+void JSReadableByteStreamController::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+}
+
+JSObject* JSReadableByteStreamController::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSReadableByteStreamControllerPrototype::create(vm, &globalObject, JSReadableByteStreamControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSReadableByteStreamController::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSReadableByteStreamController>(vm, globalObject);
+}
+
+JSValue JSReadableByteStreamController::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSReadableByteStreamControllerDOMConstructor, DOMConstructorID::ReadableByteStreamController>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSReadableByteStreamController::destroy(JSC::JSCell* cell)
+{
+ JSReadableByteStreamController* thisObject = static_cast<JSReadableByteStreamController*>(cell);
+ thisObject->JSReadableByteStreamController::~JSReadableByteStreamController();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsReadableByteStreamControllerConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSReadableByteStreamControllerPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSReadableByteStreamController::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+JSC::GCClient::IsoSubspace* JSReadableByteStreamController::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSReadableByteStreamController, UseCustomHeapCellType::No>(vm,
+ [] (auto& spaces) { return spaces.m_clientSubspaceForReadableByteStreamController.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForReadableByteStreamController = WTFMove(space); },
+ [] (auto& spaces) { return spaces.m_subspaceForReadableByteStreamController.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_subspaceForReadableByteStreamController = WTFMove(space); }
+ );
+}
+
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableByteStreamController.dep b/src/javascript/jsc/bindings/webcore/JSReadableByteStreamController.dep
new file mode 100644
index 000000000..605eb3e4a
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableByteStreamController.dep
@@ -0,0 +1 @@
+JSReadableByteStreamController.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableByteStreamController.h b/src/javascript/jsc/bindings/webcore/JSReadableByteStreamController.h
new file mode 100644
index 000000000..6d512aaed
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableByteStreamController.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+
+namespace WebCore {
+
+class JSReadableByteStreamController : public JSDOMObject {
+public:
+ using Base = JSDOMObject;
+ static JSReadableByteStreamController* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+ {
+ JSReadableByteStreamController* ptr = new (NotNull, JSC::allocateCell<JSReadableByteStreamController>(globalObject->vm())) JSReadableByteStreamController(structure, *globalObject);
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+protected:
+ JSReadableByteStreamController(JSC::Structure*, JSDOMGlobalObject&);
+
+ void finishCreation(JSC::VM&);
+};
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStream.cpp b/src/javascript/jsc/bindings/webcore/JSReadableStream.cpp
new file mode 100644
index 000000000..c3f63929d
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStream.cpp
@@ -0,0 +1,186 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSReadableStream.h"
+
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMBuiltinConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+#include "ReadableStreamBuiltins.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsReadableStreamConstructor);
+
+class JSReadableStreamPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSReadableStreamPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSReadableStreamPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamPrototype>(vm)) JSReadableStreamPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSReadableStreamPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamPrototype, JSReadableStreamPrototype::Base);
+
+using JSReadableStreamDOMConstructor = JSDOMBuiltinConstructor<JSReadableStream>;
+
+template<> const ClassInfo JSReadableStreamDOMConstructor::s_info = { "ReadableStream"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDOMConstructor) };
+
+template<> JSValue JSReadableStreamDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSReadableStreamDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "ReadableStream"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSReadableStream::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+template<> FunctionExecutable* JSReadableStreamDOMConstructor::initializeExecutable(VM& vm)
+{
+ return readableStreamInitializeReadableStreamCodeGenerator(vm);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSReadableStreamPrototypeTableValues[] =
+{
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadableStreamConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "locked"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamLockedCodeGenerator), (intptr_t) (0) } },
+ { "cancel"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamCancelCodeGenerator), (intptr_t) (0) } },
+ { "getReader"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamGetReaderCodeGenerator), (intptr_t) (0) } },
+ { "pipeTo"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamPipeToCodeGenerator), (intptr_t) (1) } },
+ { "pipeThrough"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamPipeThroughCodeGenerator), (intptr_t) (2) } },
+ { "tee"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamTeeCodeGenerator), (intptr_t) (0) } },
+};
+
+const ClassInfo JSReadableStreamPrototype::s_info = { "ReadableStream"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamPrototype) };
+
+void JSReadableStreamPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSReadableStream::info(), JSReadableStreamPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSReadableStream::s_info = { "ReadableStream"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStream) };
+
+JSReadableStream::JSReadableStream(Structure* structure, JSDOMGlobalObject& globalObject)
+ : JSDOMObject(structure, globalObject) { }
+
+void JSReadableStream::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+}
+
+JSObject* JSReadableStream::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSReadableStreamPrototype::create(vm, &globalObject, JSReadableStreamPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSReadableStream::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSReadableStream>(vm, globalObject);
+}
+
+JSValue JSReadableStream::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSReadableStreamDOMConstructor, DOMConstructorID::ReadableStream>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSReadableStream::destroy(JSC::JSCell* cell)
+{
+ JSReadableStream* thisObject = static_cast<JSReadableStream*>(cell);
+ thisObject->JSReadableStream::~JSReadableStream();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsReadableStreamConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSReadableStreamPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSReadableStream::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+JSC::GCClient::IsoSubspace* JSReadableStream::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSReadableStream, UseCustomHeapCellType::No>(vm,
+ [] (auto& spaces) { return spaces.m_clientSubspaceForReadableStream.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForReadableStream = WTFMove(space); },
+ [] (auto& spaces) { return spaces.m_subspaceForReadableStream.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_subspaceForReadableStream = WTFMove(space); }
+ );
+}
+
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStream.dep b/src/javascript/jsc/bindings/webcore/JSReadableStream.dep
new file mode 100644
index 000000000..f4ea48d43
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStream.dep
@@ -0,0 +1 @@
+JSReadableStream.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStream.h b/src/javascript/jsc/bindings/webcore/JSReadableStream.h
new file mode 100644
index 000000000..b86f4ac8e
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStream.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+
+namespace WebCore {
+
+class JSReadableStream : public JSDOMObject {
+public:
+ using Base = JSDOMObject;
+ static JSReadableStream* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+ {
+ JSReadableStream* ptr = new (NotNull, JSC::allocateCell<JSReadableStream>(globalObject->vm())) JSReadableStream(structure, *globalObject);
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+protected:
+ JSReadableStream(JSC::Structure*, JSDOMGlobalObject&);
+
+ void finishCreation(JSC::VM&);
+};
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBReader.cpp b/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBReader.cpp
new file mode 100644
index 000000000..e6e5b7743
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBReader.cpp
@@ -0,0 +1,184 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSReadableStreamBYOBReader.h"
+
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMBuiltinConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+#include "ReadableStreamBYOBReaderBuiltins.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsReadableStreamBYOBReaderConstructor);
+
+class JSReadableStreamBYOBReaderPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSReadableStreamBYOBReaderPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSReadableStreamBYOBReaderPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamBYOBReaderPrototype>(vm)) JSReadableStreamBYOBReaderPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamBYOBReaderPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSReadableStreamBYOBReaderPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamBYOBReaderPrototype, JSReadableStreamBYOBReaderPrototype::Base);
+
+using JSReadableStreamBYOBReaderDOMConstructor = JSDOMBuiltinConstructor<JSReadableStreamBYOBReader>;
+
+template<> const ClassInfo JSReadableStreamBYOBReaderDOMConstructor::s_info = { "ReadableStreamBYOBReader"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamBYOBReaderDOMConstructor) };
+
+template<> JSValue JSReadableStreamBYOBReaderDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSReadableStreamBYOBReaderDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "ReadableStreamBYOBReader"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSReadableStreamBYOBReader::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+template<> FunctionExecutable* JSReadableStreamBYOBReaderDOMConstructor::initializeExecutable(VM& vm)
+{
+ return readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeGenerator(vm);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSReadableStreamBYOBReaderPrototypeTableValues[] =
+{
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadableStreamBYOBReaderConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "closed"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamBYOBReaderClosedCodeGenerator), (intptr_t) (0) } },
+ { "read"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamBYOBReaderReadCodeGenerator), (intptr_t) (0) } },
+ { "cancel"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamBYOBReaderCancelCodeGenerator), (intptr_t) (0) } },
+ { "releaseLock"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamBYOBReaderReleaseLockCodeGenerator), (intptr_t) (0) } },
+};
+
+const ClassInfo JSReadableStreamBYOBReaderPrototype::s_info = { "ReadableStreamBYOBReader"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamBYOBReaderPrototype) };
+
+void JSReadableStreamBYOBReaderPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSReadableStreamBYOBReader::info(), JSReadableStreamBYOBReaderPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSReadableStreamBYOBReader::s_info = { "ReadableStreamBYOBReader"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamBYOBReader) };
+
+JSReadableStreamBYOBReader::JSReadableStreamBYOBReader(Structure* structure, JSDOMGlobalObject& globalObject)
+ : JSDOMObject(structure, globalObject) { }
+
+void JSReadableStreamBYOBReader::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+}
+
+JSObject* JSReadableStreamBYOBReader::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSReadableStreamBYOBReaderPrototype::create(vm, &globalObject, JSReadableStreamBYOBReaderPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSReadableStreamBYOBReader::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSReadableStreamBYOBReader>(vm, globalObject);
+}
+
+JSValue JSReadableStreamBYOBReader::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSReadableStreamBYOBReaderDOMConstructor, DOMConstructorID::ReadableStreamBYOBReader>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSReadableStreamBYOBReader::destroy(JSC::JSCell* cell)
+{
+ JSReadableStreamBYOBReader* thisObject = static_cast<JSReadableStreamBYOBReader*>(cell);
+ thisObject->JSReadableStreamBYOBReader::~JSReadableStreamBYOBReader();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsReadableStreamBYOBReaderConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSReadableStreamBYOBReaderPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSReadableStreamBYOBReader::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+JSC::GCClient::IsoSubspace* JSReadableStreamBYOBReader::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSReadableStreamBYOBReader, UseCustomHeapCellType::No>(vm,
+ [] (auto& spaces) { return spaces.m_clientSubspaceForReadableStreamBYOBReader.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForReadableStreamBYOBReader = WTFMove(space); },
+ [] (auto& spaces) { return spaces.m_subspaceForReadableStreamBYOBReader.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_subspaceForReadableStreamBYOBReader = WTFMove(space); }
+ );
+}
+
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBReader.dep b/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBReader.dep
new file mode 100644
index 000000000..1acef694c
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBReader.dep
@@ -0,0 +1 @@
+JSReadableStreamBYOBReader.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBReader.h b/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBReader.h
new file mode 100644
index 000000000..8d69390ae
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBReader.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+
+namespace WebCore {
+
+class JSReadableStreamBYOBReader : public JSDOMObject {
+public:
+ using Base = JSDOMObject;
+ static JSReadableStreamBYOBReader* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+ {
+ JSReadableStreamBYOBReader* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamBYOBReader>(globalObject->vm())) JSReadableStreamBYOBReader(structure, *globalObject);
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+protected:
+ JSReadableStreamBYOBReader(JSC::Structure*, JSDOMGlobalObject&);
+
+ void finishCreation(JSC::VM&);
+};
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBRequest.cpp b/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBRequest.cpp
new file mode 100644
index 000000000..0b3dec469
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBRequest.cpp
@@ -0,0 +1,183 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSReadableStreamBYOBRequest.h"
+
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMBuiltinConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+#include "ReadableStreamBYOBRequestBuiltins.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsReadableStreamBYOBRequestConstructor);
+
+class JSReadableStreamBYOBRequestPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSReadableStreamBYOBRequestPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSReadableStreamBYOBRequestPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamBYOBRequestPrototype>(vm)) JSReadableStreamBYOBRequestPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamBYOBRequestPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSReadableStreamBYOBRequestPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamBYOBRequestPrototype, JSReadableStreamBYOBRequestPrototype::Base);
+
+using JSReadableStreamBYOBRequestDOMConstructor = JSDOMBuiltinConstructor<JSReadableStreamBYOBRequest>;
+
+template<> const ClassInfo JSReadableStreamBYOBRequestDOMConstructor::s_info = { "ReadableStreamBYOBRequest"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamBYOBRequestDOMConstructor) };
+
+template<> JSValue JSReadableStreamBYOBRequestDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSReadableStreamBYOBRequestDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(2), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "ReadableStreamBYOBRequest"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSReadableStreamBYOBRequest::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+template<> FunctionExecutable* JSReadableStreamBYOBRequestDOMConstructor::initializeExecutable(VM& vm)
+{
+ return readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeGenerator(vm);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSReadableStreamBYOBRequestPrototypeTableValues[] =
+{
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadableStreamBYOBRequestConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "view"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamBYOBRequestViewCodeGenerator), (intptr_t) (0) } },
+ { "respond"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamBYOBRequestRespondCodeGenerator), (intptr_t) (0) } },
+ { "respondWithNewView"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamBYOBRequestRespondWithNewViewCodeGenerator), (intptr_t) (0) } },
+};
+
+const ClassInfo JSReadableStreamBYOBRequestPrototype::s_info = { "ReadableStreamBYOBRequest"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamBYOBRequestPrototype) };
+
+void JSReadableStreamBYOBRequestPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSReadableStreamBYOBRequest::info(), JSReadableStreamBYOBRequestPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSReadableStreamBYOBRequest::s_info = { "ReadableStreamBYOBRequest"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamBYOBRequest) };
+
+JSReadableStreamBYOBRequest::JSReadableStreamBYOBRequest(Structure* structure, JSDOMGlobalObject& globalObject)
+ : JSDOMObject(structure, globalObject) { }
+
+void JSReadableStreamBYOBRequest::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+}
+
+JSObject* JSReadableStreamBYOBRequest::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSReadableStreamBYOBRequestPrototype::create(vm, &globalObject, JSReadableStreamBYOBRequestPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSReadableStreamBYOBRequest::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSReadableStreamBYOBRequest>(vm, globalObject);
+}
+
+JSValue JSReadableStreamBYOBRequest::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSReadableStreamBYOBRequestDOMConstructor, DOMConstructorID::ReadableStreamBYOBRequest>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSReadableStreamBYOBRequest::destroy(JSC::JSCell* cell)
+{
+ JSReadableStreamBYOBRequest* thisObject = static_cast<JSReadableStreamBYOBRequest*>(cell);
+ thisObject->JSReadableStreamBYOBRequest::~JSReadableStreamBYOBRequest();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsReadableStreamBYOBRequestConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSReadableStreamBYOBRequestPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSReadableStreamBYOBRequest::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+JSC::GCClient::IsoSubspace* JSReadableStreamBYOBRequest::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSReadableStreamBYOBRequest, UseCustomHeapCellType::No>(vm,
+ [] (auto& spaces) { return spaces.m_clientSubspaceForReadableStreamBYOBRequest.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForReadableStreamBYOBRequest = WTFMove(space); },
+ [] (auto& spaces) { return spaces.m_subspaceForReadableStreamBYOBRequest.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_subspaceForReadableStreamBYOBRequest = WTFMove(space); }
+ );
+}
+
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBRequest.dep b/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBRequest.dep
new file mode 100644
index 000000000..12e0f602d
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBRequest.dep
@@ -0,0 +1 @@
+JSReadableStreamBYOBRequest.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBRequest.h b/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBRequest.h
new file mode 100644
index 000000000..39f18c229
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamBYOBRequest.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+
+namespace WebCore {
+
+class JSReadableStreamBYOBRequest : public JSDOMObject {
+public:
+ using Base = JSDOMObject;
+ static JSReadableStreamBYOBRequest* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+ {
+ JSReadableStreamBYOBRequest* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamBYOBRequest>(globalObject->vm())) JSReadableStreamBYOBRequest(structure, *globalObject);
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+protected:
+ JSReadableStreamBYOBRequest(JSC::Structure*, JSDOMGlobalObject&);
+
+ void finishCreation(JSC::VM&);
+};
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultController.cpp b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultController.cpp
new file mode 100644
index 000000000..96baf755a
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultController.cpp
@@ -0,0 +1,184 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSReadableStreamDefaultController.h"
+
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMBuiltinConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+#include "ReadableStreamDefaultControllerBuiltins.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsReadableStreamDefaultControllerConstructor);
+
+class JSReadableStreamDefaultControllerPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSReadableStreamDefaultControllerPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSReadableStreamDefaultControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamDefaultControllerPrototype>(vm)) JSReadableStreamDefaultControllerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamDefaultControllerPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSReadableStreamDefaultControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamDefaultControllerPrototype, JSReadableStreamDefaultControllerPrototype::Base);
+
+using JSReadableStreamDefaultControllerDOMConstructor = JSDOMBuiltinConstructor<JSReadableStreamDefaultController>;
+
+template<> const ClassInfo JSReadableStreamDefaultControllerDOMConstructor::s_info = { "ReadableStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultControllerDOMConstructor) };
+
+template<> JSValue JSReadableStreamDefaultControllerDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSReadableStreamDefaultControllerDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(4), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "ReadableStreamDefaultController"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSReadableStreamDefaultController::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+template<> FunctionExecutable* JSReadableStreamDefaultControllerDOMConstructor::initializeExecutable(VM& vm)
+{
+ return readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeGenerator(vm);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSReadableStreamDefaultControllerPrototypeTableValues[] =
+{
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadableStreamDefaultControllerConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "desiredSize"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultControllerDesiredSizeCodeGenerator), (intptr_t) (0) } },
+ { "enqueue"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultControllerEnqueueCodeGenerator), (intptr_t) (0) } },
+ { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultControllerCloseCodeGenerator), (intptr_t) (0) } },
+ { "error"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultControllerErrorCodeGenerator), (intptr_t) (0) } },
+};
+
+const ClassInfo JSReadableStreamDefaultControllerPrototype::s_info = { "ReadableStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultControllerPrototype) };
+
+void JSReadableStreamDefaultControllerPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSReadableStreamDefaultController::info(), JSReadableStreamDefaultControllerPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSReadableStreamDefaultController::s_info = { "ReadableStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultController) };
+
+JSReadableStreamDefaultController::JSReadableStreamDefaultController(Structure* structure, JSDOMGlobalObject& globalObject)
+ : JSDOMObject(structure, globalObject) { }
+
+void JSReadableStreamDefaultController::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+}
+
+JSObject* JSReadableStreamDefaultController::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSReadableStreamDefaultControllerPrototype::create(vm, &globalObject, JSReadableStreamDefaultControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSReadableStreamDefaultController::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSReadableStreamDefaultController>(vm, globalObject);
+}
+
+JSValue JSReadableStreamDefaultController::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSReadableStreamDefaultControllerDOMConstructor, DOMConstructorID::ReadableStreamDefaultController>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSReadableStreamDefaultController::destroy(JSC::JSCell* cell)
+{
+ JSReadableStreamDefaultController* thisObject = static_cast<JSReadableStreamDefaultController*>(cell);
+ thisObject->JSReadableStreamDefaultController::~JSReadableStreamDefaultController();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsReadableStreamDefaultControllerConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSReadableStreamDefaultControllerPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSReadableStreamDefaultController::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+JSC::GCClient::IsoSubspace* JSReadableStreamDefaultController::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSReadableStreamDefaultController, UseCustomHeapCellType::No>(vm,
+ [] (auto& spaces) { return spaces.m_clientSubspaceForReadableStreamDefaultController.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForReadableStreamDefaultController = WTFMove(space); },
+ [] (auto& spaces) { return spaces.m_subspaceForReadableStreamDefaultController.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_subspaceForReadableStreamDefaultController = WTFMove(space); }
+ );
+}
+
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultController.dep b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultController.dep
new file mode 100644
index 000000000..3e3e1cd15
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultController.dep
@@ -0,0 +1 @@
+JSReadableStreamDefaultController.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultController.h b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultController.h
new file mode 100644
index 000000000..a38c95daf
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultController.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+
+namespace WebCore {
+
+class JSReadableStreamDefaultController : public JSDOMObject {
+public:
+ using Base = JSDOMObject;
+ static JSReadableStreamDefaultController* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+ {
+ JSReadableStreamDefaultController* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamDefaultController>(globalObject->vm())) JSReadableStreamDefaultController(structure, *globalObject);
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+protected:
+ JSReadableStreamDefaultController(JSC::Structure*, JSDOMGlobalObject&);
+
+ void finishCreation(JSC::VM&);
+};
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.cpp b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.cpp
new file mode 100644
index 000000000..63ab009e2
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.cpp
@@ -0,0 +1,184 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSReadableStreamDefaultReader.h"
+
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMBuiltinConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+#include "ReadableStreamDefaultReaderBuiltins.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsReadableStreamDefaultReaderConstructor);
+
+class JSReadableStreamDefaultReaderPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSReadableStreamDefaultReaderPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSReadableStreamDefaultReaderPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamDefaultReaderPrototype>(vm)) JSReadableStreamDefaultReaderPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamDefaultReaderPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSReadableStreamDefaultReaderPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamDefaultReaderPrototype, JSReadableStreamDefaultReaderPrototype::Base);
+
+using JSReadableStreamDefaultReaderDOMConstructor = JSDOMBuiltinConstructor<JSReadableStreamDefaultReader>;
+
+template<> const ClassInfo JSReadableStreamDefaultReaderDOMConstructor::s_info = { "ReadableStreamDefaultReader"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultReaderDOMConstructor) };
+
+template<> JSValue JSReadableStreamDefaultReaderDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSReadableStreamDefaultReaderDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "ReadableStreamDefaultReader"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSReadableStreamDefaultReader::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+template<> FunctionExecutable* JSReadableStreamDefaultReaderDOMConstructor::initializeExecutable(VM& vm)
+{
+ return readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeGenerator(vm);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSReadableStreamDefaultReaderPrototypeTableValues[] =
+{
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadableStreamDefaultReaderConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "closed"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultReaderClosedCodeGenerator), (intptr_t) (0) } },
+ { "read"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultReaderReadCodeGenerator), (intptr_t) (0) } },
+ { "cancel"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultReaderCancelCodeGenerator), (intptr_t) (0) } },
+ { "releaseLock"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultReaderReleaseLockCodeGenerator), (intptr_t) (0) } },
+};
+
+const ClassInfo JSReadableStreamDefaultReaderPrototype::s_info = { "ReadableStreamDefaultReader"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultReaderPrototype) };
+
+void JSReadableStreamDefaultReaderPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSReadableStreamDefaultReader::info(), JSReadableStreamDefaultReaderPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSReadableStreamDefaultReader::s_info = { "ReadableStreamDefaultReader"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultReader) };
+
+JSReadableStreamDefaultReader::JSReadableStreamDefaultReader(Structure* structure, JSDOMGlobalObject& globalObject)
+ : JSDOMObject(structure, globalObject) { }
+
+void JSReadableStreamDefaultReader::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+}
+
+JSObject* JSReadableStreamDefaultReader::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSReadableStreamDefaultReaderPrototype::create(vm, &globalObject, JSReadableStreamDefaultReaderPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSReadableStreamDefaultReader::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSReadableStreamDefaultReader>(vm, globalObject);
+}
+
+JSValue JSReadableStreamDefaultReader::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSReadableStreamDefaultReaderDOMConstructor, DOMConstructorID::ReadableStreamDefaultReader>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSReadableStreamDefaultReader::destroy(JSC::JSCell* cell)
+{
+ JSReadableStreamDefaultReader* thisObject = static_cast<JSReadableStreamDefaultReader*>(cell);
+ thisObject->JSReadableStreamDefaultReader::~JSReadableStreamDefaultReader();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsReadableStreamDefaultReaderConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSReadableStreamDefaultReaderPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSReadableStreamDefaultReader::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+JSC::GCClient::IsoSubspace* JSReadableStreamDefaultReader::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSReadableStreamDefaultReader, UseCustomHeapCellType::No>(vm,
+ [] (auto& spaces) { return spaces.m_clientSubspaceForReadableStreamDefaultReader.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForReadableStreamDefaultReader = WTFMove(space); },
+ [] (auto& spaces) { return spaces.m_subspaceForReadableStreamDefaultReader.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_subspaceForReadableStreamDefaultReader = WTFMove(space); }
+ );
+}
+
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.dep b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.dep
new file mode 100644
index 000000000..466ee5c61
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.dep
@@ -0,0 +1 @@
+JSReadableStreamDefaultReader.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.h b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.h
new file mode 100644
index 000000000..61a4d1336
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+
+namespace WebCore {
+
+class JSReadableStreamDefaultReader : public JSDOMObject {
+public:
+ using Base = JSDOMObject;
+ static JSReadableStreamDefaultReader* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+ {
+ JSReadableStreamDefaultReader* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamDefaultReader>(globalObject->vm())) JSReadableStreamDefaultReader(structure, *globalObject);
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+protected:
+ JSReadableStreamDefaultReader(JSC::Structure*, JSDOMGlobalObject&);
+
+ void finishCreation(JSC::VM&);
+};
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamSink.cpp b/src/javascript/jsc/bindings/webcore/JSReadableStreamSink.cpp
new file mode 100644
index 000000000..2fd819460
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamSink.cpp
@@ -0,0 +1,243 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSReadableStreamSink.h"
+
+#include "ActiveDOMObject.h"
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "IDLTypes.h"
+#include "JSDOMBinding.h"
+#include "JSDOMConvertBase.h"
+#include "JSDOMConvertBufferSource.h"
+#include "JSDOMConvertStrings.h"
+#include "JSDOMConvertUnion.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+#include "ScriptExecutionContext.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapAnalyzer.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <variant>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+#include <wtf/URL.h>
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+static JSC_DECLARE_HOST_FUNCTION(jsReadableStreamSinkPrototypeFunction_enqueue);
+static JSC_DECLARE_HOST_FUNCTION(jsReadableStreamSinkPrototypeFunction_close);
+static JSC_DECLARE_HOST_FUNCTION(jsReadableStreamSinkPrototypeFunction_error);
+
+class JSReadableStreamSinkPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSReadableStreamSinkPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSReadableStreamSinkPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamSinkPrototype>(vm)) JSReadableStreamSinkPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamSinkPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSReadableStreamSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamSinkPrototype, JSReadableStreamSinkPrototype::Base);
+
+/* Hash table for prototype */
+
+static const HashTableValue JSReadableStreamSinkPrototypeTableValues[] = {
+ { "enqueue"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsReadableStreamSinkPrototypeFunction_enqueue), (intptr_t)(1) } },
+ { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsReadableStreamSinkPrototypeFunction_close), (intptr_t)(0) } },
+ { "error"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsReadableStreamSinkPrototypeFunction_error), (intptr_t)(1) } },
+};
+
+const ClassInfo JSReadableStreamSinkPrototype::s_info = { "ReadableStreamSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamSinkPrototype) };
+
+void JSReadableStreamSinkPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSReadableStreamSink::info(), JSReadableStreamSinkPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSReadableStreamSink::s_info = { "ReadableStreamSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamSink) };
+
+JSReadableStreamSink::JSReadableStreamSink(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ReadableStreamSink>&& impl)
+ : JSDOMWrapper<ReadableStreamSink>(structure, globalObject, WTFMove(impl))
+{
+}
+
+void JSReadableStreamSink::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+ // static_assert(!std::is_base_of<ActiveDOMObject, ReadableStreamSink>::value, "Interface is not marked as [ActiveDOMObject] even though implementation class subclasses ActiveDOMObject.");
+}
+
+JSObject* JSReadableStreamSink::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSReadableStreamSinkPrototype::create(vm, &globalObject, JSReadableStreamSinkPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSReadableStreamSink::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSReadableStreamSink>(vm, globalObject);
+}
+
+void JSReadableStreamSink::destroy(JSC::JSCell* cell)
+{
+ JSReadableStreamSink* thisObject = static_cast<JSReadableStreamSink*>(cell);
+ thisObject->JSReadableStreamSink::~JSReadableStreamSink();
+}
+
+static inline JSC::EncodedJSValue jsReadableStreamSinkPrototypeFunction_enqueueBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSReadableStreamSink>::ClassParameter castedThis)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ auto& impl = castedThis->wrapped();
+ if (UNLIKELY(callFrame->argumentCount() < 1))
+ return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
+ EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
+ auto chunk = convert<IDLUnion<IDLArrayBufferView, IDLArrayBuffer>>(*lexicalGlobalObject, argument0.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.enqueue(WTFMove(chunk)); })));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsReadableStreamSinkPrototypeFunction_enqueue, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperation<JSReadableStreamSink>::call<jsReadableStreamSinkPrototypeFunction_enqueueBody>(*lexicalGlobalObject, *callFrame, "enqueue");
+}
+
+static inline JSC::EncodedJSValue jsReadableStreamSinkPrototypeFunction_closeBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSReadableStreamSink>::ClassParameter castedThis)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ auto& impl = castedThis->wrapped();
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.close(); })));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsReadableStreamSinkPrototypeFunction_close, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperation<JSReadableStreamSink>::call<jsReadableStreamSinkPrototypeFunction_closeBody>(*lexicalGlobalObject, *callFrame, "close");
+}
+
+static inline JSC::EncodedJSValue jsReadableStreamSinkPrototypeFunction_errorBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSReadableStreamSink>::ClassParameter castedThis)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ auto& impl = castedThis->wrapped();
+ if (UNLIKELY(callFrame->argumentCount() < 1))
+ return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
+ EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
+ auto message = convert<IDLDOMString>(*lexicalGlobalObject, argument0.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.error(WTFMove(message)); })));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsReadableStreamSinkPrototypeFunction_error, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperation<JSReadableStreamSink>::call<jsReadableStreamSinkPrototypeFunction_errorBody>(*lexicalGlobalObject, *callFrame, "error");
+}
+
+JSC::GCClient::IsoSubspace* JSReadableStreamSink::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSReadableStreamSink, UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForReadableStreamSink.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForReadableStreamSink = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForReadableStreamSink.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForReadableStreamSink = WTFMove(space); });
+}
+
+void JSReadableStreamSink::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSReadableStreamSink*>(cell);
+ analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
+ if (thisObject->scriptExecutionContext())
+ analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ Base::analyzeHeap(cell, analyzer);
+}
+
+bool JSReadableStreamSinkOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, AbstractSlotVisitor& visitor, const char** reason)
+{
+ UNUSED_PARAM(handle);
+ UNUSED_PARAM(visitor);
+ UNUSED_PARAM(reason);
+ return false;
+}
+
+void JSReadableStreamSinkOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
+{
+ auto* jsReadableStreamSink = static_cast<JSReadableStreamSink*>(handle.slot()->asCell());
+ auto& world = *static_cast<DOMWrapperWorld*>(context);
+ uncacheWrapper(world, &jsReadableStreamSink->wrapped(), jsReadableStreamSink);
+}
+
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<ReadableStreamSink>&& impl)
+{
+ return createWrapper<ReadableStreamSink>(globalObject, WTFMove(impl));
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, ReadableStreamSink& impl)
+{
+ return wrap(lexicalGlobalObject, globalObject, impl);
+}
+
+ReadableStreamSink* JSReadableStreamSink::toWrapped(JSC::VM&, JSC::JSValue value)
+{
+ if (auto* wrapper = jsDynamicCast<JSReadableStreamSink*>(value))
+ return &wrapper->wrapped();
+ return nullptr;
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamSink.dep b/src/javascript/jsc/bindings/webcore/JSReadableStreamSink.dep
new file mode 100644
index 000000000..9c5594686
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamSink.dep
@@ -0,0 +1 @@
+JSReadableStreamSink.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamSink.h b/src/javascript/jsc/bindings/webcore/JSReadableStreamSink.h
new file mode 100644
index 000000000..83fa457ad
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamSink.h
@@ -0,0 +1,92 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+#include "ReadableStreamSink.h"
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+class JSReadableStreamSink : public JSDOMWrapper<ReadableStreamSink> {
+public:
+ using Base = JSDOMWrapper<ReadableStreamSink>;
+ static JSReadableStreamSink* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<ReadableStreamSink>&& impl)
+ {
+ JSReadableStreamSink* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamSink>(globalObject->vm())) JSReadableStreamSink(structure, *globalObject, WTFMove(impl));
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static ReadableStreamSink* toWrapped(JSC::VM&, JSC::JSValue);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+protected:
+ JSReadableStreamSink(JSC::Structure*, JSDOMGlobalObject&, Ref<ReadableStreamSink>&&);
+
+ void finishCreation(JSC::VM&);
+};
+
+class JSReadableStreamSinkOwner final : public JSC::WeakHandleOwner {
+public:
+ bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::AbstractSlotVisitor&, const char**) final;
+ void finalize(JSC::Handle<JSC::Unknown>, void* context) final;
+};
+
+inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, ReadableStreamSink*)
+{
+ static NeverDestroyed<JSReadableStreamSinkOwner> owner;
+ return &owner.get();
+}
+
+inline void* wrapperKey(ReadableStreamSink* wrappableObject)
+{
+ return wrappableObject;
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject*, JSDOMGlobalObject*, ReadableStreamSink&);
+inline JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, ReadableStreamSink* impl) { return impl ? toJS(lexicalGlobalObject, globalObject, *impl) : JSC::jsNull(); }
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<ReadableStreamSink>&&);
+inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, RefPtr<ReadableStreamSink>&& impl) { return impl ? toJSNewlyCreated(lexicalGlobalObject, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
+
+template<> struct JSDOMWrapperConverterTraits<ReadableStreamSink> {
+ using WrapperClass = JSReadableStreamSink;
+ using ToWrappedReturnType = ReadableStreamSink*;
+};
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.cpp b/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.cpp
new file mode 100644
index 000000000..eb231277e
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.cpp
@@ -0,0 +1,262 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSReadableStreamSource.h"
+
+#include "ActiveDOMObject.h"
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "IDLTypes.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMConvertAny.h"
+#include "JSDOMConvertBase.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMOperation.h"
+#include "JSDOMOperationReturningPromise.h"
+#include "JSDOMWrapperCache.h"
+#include "ScriptExecutionContext.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapAnalyzer.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+#include <wtf/URL.h>
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+static JSC_DECLARE_HOST_FUNCTION(jsReadableStreamSourcePrototypeFunction_start);
+static JSC_DECLARE_HOST_FUNCTION(jsReadableStreamSourcePrototypeFunction_pull);
+static JSC_DECLARE_HOST_FUNCTION(jsReadableStreamSourcePrototypeFunction_cancel);
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsReadableStreamSource_controller);
+
+class JSReadableStreamSourcePrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSReadableStreamSourcePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSReadableStreamSourcePrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamSourcePrototype>(vm)) JSReadableStreamSourcePrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamSourcePrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSReadableStreamSourcePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSReadableStreamSourcePrototype, JSReadableStreamSourcePrototype::Base);
+
+/* Hash table for prototype */
+
+static const HashTableValue JSReadableStreamSourcePrototypeTableValues[] = {
+ { "controller"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsReadableStreamSource_controller), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "start"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsReadableStreamSourcePrototypeFunction_start), (intptr_t)(1) } },
+ { "pull"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsReadableStreamSourcePrototypeFunction_pull), (intptr_t)(1) } },
+ { "cancel"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsReadableStreamSourcePrototypeFunction_cancel), (intptr_t)(1) } },
+};
+
+const ClassInfo JSReadableStreamSourcePrototype::s_info = { "ReadableStreamSource"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamSourcePrototype) };
+
+void JSReadableStreamSourcePrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSReadableStreamSource::info(), JSReadableStreamSourcePrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSReadableStreamSource::s_info = { "ReadableStreamSource"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamSource) };
+
+JSReadableStreamSource::JSReadableStreamSource(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ReadableStreamSource>&& impl)
+ : JSDOMWrapper<ReadableStreamSource>(structure, globalObject, WTFMove(impl))
+{
+}
+
+void JSReadableStreamSource::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+ // static_assert(!std::is_base_of<ActiveDOMObject, ReadableStreamSource>::value, "Interface is not marked as [ActiveDOMObject] even though implementation class subclasses ActiveDOMObject.");
+}
+
+JSObject* JSReadableStreamSource::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSReadableStreamSourcePrototype::create(vm, &globalObject, JSReadableStreamSourcePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSReadableStreamSource::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSReadableStreamSource>(vm, globalObject);
+}
+
+void JSReadableStreamSource::destroy(JSC::JSCell* cell)
+{
+ JSReadableStreamSource* thisObject = static_cast<JSReadableStreamSource*>(cell);
+ thisObject->JSReadableStreamSource::~JSReadableStreamSource();
+}
+
+static inline JSValue jsReadableStreamSource_controllerGetter(JSGlobalObject& lexicalGlobalObject, JSReadableStreamSource& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return thisObject.controller(lexicalGlobalObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsReadableStreamSource_controller, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<JSReadableStreamSource>::get<jsReadableStreamSource_controllerGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSC::EncodedJSValue jsReadableStreamSourcePrototypeFunction_startBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperationReturningPromise<JSReadableStreamSource>::ClassParameter castedThis, Ref<DeferredPromise>&& promise)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ RELEASE_AND_RETURN(throwScope, (JSValue::encode(castedThis->start(*lexicalGlobalObject, *callFrame, WTFMove(promise)))));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsReadableStreamSourcePrototypeFunction_start, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperationReturningPromise<JSReadableStreamSource>::call<jsReadableStreamSourcePrototypeFunction_startBody>(*lexicalGlobalObject, *callFrame, "start");
+}
+
+static inline JSC::EncodedJSValue jsReadableStreamSourcePrototypeFunction_pullBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperationReturningPromise<JSReadableStreamSource>::ClassParameter castedThis, Ref<DeferredPromise>&& promise)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ RELEASE_AND_RETURN(throwScope, (JSValue::encode(castedThis->pull(*lexicalGlobalObject, *callFrame, WTFMove(promise)))));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsReadableStreamSourcePrototypeFunction_pull, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperationReturningPromise<JSReadableStreamSource>::call<jsReadableStreamSourcePrototypeFunction_pullBody>(*lexicalGlobalObject, *callFrame, "pull");
+}
+
+static inline JSC::EncodedJSValue jsReadableStreamSourcePrototypeFunction_cancelBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSReadableStreamSource>::ClassParameter castedThis)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ auto& impl = castedThis->wrapped();
+ if (UNLIKELY(callFrame->argumentCount() < 1))
+ return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
+ EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
+ auto reason = convert<IDLAny>(*lexicalGlobalObject, argument0.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.cancel(WTFMove(reason)); })));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsReadableStreamSourcePrototypeFunction_cancel, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperation<JSReadableStreamSource>::call<jsReadableStreamSourcePrototypeFunction_cancelBody>(*lexicalGlobalObject, *callFrame, "cancel");
+}
+
+JSC::GCClient::IsoSubspace* JSReadableStreamSource::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSReadableStreamSource, UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForReadableStreamSource.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForReadableStreamSource = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForReadableStreamSource.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForReadableStreamSource = WTFMove(space); });
+}
+
+template<typename Visitor>
+void JSReadableStreamSource::visitChildrenImpl(JSCell* cell, Visitor& visitor)
+{
+ auto* thisObject = jsCast<JSReadableStreamSource*>(cell);
+ ASSERT_GC_OBJECT_INHERITS(thisObject, info());
+ Base::visitChildren(thisObject, visitor);
+ visitor.append(thisObject->m_controller);
+}
+
+DEFINE_VISIT_CHILDREN(JSReadableStreamSource);
+
+void JSReadableStreamSource::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSReadableStreamSource*>(cell);
+ analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
+ if (thisObject->scriptExecutionContext())
+ analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ Base::analyzeHeap(cell, analyzer);
+}
+
+bool JSReadableStreamSourceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, AbstractSlotVisitor& visitor, const char** reason)
+{
+ UNUSED_PARAM(handle);
+ UNUSED_PARAM(visitor);
+ UNUSED_PARAM(reason);
+ return false;
+}
+
+void JSReadableStreamSourceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
+{
+ auto* jsReadableStreamSource = static_cast<JSReadableStreamSource*>(handle.slot()->asCell());
+ auto& world = *static_cast<DOMWrapperWorld*>(context);
+ uncacheWrapper(world, &jsReadableStreamSource->wrapped(), jsReadableStreamSource);
+}
+
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<ReadableStreamSource>&& impl)
+{
+ return createWrapper<ReadableStreamSource>(globalObject, WTFMove(impl));
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, ReadableStreamSource& impl)
+{
+ return wrap(lexicalGlobalObject, globalObject, impl);
+}
+
+ReadableStreamSource* JSReadableStreamSource::toWrapped(JSC::VM&, JSC::JSValue value)
+{
+ if (auto* wrapper = jsDynamicCast<JSReadableStreamSource*>(value))
+ return &wrapper->wrapped();
+ return nullptr;
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.dep b/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.dep
new file mode 100644
index 000000000..f459688e5
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.dep
@@ -0,0 +1 @@
+JSReadableStreamSource.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.h b/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.h
new file mode 100644
index 000000000..4a7fec950
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.h
@@ -0,0 +1,102 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+#include "ReadableStreamSource.h"
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+class JSReadableStreamSource : public JSDOMWrapper<ReadableStreamSource> {
+public:
+ using Base = JSDOMWrapper<ReadableStreamSource>;
+ static JSReadableStreamSource* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<ReadableStreamSource>&& impl)
+ {
+ JSReadableStreamSource* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamSource>(globalObject->vm())) JSReadableStreamSource(structure, *globalObject, WTFMove(impl));
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static ReadableStreamSource* toWrapped(JSC::VM&, JSC::JSValue);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ mutable JSC::WriteBarrier<JSC::Unknown> m_controller;
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+ DECLARE_VISIT_CHILDREN;
+
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+
+ // Custom attributes
+ JSC::JSValue controller(JSC::JSGlobalObject&) const;
+
+ // Custom functions
+ JSC::JSValue start(JSC::JSGlobalObject&, JSC::CallFrame&, Ref<DeferredPromise>&&);
+ JSC::JSValue pull(JSC::JSGlobalObject&, JSC::CallFrame&, Ref<DeferredPromise>&&);
+protected:
+ JSReadableStreamSource(JSC::Structure*, JSDOMGlobalObject&, Ref<ReadableStreamSource>&&);
+
+ void finishCreation(JSC::VM&);
+};
+
+class JSReadableStreamSourceOwner final : public JSC::WeakHandleOwner {
+public:
+ bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::AbstractSlotVisitor&, const char**) final;
+ void finalize(JSC::Handle<JSC::Unknown>, void* context) final;
+};
+
+inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, ReadableStreamSource*)
+{
+ static NeverDestroyed<JSReadableStreamSourceOwner> owner;
+ return &owner.get();
+}
+
+inline void* wrapperKey(ReadableStreamSource* wrappableObject)
+{
+ return wrappableObject;
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject*, JSDOMGlobalObject*, ReadableStreamSource&);
+inline JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, ReadableStreamSource* impl) { return impl ? toJS(lexicalGlobalObject, globalObject, *impl) : JSC::jsNull(); }
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<ReadableStreamSource>&&);
+inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, RefPtr<ReadableStreamSource>&& impl) { return impl ? toJSNewlyCreated(lexicalGlobalObject, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
+
+template<> struct JSDOMWrapperConverterTraits<ReadableStreamSource> {
+ using WrapperClass = JSReadableStreamSource;
+ using ToWrappedReturnType = ReadableStreamSource*;
+};
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamSourceCustom.cpp b/src/javascript/jsc/bindings/webcore/JSReadableStreamSourceCustom.cpp
new file mode 100644
index 000000000..476c0f852
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamSourceCustom.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2016 Canon Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be 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.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON 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 CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSReadableStreamSource.h"
+
+#include "JSDOMPromiseDeferred.h"
+
+namespace WebCore {
+using namespace JSC;
+
+JSValue JSReadableStreamSource::start(JSGlobalObject& lexicalGlobalObject, CallFrame& callFrame, Ref<DeferredPromise>&& promise)
+{
+ VM& vm = lexicalGlobalObject.vm();
+
+ // FIXME: Why is it ok to ASSERT the argument count here?
+ ASSERT(callFrame.argumentCount());
+ JSReadableStreamDefaultController* controller = jsDynamicCast<JSReadableStreamDefaultController*>(callFrame.uncheckedArgument(0));
+ ASSERT(controller);
+
+ m_controller.set(vm, this, controller);
+
+ wrapped().start(ReadableStreamDefaultController(controller), WTFMove(promise));
+
+ return jsUndefined();
+}
+
+JSValue JSReadableStreamSource::pull(JSGlobalObject&, CallFrame&, Ref<DeferredPromise>&& promise)
+{
+ wrapped().pull(WTFMove(promise));
+ return jsUndefined();
+}
+
+JSValue JSReadableStreamSource::controller(JSGlobalObject&) const
+{
+ ASSERT_NOT_REACHED();
+ return jsUndefined();
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSTransformStream.cpp b/src/javascript/jsc/bindings/webcore/JSTransformStream.cpp
new file mode 100644
index 000000000..68b9c4dae
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSTransformStream.cpp
@@ -0,0 +1,178 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSTransformStream.h"
+
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMBuiltinConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMWrapperCache.h"
+#include "TransformStreamBuiltins.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsTransformStreamConstructor);
+
+class JSTransformStreamPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSTransformStreamPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSTransformStreamPrototype* ptr = new (NotNull, JSC::allocateCell<JSTransformStreamPrototype>(vm)) JSTransformStreamPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTransformStreamPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSTransformStreamPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTransformStreamPrototype, JSTransformStreamPrototype::Base);
+
+using JSTransformStreamDOMConstructor = JSDOMBuiltinConstructor<JSTransformStream>;
+
+template<> const ClassInfo JSTransformStreamDOMConstructor::s_info = { "TransformStream"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTransformStreamDOMConstructor) };
+
+template<> JSValue JSTransformStreamDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSTransformStreamDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "TransformStream"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSTransformStream::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+template<> FunctionExecutable* JSTransformStreamDOMConstructor::initializeExecutable(VM& vm)
+{
+ return transformStreamInitializeTransformStreamCodeGenerator(vm);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSTransformStreamPrototypeTableValues[] =
+{
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTransformStreamConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "readable"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(transformStreamReadableCodeGenerator), (intptr_t) (0) } },
+ { "writable"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(transformStreamWritableCodeGenerator), (intptr_t) (0) } },
+};
+
+const ClassInfo JSTransformStreamPrototype::s_info = { "TransformStream"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTransformStreamPrototype) };
+
+void JSTransformStreamPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSTransformStream::info(), JSTransformStreamPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSTransformStream::s_info = { "TransformStream"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTransformStream) };
+
+JSTransformStream::JSTransformStream(Structure* structure, JSDOMGlobalObject& globalObject)
+ : JSDOMObject(structure, globalObject) { }
+
+void JSTransformStream::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+}
+
+JSObject* JSTransformStream::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSTransformStreamPrototype::create(vm, &globalObject, JSTransformStreamPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSTransformStream::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSTransformStream>(vm, globalObject);
+}
+
+JSValue JSTransformStream::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSTransformStreamDOMConstructor, DOMConstructorID::TransformStream>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSTransformStream::destroy(JSC::JSCell* cell)
+{
+ JSTransformStream* thisObject = static_cast<JSTransformStream*>(cell);
+ thisObject->JSTransformStream::~JSTransformStream();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsTransformStreamConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSTransformStreamPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSTransformStream::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+JSC::GCClient::IsoSubspace* JSTransformStream::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSTransformStream, UseCustomHeapCellType::No>(vm,
+ [] (auto& spaces) { return spaces.m_clientSubspaceForTransformStream.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForTransformStream = WTFMove(space); },
+ [] (auto& spaces) { return spaces.m_subspaceForTransformStream.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_subspaceForTransformStream = WTFMove(space); }
+ );
+}
+
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSTransformStream.dep b/src/javascript/jsc/bindings/webcore/JSTransformStream.dep
new file mode 100644
index 000000000..30374925b
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSTransformStream.dep
@@ -0,0 +1 @@
+JSTransformStream.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSTransformStream.h b/src/javascript/jsc/bindings/webcore/JSTransformStream.h
new file mode 100644
index 000000000..26646df03
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSTransformStream.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+
+namespace WebCore {
+
+class JSTransformStream : public JSDOMObject {
+public:
+ using Base = JSDOMObject;
+ static JSTransformStream* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+ {
+ JSTransformStream* ptr = new (NotNull, JSC::allocateCell<JSTransformStream>(globalObject->vm())) JSTransformStream(structure, *globalObject);
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+protected:
+ JSTransformStream(JSC::Structure*, JSDOMGlobalObject&);
+
+ void finishCreation(JSC::VM&);
+};
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSTransformStreamDefaultController.cpp b/src/javascript/jsc/bindings/webcore/JSTransformStreamDefaultController.cpp
new file mode 100644
index 000000000..77532ac9e
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSTransformStreamDefaultController.cpp
@@ -0,0 +1,184 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSTransformStreamDefaultController.h"
+
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMBuiltinConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+#include "TransformStreamDefaultControllerBuiltins.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsTransformStreamDefaultControllerConstructor);
+
+class JSTransformStreamDefaultControllerPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSTransformStreamDefaultControllerPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSTransformStreamDefaultControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSTransformStreamDefaultControllerPrototype>(vm)) JSTransformStreamDefaultControllerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTransformStreamDefaultControllerPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSTransformStreamDefaultControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTransformStreamDefaultControllerPrototype, JSTransformStreamDefaultControllerPrototype::Base);
+
+using JSTransformStreamDefaultControllerDOMConstructor = JSDOMBuiltinConstructor<JSTransformStreamDefaultController>;
+
+template<> const ClassInfo JSTransformStreamDefaultControllerDOMConstructor::s_info = { "TransformStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTransformStreamDefaultControllerDOMConstructor) };
+
+template<> JSValue JSTransformStreamDefaultControllerDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSTransformStreamDefaultControllerDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "TransformStreamDefaultController"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSTransformStreamDefaultController::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+template<> FunctionExecutable* JSTransformStreamDefaultControllerDOMConstructor::initializeExecutable(VM& vm)
+{
+ return transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeGenerator(vm);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSTransformStreamDefaultControllerPrototypeTableValues[] =
+{
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTransformStreamDefaultControllerConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "desiredSize"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(transformStreamDefaultControllerDesiredSizeCodeGenerator), (intptr_t) (0) } },
+ { "enqueue"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(transformStreamDefaultControllerEnqueueCodeGenerator), (intptr_t) (0) } },
+ { "error"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(transformStreamDefaultControllerErrorCodeGenerator), (intptr_t) (0) } },
+ { "terminate"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(transformStreamDefaultControllerTerminateCodeGenerator), (intptr_t) (0) } },
+};
+
+const ClassInfo JSTransformStreamDefaultControllerPrototype::s_info = { "TransformStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTransformStreamDefaultControllerPrototype) };
+
+void JSTransformStreamDefaultControllerPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSTransformStreamDefaultController::info(), JSTransformStreamDefaultControllerPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSTransformStreamDefaultController::s_info = { "TransformStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTransformStreamDefaultController) };
+
+JSTransformStreamDefaultController::JSTransformStreamDefaultController(Structure* structure, JSDOMGlobalObject& globalObject)
+ : JSDOMObject(structure, globalObject) { }
+
+void JSTransformStreamDefaultController::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+}
+
+JSObject* JSTransformStreamDefaultController::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSTransformStreamDefaultControllerPrototype::create(vm, &globalObject, JSTransformStreamDefaultControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSTransformStreamDefaultController::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSTransformStreamDefaultController>(vm, globalObject);
+}
+
+JSValue JSTransformStreamDefaultController::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSTransformStreamDefaultControllerDOMConstructor, DOMConstructorID::TransformStreamDefaultController>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSTransformStreamDefaultController::destroy(JSC::JSCell* cell)
+{
+ JSTransformStreamDefaultController* thisObject = static_cast<JSTransformStreamDefaultController*>(cell);
+ thisObject->JSTransformStreamDefaultController::~JSTransformStreamDefaultController();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsTransformStreamDefaultControllerConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSTransformStreamDefaultControllerPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSTransformStreamDefaultController::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+JSC::GCClient::IsoSubspace* JSTransformStreamDefaultController::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSTransformStreamDefaultController, UseCustomHeapCellType::No>(vm,
+ [] (auto& spaces) { return spaces.m_clientSubspaceForTransformStreamDefaultController.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForTransformStreamDefaultController = WTFMove(space); },
+ [] (auto& spaces) { return spaces.m_subspaceForTransformStreamDefaultController.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_subspaceForTransformStreamDefaultController = WTFMove(space); }
+ );
+}
+
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSTransformStreamDefaultController.dep b/src/javascript/jsc/bindings/webcore/JSTransformStreamDefaultController.dep
new file mode 100644
index 000000000..0d59bed06
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSTransformStreamDefaultController.dep
@@ -0,0 +1 @@
+JSTransformStreamDefaultController.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSTransformStreamDefaultController.h b/src/javascript/jsc/bindings/webcore/JSTransformStreamDefaultController.h
new file mode 100644
index 000000000..e63fdd7c4
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSTransformStreamDefaultController.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+
+namespace WebCore {
+
+class JSTransformStreamDefaultController : public JSDOMObject {
+public:
+ using Base = JSDOMObject;
+ static JSTransformStreamDefaultController* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+ {
+ JSTransformStreamDefaultController* ptr = new (NotNull, JSC::allocateCell<JSTransformStreamDefaultController>(globalObject->vm())) JSTransformStreamDefaultController(structure, *globalObject);
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+protected:
+ JSTransformStreamDefaultController(JSC::Structure*, JSDOMGlobalObject&);
+
+ void finishCreation(JSC::VM&);
+};
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSWritableStream.cpp b/src/javascript/jsc/bindings/webcore/JSWritableStream.cpp
new file mode 100644
index 000000000..1d996f3ef
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWritableStream.cpp
@@ -0,0 +1,311 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSWritableStream.h"
+
+#include "ActiveDOMObject.h"
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMConstructor.h"
+#include "JSDOMConvertBoolean.h"
+#include "JSDOMConvertInterface.h"
+#include "JSDOMConvertObject.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMOperationReturningPromise.h"
+#include "JSDOMWrapperCache.h"
+#include "ScriptExecutionContext.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/HeapAnalyzer.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+#include <wtf/URL.h>
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+static JSC_DECLARE_HOST_FUNCTION(jsWritableStreamPrototypeFunction_abort);
+static JSC_DECLARE_HOST_FUNCTION(jsWritableStreamPrototypeFunction_close);
+static JSC_DECLARE_HOST_FUNCTION(jsWritableStreamPrototypeFunction_getWriter);
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsWritableStreamConstructor);
+static JSC_DECLARE_CUSTOM_GETTER(jsWritableStream_locked);
+
+class JSWritableStreamPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSWritableStreamPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSWritableStreamPrototype* ptr = new (NotNull, JSC::allocateCell<JSWritableStreamPrototype>(vm)) JSWritableStreamPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSWritableStreamPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSWritableStreamPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSWritableStreamPrototype, JSWritableStreamPrototype::Base);
+
+using JSWritableStreamDOMConstructor = JSDOMConstructor<JSWritableStream>;
+
+template<> EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSWritableStreamDOMConstructor::construct(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+ VM& vm = lexicalGlobalObject->vm();
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* castedThis = jsCast<JSWritableStreamDOMConstructor*>(callFrame->jsCallee());
+ ASSERT(castedThis);
+ EnsureStillAliveScope argument0 = callFrame->argument(0);
+ auto underlyingSink = argument0.value().isUndefined() ? std::optional<Converter<IDLObject>::ReturnType>() : std::optional<Converter<IDLObject>::ReturnType>(convert<IDLObject>(*lexicalGlobalObject, argument0.value()));
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ EnsureStillAliveScope argument1 = callFrame->argument(1);
+ auto strategy = argument1.value().isUndefined() ? std::optional<Converter<IDLObject>::ReturnType>() : std::optional<Converter<IDLObject>::ReturnType>(convert<IDLObject>(*lexicalGlobalObject, argument1.value()));
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ auto object = WritableStream::create(*castedThis->globalObject(), WTFMove(underlyingSink), WTFMove(strategy));
+ if constexpr (IsExceptionOr<decltype(object)>)
+ RETURN_IF_EXCEPTION(throwScope, {});
+ static_assert(TypeOrExceptionOrUnderlyingType<decltype(object)>::isRef);
+ auto jsValue = toJSNewlyCreated<IDLInterface<WritableStream>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, WTFMove(object));
+ if constexpr (IsExceptionOr<decltype(object)>)
+ RETURN_IF_EXCEPTION(throwScope, {});
+ setSubclassStructureIfNeeded<WritableStream>(lexicalGlobalObject, callFrame, asObject(jsValue));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ return JSValue::encode(jsValue);
+}
+JSC_ANNOTATE_HOST_FUNCTION(JSWritableStreamDOMConstructorConstruct, JSWritableStreamDOMConstructor::construct);
+
+template<> const ClassInfo JSWritableStreamDOMConstructor::s_info = { "WritableStream"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWritableStreamDOMConstructor) };
+
+template<> JSValue JSWritableStreamDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSWritableStreamDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "WritableStream"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSWritableStream::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSWritableStreamPrototypeTableValues[] = {
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsWritableStreamConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "locked"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsWritableStream_locked), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "abort"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsWritableStreamPrototypeFunction_abort), (intptr_t)(0) } },
+ { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsWritableStreamPrototypeFunction_close), (intptr_t)(0) } },
+ { "getWriter"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsWritableStreamPrototypeFunction_getWriter), (intptr_t)(0) } },
+};
+
+const ClassInfo JSWritableStreamPrototype::s_info = { "WritableStream"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWritableStreamPrototype) };
+
+void JSWritableStreamPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSWritableStream::info(), JSWritableStreamPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSWritableStream::s_info = { "WritableStream"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWritableStream) };
+
+JSWritableStream::JSWritableStream(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WritableStream>&& impl)
+ : JSDOMWrapper<WritableStream>(structure, globalObject, WTFMove(impl))
+{
+}
+
+void JSWritableStream::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+ // static_assert(!std::is_base_of<ActiveDOMObject, WritableStream>::value, "Interface is not marked as [ActiveDOMObject] even though implementation class subclasses ActiveDOMObject.");
+}
+
+JSObject* JSWritableStream::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSWritableStreamPrototype::create(vm, &globalObject, JSWritableStreamPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSWritableStream::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSWritableStream>(vm, globalObject);
+}
+
+JSValue JSWritableStream::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSWritableStreamDOMConstructor, DOMConstructorID::WritableStream>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSWritableStream::destroy(JSC::JSCell* cell)
+{
+ JSWritableStream* thisObject = static_cast<JSWritableStream*>(cell);
+ thisObject->JSWritableStream::~JSWritableStream();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsWritableStreamConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSWritableStreamPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSWritableStream::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+static inline JSValue jsWritableStream_lockedGetter(JSGlobalObject& lexicalGlobalObject, JSWritableStream& thisObject)
+{
+ auto& vm = JSC::getVM(&lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto& impl = thisObject.wrapped();
+ RELEASE_AND_RETURN(throwScope, (toJS<IDLBoolean>(lexicalGlobalObject, throwScope, impl.locked())));
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsWritableStream_locked, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<JSWritableStream>::get<jsWritableStream_lockedGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSC::EncodedJSValue jsWritableStreamPrototypeFunction_abortBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperationReturningPromise<JSWritableStream>::ClassParameter castedThis)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ RELEASE_AND_RETURN(throwScope, (JSValue::encode(castedThis->abort(*lexicalGlobalObject, *callFrame))));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsWritableStreamPrototypeFunction_abort, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperationReturningPromise<JSWritableStream>::callReturningOwnPromise<jsWritableStreamPrototypeFunction_abortBody>(*lexicalGlobalObject, *callFrame, "abort");
+}
+
+static inline JSC::EncodedJSValue jsWritableStreamPrototypeFunction_closeBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperationReturningPromise<JSWritableStream>::ClassParameter castedThis)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ RELEASE_AND_RETURN(throwScope, (JSValue::encode(castedThis->close(*lexicalGlobalObject, *callFrame))));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsWritableStreamPrototypeFunction_close, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperationReturningPromise<JSWritableStream>::callReturningOwnPromise<jsWritableStreamPrototypeFunction_closeBody>(*lexicalGlobalObject, *callFrame, "close");
+}
+
+static inline JSC::EncodedJSValue jsWritableStreamPrototypeFunction_getWriterBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSWritableStream>::ClassParameter castedThis)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ RELEASE_AND_RETURN(throwScope, (JSValue::encode(castedThis->getWriter(*lexicalGlobalObject, *callFrame))));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsWritableStreamPrototypeFunction_getWriter, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperation<JSWritableStream>::call<jsWritableStreamPrototypeFunction_getWriterBody>(*lexicalGlobalObject, *callFrame, "getWriter");
+}
+
+JSC::GCClient::IsoSubspace* JSWritableStream::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSWritableStream, UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForWritableStream.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForWritableStream = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForWritableStream.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForWritableStream = WTFMove(space); });
+}
+
+void JSWritableStream::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSWritableStream*>(cell);
+ analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
+ if (thisObject->scriptExecutionContext())
+ analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ Base::analyzeHeap(cell, analyzer);
+}
+
+bool JSWritableStreamOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, AbstractSlotVisitor& visitor, const char** reason)
+{
+ UNUSED_PARAM(handle);
+ UNUSED_PARAM(visitor);
+ UNUSED_PARAM(reason);
+ return false;
+}
+
+void JSWritableStreamOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
+{
+ auto* jsWritableStream = static_cast<JSWritableStream*>(handle.slot()->asCell());
+ auto& world = *static_cast<DOMWrapperWorld*>(context);
+ uncacheWrapper(world, &jsWritableStream->wrapped(), jsWritableStream);
+}
+
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<WritableStream>&& impl)
+{
+ return createWrapper<WritableStream>(globalObject, WTFMove(impl));
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, WritableStream& impl)
+{
+ return wrap(lexicalGlobalObject, globalObject, impl);
+}
+
+WritableStream* JSWritableStream::toWrapped(JSC::VM&, JSC::JSValue value)
+{
+ if (auto* wrapper = jsDynamicCast<JSWritableStream*>(value))
+ return &wrapper->wrapped();
+ return nullptr;
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSWritableStream.dep b/src/javascript/jsc/bindings/webcore/JSWritableStream.dep
new file mode 100644
index 000000000..d936b4581
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWritableStream.dep
@@ -0,0 +1 @@
+JSWritableStream.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSWritableStream.h b/src/javascript/jsc/bindings/webcore/JSWritableStream.h
new file mode 100644
index 000000000..d8b971645
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWritableStream.h
@@ -0,0 +1,98 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+#include "WritableStream.h"
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+class JSWritableStream : public JSDOMWrapper<WritableStream> {
+public:
+ using Base = JSDOMWrapper<WritableStream>;
+ static JSWritableStream* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<WritableStream>&& impl)
+ {
+ JSWritableStream* ptr = new (NotNull, JSC::allocateCell<JSWritableStream>(globalObject->vm())) JSWritableStream(structure, *globalObject, WTFMove(impl));
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static WritableStream* toWrapped(JSC::VM&, JSC::JSValue);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+
+ // Custom functions
+ JSC::JSValue abort(JSC::JSGlobalObject&, JSC::CallFrame&);
+ JSC::JSValue close(JSC::JSGlobalObject&, JSC::CallFrame&);
+ JSC::JSValue getWriter(JSC::JSGlobalObject&, JSC::CallFrame&);
+protected:
+ JSWritableStream(JSC::Structure*, JSDOMGlobalObject&, Ref<WritableStream>&&);
+
+ void finishCreation(JSC::VM&);
+};
+
+class JSWritableStreamOwner final : public JSC::WeakHandleOwner {
+public:
+ bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::AbstractSlotVisitor&, const char**) final;
+ void finalize(JSC::Handle<JSC::Unknown>, void* context) final;
+};
+
+inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, WritableStream*)
+{
+ static NeverDestroyed<JSWritableStreamOwner> owner;
+ return &owner.get();
+}
+
+inline void* wrapperKey(WritableStream* wrappableObject)
+{
+ return wrappableObject;
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject*, JSDOMGlobalObject*, WritableStream&);
+inline JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, WritableStream* impl) { return impl ? toJS(lexicalGlobalObject, globalObject, *impl) : JSC::jsNull(); }
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<WritableStream>&&);
+inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, RefPtr<WritableStream>&& impl) { return impl ? toJSNewlyCreated(lexicalGlobalObject, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
+
+template<> struct JSDOMWrapperConverterTraits<WritableStream> {
+ using WrapperClass = JSWritableStream;
+ using ToWrappedReturnType = WritableStream*;
+};
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultController.cpp b/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultController.cpp
new file mode 100644
index 000000000..fd4a50e3c
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultController.cpp
@@ -0,0 +1,180 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSWritableStreamDefaultController.h"
+
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMBinding.h"
+#include "JSDOMBuiltinConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+#include "WebCoreJSClientData.h"
+#include "WritableStreamDefaultControllerBuiltins.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsWritableStreamDefaultControllerConstructor);
+
+class JSWritableStreamDefaultControllerPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSWritableStreamDefaultControllerPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSWritableStreamDefaultControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSWritableStreamDefaultControllerPrototype>(vm)) JSWritableStreamDefaultControllerPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSWritableStreamDefaultControllerPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSWritableStreamDefaultControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSWritableStreamDefaultControllerPrototype, JSWritableStreamDefaultControllerPrototype::Base);
+
+using JSWritableStreamDefaultControllerDOMConstructor = JSDOMBuiltinConstructor<JSWritableStreamDefaultController>;
+
+template<> const ClassInfo JSWritableStreamDefaultControllerDOMConstructor::s_info = { "WritableStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWritableStreamDefaultControllerDOMConstructor) };
+
+template<> JSValue JSWritableStreamDefaultControllerDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSWritableStreamDefaultControllerDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "WritableStreamDefaultController"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSWritableStreamDefaultController::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+template<> FunctionExecutable* JSWritableStreamDefaultControllerDOMConstructor::initializeExecutable(VM& vm)
+{
+ return writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeGenerator(vm);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSWritableStreamDefaultControllerPrototypeTableValues[] =
+{
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWritableStreamDefaultControllerConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "error"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(writableStreamDefaultControllerErrorCodeGenerator), (intptr_t) (0) } },
+};
+
+const ClassInfo JSWritableStreamDefaultControllerPrototype::s_info = { "WritableStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWritableStreamDefaultControllerPrototype) };
+
+void JSWritableStreamDefaultControllerPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSWritableStreamDefaultController::info(), JSWritableStreamDefaultControllerPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSWritableStreamDefaultController::s_info = { "WritableStreamDefaultController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWritableStreamDefaultController) };
+
+JSWritableStreamDefaultController::JSWritableStreamDefaultController(Structure* structure, JSDOMGlobalObject& globalObject)
+ : JSDOMObject(structure, globalObject) { }
+
+void JSWritableStreamDefaultController::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+}
+
+JSObject* JSWritableStreamDefaultController::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSWritableStreamDefaultControllerPrototype::create(vm, &globalObject, JSWritableStreamDefaultControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSWritableStreamDefaultController::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSWritableStreamDefaultController>(vm, globalObject);
+}
+
+JSValue JSWritableStreamDefaultController::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSWritableStreamDefaultControllerDOMConstructor, DOMConstructorID::WritableStreamDefaultController>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSWritableStreamDefaultController::destroy(JSC::JSCell* cell)
+{
+ JSWritableStreamDefaultController* thisObject = static_cast<JSWritableStreamDefaultController*>(cell);
+ thisObject->JSWritableStreamDefaultController::~JSWritableStreamDefaultController();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsWritableStreamDefaultControllerConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSWritableStreamDefaultControllerPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSWritableStreamDefaultController::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+JSC::GCClient::IsoSubspace* JSWritableStreamDefaultController::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSWritableStreamDefaultController, UseCustomHeapCellType::No>(vm,
+ [] (auto& spaces) { return spaces.m_clientSubspaceForWritableStreamDefaultController.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForWritableStreamDefaultController = WTFMove(space); },
+ [] (auto& spaces) { return spaces.m_subspaceForWritableStreamDefaultController.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_subspaceForWritableStreamDefaultController = WTFMove(space); }
+ );
+}
+
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultController.dep b/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultController.dep
new file mode 100644
index 000000000..a1ac70d47
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultController.dep
@@ -0,0 +1 @@
+JSWritableStreamDefaultController.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultController.h b/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultController.h
new file mode 100644
index 000000000..8da0be568
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultController.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+
+namespace WebCore {
+
+class JSWritableStreamDefaultController : public JSDOMObject {
+public:
+ using Base = JSDOMObject;
+ static JSWritableStreamDefaultController* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+ {
+ JSWritableStreamDefaultController* ptr = new (NotNull, JSC::allocateCell<JSWritableStreamDefaultController>(globalObject->vm())) JSWritableStreamDefaultController(structure, *globalObject);
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+protected:
+ JSWritableStreamDefaultController(JSC::Structure*, JSDOMGlobalObject&);
+
+ void finishCreation(JSC::VM&);
+};
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultWriter.cpp b/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultWriter.cpp
new file mode 100644
index 000000000..4a5eb707d
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultWriter.cpp
@@ -0,0 +1,187 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSWritableStreamDefaultWriter.h"
+
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+#include "JSDOMBinding.h"
+#include "JSDOMBuiltinConstructor.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+#include "WebCoreJSClientData.h"
+#include "WritableStreamDefaultWriterBuiltins.h"
+#include <JavaScriptCore/FunctionPrototype.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsWritableStreamDefaultWriterConstructor);
+
+class JSWritableStreamDefaultWriterPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSWritableStreamDefaultWriterPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSWritableStreamDefaultWriterPrototype* ptr = new (NotNull, JSC::allocateCell<JSWritableStreamDefaultWriterPrototype>(vm)) JSWritableStreamDefaultWriterPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSWritableStreamDefaultWriterPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSWritableStreamDefaultWriterPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSWritableStreamDefaultWriterPrototype, JSWritableStreamDefaultWriterPrototype::Base);
+
+using JSWritableStreamDefaultWriterDOMConstructor = JSDOMBuiltinConstructor<JSWritableStreamDefaultWriter>;
+
+template<> const ClassInfo JSWritableStreamDefaultWriterDOMConstructor::s_info = { "WritableStreamDefaultWriter"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWritableStreamDefaultWriterDOMConstructor) };
+
+template<> JSValue JSWritableStreamDefaultWriterDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSWritableStreamDefaultWriterDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(1), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "WritableStreamDefaultWriter"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSWritableStreamDefaultWriter::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+template<> FunctionExecutable* JSWritableStreamDefaultWriterDOMConstructor::initializeExecutable(VM& vm)
+{
+ return writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeGenerator(vm);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSWritableStreamDefaultWriterPrototypeTableValues[] =
+{
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsWritableStreamDefaultWriterConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "closed"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(writableStreamDefaultWriterClosedCodeGenerator), (intptr_t) (0) } },
+ { "desiredSize"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(writableStreamDefaultWriterDesiredSizeCodeGenerator), (intptr_t) (0) } },
+ { "ready"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(writableStreamDefaultWriterReadyCodeGenerator), (intptr_t) (0) } },
+ { "abort"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(writableStreamDefaultWriterAbortCodeGenerator), (intptr_t) (0) } },
+ { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(writableStreamDefaultWriterCloseCodeGenerator), (intptr_t) (0) } },
+ { "releaseLock"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(writableStreamDefaultWriterReleaseLockCodeGenerator), (intptr_t) (0) } },
+ { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(writableStreamDefaultWriterWriteCodeGenerator), (intptr_t) (0) } },
+};
+
+const ClassInfo JSWritableStreamDefaultWriterPrototype::s_info = { "WritableStreamDefaultWriter"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWritableStreamDefaultWriterPrototype) };
+
+void JSWritableStreamDefaultWriterPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSWritableStreamDefaultWriter::info(), JSWritableStreamDefaultWriterPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSWritableStreamDefaultWriter::s_info = { "WritableStreamDefaultWriter"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWritableStreamDefaultWriter) };
+
+JSWritableStreamDefaultWriter::JSWritableStreamDefaultWriter(Structure* structure, JSDOMGlobalObject& globalObject)
+ : JSDOMObject(structure, globalObject) { }
+
+void JSWritableStreamDefaultWriter::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+}
+
+JSObject* JSWritableStreamDefaultWriter::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSWritableStreamDefaultWriterPrototype::create(vm, &globalObject, JSWritableStreamDefaultWriterPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSWritableStreamDefaultWriter::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSWritableStreamDefaultWriter>(vm, globalObject);
+}
+
+JSValue JSWritableStreamDefaultWriter::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSWritableStreamDefaultWriterDOMConstructor, DOMConstructorID::WritableStreamDefaultWriter>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSWritableStreamDefaultWriter::destroy(JSC::JSCell* cell)
+{
+ JSWritableStreamDefaultWriter* thisObject = static_cast<JSWritableStreamDefaultWriter*>(cell);
+ thisObject->JSWritableStreamDefaultWriter::~JSWritableStreamDefaultWriter();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsWritableStreamDefaultWriterConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSWritableStreamDefaultWriterPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSWritableStreamDefaultWriter::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+JSC::GCClient::IsoSubspace* JSWritableStreamDefaultWriter::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSWritableStreamDefaultWriter, UseCustomHeapCellType::No>(vm,
+ [] (auto& spaces) { return spaces.m_clientSubspaceForWritableStreamDefaultWriter.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForWritableStreamDefaultWriter = WTFMove(space); },
+ [] (auto& spaces) { return spaces.m_subspaceForWritableStreamDefaultWriter.get(); },
+ [] (auto& spaces, auto&& space) { spaces.m_subspaceForWritableStreamDefaultWriter = WTFMove(space); }
+ );
+}
+
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultWriter.dep b/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultWriter.dep
new file mode 100644
index 000000000..3016ea662
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultWriter.dep
@@ -0,0 +1 @@
+JSWritableStreamDefaultWriter.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultWriter.h b/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultWriter.h
new file mode 100644
index 000000000..bc13fb8c1
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWritableStreamDefaultWriter.h
@@ -0,0 +1,64 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+
+namespace WebCore {
+
+class JSWritableStreamDefaultWriter : public JSDOMObject {
+public:
+ using Base = JSDOMObject;
+ static JSWritableStreamDefaultWriter* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject)
+ {
+ JSWritableStreamDefaultWriter* ptr = new (NotNull, JSC::allocateCell<JSWritableStreamDefaultWriter>(globalObject->vm())) JSWritableStreamDefaultWriter(structure, *globalObject);
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+protected:
+ JSWritableStreamDefaultWriter(JSC::Structure*, JSDOMGlobalObject&);
+
+ void finishCreation(JSC::VM&);
+};
+
+
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/JSWritableStreamSink.cpp b/src/javascript/jsc/bindings/webcore/JSWritableStreamSink.cpp
new file mode 100644
index 000000000..ffc2816f5
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWritableStreamSink.cpp
@@ -0,0 +1,248 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "JSWritableStreamSink.h"
+
+#include "ActiveDOMObject.h"
+#include "DOMPromiseProxy.h"
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "IDLTypes.h"
+#include "JSDOMBinding.h"
+#include "JSDOMConvertAny.h"
+#include "JSDOMConvertBase.h"
+#include "JSDOMConvertPromise.h"
+#include "JSDOMConvertStrings.h"
+#include "JSDOMExceptionHandling.h"
+#include "JSDOMGlobalObject.h"
+#include "JSDOMOperation.h"
+#include "JSDOMOperationReturningPromise.h"
+#include "JSDOMWrapperCache.h"
+#include "ScriptExecutionContext.h"
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/HeapAnalyzer.h>
+#include <JavaScriptCore/JSCInlines.h>
+#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
+#include <JavaScriptCore/SlotVisitorMacros.h>
+#include <JavaScriptCore/SubspaceInlines.h>
+#include <wtf/GetPtr.h>
+#include <wtf/PointerPreparations.h>
+#include <wtf/URL.h>
+
+namespace WebCore {
+using namespace JSC;
+
+// Functions
+
+static JSC_DECLARE_HOST_FUNCTION(jsWritableStreamSinkPrototypeFunction_write);
+static JSC_DECLARE_HOST_FUNCTION(jsWritableStreamSinkPrototypeFunction_close);
+static JSC_DECLARE_HOST_FUNCTION(jsWritableStreamSinkPrototypeFunction_error);
+
+class JSWritableStreamSinkPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSWritableStreamSinkPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSWritableStreamSinkPrototype* ptr = new (NotNull, JSC::allocateCell<JSWritableStreamSinkPrototype>(vm)) JSWritableStreamSinkPrototype(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSWritableStreamSinkPrototype, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSWritableStreamSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSWritableStreamSinkPrototype, JSWritableStreamSinkPrototype::Base);
+
+/* Hash table for prototype */
+
+static const HashTableValue JSWritableStreamSinkPrototypeTableValues[] = {
+ { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsWritableStreamSinkPrototypeFunction_write), (intptr_t)(1) } },
+ { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsWritableStreamSinkPrototypeFunction_close), (intptr_t)(0) } },
+ { "error"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsWritableStreamSinkPrototypeFunction_error), (intptr_t)(1) } },
+};
+
+const ClassInfo JSWritableStreamSinkPrototype::s_info = { "WritableStreamSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWritableStreamSinkPrototype) };
+
+void JSWritableStreamSinkPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSWritableStreamSink::info(), JSWritableStreamSinkPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSWritableStreamSink::s_info = { "WritableStreamSink"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSWritableStreamSink) };
+
+JSWritableStreamSink::JSWritableStreamSink(Structure* structure, JSDOMGlobalObject& globalObject, Ref<WritableStreamSink>&& impl)
+ : JSDOMWrapper<WritableStreamSink>(structure, globalObject, WTFMove(impl))
+{
+}
+
+void JSWritableStreamSink::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+ // static_assert(!std::is_base_of<ActiveDOMObject, WritableStreamSink>::value, "Interface is not marked as [ActiveDOMObject] even though implementation class subclasses ActiveDOMObject.");
+}
+
+JSObject* JSWritableStreamSink::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSWritableStreamSinkPrototype::create(vm, &globalObject, JSWritableStreamSinkPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSWritableStreamSink::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSWritableStreamSink>(vm, globalObject);
+}
+
+void JSWritableStreamSink::destroy(JSC::JSCell* cell)
+{
+ JSWritableStreamSink* thisObject = static_cast<JSWritableStreamSink*>(cell);
+ thisObject->JSWritableStreamSink::~JSWritableStreamSink();
+}
+
+static inline JSC::EncodedJSValue jsWritableStreamSinkPrototypeFunction_writeBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperationReturningPromise<JSWritableStreamSink>::ClassParameter castedThis, Ref<DeferredPromise>&& promise)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ auto& impl = castedThis->wrapped();
+ if (UNLIKELY(callFrame->argumentCount() < 1))
+ return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
+ auto* context = jsCast<JSDOMGlobalObject*>(lexicalGlobalObject)->scriptExecutionContext();
+ if (UNLIKELY(!context))
+ return JSValue::encode(jsUndefined());
+ EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
+ auto value = convert<IDLAny>(*lexicalGlobalObject, argument0.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLPromise<IDLUndefined>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, [&]() -> decltype(auto) { return impl.write(*context, WTFMove(value), WTFMove(promise)); })));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsWritableStreamSinkPrototypeFunction_write, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperationReturningPromise<JSWritableStreamSink>::call<jsWritableStreamSinkPrototypeFunction_writeBody>(*lexicalGlobalObject, *callFrame, "write");
+}
+
+static inline JSC::EncodedJSValue jsWritableStreamSinkPrototypeFunction_closeBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSWritableStreamSink>::ClassParameter castedThis)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ auto& impl = castedThis->wrapped();
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.close(); })));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsWritableStreamSinkPrototypeFunction_close, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperation<JSWritableStreamSink>::call<jsWritableStreamSinkPrototypeFunction_closeBody>(*lexicalGlobalObject, *callFrame, "close");
+}
+
+static inline JSC::EncodedJSValue jsWritableStreamSinkPrototypeFunction_errorBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSWritableStreamSink>::ClassParameter castedThis)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ auto& impl = castedThis->wrapped();
+ if (UNLIKELY(callFrame->argumentCount() < 1))
+ return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
+ EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
+ auto message = convert<IDLDOMString>(*lexicalGlobalObject, argument0.value());
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.error(WTFMove(message)); })));
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsWritableStreamSinkPrototypeFunction_error, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperation<JSWritableStreamSink>::call<jsWritableStreamSinkPrototypeFunction_errorBody>(*lexicalGlobalObject, *callFrame, "error");
+}
+
+JSC::GCClient::IsoSubspace* JSWritableStreamSink::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSWritableStreamSink, UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForWritableStreamSink.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForWritableStreamSink = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForWritableStreamSink.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForWritableStreamSink = WTFMove(space); });
+}
+
+void JSWritableStreamSink::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSWritableStreamSink*>(cell);
+ analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
+ if (thisObject->scriptExecutionContext())
+ analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ Base::analyzeHeap(cell, analyzer);
+}
+
+bool JSWritableStreamSinkOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, AbstractSlotVisitor& visitor, const char** reason)
+{
+ UNUSED_PARAM(handle);
+ UNUSED_PARAM(visitor);
+ UNUSED_PARAM(reason);
+ return false;
+}
+
+void JSWritableStreamSinkOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
+{
+ auto* jsWritableStreamSink = static_cast<JSWritableStreamSink*>(handle.slot()->asCell());
+ auto& world = *static_cast<DOMWrapperWorld*>(context);
+ uncacheWrapper(world, &jsWritableStreamSink->wrapped(), jsWritableStreamSink);
+}
+
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<WritableStreamSink>&& impl)
+{
+ return createWrapper<WritableStreamSink>(globalObject, WTFMove(impl));
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, WritableStreamSink& impl)
+{
+ return wrap(lexicalGlobalObject, globalObject, impl);
+}
+
+WritableStreamSink* JSWritableStreamSink::toWrapped(JSC::VM&, JSC::JSValue value)
+{
+ if (auto* wrapper = jsDynamicCast<JSWritableStreamSink*>(value))
+ return &wrapper->wrapped();
+ return nullptr;
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSWritableStreamSink.dep b/src/javascript/jsc/bindings/webcore/JSWritableStreamSink.dep
new file mode 100644
index 000000000..c1891fdd8
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWritableStreamSink.dep
@@ -0,0 +1 @@
+JSWritableStreamSink.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSWritableStreamSink.h b/src/javascript/jsc/bindings/webcore/JSWritableStreamSink.h
new file mode 100644
index 000000000..7537792a2
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSWritableStreamSink.h
@@ -0,0 +1,92 @@
+/*
+ This file is part of the WebKit open source project.
+ This file has been generated by generate-bindings.pl. DO NOT MODIFY!
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#pragma once
+
+#include "JSDOMWrapper.h"
+#include "WritableStreamSink.h"
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+class JSWritableStreamSink : public JSDOMWrapper<WritableStreamSink> {
+public:
+ using Base = JSDOMWrapper<WritableStreamSink>;
+ static JSWritableStreamSink* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<WritableStreamSink>&& impl)
+ {
+ JSWritableStreamSink* ptr = new (NotNull, JSC::allocateCell<JSWritableStreamSink>(globalObject->vm())) JSWritableStreamSink(structure, *globalObject, WTFMove(impl));
+ ptr->finishCreation(globalObject->vm());
+ return ptr;
+ }
+
+ static JSC::JSObject* createPrototype(JSC::VM&, JSDOMGlobalObject&);
+ static JSC::JSObject* prototype(JSC::VM&, JSDOMGlobalObject&);
+ static WritableStreamSink* toWrapped(JSC::VM&, JSC::JSValue);
+ static void destroy(JSC::JSCell*);
+
+ DECLARE_INFO;
+
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info(), JSC::NonArray);
+ }
+
+ template<typename, JSC::SubspaceAccess mode> static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ if constexpr (mode == JSC::SubspaceAccess::Concurrently)
+ return nullptr;
+ return subspaceForImpl(vm);
+ }
+ static JSC::GCClient::IsoSubspace* subspaceForImpl(JSC::VM& vm);
+ static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&);
+protected:
+ JSWritableStreamSink(JSC::Structure*, JSDOMGlobalObject&, Ref<WritableStreamSink>&&);
+
+ void finishCreation(JSC::VM&);
+};
+
+class JSWritableStreamSinkOwner final : public JSC::WeakHandleOwner {
+public:
+ bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::AbstractSlotVisitor&, const char**) final;
+ void finalize(JSC::Handle<JSC::Unknown>, void* context) final;
+};
+
+inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, WritableStreamSink*)
+{
+ static NeverDestroyed<JSWritableStreamSinkOwner> owner;
+ return &owner.get();
+}
+
+inline void* wrapperKey(WritableStreamSink* wrappableObject)
+{
+ return wrappableObject;
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject*, JSDOMGlobalObject*, WritableStreamSink&);
+inline JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, WritableStreamSink* impl) { return impl ? toJS(lexicalGlobalObject, globalObject, *impl) : JSC::jsNull(); }
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<WritableStreamSink>&&);
+inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, RefPtr<WritableStreamSink>&& impl) { return impl ? toJSNewlyCreated(lexicalGlobalObject, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
+
+template<> struct JSDOMWrapperConverterTraits<WritableStreamSink> {
+ using WrapperClass = JSWritableStreamSink;
+ using ToWrappedReturnType = WritableStreamSink*;
+};
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/ReadableStream.cpp b/src/javascript/jsc/bindings/webcore/ReadableStream.cpp
new file mode 100644
index 000000000..1e8281a8b
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStream.cpp
@@ -0,0 +1,199 @@
+/*
+ * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. ``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 CANON INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ReadableStream.h"
+
+#include "Exception.h"
+#include "ExceptionCode.h"
+#include "JSDOMConvertSequences.h"
+#include "JSReadableStreamSink.h"
+#include "JSReadableStreamSource.h"
+#include "WebCoreJSClientData.h"
+
+
+namespace WebCore {
+using namespace JSC;
+
+static inline ExceptionOr<JSObject*> invokeConstructor(JSC::JSGlobalObject& lexicalGlobalObject, const JSC::Identifier& identifier, const Function<void(MarkedArgumentBuffer&, JSC::JSGlobalObject&, JSDOMGlobalObject&)>& buildArguments)
+{
+ VM& vm = lexicalGlobalObject.vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject);
+
+ auto constructorValue = globalObject.get(&lexicalGlobalObject, identifier);
+ EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+ RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
+ auto constructor = JSC::asObject(constructorValue);
+
+ auto constructData = JSC::getConstructData(constructor);
+ ASSERT(constructData.type != CallData::Type::None);
+
+ MarkedArgumentBuffer args;
+ buildArguments(args, lexicalGlobalObject, globalObject);
+ ASSERT(!args.hasOverflowed());
+
+ JSObject* object = JSC::construct(&lexicalGlobalObject, constructor, constructData, args);
+ ASSERT(!!scope.exception() == !object);
+ EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+ RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
+
+ return object;
+}
+
+ExceptionOr<Ref<ReadableStream>> ReadableStream::create(JSC::JSGlobalObject& lexicalGlobalObject, RefPtr<ReadableStreamSource>&& source)
+{
+ auto& builtinNames = WebCore::builtinNames(lexicalGlobalObject.vm());
+
+ auto objectOrException = invokeConstructor(lexicalGlobalObject, builtinNames.ReadableStreamPrivateName(), [&source](auto& args, auto& lexicalGlobalObject, auto& globalObject) {
+ args.append(source ? toJSNewlyCreated(&lexicalGlobalObject, &globalObject, source.releaseNonNull()) : JSC::jsUndefined());
+ });
+
+ if (objectOrException.hasException())
+ return objectOrException.releaseException();
+
+ return create(*JSC::jsCast<JSDOMGlobalObject*>(&lexicalGlobalObject), *jsCast<JSReadableStream*>(objectOrException.releaseReturnValue()));
+}
+
+static inline std::optional<JSC::JSValue> invokeReadableStreamFunction(JSC::JSGlobalObject& lexicalGlobalObject, const JSC::Identifier& identifier, JSC::JSValue thisValue, const JSC::MarkedArgumentBuffer& arguments)
+{
+ JSC::VM& vm = lexicalGlobalObject.vm();
+ JSC::JSLockHolder lock(vm);
+
+ auto function = lexicalGlobalObject.get(&lexicalGlobalObject, identifier);
+ ASSERT(function.isCallable());
+
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+ auto callData = JSC::getCallData(function);
+ auto result = call(&lexicalGlobalObject, function, callData, thisValue, arguments);
+ EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+ if (scope.exception())
+ return { };
+ return result;
+}
+
+void ReadableStream::pipeTo(ReadableStreamSink& sink)
+{
+ auto& lexicalGlobalObject = *m_globalObject;
+ auto* clientData = static_cast<JSVMClientData*>(lexicalGlobalObject.vm().clientData);
+ auto& privateName = clientData->builtinFunctions().readableStreamInternalsBuiltins().readableStreamPipeToPrivateName();
+
+ MarkedArgumentBuffer arguments;
+ arguments.append(readableStream());
+ arguments.append(toJS(&lexicalGlobalObject, m_globalObject.get(), sink));
+ ASSERT(!arguments.hasOverflowed());
+ invokeReadableStreamFunction(lexicalGlobalObject, privateName, JSC::jsUndefined(), arguments);
+}
+
+std::optional<std::pair<Ref<ReadableStream>, Ref<ReadableStream>>> ReadableStream::tee()
+{
+ auto& lexicalGlobalObject = *m_globalObject;
+ auto* clientData = static_cast<JSVMClientData*>(lexicalGlobalObject.vm().clientData);
+ auto& privateName = clientData->builtinFunctions().readableStreamInternalsBuiltins().readableStreamTeePrivateName();
+
+ MarkedArgumentBuffer arguments;
+ arguments.append(readableStream());
+ arguments.append(JSC::jsBoolean(true));
+ ASSERT(!arguments.hasOverflowed());
+ auto returnedValue = invokeReadableStreamFunction(lexicalGlobalObject, privateName, JSC::jsUndefined(), arguments);
+ if (!returnedValue)
+ return { };
+
+ auto results = Detail::SequenceConverter<IDLInterface<ReadableStream>>::convert(lexicalGlobalObject, *returnedValue);
+
+ ASSERT(results.size() == 2);
+ return std::make_pair(results[0].releaseNonNull(), results[1].releaseNonNull());
+}
+
+void ReadableStream::lock()
+{
+ auto& builtinNames = WebCore::builtinNames(m_globalObject->vm());
+ invokeConstructor(*m_globalObject, builtinNames.ReadableStreamDefaultReaderPrivateName(), [this](auto& args, auto&, auto&) {
+ args.append(readableStream());
+ });
+}
+
+void ReadableStream::cancel(const Exception& exception)
+{
+ auto& lexicalGlobalObject = *m_globalObject;
+ auto* clientData = static_cast<JSVMClientData*>(lexicalGlobalObject.vm().clientData);
+ auto& privateName = clientData->builtinFunctions().readableStreamInternalsBuiltins().readableStreamCancelPrivateName();
+
+ auto& vm = lexicalGlobalObject.vm();
+ JSC::JSLockHolder lock(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+ auto value = createDOMException(&lexicalGlobalObject, exception.code(), exception.message());
+ if (UNLIKELY(scope.exception())) {
+ ASSERT(vm.hasPendingTerminationException());
+ return;
+ }
+
+ MarkedArgumentBuffer arguments;
+ arguments.append(readableStream());
+ arguments.append(value);
+ ASSERT(!arguments.hasOverflowed());
+ invokeReadableStreamFunction(lexicalGlobalObject, privateName, JSC::jsUndefined(), arguments);
+}
+
+static inline bool checkReadableStream(JSDOMGlobalObject& globalObject, JSReadableStream* readableStream, JSC::JSValue function)
+{
+ auto& lexicalGlobalObject = globalObject;
+
+ ASSERT(function);
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(readableStream);
+ ASSERT(!arguments.hasOverflowed());
+
+ auto& vm = lexicalGlobalObject.vm();
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+ auto callData = JSC::getCallData(function);
+ ASSERT(callData.type != JSC::CallData::Type::None);
+
+ auto result = call(&lexicalGlobalObject, function, callData, JSC::jsUndefined(), arguments);
+ EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+
+ return result.isTrue() || scope.exception();
+}
+
+bool ReadableStream::isLocked() const
+{
+ return checkReadableStream(*globalObject(), readableStream(), globalObject()->builtinInternalFunctions().readableStreamInternals().m_isReadableStreamLockedFunction.get());
+}
+
+bool ReadableStream::isDisturbed() const
+{
+ return checkReadableStream(*globalObject(), readableStream(), globalObject()->builtinInternalFunctions().readableStreamInternals().m_isReadableStreamDisturbedFunction.get());
+}
+
+bool ReadableStream::isDisturbed(JSGlobalObject& lexicalGlobalObject, JSValue value)
+{
+ auto& globalObject = *jsDynamicCast<JSDOMGlobalObject*>(&lexicalGlobalObject);
+ auto* readableStream = jsDynamicCast<JSReadableStream*>(value);
+
+ return checkReadableStream(globalObject, readableStream, globalObject.builtinInternalFunctions().readableStreamInternals().m_isReadableStreamDisturbedFunction.get());
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/ReadableStream.h b/src/javascript/jsc/bindings/webcore/ReadableStream.h
new file mode 100644
index 000000000..9c122934f
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStream.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2017-2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON INC. ``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 CANON INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "ExceptionOr.h"
+#include "JSDOMBinding.h"
+#include "JSDOMConvert.h"
+#include "JSDOMGuardedObject.h"
+#include "JSReadableStream.h"
+
+namespace WebCore {
+
+class ReadableStreamSink;
+class ReadableStreamSource;
+
+class ReadableStream final : public DOMGuarded<JSReadableStream> {
+public:
+ static Ref<ReadableStream> create(JSDOMGlobalObject& globalObject, JSReadableStream& readableStream) { return adoptRef(*new ReadableStream(globalObject, readableStream)); }
+
+ static ExceptionOr<Ref<ReadableStream>> create(JSC::JSGlobalObject&, RefPtr<ReadableStreamSource>&&);
+
+ WEBCORE_EXPORT static bool isDisturbed(JSC::JSGlobalObject&, JSC::JSValue);
+
+ std::optional<std::pair<Ref<ReadableStream>, Ref<ReadableStream>>> tee();
+
+ void cancel(const Exception&);
+ void lock();
+ void pipeTo(ReadableStreamSink&);
+ bool isLocked() const;
+ bool isDisturbed() const;
+
+ JSReadableStream* readableStream() const { return guarded(); }
+
+private:
+ ReadableStream(JSDOMGlobalObject& globalObject, JSReadableStream& readableStream) : DOMGuarded<JSReadableStream>(globalObject, readableStream) { }
+};
+
+struct JSReadableStreamWrapperConverter {
+ static RefPtr<ReadableStream> toWrapped(JSC::JSGlobalObject& lexicalGlobalObject, JSC::JSValue value)
+ {
+ auto* globalObject = JSC::jsDynamicCast<JSDOMGlobalObject*>(&lexicalGlobalObject);
+ if (!globalObject)
+ return nullptr;
+
+ auto* readableStream = JSC::jsDynamicCast<JSReadableStream*>(value);
+ if (!readableStream)
+ return nullptr;
+
+ return ReadableStream::create(*globalObject, *readableStream);
+ }
+};
+
+template<> struct JSDOMWrapperConverterTraits<ReadableStream> {
+ using WrapperClass = JSReadableStreamWrapperConverter;
+ using ToWrappedReturnType = RefPtr<ReadableStream>;
+ static constexpr bool needsState = true;
+};
+
+inline JSC::JSValue toJS(JSC::JSGlobalObject*, JSC::JSGlobalObject*, ReadableStream* stream)
+{
+ return stream ? stream->readableStream() : JSC::jsUndefined();
+}
+
+inline JSC::JSValue toJS(JSC::JSGlobalObject*, JSC::JSGlobalObject*, ReadableStream& stream)
+{
+ return stream.readableStream();
+}
+
+inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<ReadableStream>&& stream)
+{
+ return stream->readableStream();
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/ReadableStreamDefaultController.cpp b/src/javascript/jsc/bindings/webcore/ReadableStreamDefaultController.cpp
new file mode 100644
index 000000000..fc661b3ec
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStreamDefaultController.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2016 Canon Inc.
+ * Copyright (C) 2016-2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be 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.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON 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 CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+#include "ReadableStreamDefaultController.h"
+
+#include "WebCoreJSClientData.h"
+#include <JavaScriptCore/CatchScope.h>
+#include <JavaScriptCore/HeapInlines.h>
+#include <JavaScriptCore/IdentifierInlines.h>
+#include <JavaScriptCore/JSObjectInlines.h>
+
+namespace WebCore {
+
+static bool invokeReadableStreamDefaultControllerFunction(JSC::JSGlobalObject& lexicalGlobalObject, const JSC::Identifier& identifier, const JSC::MarkedArgumentBuffer& arguments)
+{
+ JSC::VM& vm = lexicalGlobalObject.vm();
+ JSC::JSLockHolder lock(vm);
+
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+ auto function = lexicalGlobalObject.get(&lexicalGlobalObject, identifier);
+
+ EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+ RETURN_IF_EXCEPTION(scope, false);
+
+ ASSERT(function.isCallable());
+
+ auto callData = JSC::getCallData(function);
+ call(&lexicalGlobalObject, function, callData, JSC::jsUndefined(), arguments);
+ EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+ return !scope.exception();
+}
+
+void ReadableStreamDefaultController::close()
+{
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(&jsController());
+
+ auto* clientData = static_cast<JSVMClientData*>(globalObject().vm().clientData);
+ auto& privateName = clientData->builtinFunctions().readableStreamInternalsBuiltins().readableStreamDefaultControllerClosePrivateName();
+
+ invokeReadableStreamDefaultControllerFunction(globalObject(), privateName, arguments);
+}
+
+
+void ReadableStreamDefaultController::error(const Exception& exception)
+{
+ JSC::JSGlobalObject& lexicalGlobalObject = this->globalObject();
+ auto& vm = lexicalGlobalObject.vm();
+ JSC::JSLockHolder lock(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+ auto value = createDOMException(&lexicalGlobalObject, exception.code(), exception.message());
+
+ if (UNLIKELY(scope.exception())) {
+ ASSERT(vm.hasPendingTerminationException());
+ return;
+ }
+
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(&jsController());
+ arguments.append(value);
+
+ auto* clientData = static_cast<JSVMClientData*>(vm.clientData);
+ auto& privateName = clientData->builtinFunctions().readableStreamInternalsBuiltins().readableStreamDefaultControllerErrorPrivateName();
+
+ invokeReadableStreamDefaultControllerFunction(globalObject(), privateName, arguments);
+}
+
+bool ReadableStreamDefaultController::enqueue(JSC::JSValue value)
+{
+ JSC::JSGlobalObject& lexicalGlobalObject = this->globalObject();
+ auto& vm = lexicalGlobalObject.vm();
+ JSC::JSLockHolder lock(vm);
+
+ JSC::MarkedArgumentBuffer arguments;
+ arguments.append(&jsController());
+ arguments.append(value);
+
+ auto* clientData = static_cast<JSVMClientData*>(lexicalGlobalObject.vm().clientData);
+ auto& privateName = clientData->builtinFunctions().readableStreamInternalsBuiltins().readableStreamDefaultControllerEnqueuePrivateName();
+
+ return invokeReadableStreamDefaultControllerFunction(globalObject(), privateName, arguments);
+}
+
+bool ReadableStreamDefaultController::enqueue(RefPtr<JSC::ArrayBuffer>&& buffer)
+{
+ if (!buffer) {
+ error(Exception { OutOfMemoryError });
+ return false;
+ }
+
+ JSC::JSGlobalObject& lexicalGlobalObject = this->globalObject();
+ auto& vm = lexicalGlobalObject.vm();
+ JSC::JSLockHolder lock(vm);
+ auto scope = DECLARE_CATCH_SCOPE(vm);
+ auto length = buffer->byteLength();
+ auto chunk = JSC::Uint8Array::create(WTFMove(buffer), 0, length);
+ auto value = toJS(&lexicalGlobalObject, &lexicalGlobalObject, chunk.get());
+
+ EXCEPTION_ASSERT(!scope.exception() || vm.hasPendingTerminationException());
+ RETURN_IF_EXCEPTION(scope, false);
+
+ return enqueue(value);
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/ReadableStreamDefaultController.h b/src/javascript/jsc/bindings/webcore/ReadableStreamDefaultController.h
new file mode 100644
index 000000000..884c0a9ac
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStreamDefaultController.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2016 Canon Inc.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be 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.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON 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 CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "JSDOMConvertBufferSource.h"
+#include "JSReadableStreamDefaultController.h"
+#include <JavaScriptCore/JSCJSValue.h>
+#include <JavaScriptCore/JSCJSValueInlines.h>
+#include <JavaScriptCore/TypedArrays.h>
+
+namespace WebCore {
+
+class ReadableStreamSource;
+
+class ReadableStreamDefaultController {
+public:
+ explicit ReadableStreamDefaultController(JSReadableStreamDefaultController* controller) : m_jsController(controller) { }
+
+ bool enqueue(RefPtr<JSC::ArrayBuffer>&&);
+ bool enqueue(JSC::JSValue);
+ void error(const Exception&);
+ void close();
+
+private:
+ JSReadableStreamDefaultController& jsController() const;
+
+ JSDOMGlobalObject& globalObject() const;
+
+ // The owner of ReadableStreamDefaultController is responsible to keep uncollected the JSReadableStreamDefaultController.
+ JSReadableStreamDefaultController* m_jsController { nullptr };
+};
+
+inline JSReadableStreamDefaultController& ReadableStreamDefaultController::jsController() const
+{
+ ASSERT(m_jsController);
+ return *m_jsController;
+}
+
+inline JSDOMGlobalObject& ReadableStreamDefaultController::globalObject() const
+{
+ ASSERT(m_jsController);
+ ASSERT(m_jsController->globalObject());
+ return *static_cast<JSDOMGlobalObject*>(m_jsController->globalObject());
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/ReadableStreamSink.cpp b/src/javascript/jsc/bindings/webcore/ReadableStreamSink.cpp
new file mode 100644
index 000000000..960756a28
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStreamSink.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ReadableStreamSink.h"
+
+#include "BufferSource.h"
+#include "DOMException.h"
+#include "ReadableStream.h"
+
+namespace WebCore {
+
+ReadableStreamToSharedBufferSink::ReadableStreamToSharedBufferSink(Callback&& callback)
+ : m_callback { WTFMove(callback) }
+{
+}
+
+void ReadableStreamToSharedBufferSink::pipeFrom(ReadableStream& stream)
+{
+ stream.pipeTo(*this);
+}
+
+void ReadableStreamToSharedBufferSink::enqueue(const BufferSource& buffer)
+{
+ if (!buffer.length())
+ return;
+
+ if (m_callback) {
+ Span chunk { buffer.data(), buffer.length() };
+ m_callback(&chunk);
+ }
+}
+
+void ReadableStreamToSharedBufferSink::close()
+{
+ if (m_callback)
+ m_callback(nullptr);
+}
+
+void ReadableStreamToSharedBufferSink::error(String&& message)
+{
+ if (auto callback = WTFMove(m_callback))
+ callback(Exception { TypeError, WTFMove(message) });
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/ReadableStreamSink.h b/src/javascript/jsc/bindings/webcore/ReadableStreamSink.h
new file mode 100644
index 000000000..fee988422
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStreamSink.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#pragma once
+
+#include "ExceptionOr.h"
+#include <wtf/Function.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Span.h>
+
+namespace WebCore {
+
+class BufferSource;
+class ReadableStream;
+
+class ReadableStreamSink : public RefCounted<ReadableStreamSink> {
+public:
+ virtual ~ReadableStreamSink() = default;
+
+ virtual void enqueue(const BufferSource&) = 0;
+ virtual void close() = 0;
+ virtual void error(String&&) = 0;
+};
+
+class ReadableStreamToSharedBufferSink final : public ReadableStreamSink {
+public:
+ using Callback = Function<void(ExceptionOr<Span<const uint8_t>*>&&)>;
+ static Ref<ReadableStreamToSharedBufferSink> create(Callback&& callback) { return adoptRef(*new ReadableStreamToSharedBufferSink(WTFMove(callback))); }
+ void pipeFrom(ReadableStream&);
+ void clearCallback() { m_callback = { }; }
+
+private:
+ explicit ReadableStreamToSharedBufferSink(Callback&&);
+
+ void enqueue(const BufferSource&) final;
+ void close() final;
+ void error(String&&) final;
+
+ Callback m_callback;
+};
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/ReadableStreamSource.cpp b/src/javascript/jsc/bindings/webcore/ReadableStreamSource.cpp
new file mode 100644
index 000000000..faa46c03b
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStreamSource.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+#include "ReadableStreamSource.h"
+
+namespace WebCore {
+
+ReadableStreamSource::~ReadableStreamSource() = default;
+
+void ReadableStreamSource::start(ReadableStreamDefaultController&& controller, DOMPromiseDeferred<void>&& promise)
+{
+ ASSERT(!m_promise);
+ m_promise = makeUnique<DOMPromiseDeferred<void>>(WTFMove(promise));
+ m_controller = WTFMove(controller);
+
+ setActive();
+ doStart();
+}
+
+void ReadableStreamSource::pull(DOMPromiseDeferred<void>&& promise)
+{
+ ASSERT(!m_promise);
+ ASSERT(m_controller);
+
+ m_promise = makeUnique<DOMPromiseDeferred<void>>(WTFMove(promise));
+
+ setActive();
+ doPull();
+}
+
+void ReadableStreamSource::startFinished()
+{
+ ASSERT(m_promise);
+ m_promise->resolve();
+ m_promise = nullptr;
+ setInactive();
+}
+
+void ReadableStreamSource::pullFinished()
+{
+ ASSERT(m_promise);
+ m_promise->resolve();
+ m_promise = nullptr;
+ setInactive();
+}
+
+void ReadableStreamSource::cancel(JSC::JSValue)
+{
+ clean();
+ doCancel();
+}
+
+void ReadableStreamSource::clean()
+{
+ if (m_promise) {
+ m_promise = nullptr;
+ setInactive();
+ }
+}
+
+void SimpleReadableStreamSource::doCancel()
+{
+ m_isCancelled = true;
+}
+
+void SimpleReadableStreamSource::close()
+{
+ if (!m_isCancelled)
+ controller().close();
+}
+
+void SimpleReadableStreamSource::enqueue(JSC::JSValue value)
+{
+ if (!m_isCancelled)
+ controller().enqueue(value);
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/ReadableStreamSource.h b/src/javascript/jsc/bindings/webcore/ReadableStreamSource.h
new file mode 100644
index 000000000..2438e1eaf
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStreamSource.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2016 Canon Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be 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.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON 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 CANON INC. AND ITS CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "JSDOMPromiseDeferred.h"
+#include "ReadableStreamDefaultController.h"
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+class ReadableStreamSource : public RefCounted<ReadableStreamSource> {
+public:
+ virtual ~ReadableStreamSource();
+
+ void start(ReadableStreamDefaultController&&, DOMPromiseDeferred<void>&&);
+ void pull(DOMPromiseDeferred<void>&&);
+ void cancel(JSC::JSValue);
+
+ bool isPulling() const { return !!m_promise; }
+
+protected:
+ ReadableStreamDefaultController& controller() { return m_controller.value(); }
+ const ReadableStreamDefaultController& controller() const { return m_controller.value(); }
+
+ void startFinished();
+ void pullFinished();
+ void cancelFinished();
+ void clean();
+
+ virtual void setActive() = 0;
+ virtual void setInactive() = 0;
+
+ virtual void doStart() = 0;
+ virtual void doPull() = 0;
+ virtual void doCancel() = 0;
+
+private:
+ std::unique_ptr<DOMPromiseDeferred<void>> m_promise;
+ std::optional<ReadableStreamDefaultController> m_controller;
+};
+
+class SimpleReadableStreamSource
+ : public ReadableStreamSource
+ , public CanMakeWeakPtr<SimpleReadableStreamSource> {
+public:
+ static Ref<SimpleReadableStreamSource> create() { return adoptRef(*new SimpleReadableStreamSource); }
+
+ void close();
+ void enqueue(JSC::JSValue);
+
+private:
+ SimpleReadableStreamSource() = default;
+
+ // ReadableStreamSource
+ void setActive() final { }
+ void setInactive() final { }
+ void doStart() final { }
+ void doPull() final { }
+ void doCancel() final;
+
+ bool m_isCancelled { false };
+};
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/StructuredClone.cpp b/src/javascript/jsc/bindings/webcore/StructuredClone.cpp
new file mode 100644
index 000000000..aabc9009c
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/StructuredClone.cpp
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "config.h"
+#include "StructuredClone.h"
+
+#include "JSDOMBinding.h"
+#include "JSDOMExceptionHandling.h"
+#include <JavaScriptCore/JSTypedArrays.h>
+
+namespace WebCore {
+using namespace JSC;
+
+enum class CloneMode {
+ Full,
+ Partial,
+};
+
+static EncodedJSValue cloneArrayBufferImpl(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame, CloneMode mode)
+{
+ VM& vm = lexicalGlobalObject->vm();
+
+ ASSERT(lexicalGlobalObject);
+ ASSERT(callFrame->argumentCount());
+ ASSERT(callFrame->lexicalGlobalObject(vm) == lexicalGlobalObject);
+
+ auto* buffer = toUnsharedArrayBuffer(vm, callFrame->uncheckedArgument(0));
+ if (!buffer) {
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ throwDataCloneError(*lexicalGlobalObject, scope);
+ return { };
+ }
+ if (mode == CloneMode::Partial) {
+ ASSERT(callFrame->argumentCount() == 3);
+ int srcByteOffset = static_cast<int>(callFrame->uncheckedArgument(1).toNumber(lexicalGlobalObject));
+ int srcLength = static_cast<int>(callFrame->uncheckedArgument(2).toNumber(lexicalGlobalObject));
+ return JSValue::encode(JSArrayBuffer::create(lexicalGlobalObject->vm(), lexicalGlobalObject->arrayBufferStructure(ArrayBufferSharingMode::Default), buffer->slice(srcByteOffset, srcByteOffset + srcLength)));
+ }
+ return JSValue::encode(JSArrayBuffer::create(lexicalGlobalObject->vm(), lexicalGlobalObject->arrayBufferStructure(ArrayBufferSharingMode::Default), ArrayBuffer::tryCreate(buffer->data(), buffer->byteLength())));
+}
+
+JSC_DEFINE_HOST_FUNCTION(cloneArrayBuffer, (JSGlobalObject* globalObject, CallFrame* callFrame))
+{
+ return cloneArrayBufferImpl(globalObject, callFrame, CloneMode::Partial);
+}
+
+JSC_DEFINE_HOST_FUNCTION(structuredCloneForStream, (JSGlobalObject* globalObject, CallFrame* callFrame))
+{
+ ASSERT(callFrame);
+ ASSERT(callFrame->argumentCount());
+
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ JSValue value = callFrame->uncheckedArgument(0);
+
+ if (value.inherits<JSArrayBuffer>())
+ RELEASE_AND_RETURN(scope, cloneArrayBufferImpl(globalObject, callFrame, CloneMode::Full));
+
+ if (value.inherits<JSArrayBufferView>()) {
+ auto* bufferView = jsCast<JSArrayBufferView*>(value);
+ ASSERT(bufferView);
+
+ auto* buffer = bufferView->unsharedBuffer();
+ if (!buffer) {
+ throwDataCloneError(*globalObject, scope);
+ return { };
+ }
+ auto bufferClone = ArrayBuffer::tryCreate(buffer->data(), buffer->byteLength());
+ Structure* structure = bufferView->structure();
+
+#define CLONE_TYPED_ARRAY(name) \
+ do { \
+ if (bufferView->inherits<JS##name##Array>()) \
+ RELEASE_AND_RETURN(scope, JSValue::encode(JS##name##Array::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length()))); \
+ } while (0);
+
+ FOR_EACH_TYPED_ARRAY_TYPE_EXCLUDING_DATA_VIEW(CLONE_TYPED_ARRAY)
+
+#undef CLONE_TYPED_ARRAY
+
+ if (value.inherits<JSDataView>())
+ RELEASE_AND_RETURN(scope, JSValue::encode(JSDataView::create(globalObject, structure, WTFMove(bufferClone), bufferView->byteOffset(), bufferView->length())));
+ }
+
+ throwTypeError(globalObject, scope, "structuredClone not implemented for non-ArrayBuffer / non-ArrayBufferView"_s);
+ return { };
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/StructuredClone.h b/src/javascript/jsc/bindings/webcore/StructuredClone.h
new file mode 100644
index 000000000..af14c0873
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/StructuredClone.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016-2020 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+namespace JSC {
+class CallFrame;
+class JSGlobalObject;
+using EncodedJSValue = int64_t;
+}
+
+namespace WebCore {
+
+JSC_DECLARE_HOST_FUNCTION(cloneArrayBuffer);
+JSC_DECLARE_HOST_FUNCTION(structuredCloneForStream);
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/WritableStream.cpp b/src/javascript/jsc/bindings/webcore/WritableStream.cpp
new file mode 100644
index 000000000..97d56b476
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/WritableStream.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WritableStream.h"
+
+#include "JSWritableStream.h"
+#include "JSWritableStreamSink.h"
+
+namespace WebCore {
+
+ExceptionOr<Ref<WritableStream>> WritableStream::create(JSC::JSGlobalObject& globalObject, std::optional<JSC::Strong<JSC::JSObject>>&& underlyingSink, std::optional<JSC::Strong<JSC::JSObject>>&& strategy)
+{
+ JSC::JSValue underlyingSinkValue = JSC::jsUndefined();
+ if (underlyingSink)
+ underlyingSinkValue = underlyingSink->get();
+
+ JSC::JSValue strategyValue = JSC::jsUndefined();
+ if (strategy)
+ strategyValue = strategy->get();
+
+ return create(globalObject, underlyingSinkValue, strategyValue);
+}
+
+ExceptionOr<Ref<WritableStream>> WritableStream::create(JSC::JSGlobalObject& globalObject, JSC::JSValue underlyingSink, JSC::JSValue strategy)
+{
+ auto result = InternalWritableStream::createFromUnderlyingSink(*JSC::jsCast<JSDOMGlobalObject*>(&globalObject), underlyingSink, strategy);
+ if (result.hasException())
+ return result.releaseException();
+
+ return adoptRef(*new WritableStream(result.releaseReturnValue()));
+}
+
+ExceptionOr<Ref<WritableStream>> WritableStream::create(JSDOMGlobalObject& globalObject, Ref<WritableStreamSink>&& sink)
+{
+ return create(globalObject, toJSNewlyCreated(&globalObject, &globalObject, WTFMove(sink)), JSC::jsUndefined());
+}
+
+Ref<WritableStream> WritableStream::create(Ref<InternalWritableStream>&& internalWritableStream)
+{
+ return adoptRef(*new WritableStream(WTFMove(internalWritableStream)));
+}
+
+WritableStream::WritableStream(Ref<InternalWritableStream>&& internalWritableStream)
+ : m_internalWritableStream(WTFMove(internalWritableStream))
+{
+}
+
+JSC::JSValue JSWritableStream::abort(JSC::JSGlobalObject& globalObject, JSC::CallFrame& callFrame)
+{
+ return wrapped().internalWritableStream().abort(globalObject, callFrame.argument(0));
+}
+
+JSC::JSValue JSWritableStream::close(JSC::JSGlobalObject& globalObject, JSC::CallFrame&)
+{
+ return wrapped().internalWritableStream().close(globalObject);
+}
+
+JSC::JSValue JSWritableStream::getWriter(JSC::JSGlobalObject& globalObject, JSC::CallFrame&)
+{
+ return wrapped().internalWritableStream().getWriter(globalObject);
+}
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/WritableStream.h b/src/javascript/jsc/bindings/webcore/WritableStream.h
new file mode 100644
index 000000000..63a4b3377
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/WritableStream.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "root.h"
+
+#include "InternalWritableStream.h"
+#include <JavaScriptCore/Strong.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class InternalWritableStream;
+class WritableStreamSink;
+
+class WritableStream : public RefCounted<WritableStream> {
+public:
+ static ExceptionOr<Ref<WritableStream>> create(JSC::JSGlobalObject&, std::optional<JSC::Strong<JSC::JSObject>>&&, std::optional<JSC::Strong<JSC::JSObject>>&&);
+ static ExceptionOr<Ref<WritableStream>> create(JSDOMGlobalObject&, Ref<WritableStreamSink>&&);
+ static Ref<WritableStream> create(Ref<InternalWritableStream>&&);
+
+ ~WritableStream() = default;
+
+ void lock() { m_internalWritableStream->lock(); }
+ bool locked() const { return m_internalWritableStream->locked(); }
+
+ InternalWritableStream& internalWritableStream() { return m_internalWritableStream.get(); }
+
+private:
+ static ExceptionOr<Ref<WritableStream>> create(JSC::JSGlobalObject&, JSC::JSValue, JSC::JSValue);
+ explicit WritableStream(Ref<InternalWritableStream>&&);
+
+ Ref<InternalWritableStream> m_internalWritableStream;
+};
+
+} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/webcore/WritableStream.idl b/src/javascript/jsc/bindings/webcore/WritableStream.idl
new file mode 100644
index 000000000..cd32d17f0
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/WritableStream.idl
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2015 Canon Inc.
+ * Copyright (C) 2015 Igalia S.L.
+ * Copyright (C) 2020-2021 Apple Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted, provided that the following conditions
+ * are required to be 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.
+ * 3. Neither the name of Canon Inc. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CANON 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 CANON INC. AND 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.
+ */
+
+[
+ Exposed=*,
+ PrivateIdentifier,
+ PublicIdentifier,
+ SkipVTableValidation
+] interface WritableStream {
+ // FIXME: Tighten parameter matching
+ [CallWith=CurrentGlobalObject] constructor(optional object underlyingSink, optional object strategy);
+
+ readonly attribute boolean locked;
+
+ [Custom, ReturnsOwnPromise] Promise<any> abort(optional any reason);
+ [Custom, ReturnsOwnPromise] Promise<any> close();
+ [Custom] WritableStreamDefaultWriter getWriter();
+};
diff --git a/src/javascript/jsc/bindings/webcore/WritableStreamSink.h b/src/javascript/jsc/bindings/webcore/WritableStreamSink.h
new file mode 100644
index 000000000..2caa86c39
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/WritableStreamSink.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#pragma once
+
+#include "JSDOMPromiseDeferred.h"
+#include <wtf/RefCounted.h>
+#include <wtf/text/WTFString.h>
+
+namespace JSC {
+class JSValue;
+}
+
+namespace WebCore {
+
+class WritableStreamSink : public RefCounted<WritableStreamSink> {
+public:
+ virtual ~WritableStreamSink() = default;
+
+ virtual void write(ScriptExecutionContext&, JSC::JSValue, DOMPromiseDeferred<void>&&) = 0;
+ virtual void close() = 0;
+ virtual void error(String&&) = 0;
+};
+
+class SimpleWritableStreamSink : public WritableStreamSink {
+public:
+ using WriteCallback = Function<ExceptionOr<void>(ScriptExecutionContext&, JSC::JSValue)>;
+ static Ref<SimpleWritableStreamSink> create(WriteCallback&& writeCallback) { return adoptRef(*new SimpleWritableStreamSink(WTFMove(writeCallback))); }
+
+private:
+ explicit SimpleWritableStreamSink(WriteCallback&&);
+
+ void write(ScriptExecutionContext&, JSC::JSValue, DOMPromiseDeferred<void>&&) final;
+ void close() final { }
+ void error(String&&) final { }
+
+ WriteCallback m_writeCallback;
+};
+
+inline SimpleWritableStreamSink::SimpleWritableStreamSink(WriteCallback&& writeCallback)
+ : m_writeCallback(WTFMove(writeCallback))
+{
+}
+
+inline void SimpleWritableStreamSink::write(ScriptExecutionContext& context, JSC::JSValue value, DOMPromiseDeferred<void>&& promise)
+{
+ promise.settle(m_writeCallback(context, value));
+}
+
+} // namespace WebCore