aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-06-07 22:32:46 -0700
committerGravatar GitHub <noreply@github.com> 2022-06-07 22:32:46 -0700
commit43de33afc7fcc4cab25f578566e225ba9e4d4258 (patch)
tree141676095981741c3a5740093fee79ed12d4edcd /src
parent958fc3d4f5ba2a1fb5b5e1e2b9fe3a4500dbefc6 (diff)
downloadbun-43de33afc7fcc4cab25f578566e225ba9e4d4258.tar.gz
bun-43de33afc7fcc4cab25f578566e225ba9e4d4258.tar.zst
bun-43de33afc7fcc4cab25f578566e225ba9e4d4258.zip
Web Streams API (#176)
* [bun.js] `WritableStream`, `ReadableStream`, `TransformStream`, `WritableStreamDefaultController`, `ReadableStreamDefaultController` & more * Implement `Blob.stream()` * Update streams.test.js * Fix sourcemaps crash * [TextEncoder] 3x faster in hot loops * reading almost works * start to implement native streams * Implement `Blob.stream()` * Implement `Bun.file(pathOrFd).stream()` * Add an extra function * [fs.readFile] Improve performance * make jsc bindings a little easier to work with * fix segfault * faster async/await + readablestream optimizations * WebKit updates * More WebKit updates * Add releaseWEakrefs binding * `bun:jsc` * More streams * Update streams.test.js * Update Makefile * Update mimalloc * Update WebKit * Create bun-jsc.test.js * Faster ReadableStream * Fix off by one & exceptions * Handle empty files/blobs * Update streams.test.js * Move streams to it's own file * temp * impl #1 * take two * good enough for now * Implement `readableStreamToArray`, `readableStreamToArrayBuffer`, `concatArrayBuffers` * jsxOptimizationInlining * Fix crash * Add `jsxOptimizationInline` to Bun.Transpiler * Update Transpiler types * Update js_ast.zig * Automatically choose production mode when NODE_ENV="production" * Update cli.zig * [jsx] Handle defaultProps when inlining * Update transpiler.test.js * uncomment some tests Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/baby_list.zig104
-rw-r--r--src/bun_js.zig5
-rw-r--r--src/bundler.zig29
-rw-r--r--src/bunfig.zig7
-rw-r--r--src/c.zig56
-rw-r--r--src/cli.zig4
m---------src/deps/mimalloc0
-rw-r--r--src/deps/uws.zig126
-rw-r--r--src/feature_flags.zig3
-rw-r--r--src/global.zig42
-rw-r--r--src/io/io_darwin.zig29
-rw-r--r--src/io/io_linux.zig5
m---------src/javascript/jsc/WebKit0
-rw-r--r--src/javascript/jsc/api/bun.zig108
-rw-r--r--src/javascript/jsc/api/ffi.zig11
-rw-r--r--src/javascript/jsc/api/html_rewriter.zig118
-rw-r--r--src/javascript/jsc/api/server.zig180
-rw-r--r--src/javascript/jsc/api/transpiler.zig23
-rw-r--r--src/javascript/jsc/base.zig9
-rw-r--r--src/javascript/jsc/bindings/BunBuiltinNames.h139
-rw-r--r--src/javascript/jsc/bindings/BunClientData.cpp29
-rw-r--r--src/javascript/jsc/bindings/BunClientData.h16
-rw-r--r--src/javascript/jsc/bindings/BunGCOutputConstraint.cpp198
-rw-r--r--src/javascript/jsc/bindings/BunJSCModule.cpp293
-rw-r--r--src/javascript/jsc/bindings/BunJSCModule.h4
-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/JSBuffer.cpp200
-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/JSFFIFunction.cpp10
-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.cpp4
-rw-r--r--src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.cpp188
-rw-r--r--src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.h167
-rw-r--r--src/javascript/jsc/bindings/ReadableByteStreamInternalsBuiltins.cpp945
-rw-r--r--src/javascript/jsc/bindings/ReadableByteStreamInternalsBuiltins.h436
-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.cpp640
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamBuiltins.h215
-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.cpp237
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamDefaultReaderBuiltins.h167
-rw-r--r--src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.cpp1092
-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.cpp464
-rw-r--r--src/javascript/jsc/bindings/StreamInternalsBuiltins.h308
-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/URLDecomposition.cpp10
-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.cpp1103
-rw-r--r--src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.h540
-rw-r--r--src/javascript/jsc/bindings/ZigGlobalObject.cpp911
-rw-r--r--src/javascript/jsc/bindings/ZigGlobalObject.h82
-rw-r--r--src/javascript/jsc/bindings/bindings.cpp327
-rw-r--r--src/javascript/jsc/bindings/bindings.zig471
-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.js117
-rw-r--r--src/javascript/jsc/bindings/builtins/js/ReadableByteStreamInternals.js705
-rw-r--r--src/javascript/jsc/bindings/builtins/js/ReadableStream.js540
-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.js165
-rw-r--r--src/javascript/jsc/bindings/builtins/js/ReadableStreamInternals.js818
-rw-r--r--src/javascript/jsc/bindings/builtins/js/StreamInternals.js317
-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.js782
-rw-r--r--src/javascript/jsc/bindings/exports.zig7
-rw-r--r--src/javascript/jsc/bindings/headers-cpp.h263
-rw-r--r--src/javascript/jsc/bindings/headers-handwritten.h2
-rw-r--r--src/javascript/jsc/bindings/headers-replacements.zig1
-rw-r--r--src/javascript/jsc/bindings/headers.h775
-rw-r--r--src/javascript/jsc/bindings/headers.zig33
-rw-r--r--src/javascript/jsc/bindings/helpers.h15
-rw-r--r--src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp36
-rw-r--r--src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h38
-rw-r--r--src/javascript/jsc/bindings/webcore/DOMConstructors.h18
-rw-r--r--src/javascript/jsc/bindings/webcore/DOMIsoSubspaces.h39
-rw-r--r--src/javascript/jsc/bindings/webcore/DOMPromiseProxy.h350
-rw-r--r--src/javascript/jsc/bindings/webcore/HTTPParsers.cpp2
-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/JSAbortController.cpp6
-rw-r--r--src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp16
-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/JSCustomEvent.cpp6
-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/JSDOMException.cpp108
-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.cpp311
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMPromiseDeferred.h377
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMURL.cpp34
-rw-r--r--src/javascript/jsc/bindings/webcore/JSDOMWindow.h1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSErrorEvent.cpp12
-rw-r--r--src/javascript/jsc/bindings/webcore/JSEvent.cpp54
-rw-r--r--src/javascript/jsc/bindings/webcore/JSEventTarget.cpp8
-rw-r--r--src/javascript/jsc/bindings/webcore/JSFetchHeaders.cpp20
-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.h63
-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.cpp182
-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.cpp268
-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/JSTextEncoder.cpp423
-rw-r--r--src/javascript/jsc/bindings/webcore/JSTextEncoder.dep1
-rw-r--r--src/javascript/jsc/bindings/webcore/JSTextEncoder.h100
-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/JSURLSearchParams.cpp26
-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.cpp220
-rw-r--r--src/javascript/jsc/bindings/webcore/ReadableStream.h105
-rw-r--r--src/javascript/jsc/bindings/webcore/ReadableStreamDefaultController.cpp154
-rw-r--r--src/javascript/jsc/bindings/webcore/ReadableStreamDefaultController.h75
-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.cpp112
-rw-r--r--src/javascript/jsc/bindings/webcore/ReadableStreamSource.h94
-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/TextEncoder.cpp74
-rw-r--r--src/javascript/jsc/bindings/webcore/TextEncoder.h54
-rw-r--r--src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp5
-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
-rw-r--r--src/javascript/jsc/bindings/webcore/weak_handle.cpp21
-rw-r--r--src/javascript/jsc/bindings/webcore/weak_handle.h16
-rw-r--r--src/javascript/jsc/bun-jsc.exports.js23
-rw-r--r--src/javascript/jsc/event_loop.zig612
-rw-r--r--src/javascript/jsc/javascript.zig467
-rw-r--r--src/javascript/jsc/javascript_core_c_api.zig14
-rw-r--r--src/javascript/jsc/node/dir_iterator.zig2
-rw-r--r--src/javascript/jsc/node/node_fs.zig9
-rw-r--r--src/javascript/jsc/node/node_fs_binding.zig6
-rw-r--r--src/javascript/jsc/node/syscall.zig51
-rw-r--r--src/javascript/jsc/node/types.zig30
-rw-r--r--src/javascript/jsc/test/jest.zig12
-rw-r--r--src/javascript/jsc/typescript.zig1
-rw-r--r--src/javascript/jsc/webcore.zig2
-rw-r--r--src/javascript/jsc/webcore/encoding.zig231
-rw-r--r--src/javascript/jsc/webcore/response.zig123
-rw-r--r--src/javascript/jsc/webcore/streams.zig1321
-rw-r--r--src/js_ast.zig109
-rw-r--r--src/js_parser.zig475
-rw-r--r--src/jsc.zig3
-rw-r--r--src/memory_allocator.zig126
-rw-r--r--src/napi/napi.zig38
-rw-r--r--src/options.zig9
-rw-r--r--src/runtime.js16
-rw-r--r--src/runtime.zig15
-rw-r--r--src/sourcemap/sourcemap.zig4
-rw-r--r--src/string_immutable.zig746
232 files changed, 31198 insertions, 1986 deletions
diff --git a/src/baby_list.zig b/src/baby_list.zig
new file mode 100644
index 000000000..b1bfc1786
--- /dev/null
+++ b/src/baby_list.zig
@@ -0,0 +1,104 @@
+const std = @import("std");
+const Environment = @import("./env.zig");
+
+/// This is like ArrayList except it stores the length and capacity as u32
+/// In practice, it is very unusual to have lengths above 4 GB
+///
+/// This lets us have array lists which occupy the same amount of space as a slice
+pub fn BabyList(comptime Type: type) type {
+ return struct {
+ const ListType = @This();
+ ptr: [*]Type = undefined,
+ len: u32 = 0,
+ cap: u32 = 0,
+
+ pub inline fn init(items: []const Type) ListType {
+ @setRuntimeSafety(false);
+ return ListType{
+ // Remove the const qualifier from the items
+ .ptr = @intToPtr([*]Type, @ptrToInt(items.ptr)),
+
+ .len = @truncate(u32, items.len),
+ .cap = @truncate(u32, items.len),
+ };
+ }
+
+ pub inline fn fromList(list_: anytype) ListType {
+ @setRuntimeSafety(false);
+
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(list_.items.len <= list_.capacity);
+ }
+
+ return ListType{
+ .ptr = list_.items.ptr,
+ .len = @truncate(u32, list_.items.len),
+ .cap = @truncate(u32, list_.capacity),
+ };
+ }
+
+ pub fn update(this: *ListType, list_: anytype) void {
+ @setRuntimeSafety(false);
+ this.ptr = list_.items.ptr;
+ this.len = @truncate(u32, list_.items.len);
+ this.cap = @truncate(u32, list_.capacity);
+
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(this.len <= this.cap);
+ }
+ }
+
+ pub fn list(this: ListType) std.ArrayListUnmanaged(Type) {
+ return std.ArrayListUnmanaged(Type){
+ .items = this.ptr[0..this.len],
+ .capacity = this.cap,
+ };
+ }
+
+ pub fn listManaged(this: ListType, allocator: std.mem.Allocator) std.ArrayList(Type) {
+ return std.ArrayList(Type){
+ .items = this.ptr[0..this.len],
+ .capacity = this.cap,
+ .allocator = allocator,
+ };
+ }
+
+ pub inline fn first(this: ListType) ?*Type {
+ return if (this.len > 0) this.ptr[0] else @as(?*Type, null);
+ }
+
+ pub inline fn last(this: ListType) ?*Type {
+ return if (this.len > 0) &this.ptr[this.len - 1] else @as(?*Type, null);
+ }
+
+ pub inline fn first_(this: ListType) Type {
+ return this.ptr[0];
+ }
+
+ pub fn one(allocator: std.mem.Allocator, value: Type) !ListType {
+ var items = try allocator.alloc(Type, 1);
+ items[0] = value;
+ return ListType{
+ .ptr = @ptrCast([*]Type, items.ptr),
+ .len = 1,
+ .cap = 1,
+ };
+ }
+
+ pub inline fn @"[0]"(this: ListType) Type {
+ return this.ptr[0];
+ }
+ const OOM = error{OutOfMemory};
+
+ pub fn push(this: *ListType, allocator: std.mem.Allocator, value: Type) OOM!void {
+ var list_ = this.list();
+ try list_.append(allocator, value);
+ this.update(list_);
+ }
+
+ pub inline fn slice(this: ListType) []Type {
+ @setRuntimeSafety(false);
+ return this.ptr[0..this.len];
+ }
+ };
+}
diff --git a/src/bun_js.zig b/src/bun_js.zig
index 29f152049..7ccdc8747 100644
--- a/src/bun_js.zig
+++ b/src/bun_js.zig
@@ -120,8 +120,7 @@ pub const Run = struct {
Global.exit(1);
}
- const result = promise.result(this.vm.global.vm());
- JSC.C.JSValueProtect(this.vm.global.ref(), result.asObjectRef());
+ _ = promise.result(this.vm.global.vm());
if (this.vm.log.msgs.items.len > 0) {
if (Output.enable_ansi_colors) {
@@ -133,6 +132,8 @@ pub const Run = struct {
Output.flush();
}
+ this.vm.global.vm().releaseWeakRefs();
+ _ = this.vm.global.vm().runGC(false);
this.vm.tick();
{
diff --git a/src/bundler.zig b/src/bundler.zig
index 936f761b3..edfdf2aa6 100644
--- a/src/bundler.zig
+++ b/src/bundler.zig
@@ -345,6 +345,29 @@ pub const Bundler = struct {
} else {
try this.options.loadDefines(this.allocator, this.env, &this.options.env);
}
+
+ if (this.options.define.dots.get("NODE_ENV")) |NODE_ENV| {
+ if (NODE_ENV.len > 0 and NODE_ENV[0].data.value == .e_string and NODE_ENV[0].data.value.e_string.eqlComptime("production")) {
+ this.options.production = true;
+ this.options.jsx.development = false;
+
+ if (this.options.jsx.import_source.ptr == options.JSX.Pragma.Defaults.ImportSourceDev) {
+ this.options.jsx.import_source = options.JSX.Pragma.Defaults.ImportSource;
+ }
+
+ if (options.JSX.Pragma.Defaults.ImportSource.ptr == this.options.jsx.import_source.ptr or
+ strings.eqlComptime(this.options.jsx.import_source, comptime options.JSX.Pragma.Defaults.ImportSource) or strings.eqlComptime(this.options.jsx.package_name, "react"))
+ {
+ if (this.options.jsx_optimization_inline == null) {
+ this.options.jsx_optimization_inline = true;
+ }
+
+ if (this.options.jsx_optimization_hoist == null and (this.options.jsx_optimization_inline orelse false)) {
+ this.options.jsx_optimization_hoist = true;
+ }
+ }
+ }
+ }
}
pub fn configureFramework(
@@ -1096,6 +1119,7 @@ pub const Bundler = struct {
var jsx = this_parse.jsx;
jsx.parse = loader.isJSX();
+
var opts = js_parser.Parser.Options.init(jsx, loader);
opts.enable_bundling = false;
opts.transform_require_to_import = bundler.options.allow_runtime;
@@ -1122,6 +1146,11 @@ pub const Bundler = struct {
opts.filepath_hash_for_hmr = file_hash orelse 0;
opts.features.auto_import_jsx = bundler.options.auto_import_jsx;
opts.warn_about_unbundled_modules = platform.isNotBun();
+ opts.features.jsx_optimization_inline = (bundler.options.jsx_optimization_inline orelse (platform.isBun() and jsx.parse and
+ !jsx.development)) and
+ (jsx.runtime == .automatic or jsx.runtime == .classic);
+
+ opts.features.jsx_optimization_hoist = bundler.options.jsx_optimization_hoist orelse opts.features.jsx_optimization_inline;
if (bundler.macro_context == null) {
bundler.macro_context = js_ast.Macro.MacroContext.init(bundler);
diff --git a/src/bunfig.zig b/src/bunfig.zig
index b0c763498..4fd3b7a55 100644
--- a/src/bunfig.zig
+++ b/src/bunfig.zig
@@ -126,7 +126,6 @@ pub const Bunfig = struct {
if (prop.value.?.data != .e_string) continue;
valid_count += 1;
}
-
var buffer = allocator.alloc([]const u8, valid_count * 2) catch unreachable;
var keys = buffer[0..valid_count];
var values = buffer[valid_count..];
@@ -442,19 +441,19 @@ pub const Bunfig = struct {
if (json.get("jsxImportSource")) |expr| {
if (expr.asString(allocator)) |value| {
- jsx_import_source = value;
+ jsx_import_source = try allocator.dupe(u8, value);
}
}
if (json.get("jsxFragment")) |expr| {
if (expr.asString(allocator)) |value| {
- jsx_fragment = value;
+ jsx_fragment = try allocator.dupe(u8, value);
}
}
if (json.get("jsxFactory")) |expr| {
if (expr.asString(allocator)) |value| {
- jsx_factory = value;
+ jsx_factory = try allocator.dupe(u8, value);
}
}
diff --git a/src/c.zig b/src/c.zig
index aaeb980da..7817bdfe9 100644
--- a/src/c.zig
+++ b/src/c.zig
@@ -249,3 +249,59 @@ pub fn getSelfExeSharedLibPaths(allocator: std.mem.Allocator) error{OutOfMemory}
else => @compileError("getSelfExeSharedLibPaths unimplemented for this target"),
}
}
+
+/// The madvise() system call allows a process that has knowledge of its mem-ory memory
+/// ory behavior to describe it to the system. The advice passed in may be
+/// used by the system to alter its virtual memory paging strategy. This
+/// advice may improve application and system performance. The behavior
+/// specified in advice can only be one of the following values:
+///
+/// MADV_NORMAL Indicates that the application has no advice to give on
+/// its behavior in the specified address range. This is
+/// the system default behavior. This is used with
+/// madvise() system call.
+///
+/// POSIX_MADV_NORMAL
+/// Same as MADV_NORMAL but used with posix_madvise() system
+/// call.
+///
+/// MADV_SEQUENTIAL Indicates that the application expects to access this
+/// address range in a sequential manner. This is used with
+/// madvise() system call.
+///
+/// POSIX_MADV_SEQUENTIAL
+/// Same as MADV_SEQUENTIAL but used with posix_madvise()
+/// system call.
+///
+/// MADV_RANDOM Indicates that the application expects to access this
+/// address range in a random manner. This is used with
+/// madvise() system call.
+///
+/// POSIX_MADV_RANDOM
+/// Same as MADV_RANDOM but used with posix_madvise() system
+/// call.
+///
+/// MADV_WILLNEED Indicates that the application expects to access this
+/// address range soon. This is used with madvise() system
+/// call.
+///
+/// POSIX_MADV_WILLNEED
+/// Same as MADV_WILLNEED but used with posix_madvise() sys-tem system
+/// tem call.
+///
+/// MADV_DONTNEED Indicates that the application is not expecting to
+/// access this address range soon. This is used with
+/// madvise() system call.
+///
+/// POSIX_MADV_DONTNEED
+/// Same as MADV_DONTNEED but used with posix_madvise() sys-tem system
+/// tem call.
+///
+/// MADV_FREE Indicates that the application will not need the infor-mation information
+/// mation contained in this address range, so the pages may
+/// be reused right away. The address range will remain
+/// valid. This is used with madvise() system call.
+///
+/// The posix_madvise() behaves same as madvise() except that it uses values
+/// with POSIX_ prefix for the advice system call argument.
+pub extern "c" fn posix_madvise(ptr: *anyopaque, len: usize, advice: i32) c_int;
diff --git a/src/cli.zig b/src/cli.zig
index 5aa02284d..10721a5d2 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -512,7 +512,7 @@ pub const Arguments = struct {
var jsx_fragment = args.option("--jsx-fragment");
var jsx_import_source = args.option("--jsx-import-source");
var jsx_runtime = args.option("--jsx-runtime");
- var jsx_production = args.flag("--jsx-production") or production;
+ var jsx_production = args.flag("--jsx-production");
const react_fast_refresh = switch (comptime cmd) {
.BunCommand, .DevCommand => !(args.flag("--disable-react-fast-refresh") or jsx_production),
else => true,
@@ -611,7 +611,7 @@ pub const Arguments = struct {
.fragment = constStrToU8(jsx_fragment orelse opts.jsx.?.fragment),
.import_source = constStrToU8(jsx_import_source orelse opts.jsx.?.import_source),
.runtime = if (jsx_runtime != null) try resolve_jsx_runtime(jsx_runtime.?) else opts.jsx.?.runtime,
- .development = jsx_production,
+ .development = !jsx_production,
.react_fast_refresh = react_fast_refresh,
};
}
diff --git a/src/deps/mimalloc b/src/deps/mimalloc
-Subproject 9e41263d39041aee3b647eff64d5ef4918a60ce
+Subproject 6d07c0b9ba535617cf9665ea77d099dad265818
diff --git a/src/deps/uws.zig b/src/deps/uws.zig
index 101bac88e..ae0efef79 100644
--- a/src/deps/uws.zig
+++ b/src/deps/uws.zig
@@ -1,11 +1,13 @@
const Api = @import("../api/schema.zig").Api;
+const std = @import("std");
+const Environment = @import("../env.zig");
pub const u_int8_t = u8;
pub const u_int16_t = c_ushort;
pub const u_int32_t = c_uint;
pub const u_int64_t = c_ulonglong;
pub const LIBUS_LISTEN_DEFAULT: c_int = 0;
pub const LIBUS_LISTEN_EXCLUSIVE_PORT: c_int = 1;
-pub const us_socket_t = opaque {};
+pub const Socket = opaque {};
pub const us_timer_t = opaque {};
pub const us_socket_context_t = opaque {};
pub const Loop = opaque {
@@ -17,10 +19,13 @@ pub const Loop = opaque {
return us_wakeup_loop(this);
}
+ pub fn tick(this: *Loop) void {
+ us_loop_tick(this);
+ }
+
pub fn nextTick(this: *Loop, comptime UserType: type, user_data: UserType, comptime deferCallback: fn (ctx: UserType) void) void {
const Handler = struct {
pub fn callback(data: *anyopaque) callconv(.C) void {
- const std = @import("std");
deferCallback(@ptrCast(UserType, @alignCast(@alignOf(std.meta.Child(UserType)), data)));
}
};
@@ -34,7 +39,6 @@ pub const Loop = opaque {
return uws_loop_removePostHandler(handler.loop, callback);
}
pub fn callback(data: *anyopaque, _: *Loop) callconv(.C) void {
- const std = @import("std");
callback(@ptrCast(UserType, @alignCast(@alignOf(std.meta.Child(UserType)), data)));
}
};
@@ -56,6 +60,7 @@ pub const Loop = opaque {
extern fn us_loop_free(loop: ?*Loop) void;
extern fn us_loop_ext(loop: ?*Loop) ?*anyopaque;
extern fn us_loop_run(loop: ?*Loop) void;
+ extern fn us_loop_tick(loop: ?*Loop) void;
extern fn us_wakeup_loop(loop: ?*Loop) void;
extern fn us_loop_integrate(loop: ?*Loop) void;
extern fn us_loop_iteration_number(loop: ?*Loop) c_longlong;
@@ -85,26 +90,87 @@ extern fn us_socket_context_on_server_name(ssl: c_int, context: ?*us_socket_cont
extern fn us_socket_context_get_native_handle(ssl: c_int, context: ?*us_socket_context_t) ?*anyopaque;
extern fn us_create_socket_context(ssl: c_int, loop: ?*Loop, ext_size: c_int, options: us_socket_context_options_t) ?*us_socket_context_t;
extern fn us_socket_context_free(ssl: c_int, context: ?*us_socket_context_t) void;
-extern fn us_socket_context_on_open(ssl: c_int, context: ?*us_socket_context_t, on_open: ?fn (?*us_socket_t, c_int, [*c]u8, c_int) callconv(.C) ?*us_socket_t) void;
-extern fn us_socket_context_on_close(ssl: c_int, context: ?*us_socket_context_t, on_close: ?fn (?*us_socket_t, c_int, ?*anyopaque) callconv(.C) ?*us_socket_t) void;
-extern fn us_socket_context_on_data(ssl: c_int, context: ?*us_socket_context_t, on_data: ?fn (?*us_socket_t, [*c]u8, c_int) callconv(.C) ?*us_socket_t) void;
-extern fn us_socket_context_on_writable(ssl: c_int, context: ?*us_socket_context_t, on_writable: ?fn (*us_socket_t) callconv(.C) ?*us_socket_t) void;
-extern fn us_socket_context_on_timeout(ssl: c_int, context: ?*us_socket_context_t, on_timeout: ?fn (?*us_socket_t) callconv(.C) ?*us_socket_t) void;
-extern fn us_socket_context_on_connect_error(ssl: c_int, context: ?*us_socket_context_t, on_connect_error: ?fn (?*us_socket_t, c_int) callconv(.C) ?*us_socket_t) void;
-extern fn us_socket_context_on_end(ssl: c_int, context: ?*us_socket_context_t, on_end: ?fn (?*us_socket_t) callconv(.C) ?*us_socket_t) void;
+extern fn us_socket_context_on_open(ssl: c_int, context: ?*us_socket_context_t, on_open: ?fn (?*Socket, c_int, [*c]u8, c_int) callconv(.C) ?*Socket) void;
+extern fn us_socket_context_on_close(ssl: c_int, context: ?*us_socket_context_t, on_close: ?fn (?*Socket, c_int, ?*anyopaque) callconv(.C) ?*Socket) void;
+extern fn us_socket_context_on_data(ssl: c_int, context: ?*us_socket_context_t, on_data: ?fn (?*Socket, [*c]u8, c_int) callconv(.C) ?*Socket) void;
+extern fn us_socket_context_on_writable(ssl: c_int, context: ?*us_socket_context_t, on_writable: ?fn (*Socket) callconv(.C) ?*Socket) void;
+extern fn us_socket_context_on_timeout(ssl: c_int, context: ?*us_socket_context_t, on_timeout: ?fn (?*Socket) callconv(.C) ?*Socket) void;
+extern fn us_socket_context_on_connect_error(ssl: c_int, context: ?*us_socket_context_t, on_connect_error: ?fn (?*Socket, c_int) callconv(.C) ?*Socket) void;
+extern fn us_socket_context_on_end(ssl: c_int, context: ?*us_socket_context_t, on_end: ?fn (?*Socket) callconv(.C) ?*Socket) void;
extern fn us_socket_context_ext(ssl: c_int, context: ?*us_socket_context_t) ?*anyopaque;
extern fn us_socket_context_listen(ssl: c_int, context: ?*us_socket_context_t, host: [*c]const u8, port: c_int, options: c_int, socket_ext_size: c_int) ?*listen_socket_t;
-extern fn us_socket_context_connect(ssl: c_int, context: ?*us_socket_context_t, host: [*c]const u8, port: c_int, source_host: [*c]const u8, options: c_int, socket_ext_size: c_int) ?*us_socket_t;
-extern fn us_socket_is_established(ssl: c_int, s: ?*us_socket_t) c_int;
-extern fn us_socket_close_connecting(ssl: c_int, s: ?*us_socket_t) ?*us_socket_t;
+extern fn us_socket_context_connect(ssl: c_int, context: ?*us_socket_context_t, host: [*c]const u8, port: c_int, source_host: [*c]const u8, options: c_int, socket_ext_size: c_int) ?*Socket;
+extern fn us_socket_is_established(ssl: c_int, s: ?*Socket) c_int;
+extern fn us_socket_close_connecting(ssl: c_int, s: ?*Socket) ?*Socket;
extern fn us_socket_context_loop(ssl: c_int, context: ?*us_socket_context_t) ?*Loop;
-extern fn us_socket_context_adopt_socket(ssl: c_int, context: ?*us_socket_context_t, s: ?*us_socket_t, ext_size: c_int) ?*us_socket_t;
+extern fn us_socket_context_adopt_socket(ssl: c_int, context: ?*us_socket_context_t, s: ?*Socket, ext_size: c_int) ?*Socket;
extern fn us_create_child_socket_context(ssl: c_int, context: ?*us_socket_context_t, context_ext_size: c_int) ?*us_socket_context_t;
pub const Poll = opaque {
- extern fn us_create_poll(loop: ?*Loop, fallthrough: c_int, ext_size: c_uint) *Poll;
+ pub fn create(
+ loop: *Loop,
+ comptime Data: type,
+ file: c_int,
+ val: Data,
+ fallthrough: bool,
+ flags: Flags,
+ callback: CallbackType,
+ ) ?*Poll {
+ var poll = us_create_callback(loop, @as(c_int, @boolToInt(fallthrough)), file, @sizeOf(Data));
+ if (comptime Data != void) {
+ poll.data(Data).* = val;
+ }
+ var flags_int: c_int = 0;
+ if (flags.read) {
+ flags_int |= Flags.read_flag;
+ }
+
+ if (flags.write) {
+ flags_int |= Flags.write_flag;
+ }
+
+ us_callback_set(poll, flags_int, callback);
+ return poll;
+ }
+
+ pub fn stop(self: *Poll, loop: *Loop) void {
+ us_poll_stop(self, loop);
+ }
+
+ pub fn data(self: *Poll, comptime Data: type) *Data {
+ return us_poll_ext(self).?;
+ }
+
+ pub fn fd(self: *Poll) @import("std").os.fd_t {
+ return @intCast(@import("std").os.fd_t, us_poll_fd(self));
+ }
+
+ pub fn start(self: *Poll, poll_type: Flags) void {
+ // us_poll_start(self, loop: ?*Loop, events: c_int)
+ _ = self;
+ _ = poll_type;
+ }
+
+ pub const Flags = struct {
+ read: bool = false,
+ write: bool = false,
+
+ //#define LIBUS_SOCKET_READABLE
+ pub const read_flag = if (Environment.isLinux) std.os.linux.EPOLL.IN else 1;
+ // #define LIBUS_SOCKET_WRITABLE
+ pub const write_flag = if (Environment.isLinux) std.os.linux.EPOLL.OUT else 2;
+ };
+
+ pub fn deinit(self: *Poll) void {
+ us_poll_free(self);
+ }
+
+ // (void* userData, int fd, int events, int error, struct us_poll_t *poll)
+ pub const CallbackType = fn (?*anyopaque, c_int, c_int, c_int, *Poll) void;
+ extern fn us_create_callback(loop: ?*Loop, fallthrough: c_int, fd: c_int, ext_size: c_uint) *Poll;
+ extern fn us_callback_set(poll: *Poll, events: c_int, callback: CallbackType) *Poll;
extern fn us_poll_free(p: ?*Poll, loop: ?*Loop) void;
extern fn us_poll_init(p: ?*Poll, fd: c_int, poll_type: c_int) void;
extern fn us_poll_start(p: ?*Poll, loop: ?*Loop, events: c_int) void;
@@ -116,19 +182,19 @@ pub const Poll = opaque {
extern fn us_poll_resize(p: ?*Poll, loop: ?*Loop, ext_size: c_uint) ?*Poll;
};
-extern fn us_socket_get_native_handle(ssl: c_int, s: ?*us_socket_t) ?*anyopaque;
-extern fn us_socket_write(ssl: c_int, s: ?*us_socket_t, data: [*c]const u8, length: c_int, msg_more: c_int) c_int;
-extern fn us_socket_timeout(ssl: c_int, s: ?*us_socket_t, seconds: c_uint) void;
-extern fn us_socket_ext(ssl: c_int, s: ?*us_socket_t) ?*anyopaque;
-extern fn us_socket_context(ssl: c_int, s: ?*us_socket_t) ?*us_socket_context_t;
-extern fn us_socket_flush(ssl: c_int, s: ?*us_socket_t) void;
-extern fn us_socket_shutdown(ssl: c_int, s: ?*us_socket_t) void;
-extern fn us_socket_shutdown_read(ssl: c_int, s: ?*us_socket_t) void;
-extern fn us_socket_is_shut_down(ssl: c_int, s: ?*us_socket_t) c_int;
-extern fn us_socket_is_closed(ssl: c_int, s: ?*us_socket_t) c_int;
-extern fn us_socket_close(ssl: c_int, s: ?*us_socket_t, code: c_int, reason: ?*anyopaque) ?*us_socket_t;
-extern fn us_socket_local_port(ssl: c_int, s: ?*us_socket_t) c_int;
-extern fn us_socket_remote_address(ssl: c_int, s: ?*us_socket_t, buf: [*c]u8, length: [*c]c_int) void;
+extern fn us_socket_get_native_handle(ssl: c_int, s: ?*Socket) ?*anyopaque;
+extern fn us_socket_write(ssl: c_int, s: ?*Socket, data: [*c]const u8, length: c_int, msg_more: c_int) c_int;
+extern fn Socketimeout(ssl: c_int, s: ?*Socket, seconds: c_uint) void;
+extern fn us_socket_ext(ssl: c_int, s: ?*Socket) ?*anyopaque;
+extern fn us_socket_context(ssl: c_int, s: ?*Socket) ?*us_socket_context_t;
+extern fn us_socket_flush(ssl: c_int, s: ?*Socket) void;
+extern fn us_socket_shutdown(ssl: c_int, s: ?*Socket) void;
+extern fn us_socket_shutdown_read(ssl: c_int, s: ?*Socket) void;
+extern fn us_socket_is_shut_down(ssl: c_int, s: ?*Socket) c_int;
+extern fn us_socket_is_closed(ssl: c_int, s: ?*Socket) c_int;
+extern fn us_socket_close(ssl: c_int, s: ?*Socket, code: c_int, reason: ?*anyopaque) ?*Socket;
+extern fn us_socket_local_port(ssl: c_int, s: ?*Socket) c_int;
+extern fn us_socket_remote_address(ssl: c_int, s: ?*Socket, buf: [*c]u8, length: [*c]c_int) void;
pub const uws_app_s = opaque {};
pub const uws_req_s = opaque {};
pub const uws_websocket_s = opaque {};
@@ -607,7 +673,7 @@ pub fn NewApp(comptime ssl: bool) type {
// };
// const OnWritable = struct {
- // pub fn handle(socket: *us_socket_t) callconv(.C) ?*us_socket_t {
+ // pub fn handle(socket: *Socket) callconv(.C) ?*Socket {
// if (comptime UserDataType == void) {
// @call(.{ .modifier = .always_inline }, handler, .{
// void{},
@@ -644,7 +710,7 @@ pub fn NewApp(comptime ssl: bool) type {
};
}
extern fn uws_res_prepare_for_sendfile(ssl: c_int, res: *uws_res) void;
-extern fn uws_res_get_native_handle(ssl: c_int, res: *uws_res) *us_socket_t;
+extern fn uws_res_get_native_handle(ssl: c_int, res: *uws_res) *Socket;
extern fn uws_create_app(ssl: c_int, options: us_socket_context_options_t) *uws_app_t;
extern fn uws_app_destroy(ssl: c_int, app: *uws_app_t) void;
extern fn uws_app_get(ssl: c_int, app: *uws_app_t, pattern: [*c]const u8, handler: uws_method_handler, user_data: ?*anyopaque) void;
diff --git a/src/feature_flags.zig b/src/feature_flags.zig
index 02d09faee..4a9a7a776 100644
--- a/src/feature_flags.zig
+++ b/src/feature_flags.zig
@@ -91,3 +91,6 @@ pub const atomic_file_watcher = env.isLinux;
pub const node_streams = env.isDebug or env.isTest;
pub const simd = true;
+
+// This change didn't seem to make a meaningful difference in microbenchmarks
+pub const latin1_is_now_ascii = false;
diff --git a/src/global.zig b/src/global.zig
index 9c506404e..6160ce781 100644
--- a/src/global.zig
+++ b/src/global.zig
@@ -8,6 +8,18 @@ pub const default_allocator: std.mem.Allocator = if (!use_mimalloc)
else
@import("./memory_allocator.zig").c_allocator;
+pub const huge_allocator: std.mem.Allocator = if (!use_mimalloc)
+ std.heap.c_allocator
+else
+ @import("./memory_allocator.zig").huge_allocator;
+
+pub const auto_allocator: std.mem.Allocator = if (!use_mimalloc)
+ std.heap.c_allocator
+else
+ @import("./memory_allocator.zig").auto_allocator;
+
+pub const huge_allocator_threshold: comptime_int = @import("./memory_allocator.zig").huge_threshold;
+
pub const C = @import("c.zig");
pub const FeatureFlags = @import("feature_flags.zig");
@@ -159,3 +171,33 @@ pub fn span(ptr: anytype) std.mem.Span(@TypeOf(ptr)) {
pub const IdentityContext = @import("./identity_context.zig").IdentityContext;
pub const ArrayIdentityContext = @import("./identity_context.zig").ArrayIdentityContext;
+pub const BabyList = @import("./baby_list.zig").BabyList;
+pub const ByteList = BabyList(u8);
+
+pub fn DebugOnly(comptime Type: type) type {
+ if (comptime Environment.isDebug) {
+ return Type;
+ }
+
+ return void;
+}
+
+pub fn DebugOnlyDefault(comptime val: anytype) if (Environment.isDebug) @TypeOf(val) else void {
+ if (comptime Environment.isDebug) {
+ return val;
+ }
+
+ return {};
+}
+
+pub inline fn range(comptime min: anytype, comptime max: anytype) [max - min]usize {
+ return comptime brk: {
+ var slice: [max - min]usize = undefined;
+ var i: usize = min;
+ while (i < max) {
+ slice[i - min] = i;
+ i += 1;
+ }
+ break :brk slice;
+ };
+}
diff --git a/src/io/io_darwin.zig b/src/io/io_darwin.zig
index 17cf9cca6..f72ea73ae 100644
--- a/src/io/io_darwin.zig
+++ b/src/io/io_darwin.zig
@@ -270,8 +270,9 @@ pub const darwin = struct {
pub extern "c" fn @"accept$NOCANCEL"(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) c_int;
pub extern "c" fn @"accept4$NOCANCEL"(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t, flags: c_uint) c_int;
pub extern "c" fn @"open$NOCANCEL"(path: [*:0]const u8, oflag: c_uint, ...) c_int;
+ pub extern "c" fn @"read$NOCANCEL"(fd: c.fd_t, buf: [*]u8, nbyte: usize) isize;
+ pub extern "c" fn @"pread$NOCANCEL"(fd: c.fd_t, buf: [*]u8, nbyte: usize, offset: c.off_t) isize;
};
-
pub const OpenError = error{
/// In WASI, this error may occur when the file descriptor does
/// not hold the required rights to open a new resource relative to it.
@@ -539,9 +540,11 @@ pub fn run_for_ns(self: *IO, nanoseconds: u63) !void {
}
}
+const default_timespec = std.mem.zeroInit(os.timespec, .{});
+
fn flush(self: *IO, wait_for_completions: bool) !void {
var io_pending = self.io_pending.peek();
- var events: [256]os.Kevent = undefined;
+ var events: [512]os.Kevent = undefined;
// Check timeouts and fill events with completions in io_pending
// (they will be submitted through kevent).
@@ -552,7 +555,7 @@ fn flush(self: *IO, wait_for_completions: bool) !void {
// Only call kevent() if we need to submit io events or if we need to wait for completions.
if (change_events > 0 or self.completed.peek() == null) {
// Zero timeouts for kevent() implies a non-blocking poll
- var ts = std.mem.zeroes(os.timespec);
+ var ts = default_timespec;
// We need to wait (not poll) on kevent if there's nothing to submit or complete.
// We should never wait indefinitely (timeout_ptr = null for kevent) given:
@@ -602,7 +605,6 @@ fn flush_io(_: *IO, events: []os.Kevent, io_pending_top: *?*Completion) usize {
for (events) |*kevent, flushed| {
const completion = io_pending_top.* orelse return flushed;
io_pending_top.* = completion.next;
-
const event_info = switch (completion.operation) {
.accept => |op| [3]c_int{
op.socket,
@@ -711,6 +713,7 @@ const Operation = union(enum) {
buf: [*]u8,
len: u32,
offset: u64,
+ positional: bool = true,
},
recv: struct {
socket: os.socket_t,
@@ -774,9 +777,13 @@ fn submitWithIncrementPending(
self.pending_count += 1;
const Context = @TypeOf(context);
const onCompleteFn = struct {
- fn onComplete(io: *IO, _completion: *Completion) void {
+ fn onComplete(
+ io: *IO,
+ _completion: *Completion,
+ ) void {
// Perform the actual operaton
const op_data = &@field(_completion.operation, @tagName(operation_tag));
+
const result = OperationImpl.doOperation(op_data);
// Requeue onto io_pending if error.WouldBlock
@@ -1161,8 +1168,9 @@ pub fn read(
completion: *Completion,
fd: os.fd_t,
buffer: []u8,
- offset: u64,
+ offset: ?u64,
) void {
+ const offset_ = offset orelse @as(u64, 0);
self.submit(
context,
callback,
@@ -1172,16 +1180,21 @@ pub fn read(
.fd = fd,
.buf = buffer.ptr,
.len = @intCast(u32, buffer_limit(buffer.len)),
- .offset = offset,
+ .offset = offset_,
+ .positional = offset != null,
},
struct {
fn doOperation(op: anytype) ReadError!usize {
while (true) {
- const rc = os.system.pread(
+ const rc = if (op.positional) os.system.pread(
op.fd,
op.buf,
op.len,
@bitCast(isize, op.offset),
+ ) else os.system.read(
+ op.fd,
+ op.buf,
+ op.len,
);
return switch (@enumToInt(os.errno(rc))) {
0 => @intCast(usize, rc),
diff --git a/src/io/io_linux.zig b/src/io/io_linux.zig
index 374ba9d78..b4f21dee5 100644
--- a/src/io/io_linux.zig
+++ b/src/io/io_linux.zig
@@ -1231,7 +1231,7 @@ pub fn read(
completion: *Completion,
fd: os.fd_t,
buffer: []u8,
- offset: u64,
+ offset: ?u64,
) void {
completion.* = .{
.io = self,
@@ -1250,7 +1250,8 @@ pub fn read(
.read = .{
.fd = fd,
.buffer = buffer,
- .offset = offset,
+ // pread is irrelevant here
+ .offset = offset orelse 0,
},
},
};
diff --git a/src/javascript/jsc/WebKit b/src/javascript/jsc/WebKit
-Subproject 06d0294f9cbf1ba697593322929271c695c629c
+Subproject ff1f8e24b707d023a88aee5d9cd79b665c8471f
diff --git a/src/javascript/jsc/api/bun.zig b/src/javascript/jsc/api/bun.zig
index 906e0e53c..72d61d2e9 100644
--- a/src/javascript/jsc/api/bun.zig
+++ b/src/javascript/jsc/api/bun.zig
@@ -623,7 +623,7 @@ pub fn openInEditor(
) js.JSValueRef {
var edit = &VirtualMachine.vm.rareData().editor_context;
- var arguments = JSC.Node.ArgumentsSlice.from(args);
+ var arguments = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), args);
defer arguments.deinit();
var path: string = "";
var editor_choice: ?Editor = null;
@@ -822,7 +822,7 @@ fn doResolve(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) ?JSC.JSValue {
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
defer args.deinit();
const specifier = args.protectEatNext() orelse {
JSC.throwInvalidArguments("Expected a specifier and a from path", .{}, ctx, exception);
@@ -1543,7 +1543,7 @@ pub fn serve(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) js.JSValueRef {
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
var config = JSC.API.ServerConfig.fromJS(ctx.ptr(), &args, exception);
if (exception.* != null) {
return null;
@@ -1612,6 +1612,100 @@ pub fn serve(
unreachable;
}
+pub export fn Bun__escapeHTML(
+ globalObject: *JSGlobalObject,
+ callframe: *JSC.CallFrame,
+) JSC.JSValue {
+ const arguments = callframe.arguments();
+ if (arguments.len < 1) {
+ return ZigString.Empty.toValue(globalObject);
+ }
+
+ const input_value = arguments[0];
+ const zig_str = input_value.getZigString(globalObject);
+ if (zig_str.len == 0)
+ return ZigString.Empty.toValue(globalObject);
+
+ if (zig_str.is16Bit()) {
+ var input_slice = zig_str.utf16SliceAligned();
+ var escaped_html = strings.escapeHTMLForUTF16Input(globalObject.bunVM().allocator, input_slice) catch {
+ globalObject.vm().throwError(globalObject, ZigString.init("Out of memory").toValue(globalObject));
+ return JSC.JSValue.jsUndefined();
+ };
+
+ if (escaped_html.ptr == input_slice.ptr and escaped_html.len == input_slice.len) {
+ return input_value;
+ }
+
+ if (input_slice.len == 1) {
+ // single character escaped strings are statically allocated
+ return ZigString.init(std.mem.sliceAsBytes(escaped_html)).to16BitValue(globalObject);
+ }
+
+ if (comptime Environment.allow_assert) {
+ // assert that re-encoding the string produces the same result
+ std.debug.assert(
+ std.mem.eql(
+ u16,
+ (strings.toUTF16Alloc(bun.default_allocator, strings.toUTF8Alloc(bun.default_allocator, escaped_html) catch unreachable, false) catch unreachable).?,
+ escaped_html,
+ ),
+ );
+
+ // assert we do not allocate a new string unnecessarily
+ std.debug.assert(
+ !std.mem.eql(
+ u16,
+ input_slice,
+ escaped_html,
+ ),
+ );
+
+ // the output should always be longer than the input
+ std.debug.assert(escaped_html.len > input_slice.len);
+ }
+
+ return ZigString.from16(escaped_html.ptr, escaped_html.len).toExternalValue(globalObject);
+ } else {
+ var input_slice = zig_str.slice();
+ var escaped_html = strings.escapeHTMLForLatin1Input(globalObject.bunVM().allocator, input_slice) catch {
+ globalObject.vm().throwError(globalObject, ZigString.init("Out of memory").toValue(globalObject));
+ return JSC.JSValue.jsUndefined();
+ };
+
+ if (escaped_html.ptr == input_slice.ptr and escaped_html.len == input_slice.len) {
+ return input_value;
+ }
+
+ if (input_slice.len == 1) {
+ // single character escaped strings are statically allocated
+ return ZigString.init(escaped_html).toValue(globalObject);
+ }
+
+ if (comptime Environment.allow_assert) {
+ // the output should always be longer than the input
+ std.debug.assert(escaped_html.len > input_slice.len);
+
+ // assert we do not allocate a new string unnecessarily
+ std.debug.assert(
+ !std.mem.eql(
+ u8,
+ input_slice,
+ escaped_html,
+ ),
+ );
+ }
+
+ return ZigString.init(escaped_html).toExternalValue(globalObject);
+ }
+}
+
+comptime {
+ if (!JSC.is_bindgen) {
+ _ = Bun__escapeHTML;
+ }
+}
+
pub fn allocUnsafe(
_: void,
ctx: js.JSContextRef,
@@ -1620,7 +1714,7 @@ pub fn allocUnsafe(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) js.JSValueRef {
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
const length = @intCast(
usize,
@@ -1649,7 +1743,7 @@ pub fn mmapFile(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) js.JSValueRef {
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
var buf: [bun.MAX_PATH_BYTES]u8 = undefined;
const path = getFilePath(ctx, arguments[0..@minimum(1, arguments.len)], &buf, exception) orelse return null;
@@ -1795,7 +1889,7 @@ pub const Hash = struct {
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) js.JSValueRef {
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
var input: []const u8 = "";
var input_slice = ZigString.Slice.empty;
defer input_slice.deinit();
@@ -2375,7 +2469,7 @@ pub const FFI = struct {
return JSC.toInvalidArguments("ptr to invalid memory, that would segfault Bun :(", .{}, globalThis.ref());
}
- return JSC.JSValue.jsNumber(@bitCast(f64, @as(usize, addr)));
+ return JSC.JSValue.fromPtrAddress(addr);
}
const ValueOrError = union(enum) {
diff --git a/src/javascript/jsc/api/ffi.zig b/src/javascript/jsc/api/ffi.zig
index 820a0e3d5..864a5d889 100644
--- a/src/javascript/jsc/api/ffi.zig
+++ b/src/javascript/jsc/api/ffi.zig
@@ -351,7 +351,7 @@ pub const FFI = struct {
return ZigString.init("Failed to compile (nothing happend!)").toErrorInstance(global);
},
.compiled => |compiled| {
- var cb = Bun__CreateFFIFunction(
+ var cb = JSC.NewFunctionPtr(
global,
&ZigString.init(std.mem.span(function_name)),
@intCast(u32, function.arg_types.items.len),
@@ -443,7 +443,7 @@ pub const FFI = struct {
return ZigString.init("Failed to compile (nothing happend!)").toErrorInstance(global);
},
.compiled => |compiled| {
- var cb = Bun__CreateFFIFunction(
+ var cb = JSC.NewFunctionPtr(
global,
&ZigString.init(std.mem.span(function_name)),
@intCast(u32, function.arg_types.items.len),
@@ -1434,10 +1434,3 @@ pub const FFI = struct {
}
};
};
-
-extern fn Bun__CreateFFIFunction(
- globalObject: *JSGlobalObject,
- symbolName: *const ZigString,
- argCount: u32,
- functionPointer: *anyopaque,
-) *anyopaque;
diff --git a/src/javascript/jsc/api/html_rewriter.zig b/src/javascript/jsc/api/html_rewriter.zig
index 70406ace5..7605cfef7 100644
--- a/src/javascript/jsc/api/html_rewriter.zig
+++ b/src/javascript/jsc/api/html_rewriter.zig
@@ -408,6 +408,124 @@ pub const HTMLRewriter = struct {
this.context.deinit(bun.default_allocator);
}
};
+
+ // pub const StreamOutputSink = struct {
+ // global: *JSGlobalObject,
+ // rewriter: *LOLHTML.HTMLRewriter,
+ // context: LOLHTMLContext,
+ // response: *Response,
+ // input: JSC.WebCore.Blob = undefined,
+ // pub fn init(context: LOLHTMLContext, global: *JSGlobalObject, original: *Response, builder: *LOLHTML.HTMLRewriter.Builder) JSValue {
+ // var result = bun.default_allocator.create(Response) catch unreachable;
+ // var sink = bun.default_allocator.create(StreamOutputSink) catch unreachable;
+ // sink.* = StreamOutputSink{
+ // .global = global,
+ // .rewriter = undefined,
+ // .context = context,
+ // .response = result,
+ // };
+
+ // for (sink.context.document_handlers.items) |doc| {
+ // doc.ctx = sink;
+ // }
+ // for (sink.context.element_handlers.items) |doc| {
+ // doc.ctx = sink;
+ // }
+
+ // sink.rewriter = builder.build(
+ // .UTF8,
+ // .{
+ // .preallocated_parsing_buffer_size = @maximum(original.body.len(), 1024),
+ // .max_allowed_memory_usage = std.math.maxInt(u32),
+ // },
+ // false,
+ // StreamOutputSink,
+ // sink,
+ // StreamOutputSink.write,
+ // StreamOutputSink.done,
+ // ) catch {
+ // sink.deinit();
+ // bun.default_allocator.destroy(result);
+
+ // return throwLOLHTMLError(global);
+ // };
+
+ // result.* = Response{
+ // .allocator = bun.default_allocator,
+ // .body = .{
+ // .init = .{
+ // .status_code = 200,
+ // },
+ // .value = .{
+ // .Locked = .{
+ // .global = global,
+ // .task = sink,
+ // },
+ // },
+ // },
+ // };
+
+ // result.body.init.headers = original.body.init.headers;
+ // result.body.init.method = original.body.init.method;
+ // result.body.init.status_code = original.body.init.status_code;
+
+ // result.url = bun.default_allocator.dupe(u8, original.url) catch unreachable;
+ // result.status_text = bun.default_allocator.dupe(u8, original.status_text) catch unreachable;
+
+ // var input: JSC.WebCore.Blob = original.body.value.use();
+
+ // const is_pending = input.needsToReadFile();
+ // defer if (!is_pending) input.detach();
+
+ // if (is_pending) {
+ // input.doReadFileInternal(*StreamOutputSink, sink, onFinishedLoading, global);
+ // } else if (sink.runOutputSink(input.sharedView(), false, false)) |error_value| {
+ // return error_value;
+ // }
+
+ // // Hold off on cloning until we're actually done.
+
+ // return JSC.JSValue.fromRef(
+ // Response.makeMaybePooled(sink.global.ref(), sink.response),
+ // );
+ // }
+
+ // pub fn runOutputSink(
+ // sink: *StreamOutputSink,
+ // bytes: []const u8,
+ // is_async: bool,
+ // free_bytes_on_end: bool,
+ // ) ?JSValue {
+ // defer if (free_bytes_on_end)
+ // bun.default_allocator.free(bun.constStrToU8(bytes));
+
+ // return null;
+ // }
+
+ // pub const Sync = enum { suspended, pending, done };
+
+ // pub fn done(this: *StreamOutputSink) void {
+ // var prev_value = this.response.body.value;
+ // var bytes = this.bytes.toOwnedSliceLeaky();
+ // this.response.body.value = .{
+ // .Blob = JSC.WebCore.Blob.init(bytes, this.bytes.allocator, this.global),
+ // };
+ // prev_value.resolve(
+ // &this.response.body.value,
+ // this.global,
+ // );
+ // }
+
+ // pub fn write(this: *StreamOutputSink, bytes: []const u8) void {
+ // this.bytes.append(bytes) catch unreachable;
+ // }
+
+ // pub fn deinit(this: *StreamOutputSink) void {
+ // this.bytes.deinit();
+
+ // this.context.deinit(bun.default_allocator);
+ // }
+ // };
};
const DocumentHandler = struct {
diff --git a/src/javascript/jsc/api/server.zig b/src/javascript/jsc/api/server.zig
index a76ddf9ab..bec079e90 100644
--- a/src/javascript/jsc/api/server.zig
+++ b/src/javascript/jsc/api/server.zig
@@ -238,7 +238,7 @@ pub const ServerConfig = struct {
};
pub fn fromJS(global: *JSC.JSGlobalObject, arguments: *JSC.Node.ArgumentsSlice, exception: JSC.C.ExceptionRef) ServerConfig {
- var env = VirtualMachine.vm.bundler.env;
+ var env = arguments.vm.bundler.env;
var args = ServerConfig{
.port = 3000,
@@ -250,7 +250,7 @@ pub const ServerConfig = struct {
args.development = false;
}
- if (VirtualMachine.vm.bundler.options.production) {
+ if (arguments.vm.bundler.options.production) {
args.development = false;
}
@@ -264,11 +264,11 @@ pub const ServerConfig = struct {
}
}
- if (VirtualMachine.vm.bundler.options.transform_options.port) |port| {
+ if (arguments.vm.bundler.options.transform_options.port) |port| {
args.port = port;
}
- if (VirtualMachine.vm.bundler.options.transform_options.origin) |origin| {
+ if (arguments.vm.bundler.options.transform_options.origin) |origin| {
args.base_uri = origin;
}
@@ -515,6 +515,11 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
url: string,
method: HTTP.Method,
aborted: bool = false,
+ finalized: bun.DebugOnly(bool) = bun.DebugOnlyDefault(false),
+
+ /// We can only safely free once the request body promise is finalized
+ /// and the response is rejected
+ pending_promises_for_abort: u8 = 0,
has_marked_complete: bool = false,
response_jsvalue: JSC.JSValue = JSC.JSValue.zero,
@@ -549,7 +554,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
arguments: []const JSC.JSValue,
) void {
if (ctx.aborted) {
- ctx.finalize();
+ ctx.finalizeForAbort();
return;
}
@@ -579,16 +584,20 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
ctx.render(response);
}
+ pub fn finalizeForAbort(this: *RequestContext) void {
+ this.pending_promises_for_abort -|= 1;
+ if (this.pending_promises_for_abort == 0) this.finalize();
+ }
+
pub fn onReject(
ctx: *RequestContext,
_: *JSC.JSGlobalObject,
arguments: []const JSC.JSValue,
) void {
if (ctx.aborted) {
- ctx.finalize();
+ ctx.finalizeForAbort();
return;
}
-
handleReject(ctx, if (arguments.len > 0) arguments[0] else JSC.JSValue.jsUndefined());
}
@@ -598,10 +607,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
);
if (ctx.aborted) {
- ctx.finalize();
+ ctx.finalizeForAbort();
return;
}
-
if (!ctx.resp.hasResponded()) {
ctx.renderMissing();
}
@@ -674,8 +682,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn onWritableResponseBuffer(this: *RequestContext, write_offset: c_ulong, resp: *App.Response) callconv(.C) bool {
+ std.debug.assert(this.resp == resp);
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return false;
}
return this.sendWritableBytes(this.response_buf_owned.items, write_offset, resp);
@@ -694,10 +703,69 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
};
}
- pub fn onAbort(this: *RequestContext, _: *App.Response) void {
+ pub fn isDeadRequest(this: *RequestContext) bool {
+ if (this.pending_promises_for_abort > 0) return false;
+
+ if (this.promise != null) {
+ return false;
+ }
+
+ if (this.request_js_object) |obj| {
+ if (obj.value().as(Request)) |req| {
+ if (req.body == .Locked) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ pub fn onAbort(this: *RequestContext, resp: *App.Response) void {
+ std.debug.assert(this.resp == resp);
+ std.debug.assert(!this.aborted);
this.aborted = true;
- this.finalizeWithoutDeinit();
- this.markComplete();
+
+ // if we can, free the request now.
+ if (this.isDeadRequest()) {
+ this.finalizeWithoutDeinit();
+ this.markComplete();
+ this.deinit();
+ } else {
+ this.pending_promises_for_abort = 0;
+
+ // if we cannot, we have to reject pending promises
+ // first, we reject the request body promise
+ if (this.request_js_object != null) {
+ var request_js = this.request_js_object.?.value();
+ request_js.ensureStillAlive();
+
+ this.request_js_object = null;
+ defer request_js.ensureStillAlive();
+ defer JSC.C.JSValueUnprotect(this.server.globalThis.ref(), request_js.asObjectRef());
+ // User called .blob(), .json(), text(), or .arrayBuffer() on the Request object
+ // but we received nothing or the connection was aborted
+ if (request_js.as(Request)) |req| {
+ // the promise is pending
+ if (req.body == .Locked and (req.body.Locked.action != .none or req.body.Locked.promise != null)) {
+ this.pending_promises_for_abort += 1;
+ req.body.toErrorInstance(JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis), this.server.globalThis);
+ }
+ req.uws_request = null;
+ }
+ }
+
+ // then, we reject the response promise
+ if (this.promise) |promise| {
+ this.pending_promises_for_abort += 1;
+ this.promise = null;
+ promise.asPromise().?.reject(this.server.globalThis, JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis));
+ }
+
+ if (this.pending_promises_for_abort > 0) {
+ this.server.vm.tick();
+ }
+ }
}
pub fn markComplete(this: *RequestContext) void {
@@ -709,7 +777,11 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
// so it's important that we can safely do that
pub fn finalizeWithoutDeinit(this: *RequestContext) void {
this.blob.detach();
- this.request_body_buf.clearAndFree(this.allocator);
+
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(!this.finalized);
+ this.finalized = true;
+ }
if (!this.response_jsvalue.isEmpty()) {
this.server.response_objects_pool.push(this.server.globalThis, this.response_jsvalue);
@@ -717,38 +789,56 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
if (this.request_js_object != null) {
+ var request_js = this.request_js_object.?.value();
+ request_js.ensureStillAlive();
+
+ this.request_js_object = null;
+ defer request_js.ensureStillAlive();
+ defer JSC.C.JSValueUnprotect(this.server.globalThis.ref(), request_js.asObjectRef());
// User called .blob(), .json(), text(), or .arrayBuffer() on the Request object
- // but we received nothing
- if (JSC.JSValue.fromRef(this.request_js_object).as(Request)) |req| {
+ // but we received nothing or the connection was aborted
+ if (request_js.as(Request)) |req| {
+ // the promise is pending
if (req.body == .Locked and req.body.Locked.action != .none and req.body.Locked.promise != null) {
- var old_body = req.body;
- req.body = JSC.WebCore.Body.Value.empty;
- old_body.Locked.callback = null;
- old_body.resolve(&req.body, this.server.globalThis);
- VirtualMachine.vm.tick();
+ req.body.toErrorInstance(JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis), this.server.globalThis);
}
req.uws_request = null;
- JSC.C.JSValueUnprotect(this.server.globalThis.ref(), this.request_js_object);
- this.request_js_object = null;
}
}
- if (this.promise != null) {
- JSC.C.JSValueUnprotect(this.server.globalThis.ref(), this.promise.?.asObjectRef());
+ if (this.promise) |promise| {
this.promise = null;
+
+ if (promise.asInternalPromise()) |prom| {
+ prom.rejectAsHandled(this.server.globalThis, (JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis)));
+ } else if (promise.asPromise()) |prom| {
+ prom.rejectAsHandled(this.server.globalThis, (JSC.toTypeError(.ABORT_ERR, "Request aborted", .{}, this.server.globalThis)));
+ }
+ JSC.C.JSValueUnprotect(this.server.globalThis.ref(), promise.asObjectRef());
}
if (this.response_headers != null) {
this.response_headers.?.deref();
this.response_headers = null;
}
-
- this.response_buf_owned.clearAndFree(this.allocator);
}
pub fn finalize(this: *RequestContext) void {
- var server = this.server;
this.finalizeWithoutDeinit();
this.markComplete();
+ this.deinit();
+ }
+
+ pub fn deinit(this: *RequestContext) void {
+ if (comptime Environment.allow_assert)
+ std.debug.assert(this.finalized);
+
+ if (comptime Environment.allow_assert)
+ std.debug.assert(this.has_marked_complete);
+
+ var server = this.server;
+ this.request_body_buf.clearAndFree(this.allocator);
+ this.response_buf_owned.clearAndFree(this.allocator);
+
server.request_pool_allocator.destroy(this);
}
@@ -855,8 +945,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn onWritableBytes(this: *RequestContext, write_offset: c_ulong, resp: *App.Response) callconv(.C) bool {
+ std.debug.assert(this.resp == resp);
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return false;
}
@@ -865,6 +956,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
pub fn sendWritableBytes(this: *RequestContext, bytes_: []const u8, write_offset: c_ulong, resp: *App.Response) bool {
+ std.debug.assert(this.resp == resp);
+
var bytes = bytes_[@minimum(bytes_.len, @truncate(usize, write_offset))..];
if (resp.tryEnd(bytes, bytes_.len)) {
this.finalize();
@@ -976,7 +1069,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
pub fn doSendfile(this: *RequestContext, blob: Blob) void {
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return;
}
@@ -994,7 +1087,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
pub fn onReadFile(this: *RequestContext, result: Blob.Store.ReadFile.ResultType) void {
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return;
}
@@ -1024,7 +1117,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
const err = value.Error;
_ = value.use();
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return;
}
this.runErrorHandler(err);
@@ -1034,7 +1127,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
this.blob = value.use();
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return;
}
@@ -1068,7 +1161,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
pub fn doRender(this: *RequestContext) void {
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return;
}
var response = this.response_ptr.?;
@@ -1232,7 +1325,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
pub fn resolveRequestBody(this: *RequestContext) void {
if (this.aborted) {
- this.finalize();
+ this.finalizeForAbort();
return;
}
@@ -1251,7 +1344,9 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
}
- pub fn onBodyChunk(this: *RequestContext, _: *App.Response, chunk: []const u8, last: bool) void {
+ pub fn onBodyChunk(this: *RequestContext, resp: *App.Response, chunk: []const u8, last: bool) void {
+ std.debug.assert(this.resp == resp);
+
if (this.aborted) return;
this.request_body_buf.appendSlice(this.allocator, chunk) catch @panic("Out of memory while allocating request body");
if (last) {
@@ -1264,7 +1359,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
}
}
- pub fn onRequestData(this: *RequestContext) void {
+ pub fn onPull(this: *RequestContext) void {
if (this.req.header("content-length")) |content_length| {
const len = std.fmt.parseInt(usize, content_length, 10) catch 0;
if (len == 0) {
@@ -1301,8 +1396,8 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
this.resp.onData(*RequestContext, onBodyChunk, this);
}
- pub fn onRequestDataCallback(this: *anyopaque) void {
- onRequestData(bun.cast(*RequestContext, this));
+ pub fn onPullCallback(this: *anyopaque) void {
+ onPull(bun.cast(*RequestContext, this));
}
};
}
@@ -1522,7 +1617,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
this.listen_callback = JSC.AnyTask.New(ThisServer, run).init(this);
this.vm.eventLoop().enqueueTask(JSC.Task.init(&this.listen_callback));
if (needs_post_handler) {
- _ = this.vm.uws_event_loop.?.addPostHandler(*JSC.VirtualMachine.EventLoop, this.vm.eventLoop(), JSC.VirtualMachine.EventLoop.tick);
+ _ = this.vm.uws_event_loop.?.addPostHandler(*JSC.EventLoop, this.vm.eventLoop(), JSC.EventLoop.tick);
}
}
@@ -1605,7 +1700,7 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
.Locked = .{
.task = ctx,
.global = this.globalThis,
- .onRequestData = RequestContext.onRequestDataCallback,
+ .onPull = RequestContext.onPullCallback,
},
},
};
@@ -1617,10 +1712,9 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type {
const response_value = JSC.C.JSObjectCallAsFunctionReturnValue(this.globalThis.ref(), this.config.onRequest.asObjectRef(), this.thisObject.asObjectRef(), 1, &args);
if (ctx.aborted) {
- ctx.finalize();
+ ctx.finalizeForAbort();
return;
}
-
if (response_value.isEmptyOrUndefinedOrNull() and !ctx.resp.hasResponded()) {
ctx.renderMissing();
return;
diff --git a/src/javascript/jsc/api/transpiler.zig b/src/javascript/jsc/api/transpiler.zig
index b8a8192c6..69732c643 100644
--- a/src/javascript/jsc/api/transpiler.zig
+++ b/src/javascript/jsc/api/transpiler.zig
@@ -547,6 +547,19 @@ fn transformOptionsFromJSC(ctx: JSC.C.JSContextRef, temp_allocator: std.mem.Allo
transpiler.runtime.allow_runtime = flag.toBoolean();
}
+ if (object.get(globalThis, "jsxOptimizationInline")) |flag| {
+ transpiler.runtime.jsx_optimization_inline = flag.toBoolean();
+ }
+
+ if (object.get(globalThis, "jsxOptimizationHoist")) |flag| {
+ transpiler.runtime.jsx_optimization_hoist = flag.toBoolean();
+
+ if (!transpiler.runtime.jsx_optimization_inline and transpiler.runtime.jsx_optimization_hoist) {
+ JSC.throwInvalidArguments("jsxOptimizationHoist requires jsxOptimizationInline", .{}, ctx, exception);
+ return transpiler;
+ }
+ }
+
if (object.get(globalThis, "sourcemap")) |flag| {
if (flag.isBoolean() or flag.isUndefinedOrNull()) {
if (flag.toBoolean()) {
@@ -737,7 +750,7 @@ pub fn constructor(
exception: js.ExceptionRef,
) js.JSObjectRef {
var temp = std.heap.ArenaAllocator.init(getAllocator(ctx));
- var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
+ var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
defer temp.deinit();
const transpiler_options: TranspilerOptions = if (arguments.len > 0)
transformOptionsFromJSC(ctx, temp.allocator(), &args, exception) catch {
@@ -874,7 +887,7 @@ pub fn scan(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) JSC.C.JSObjectRef {
- var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
+ var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
defer args.arena.deinit();
const code_arg = args.next() orelse {
JSC.throwInvalidArguments("Expected a string or Uint8Array", .{}, ctx, exception);
@@ -965,7 +978,7 @@ pub fn transform(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) JSC.C.JSObjectRef {
- var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
+ var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
defer args.arena.deinit();
const code_arg = args.next() orelse {
JSC.throwInvalidArguments("Expected a string or Uint8Array", .{}, ctx, exception);
@@ -1006,7 +1019,7 @@ pub fn transformSync(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) JSC.C.JSObjectRef {
- var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
+ var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
defer args.arena.deinit();
const code_arg = args.next() orelse {
JSC.throwInvalidArguments("Expected a string or Uint8Array", .{}, ctx, exception);
@@ -1193,7 +1206,7 @@ pub fn scanImports(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) JSC.C.JSObjectRef {
- var args = JSC.Node.ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
+ var args = JSC.Node.ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
const code_arg = args.next() orelse {
JSC.throwInvalidArguments("Expected a string or Uint8Array", .{}, ctx, exception);
return null;
diff --git a/src/javascript/jsc/base.zig b/src/javascript/jsc/base.zig
index 70570ed20..777a5d6ef 100644
--- a/src/javascript/jsc/base.zig
+++ b/src/javascript/jsc/base.zig
@@ -2553,6 +2553,7 @@ pub export fn MarkedArrayBuffer_deallocator(bytes_: *anyopaque, _: *anyopaque) v
// but we don't
mimalloc.mi_free(bytes_);
}
+
pub export fn BlobArrayBuffer_deallocator(_: *anyopaque, blob: *anyopaque) void {
// zig's memory allocator interface won't work here
// mimalloc knows the size of things
@@ -2646,7 +2647,6 @@ pub const JSPrivateDataPtr = TaggedPointerUnion(.{
Stats,
TextChunk,
TextDecoder,
- TextEncoder,
TimeoutTask,
Transpiler,
FFI,
@@ -2793,7 +2793,7 @@ pub fn wrapWithHasContainer(
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) js.JSObjectRef {
- var iter = JSC.Node.ArgumentsSlice.from(arguments);
+ var iter = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
var args: Args = undefined;
comptime var i: usize = 0;
@@ -2934,14 +2934,15 @@ pub fn wrapWithHasContainer(
}
if (comptime maybe_async) {
- JavaScript.VirtualMachine.vm.tick();
+ var vm = ctx.ptr().bunVM();
+ vm.tick();
var promise = JSC.JSInternalPromise.resolvedPromise(ctx.ptr(), result);
switch (promise.status(ctx.ptr().vm())) {
JSC.JSPromise.Status.Pending => {
while (promise.status(ctx.ptr().vm()) == .Pending) {
- JavaScript.VirtualMachine.vm.tick();
+ vm.tick();
}
result = promise.result(ctx.ptr().vm());
},
diff --git a/src/javascript/jsc/bindings/BunBuiltinNames.h b/src/javascript/jsc/bindings/BunBuiltinNames.h
index 28ab0235d..a2a6c6b3c 100644
--- a/src/javascript/jsc/bindings/BunBuiltinNames.h
+++ b/src/javascript/jsc/bindings/BunBuiltinNames.h
@@ -23,49 +23,128 @@ using namespace JSC;
#define BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
+ macro(AbortSignal) \
+ macro(ReadableByteStreamController) \
+ macro(ReadableStream) \
+ macro(ReadableStreamBYOBReader) \
+ macro(ReadableStreamBYOBRequest) \
+ macro(ReadableStreamDefaultController) \
+ macro(ReadableStreamDefaultReader) \
+ macro(TransformStream) \
+ macro(TransformStreamDefaultController) \
+ macro(WritableStream) \
+ macro(WritableStreamDefaultController) \
+ macro(WritableStreamDefaultWriter) \
+ macro(abortAlgorithm) \
+ macro(abortSteps) \
macro(addEventListener) \
+ macro(appendFromJS) \
macro(argv) \
+ macro(associatedReadableByteStreamController) \
+ macro(autoAllocateChunkSize) \
+ macro(backingMap) \
+ macro(backingSet) \
+ macro(backpressure) \
+ macro(backpressureChangePromise) \
macro(basename) \
+ macro(body) \
+ macro(bunNativePtr) \
+ macro(bunNativeType) \
+ macro(byobRequest) \
+ macro(cancel) \
+ macro(cancelAlgorithm) \
macro(chdir) \
+ macro(cloneArrayBuffer) \
macro(close) \
+ macro(closeAlgorithm) \
+ macro(closeRequest) \
+ macro(closeRequested) \
+ macro(closed) \
+ macro(closedPromise) \
+ macro(closedPromiseCapability) \
macro(code) \
macro(connect) \
+ macro(controlledReadableStream) \
+ macro(controller) \
+ macro(consumeReadableStream) \
macro(cork) \
+ macro(createFIFO) \
+ macro(createNativeReadableStream) \
+ macro(createEmptyReadableStream) \
+ macro(createReadableStream) \
+ macro(createUninitializedArrayBuffer) \
+ macro(createWritableStreamFromInternal) \
macro(cwd) \
+ macro(dataView) \
+ macro(decode) \
macro(delimiter) \
- macro(whenSignalAborted) \
macro(destroy) \
macro(dir) \
macro(dirname) \
+ macro(disturbed) \
+ macro(document) \
+ macro(encode) \
+ macro(encoding) \
macro(end) \
macro(errno) \
+ macro(errorSteps) \
macro(execArgv) \
macro(extname) \
+ macro(failureKind) \
+ macro(fatal) \
+ macro(fetch) \
+ macro(fetchRequest) \
macro(file) \
macro(filePath) \
+ macro(fillFromJS) \
+ macro(finishConsumingStream) \
+ macro(flush) \
+ macro(flushAlgorithm) \
macro(format) \
macro(get) \
+ macro(getInternalWritableStream) \
+ macro(handleEvent) \
macro(hash) \
+ macro(header) \
+ macro(highWaterMark) \
macro(host) \
macro(hostname) \
macro(href) \
+ macro(ignoreBOM) \
+ macro(inFlightCloseRequest) \
+ macro(inFlightWriteRequest) \
+ macro(initializeWith) \
+ macro(internalStream) \
+ macro(internalWritable) \
+ macro(isAbortSignal) \
macro(isAbsolute) \
+ macro(isDisturbed) \
macro(isPaused) \
+ macro(isSecureContext) \
macro(isWindows) \
macro(join) \
+ macro(kind) \
+ macro(localStreams) \
+ macro(makeDOMException) \
+ macro(makeGetterTypeError) \
+ macro(makeThisTypeError) \
macro(map) \
+ macro(nativeReadableStreamPrototype) \
macro(nextTick) \
macro(normalize) \
macro(on) \
macro(once) \
macro(options) \
macro(origin) \
+ macro(ownerReadableStream) \
macro(parse) \
macro(password) \
macro(patch) \
macro(path) \
macro(pathname) \
macro(pause) \
+ macro(pendingAbortRequest) \
+ macro(pendingPullIntos) \
macro(pid) \
macro(pipe) \
macro(port) \
@@ -74,30 +153,78 @@ using namespace JSC;
macro(prependEventListener) \
macro(process) \
macro(protocol) \
+ macro(pull) \
+ macro(pullAgain) \
+ macro(pullAlgorithm) \
+ macro(pulling) \
macro(put) \
+ macro(queue) \
macro(read) \
+ macro(readIntoRequests) \
+ macro(readRequests) \
+ macro(readable) \
+ macro(readableStreamController) \
+ macro(readableStreamToArray) \
+ macro(reader) \
+ macro(readyPromise) \
+ macro(readyPromiseCapability) \
macro(relative) \
- macro(require) \
- macro(resolveSync) \
+ macro(releaseLock) \
macro(removeEventListener) \
+ macro(require) \
macro(resolve) \
+ macro(resolveSync) \
macro(resume) \
macro(search) \
macro(searchParams) \
+ macro(self) \
macro(sep) \
+ macro(setBody) \
+ macro(setStatus) \
+ macro(size) \
+ macro(start) \
+ macro(startConsumingStream) \
+ macro(started) \
+ macro(startedPromise) \
+ macro(state) \
+ macro(storedError) \
+ macro(strategy) \
+ macro(strategyHWM) \
+ macro(strategySizeAlgorithm) \
+ macro(stream) \
+ macro(streamClosed) \
+ macro(streamClosing) \
+ macro(streamErrored) \
+ macro(streamReadable) \
+ macro(streamWaiting) \
+ macro(streamWritable) \
+ macro(structuredCloneForStream) \
macro(syscall) \
- macro(title) \
+ macro(textDecoderStreamDecoder) \
+ macro(textDecoderStreamTransform) \
+ macro(textEncoderStreamEncoder) \
+ macro(textEncoderStreamTransform) \
macro(toNamespacedPath) \
macro(trace) \
+ macro(transformAlgorithm) \
macro(uncork) \
+ macro(underlyingByteSource) \
+ macro(underlyingSink) \
+ macro(underlyingSource) \
macro(unpipe) \
macro(unshift) \
macro(url) \
macro(username) \
macro(version) \
macro(versions) \
+ macro(view) \
+ macro(whenSignalAborted) \
+ macro(writable) \
macro(write) \
- macro(dataView) \
+ macro(writeAlgorithm) \
+ macro(writeRequests) \
+ macro(writer) \
+ macro(writing) \
BUN_ADDITIONAL_PRIVATE_IDENTIFIERS(macro) \
class BunBuiltinNames {
@@ -123,5 +250,7 @@ private:
BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(DECLARE_BUILTIN_NAMES)
};
+
+
} // namespace WebCore
diff --git a/src/javascript/jsc/bindings/BunClientData.cpp b/src/javascript/jsc/bindings/BunClientData.cpp
index 807525a21..2cdd8b25a 100644
--- a/src/javascript/jsc/bindings/BunClientData.cpp
+++ b/src/javascript/jsc/bindings/BunClientData.cpp
@@ -14,21 +14,23 @@
#include "wtf/MainThread.h"
#include "JSDOMConstructorBase.h"
+#include "JSDOMBuiltinConstructorBase.h"
#include "BunGCOutputConstraint.h"
#include "WebCoreTypedArrayController.h"
-#include "JavaScriptCore/AbstractSlotVisitorInlines.h"
-#include "JavaScriptCore/JSCellInlines.h"
-#include "JavaScriptCore/WeakInlines.h"
+#include "JavaScriptCore/JSCInlines.h"
+
+#include "JSDOMWrapper.h"
namespace WebCore {
using namespace JSC;
JSHeapData::JSHeapData(Heap& heap)
- // : m_domNamespaceObjectSpace ISO_SUBSPACE_INIT(heap, heap.cellHeapCellType, JSDOMObject)
- // ,
- : m_subspaces(makeUnique<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 +38,14 @@ JSHeapData::JSHeapData(Heap& heap)
#define CLIENT_ISO_SUBSPACE_INIT(subspace) subspace(m_heapData->subspace)
JSVMClientData::JSVMClientData(VM& vm)
- : m_builtinNames(vm)
+ : m_builtinFunctions(vm)
+ , m_builtinNames(vm)
, m_heapData(JSHeapData::ensureHeapData(vm.heap))
+ , CLIENT_ISO_SUBSPACE_INIT(m_domBuiltinConstructorSpace)
, CLIENT_ISO_SUBSPACE_INIT(m_domConstructorSpace)
+ , CLIENT_ISO_SUBSPACE_INIT(m_domNamespaceObjectSpace)
, m_clientSubspaces(makeUnique<ExtendedDOMClientIsoSubspaces>())
- , m_builtinFunctions(vm)
+
{
}
@@ -59,8 +64,11 @@ JSHeapData* JSHeapData::ensureHeapData(Heap& heap)
return singleton;
}
-JSVMClientData::~JSVMClientData() {}
-
+JSVMClientData::~JSVMClientData()
+{
+ ASSERT(m_normalWorld->hasOneRef());
+ m_normalWorld = nullptr;
+}
void JSVMClientData::create(VM* vm)
{
JSVMClientData* clientData = new JSVMClientData(*vm);
@@ -68,7 +76,6 @@ void JSVMClientData::create(VM* vm)
clientData->m_normalWorld = DOMWrapperWorld::create(*vm, DOMWrapperWorld::Type::Normal);
vm->heap.addMarkingConstraint(makeUnique<WebCore::DOMGCOutputConstraint>(*vm, clientData->heapData()));
-
vm->m_typedArrayController = adoptRef(new WebCoreTypedArrayController(true));
}
diff --git a/src/javascript/jsc/bindings/BunClientData.h b/src/javascript/jsc/bindings/BunClientData.h
index 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/BunGCOutputConstraint.cpp b/src/javascript/jsc/bindings/BunGCOutputConstraint.cpp
index ec487edc9..97ee0761b 100644
--- a/src/javascript/jsc/bindings/BunGCOutputConstraint.cpp
+++ b/src/javascript/jsc/bindings/BunGCOutputConstraint.cpp
@@ -31,105 +31,105 @@
#include "JavaScriptCore/VM.h"
#include "JavaScriptCore/MarkingConstraint.h"
-namespace JSC {
-
-class VisitCounter {
-public:
- VisitCounter() {}
-
- VisitCounter(AbstractSlotVisitor& visitor)
- : m_visitor(&visitor)
- , m_initialVisitCount(visitor.visitCount())
- {
- }
-
- AbstractSlotVisitor& visitor() const { return *m_visitor; }
-
- size_t visitCount() const
- {
- return m_visitor->visitCount() - m_initialVisitCount;
- }
-
-private:
- AbstractSlotVisitor* m_visitor { nullptr };
- size_t m_initialVisitCount { 0 };
-};
-
-static constexpr bool verboseMarkingConstraint = false;
-
-MarkingConstraint::MarkingConstraint(CString abbreviatedName, CString name, ConstraintVolatility volatility, ConstraintConcurrency concurrency, ConstraintParallelism parallelism)
- : m_abbreviatedName(abbreviatedName)
- , m_name(WTFMove(name))
- , m_volatility(volatility)
- , m_concurrency(concurrency)
- , m_parallelism(parallelism)
-{
-}
-
-MarkingConstraint::~MarkingConstraint()
-{
-}
-
-void MarkingConstraint::resetStats()
-{
- m_lastVisitCount = 0;
-}
-
-void MarkingConstraint::execute(SlotVisitor& visitor)
-{
- ASSERT(!visitor.heap()->isMarkingForGCVerifier());
- VisitCounter visitCounter(visitor);
- executeImpl(visitor);
- m_lastVisitCount += visitCounter.visitCount();
- if (verboseMarkingConstraint && visitCounter.visitCount())
- dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in execute)");
-}
-
-void MarkingConstraint::executeSynchronously(AbstractSlotVisitor& visitor)
-{
- prepareToExecuteImpl(NoLockingNecessary, visitor);
- executeImpl(visitor);
-}
-
-double MarkingConstraint::quickWorkEstimate(SlotVisitor&)
-{
- return 0;
-}
-
-double MarkingConstraint::workEstimate(SlotVisitor& visitor)
-{
- return lastVisitCount() + quickWorkEstimate(visitor);
-}
-
-void MarkingConstraint::prepareToExecute(const AbstractLocker& constraintSolvingLocker, SlotVisitor& visitor)
-{
- ASSERT(!visitor.heap()->isMarkingForGCVerifier());
- dataLogIf(Options::logGC(), abbreviatedName());
- VisitCounter visitCounter(visitor);
- prepareToExecuteImpl(constraintSolvingLocker, visitor);
- m_lastVisitCount = visitCounter.visitCount();
- if (verboseMarkingConstraint && visitCounter.visitCount())
- dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in prepareToExecute)");
-}
-
-void MarkingConstraint::doParallelWork(SlotVisitor& visitor, SharedTask<void(SlotVisitor&)>& task)
-{
- ASSERT(!visitor.heap()->isMarkingForGCVerifier());
- VisitCounter visitCounter(visitor);
- task.run(visitor);
- if (verboseMarkingConstraint && visitCounter.visitCount())
- dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in doParallelWork)");
- {
- Locker locker { m_lock };
- m_lastVisitCount += visitCounter.visitCount();
- }
-}
-
-void MarkingConstraint::prepareToExecuteImpl(const AbstractLocker&, AbstractSlotVisitor&)
-{
-}
-
-} // namespace JSC
+// namespace JSC {
+
+// class VisitCounter {
+// public:
+// VisitCounter() {}
+
+// VisitCounter(AbstractSlotVisitor& visitor)
+// : m_visitor(&visitor)
+// , m_initialVisitCount(visitor.visitCount())
+// {
+// }
+
+// AbstractSlotVisitor& visitor() const { return *m_visitor; }
+
+// size_t visitCount() const
+// {
+// return m_visitor->visitCount() - m_initialVisitCount;
+// }
+
+// private:
+// AbstractSlotVisitor* m_visitor { nullptr };
+// size_t m_initialVisitCount { 0 };
+// };
+
+// static constexpr bool verboseMarkingConstraint = false;
+
+// MarkingConstraint::MarkingConstraint(CString abbreviatedName, CString name, ConstraintVolatility volatility, ConstraintConcurrency concurrency, ConstraintParallelism parallelism)
+// : m_abbreviatedName(abbreviatedName)
+// , m_name(WTFMove(name))
+// , m_volatility(volatility)
+// , m_concurrency(concurrency)
+// , m_parallelism(parallelism)
+// {
+// }
+
+// MarkingConstraint::~MarkingConstraint()
+// {
+// }
+
+// void MarkingConstraint::resetStats()
+// {
+// m_lastVisitCount = 0;
+// }
+
+// void MarkingConstraint::execute(SlotVisitor& visitor)
+// {
+// ASSERT(!visitor.heap()->isMarkingForGCVerifier());
+// VisitCounter visitCounter(visitor);
+// executeImpl(visitor);
+// m_lastVisitCount += visitCounter.visitCount();
+// if (verboseMarkingConstraint && visitCounter.visitCount())
+// dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in execute)");
+// }
+
+// void MarkingConstraint::executeSynchronously(AbstractSlotVisitor& visitor)
+// {
+// prepareToExecuteImpl(NoLockingNecessary, visitor);
+// executeImpl(visitor);
+// }
+
+// double MarkingConstraint::quickWorkEstimate(SlotVisitor&)
+// {
+// return 0;
+// }
+
+// double MarkingConstraint::workEstimate(SlotVisitor& visitor)
+// {
+// return lastVisitCount() + quickWorkEstimate(visitor);
+// }
+
+// void MarkingConstraint::prepareToExecute(const AbstractLocker& constraintSolvingLocker, SlotVisitor& visitor)
+// {
+// ASSERT(!visitor.heap()->isMarkingForGCVerifier());
+// dataLogIf(Options::logGC(), abbreviatedName());
+// VisitCounter visitCounter(visitor);
+// prepareToExecuteImpl(constraintSolvingLocker, visitor);
+// m_lastVisitCount = visitCounter.visitCount();
+// if (verboseMarkingConstraint && visitCounter.visitCount())
+// dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in prepareToExecute)");
+// }
+
+// void MarkingConstraint::doParallelWork(SlotVisitor& visitor, SharedTask<void(SlotVisitor&)>& task)
+// {
+// ASSERT(!visitor.heap()->isMarkingForGCVerifier());
+// VisitCounter visitCounter(visitor);
+// task.run(visitor);
+// if (verboseMarkingConstraint && visitCounter.visitCount())
+// dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in doParallelWork)");
+// {
+// Locker locker { m_lock };
+// m_lastVisitCount += visitCounter.visitCount();
+// }
+// }
+
+// void MarkingConstraint::prepareToExecuteImpl(const AbstractLocker&, AbstractSlotVisitor&)
+// {
+// }
+
+// } // namespace JSC
#include "BunGCOutputConstraint.h"
diff --git a/src/javascript/jsc/bindings/BunJSCModule.cpp b/src/javascript/jsc/bindings/BunJSCModule.cpp
new file mode 100644
index 000000000..c9c2e6cfa
--- /dev/null
+++ b/src/javascript/jsc/bindings/BunJSCModule.cpp
@@ -0,0 +1,293 @@
+#include "root.h"
+#include "JavaScriptCore/JSCInlines.h"
+
+#include "JavaScriptCore/JavaScript.h"
+#include "wtf/MemoryFootprint.h"
+#include "JavaScriptCore/CodeBlock.h"
+#include "JavaScriptCore/JSCInlines.h"
+#include "JavaScriptCore/TestRunnerUtils.h"
+#include "JavaScriptCore/JIT.h"
+#include "JavaScriptCore/APICast.h"
+#include "JavaScriptCore/JSBasePrivate.h"
+#include "JavaScriptCore/ObjectConstructor.h"
+
+#include "mimalloc.h"
+
+using namespace JSC;
+using namespace WTF;
+
+JSC_DECLARE_HOST_FUNCTION(functionDescribe);
+JSC_DEFINE_HOST_FUNCTION(functionDescribe, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ VM& vm = globalObject->vm();
+ if (callFrame->argumentCount() < 1)
+ return JSValue::encode(jsUndefined());
+ return JSValue::encode(jsString(vm, toString(callFrame->argument(0))));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionDescribeArray);
+JSC_DEFINE_HOST_FUNCTION(functionDescribeArray, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ if (callFrame->argumentCount() < 1)
+ return JSValue::encode(jsUndefined());
+ VM& vm = globalObject->vm();
+ JSObject* object = jsDynamicCast<JSObject*>(callFrame->argument(0));
+ if (!object)
+ return JSValue::encode(jsNontrivialString(vm, "<not object>"_s));
+ return JSValue::encode(jsNontrivialString(vm, toString("<Butterfly: ", RawPointer(object->butterfly()), "; public length: ", object->getArrayLength(), "; vector length: ", object->getVectorLength(), ">")));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionGCAndSweep);
+JSC_DEFINE_HOST_FUNCTION(functionGCAndSweep, (JSGlobalObject * globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ JSLockHolder lock(vm);
+ vm.heap.collectNow(Sync, CollectionScope::Full);
+ return JSValue::encode(jsNumber(vm.heap.sizeAfterLastFullCollection()));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionFullGC);
+JSC_DEFINE_HOST_FUNCTION(functionFullGC, (JSGlobalObject * globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ JSLockHolder lock(vm);
+ vm.heap.collectSync(CollectionScope::Full);
+ return JSValue::encode(jsNumber(vm.heap.sizeAfterLastFullCollection()));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionEdenGC);
+JSC_DEFINE_HOST_FUNCTION(functionEdenGC, (JSGlobalObject * globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ JSLockHolder lock(vm);
+ vm.heap.collectSync(CollectionScope::Eden);
+ return JSValue::encode(jsNumber(vm.heap.sizeAfterLastEdenCollection()));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionHeapSize);
+JSC_DEFINE_HOST_FUNCTION(functionHeapSize, (JSGlobalObject * globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ JSLockHolder lock(vm);
+ return JSValue::encode(jsNumber(vm.heap.size()));
+}
+
+class JSCMemoryFootprint : public JSDestructibleObject {
+ using Base = JSDestructibleObject;
+
+public:
+ template<typename CellType, SubspaceAccess>
+ static CompleteSubspace* subspaceFor(VM& vm)
+ {
+ return &vm.destructibleObjectSpace();
+ }
+
+ JSCMemoryFootprint(VM& vm, Structure* structure)
+ : Base(vm, structure)
+ {
+ }
+
+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+ {
+ return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
+ }
+
+ static JSCMemoryFootprint* create(VM& vm, JSGlobalObject* globalObject)
+ {
+ Structure* structure = createStructure(vm, globalObject, jsNull());
+ JSCMemoryFootprint* footprint = new (NotNull, allocateCell<JSCMemoryFootprint>(vm)) JSCMemoryFootprint(vm, structure);
+ footprint->finishCreation(vm);
+ return footprint;
+ }
+
+ void finishCreation(VM& vm)
+ {
+ Base::finishCreation(vm);
+
+ auto addProperty = [&](VM& vm, ASCIILiteral name, JSValue value) {
+ JSCMemoryFootprint::addProperty(vm, name, value);
+ };
+
+ size_t elapsed_msecs = 0;
+ size_t user_msecs = 0;
+ size_t system_msecs = 0;
+ size_t current_rss = 0;
+ size_t peak_rss = 0;
+ size_t current_commit = 0;
+ size_t peak_commit = 0;
+ size_t page_faults = 0;
+
+ mi_process_info(&elapsed_msecs, &user_msecs, &system_msecs,
+ &current_rss, &peak_rss,
+ &current_commit, &peak_commit, &page_faults);
+
+ addProperty(vm, "current"_s, jsNumber(current_rss));
+ addProperty(vm, "peak"_s, jsNumber(peak_rss));
+ addProperty(vm, "currentCommit"_s, jsNumber(current_commit));
+ addProperty(vm, "peakCommit"_s, jsNumber(peak_commit));
+ addProperty(vm, "pageFaults"_s, jsNumber(page_faults));
+ }
+
+ DECLARE_INFO;
+
+private:
+ void addProperty(VM& vm, ASCIILiteral name, JSValue value)
+ {
+ Identifier identifier = Identifier::fromString(vm, name);
+ putDirect(vm, identifier, value);
+ }
+};
+
+const ClassInfo JSCMemoryFootprint::s_info = { "MemoryFootprint"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCMemoryFootprint) };
+
+JSC_DECLARE_HOST_FUNCTION(functionMemoryUsageStatistics);
+JSC_DEFINE_HOST_FUNCTION(functionMemoryUsageStatistics, (JSGlobalObject * globalObject, CallFrame*))
+{
+ auto contextRef = toRef(globalObject);
+ return JSValue::encode(toJS(JSGetMemoryUsageStatistics(contextRef)));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionCreateMemoryFootprint);
+JSC_DEFINE_HOST_FUNCTION(functionCreateMemoryFootprint, (JSGlobalObject * globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ JSLockHolder lock(vm);
+ return JSValue::encode(JSCMemoryFootprint::create(vm, globalObject));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionGetRandomSeed);
+JSC_DEFINE_HOST_FUNCTION(functionGetRandomSeed, (JSGlobalObject * globalObject, CallFrame*))
+{
+ return JSValue::encode(jsNumber(globalObject->weakRandom().seed()));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionSetRandomSeed);
+JSC_DEFINE_HOST_FUNCTION(functionSetRandomSeed, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ VM& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ unsigned seed = callFrame->argument(0).toUInt32(globalObject);
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ globalObject->weakRandom().setSeed(seed);
+ return JSValue::encode(jsUndefined());
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionIsRope);
+JSC_DEFINE_HOST_FUNCTION(functionIsRope, (JSGlobalObject*, CallFrame* callFrame))
+{
+ JSValue argument = callFrame->argument(0);
+ if (!argument.isString())
+ return JSValue::encode(jsBoolean(false));
+ const StringImpl* impl = asString(argument)->tryGetValueImpl();
+ return JSValue::encode(jsBoolean(!impl));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionCallerSourceOrigin);
+JSC_DEFINE_HOST_FUNCTION(functionCallerSourceOrigin, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ VM& vm = globalObject->vm();
+ SourceOrigin sourceOrigin = callFrame->callerSourceOrigin(vm);
+ if (sourceOrigin.url().isNull())
+ return JSValue::encode(jsNull());
+ return JSValue::encode(jsString(vm, sourceOrigin.string()));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionNoFTL);
+JSC_DEFINE_HOST_FUNCTION(functionNoFTL, (JSGlobalObject*, CallFrame* callFrame))
+{
+ if (callFrame->argumentCount()) {
+ FunctionExecutable* executable = getExecutableForFunction(callFrame->argument(0));
+ if (executable)
+ executable->setNeverFTLOptimize(true);
+ }
+ return JSValue::encode(jsUndefined());
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionNoOSRExitFuzzing);
+JSC_DEFINE_HOST_FUNCTION(functionNoOSRExitFuzzing, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ return JSValue::encode(setCannotUseOSRExitFuzzing(globalObject, callFrame));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionOptimizeNextInvocation);
+JSC_DEFINE_HOST_FUNCTION(functionOptimizeNextInvocation, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ return JSValue::encode(optimizeNextInvocation(globalObject, callFrame));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionNumberOfDFGCompiles);
+JSC_DEFINE_HOST_FUNCTION(functionNumberOfDFGCompiles, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ return JSValue::encode(numberOfDFGCompiles(globalObject, callFrame));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionReleaseWeakRefs);
+JSC_DEFINE_HOST_FUNCTION(functionReleaseWeakRefs, (JSGlobalObject * globalObject, CallFrame* callFrame))
+{
+ globalObject->vm().finalizeSynchronousJSExecution();
+ return JSValue::encode(jsUndefined());
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionTotalCompileTime);
+JSC_DEFINE_HOST_FUNCTION(functionTotalCompileTime, (JSGlobalObject*, CallFrame*))
+{
+ return JSValue::encode(jsNumber(JIT::totalCompileTime().milliseconds()));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionReoptimizationRetryCount);
+JSC_DEFINE_HOST_FUNCTION(functionReoptimizationRetryCount, (JSGlobalObject*, CallFrame* callFrame))
+{
+ if (callFrame->argumentCount() < 1)
+ return JSValue::encode(jsUndefined());
+
+ CodeBlock* block = getSomeBaselineCodeBlockForFunction(callFrame->argument(0));
+ if (!block)
+ return JSValue::encode(jsNumber(0));
+
+ return JSValue::encode(jsNumber(block->reoptimizationRetryCounter()));
+}
+
+extern "C" void Bun__drainMicrotasks();
+
+JSC_DECLARE_HOST_FUNCTION(functionDrainMicrotasks);
+JSC_DEFINE_HOST_FUNCTION(functionDrainMicrotasks, (JSGlobalObject * globalObject, CallFrame*))
+{
+ VM& vm = globalObject->vm();
+ vm.drainMicrotasks();
+ Bun__drainMicrotasks();
+ return JSValue::encode(jsUndefined());
+}
+
+JSC::JSObject* createJSCModule(JSC::JSGlobalObject* globalObject)
+{
+ VM& vm = globalObject->vm();
+ JSC::JSObject* object = nullptr;
+
+ {
+ JSC::ObjectInitializationScope initializationScope(vm);
+ object = JSC::constructEmptyObject(globalObject, globalObject->objectPrototype(), 20);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "describe"_s), 1, functionDescribe, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "describeArray"_s), 1, functionDescribeArray, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "gcAndSweep"_s), 1, functionGCAndSweep, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "fullGC"_s), 1, functionFullGC, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "edenGC"_s), 1, functionEdenGC, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "heapSize"_s), 1, functionHeapSize, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "heapStats"_s), 1, functionMemoryUsageStatistics, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "memoryUsage"_s), 1, functionCreateMemoryFootprint, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "getRandomSeed"_s), 1, functionGetRandomSeed, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "setRandomSeed"_s), 1, functionSetRandomSeed, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "isRope"_s), 1, functionIsRope, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "callerSourceOrigin"_s), 1, functionCallerSourceOrigin, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "noFTL"_s), 1, functionNoFTL, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "noOSRExitFuzzing"_s), 1, functionNoOSRExitFuzzing, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "optimizeNextInvocation"_s), 1, functionOptimizeNextInvocation, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "numberOfDFGCompiles"_s), 1, functionNumberOfDFGCompiles, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "releaseWeakRefs"_s), 1, functionReleaseWeakRefs, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "totalCompileTime"_s), 1, functionTotalCompileTime, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "reoptimizationRetryCount"_s), 1, functionReoptimizationRetryCount, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ object->putDirectNativeFunction(vm, globalObject, JSC::Identifier::fromString(vm, "drainMicrotasks"_s), 1, functionDrainMicrotasks, NoIntrinsic, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontDelete | 0);
+ }
+
+ return object;
+} \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/BunJSCModule.h b/src/javascript/jsc/bindings/BunJSCModule.h
new file mode 100644
index 000000000..7df47a566
--- /dev/null
+++ b/src/javascript/jsc/bindings/BunJSCModule.h
@@ -0,0 +1,4 @@
+#include "root.h"
+#include "JavaScriptCore/JSObject.h"
+
+JSC::JSObject* createJSCModule(JSC::JSGlobalObject* globalObject); \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.cpp b/src/javascript/jsc/bindings/ByteLengthQueuingStrategyBuiltins.cpp
new file mode 100644
index 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/JSBuffer.cpp b/src/javascript/jsc/bindings/JSBuffer.cpp
index f4e639783..daca67676 100644
--- a/src/javascript/jsc/bindings/JSBuffer.cpp
+++ b/src/javascript/jsc/bindings/JSBuffer.cpp
@@ -1308,16 +1308,16 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_concat, (JSGlobalObject * l
/* Hash table for constructor */
static const HashTableValue JSBufferConstructorTableValues[] = {
- { "alloc", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_alloc), (intptr_t)(3) } },
- { "allocUnsafe", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_allocUnsafe), (intptr_t)(1) } },
- { "allocUnsafeSlow", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_allocUnsafe), (intptr_t)(1) } },
- { "byteLength", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_byteLength), (intptr_t)(2) } },
- { "compare", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_compare), (intptr_t)(2) } },
- { "concat", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_concat), (intptr_t)(2) } },
- { "from", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferConstructorFromCodeGenerator), (intptr_t)(1) } },
- { "isBuffer", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_isBuffer), (intptr_t)(1) } },
- { "toBuffer", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_toBuffer), (intptr_t)(1) } },
- { "isEncoding", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_isEncoding), (intptr_t)(1) } },
+ { "alloc"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_alloc), (intptr_t)(3) } },
+ { "allocUnsafe"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_allocUnsafe), (intptr_t)(1) } },
+ { "allocUnsafeSlow"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_allocUnsafe), (intptr_t)(1) } },
+ { "byteLength"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_byteLength), (intptr_t)(2) } },
+ { "compare"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_compare), (intptr_t)(2) } },
+ { "concat"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_concat), (intptr_t)(2) } },
+ { "from"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferConstructorFromCodeGenerator), (intptr_t)(1) } },
+ { "isBuffer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_isBuffer), (intptr_t)(1) } },
+ { "toBuffer"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_toBuffer), (intptr_t)(1) } },
+ { "isEncoding"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferConstructorFunction_isEncoding), (intptr_t)(1) } },
};
template<> EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSBufferConstructor::construct(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
@@ -1431,96 +1431,96 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_write, (JSGlobalObject * lexi
static const HashTableValue JSBufferPrototypeTableValues[]
= {
- { "asciiSlice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeAsciiSliceCodeGenerator), (intptr_t)(2) } },
- { "asciiWrite", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeAsciiWriteCodeGenerator), (intptr_t)(1) } },
- { "base64Slice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64SliceCodeGenerator), (intptr_t)(2) } },
- { "base64urlSlice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64urlSliceCodeGenerator), (intptr_t)(2) } },
- { "base64urlWrite", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64urlWriteCodeGenerator), (intptr_t)(1) } },
- { "base64Write", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64WriteCodeGenerator), (intptr_t)(1) } },
- { "compare", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_compare), (intptr_t)(5) } },
- { "copy", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_copy), (intptr_t)(4) } },
- { "equals", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_equals), (intptr_t)(1) } },
- { "fill", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_fill), (intptr_t)(4) } },
- { "hexSlice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeHexSliceCodeGenerator), (intptr_t)(2) } },
- { "hexWrite", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeHexWriteCodeGenerator), (intptr_t)(1) } },
- { "includes", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_includes), (intptr_t)(3) } },
- { "indexOf", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_indexOf), (intptr_t)(3) } },
- { "lastIndexOf", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_lastIndexOf), (intptr_t)(3) } },
- { "latin1Slice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeLatin1SliceCodeGenerator), (intptr_t)(2) } },
- { "latin1Write", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeLatin1WriteCodeGenerator), (intptr_t)(1) } },
- { "readBigInt64", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64LECodeGenerator), (intptr_t)(1) } },
- { "readBigInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64BECodeGenerator), (intptr_t)(1) } },
- { "readBigInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64LECodeGenerator), (intptr_t)(1) } },
- { "readBigUInt64", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64LECodeGenerator), (intptr_t)(1) } },
- { "readBigUInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64BECodeGenerator), (intptr_t)(1) } },
- { "readBigUInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64LECodeGenerator), (intptr_t)(1) } },
- { "readDouble", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleLECodeGenerator), (intptr_t)(1) } },
- { "readDoubleBE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleBECodeGenerator), (intptr_t)(1) } },
- { "readDoubleLE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleLECodeGenerator), (intptr_t)(1) } },
- { "readFloat", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatLECodeGenerator), (intptr_t)(1) } },
- { "readFloatBE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatBECodeGenerator), (intptr_t)(1) } },
- { "readFloatLE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatLECodeGenerator), (intptr_t)(1) } },
- { "readInt16", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16LECodeGenerator), (intptr_t)(1) } },
- { "readInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16BECodeGenerator), (intptr_t)(1) } },
- { "readInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16LECodeGenerator), (intptr_t)(1) } },
- { "readInt32", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32LECodeGenerator), (intptr_t)(1) } },
- { "readInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32BECodeGenerator), (intptr_t)(1) } },
- { "readInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32LECodeGenerator), (intptr_t)(1) } },
- { "readInt8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt8CodeGenerator), (intptr_t)(2) } },
- { "readUint16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16BECodeGenerator), (intptr_t)(1) } },
- { "readUInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16BECodeGenerator), (intptr_t)(1) } },
- { "readUint16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16LECodeGenerator), (intptr_t)(1) } },
- { "readUInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16LECodeGenerator), (intptr_t)(1) } },
- { "readUint32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32BECodeGenerator), (intptr_t)(1) } },
- { "readUInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32BECodeGenerator), (intptr_t)(1) } },
- { "readUint32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32LECodeGenerator), (intptr_t)(1) } },
- { "readUInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32LECodeGenerator), (intptr_t)(1) } },
- { "readUint8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt8CodeGenerator), (intptr_t)(1) } },
- { "readUInt8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt8CodeGenerator), (intptr_t)(1) } },
- { "slice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeSliceCodeGenerator), (intptr_t)(2) } },
- { "subarray", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeSliceCodeGenerator), (intptr_t)(2) } },
- { "swap16", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_swap16), (intptr_t)(0) } },
- { "swap32", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_swap32), (intptr_t)(0) } },
- { "swap64", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_swap64), (intptr_t)(0) } },
- { "toString", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_toString), (intptr_t)(4) } },
- { "ucs2Slice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUcs2SliceCodeGenerator), (intptr_t)(2) } },
- { "ucs2Write", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUcs2WriteCodeGenerator), (intptr_t)(1) } },
- { "utf16leSlice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf16leSliceCodeGenerator), (intptr_t)(2) } },
- { "utf16leWrite", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf16leWriteCodeGenerator), (intptr_t)(1) } },
- { "utf8Slice", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf8SliceCodeGenerator), (intptr_t)(2) } },
- { "utf8Write", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf8WriteCodeGenerator), (intptr_t)(1) } },
- { "write", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_write), (intptr_t)(4) } },
- { "writeBigInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigInt64BECodeGenerator), (intptr_t)(1) } },
- { "writeBigInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigInt64LECodeGenerator), (intptr_t)(1) } },
- { "writeBigUint64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64BECodeGenerator), (intptr_t)(1) } },
- { "writeBigUInt64BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64BECodeGenerator), (intptr_t)(1) } },
- { "writeBigUint64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64LECodeGenerator), (intptr_t)(1) } },
- { "writeBigUInt64LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64LECodeGenerator), (intptr_t)(1) } },
- { "writeDouble", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleLECodeGenerator), (intptr_t)(1) } },
- { "writeDoubleBE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleBECodeGenerator), (intptr_t)(1) } },
- { "writeDoubleLE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleLECodeGenerator), (intptr_t)(1) } },
- { "writeFloat", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatLECodeGenerator), (intptr_t)(1) } },
- { "writeFloatBE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatBECodeGenerator), (intptr_t)(1) } },
- { "writeFloatLE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatLECodeGenerator), (intptr_t)(1) } },
- { "writeInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt16BECodeGenerator), (intptr_t)(1) } },
- { "writeInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt16LECodeGenerator), (intptr_t)(1) } },
- { "writeInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt32BECodeGenerator), (intptr_t)(1) } },
- { "writeInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt32LECodeGenerator), (intptr_t)(1) } },
- { "writeInt8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt8CodeGenerator), (intptr_t)(1) } },
- { "writeUint16", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
- { "writeUInt16", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
- { "writeUint16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16BECodeGenerator), (intptr_t)(1) } },
- { "writeUInt16BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16BECodeGenerator), (intptr_t)(1) } },
- { "writeUint16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
- { "writeUInt16LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
- { "writeUint32", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
- { "writeUInt32", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
- { "writeUint32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32BECodeGenerator), (intptr_t)(1) } },
- { "writeUInt32BE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32BECodeGenerator), (intptr_t)(1) } },
- { "writeUint32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
- { "writeUInt32LE", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
- { "writeUint8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt8CodeGenerator), (intptr_t)(1) } },
- { "writeUInt8", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt8CodeGenerator), (intptr_t)(1) } },
+ { "asciiSlice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeAsciiSliceCodeGenerator), (intptr_t)(2) } },
+ { "asciiWrite"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeAsciiWriteCodeGenerator), (intptr_t)(1) } },
+ { "base64Slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64SliceCodeGenerator), (intptr_t)(2) } },
+ { "base64urlSlice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64urlSliceCodeGenerator), (intptr_t)(2) } },
+ { "base64urlWrite"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64urlWriteCodeGenerator), (intptr_t)(1) } },
+ { "base64Write"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeBase64WriteCodeGenerator), (intptr_t)(1) } },
+ { "compare"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_compare), (intptr_t)(5) } },
+ { "copy"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_copy), (intptr_t)(4) } },
+ { "equals"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_equals), (intptr_t)(1) } },
+ { "fill"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_fill), (intptr_t)(4) } },
+ { "hexSlice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeHexSliceCodeGenerator), (intptr_t)(2) } },
+ { "hexWrite"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeHexWriteCodeGenerator), (intptr_t)(1) } },
+ { "includes"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_includes), (intptr_t)(3) } },
+ { "indexOf"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_indexOf), (intptr_t)(3) } },
+ { "lastIndexOf"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_lastIndexOf), (intptr_t)(3) } },
+ { "latin1Slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeLatin1SliceCodeGenerator), (intptr_t)(2) } },
+ { "latin1Write"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeLatin1WriteCodeGenerator), (intptr_t)(1) } },
+ { "readBigInt64"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64LECodeGenerator), (intptr_t)(1) } },
+ { "readBigInt64BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64BECodeGenerator), (intptr_t)(1) } },
+ { "readBigInt64LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigInt64LECodeGenerator), (intptr_t)(1) } },
+ { "readBigUInt64"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64LECodeGenerator), (intptr_t)(1) } },
+ { "readBigUInt64BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64BECodeGenerator), (intptr_t)(1) } },
+ { "readBigUInt64LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadBigUInt64LECodeGenerator), (intptr_t)(1) } },
+ { "readDouble"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleLECodeGenerator), (intptr_t)(1) } },
+ { "readDoubleBE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleBECodeGenerator), (intptr_t)(1) } },
+ { "readDoubleLE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadDoubleLECodeGenerator), (intptr_t)(1) } },
+ { "readFloat"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatLECodeGenerator), (intptr_t)(1) } },
+ { "readFloatBE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatBECodeGenerator), (intptr_t)(1) } },
+ { "readFloatLE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadFloatLECodeGenerator), (intptr_t)(1) } },
+ { "readInt16"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16LECodeGenerator), (intptr_t)(1) } },
+ { "readInt16BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16BECodeGenerator), (intptr_t)(1) } },
+ { "readInt16LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt16LECodeGenerator), (intptr_t)(1) } },
+ { "readInt32"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32LECodeGenerator), (intptr_t)(1) } },
+ { "readInt32BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32BECodeGenerator), (intptr_t)(1) } },
+ { "readInt32LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt32LECodeGenerator), (intptr_t)(1) } },
+ { "readInt8"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadInt8CodeGenerator), (intptr_t)(2) } },
+ { "readUint16BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16BECodeGenerator), (intptr_t)(1) } },
+ { "readUInt16BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16BECodeGenerator), (intptr_t)(1) } },
+ { "readUint16LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16LECodeGenerator), (intptr_t)(1) } },
+ { "readUInt16LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt16LECodeGenerator), (intptr_t)(1) } },
+ { "readUint32BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32BECodeGenerator), (intptr_t)(1) } },
+ { "readUInt32BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32BECodeGenerator), (intptr_t)(1) } },
+ { "readUint32LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32LECodeGenerator), (intptr_t)(1) } },
+ { "readUInt32LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt32LECodeGenerator), (intptr_t)(1) } },
+ { "readUint8"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt8CodeGenerator), (intptr_t)(1) } },
+ { "readUInt8"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeReadUInt8CodeGenerator), (intptr_t)(1) } },
+ { "slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeSliceCodeGenerator), (intptr_t)(2) } },
+ { "subarray"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeSliceCodeGenerator), (intptr_t)(2) } },
+ { "swap16"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_swap16), (intptr_t)(0) } },
+ { "swap32"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_swap32), (intptr_t)(0) } },
+ { "swap64"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_swap64), (intptr_t)(0) } },
+ { "toString"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_toString), (intptr_t)(4) } },
+ { "ucs2Slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUcs2SliceCodeGenerator), (intptr_t)(2) } },
+ { "ucs2Write"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUcs2WriteCodeGenerator), (intptr_t)(1) } },
+ { "utf16leSlice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf16leSliceCodeGenerator), (intptr_t)(2) } },
+ { "utf16leWrite"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf16leWriteCodeGenerator), (intptr_t)(1) } },
+ { "utf8Slice"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf8SliceCodeGenerator), (intptr_t)(2) } },
+ { "utf8Write"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeUtf8WriteCodeGenerator), (intptr_t)(1) } },
+ { "write"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsBufferPrototypeFunction_write), (intptr_t)(4) } },
+ { "writeBigInt64BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigInt64BECodeGenerator), (intptr_t)(1) } },
+ { "writeBigInt64LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigInt64LECodeGenerator), (intptr_t)(1) } },
+ { "writeBigUint64BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64BECodeGenerator), (intptr_t)(1) } },
+ { "writeBigUInt64BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64BECodeGenerator), (intptr_t)(1) } },
+ { "writeBigUint64LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64LECodeGenerator), (intptr_t)(1) } },
+ { "writeBigUInt64LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteBigUInt64LECodeGenerator), (intptr_t)(1) } },
+ { "writeDouble"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleLECodeGenerator), (intptr_t)(1) } },
+ { "writeDoubleBE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleBECodeGenerator), (intptr_t)(1) } },
+ { "writeDoubleLE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteDoubleLECodeGenerator), (intptr_t)(1) } },
+ { "writeFloat"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatLECodeGenerator), (intptr_t)(1) } },
+ { "writeFloatBE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatBECodeGenerator), (intptr_t)(1) } },
+ { "writeFloatLE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteFloatLECodeGenerator), (intptr_t)(1) } },
+ { "writeInt16BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt16BECodeGenerator), (intptr_t)(1) } },
+ { "writeInt16LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt16LECodeGenerator), (intptr_t)(1) } },
+ { "writeInt32BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt32BECodeGenerator), (intptr_t)(1) } },
+ { "writeInt32LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt32LECodeGenerator), (intptr_t)(1) } },
+ { "writeInt8"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteInt8CodeGenerator), (intptr_t)(1) } },
+ { "writeUint16"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
+ { "writeUInt16"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
+ { "writeUint16BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16BECodeGenerator), (intptr_t)(1) } },
+ { "writeUInt16BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16BECodeGenerator), (intptr_t)(1) } },
+ { "writeUint16LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
+ { "writeUInt16LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt16LECodeGenerator), (intptr_t)(1) } },
+ { "writeUint32"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
+ { "writeUInt32"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
+ { "writeUint32BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32BECodeGenerator), (intptr_t)(1) } },
+ { "writeUInt32BE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32BECodeGenerator), (intptr_t)(1) } },
+ { "writeUint32LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
+ { "writeUInt32LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt32LECodeGenerator), (intptr_t)(1) } },
+ { "writeUint8"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt8CodeGenerator), (intptr_t)(1) } },
+ { "writeUInt8"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(jsBufferPrototypeWriteUInt8CodeGenerator), (intptr_t)(1) } },
};
void JSBufferPrototype::finishCreation(VM& vm, JSC::JSGlobalObject* globalThis)
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/JSFFIFunction.cpp b/src/javascript/jsc/bindings/JSFFIFunction.cpp
index 5c4ad3ed6..731ea60c6 100644
--- a/src/javascript/jsc/bindings/JSFFIFunction.cpp
+++ b/src/javascript/jsc/bindings/JSFFIFunction.cpp
@@ -33,10 +33,14 @@
extern "C" Zig::JSFFIFunction* Bun__CreateFFIFunction(Zig::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer)
{
JSC::VM& vm = globalObject->vm();
- Zig::JSFFIFunction* function = Zig::JSFFIFunction::create(vm, globalObject, argCount, Zig::toStringCopy(*symbolName), functionPointer, JSC::NoIntrinsic);
- JSC::gcProtect(function);
+ Zig::JSFFIFunction* function = Zig::JSFFIFunction::create(vm, globalObject, argCount, symbolName != nullptr ? Zig::toStringCopy(*symbolName) : String(), functionPointer, JSC::NoIntrinsic);
return function;
}
+extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionValue(Zig::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer);
+extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionValue(Zig::GlobalObject* globalObject, const ZigString* symbolName, unsigned argCount, Zig::FFIFunction functionPointer)
+{
+ return JSC::JSValue::encode(JSC::JSValue(Bun__CreateFFIFunction(globalObject, symbolName, argCount, functionPointer)));
+}
namespace Zig {
using namespace JSC;
@@ -70,7 +74,7 @@ void JSFFIFunction::finishCreation(VM& vm, NativeExecutable* executable, unsigne
JSFFIFunction* JSFFIFunction::create(VM& vm, Zig::GlobalObject* globalObject, unsigned length, const String& name, FFIFunction FFIFunction, Intrinsic intrinsic, NativeFunction nativeConstructor)
{
- NativeExecutable* executable = vm.getHostFunction(FFIFunction, intrinsic, nativeConstructor, nullptr, name);
+ NativeExecutable* executable = vm.getHostFunction(FFIFunction, intrinsic, FFIFunction, nullptr, name);
Structure* structure = globalObject->FFIFunctionStructure();
JSFFIFunction* function = new (NotNull, allocateCell<JSFFIFunction>(vm)) JSFFIFunction(vm, executable, globalObject, structure, WTFMove(FFIFunction));
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..34597ade4 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));
@@ -249,7 +249,7 @@ void Process::finishCreation(JSC::VM& vm)
JSC::JSValue(JSC::jsNumber(0)));
this->putDirect(this->vm(), clientData->builtinNames().versionPublicName(),
- JSC::jsString(this->vm(), Bun__version));
+ JSC::jsString(this->vm(), makeAtomString(Bun__version)));
// this gives some way of identifying at runtime whether the SSR is happening in node or not.
// this should probably be renamed to what the name of the bundler is, instead of "notNodeJS"
diff --git a/src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.cpp b/src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.cpp
new file mode 100644
index 000000000..b09754494
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableByteStreamControllerBuiltins.cpp
@@ -0,0 +1,188 @@
+/*
+ * 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 = 817;
+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" \
+ " \n" \
+ " var request = @getByIdDirectPrivate(this, \"byobRequest\");\n" \
+ " if (request === @undefined) {\n" \
+ " var pending = @getByIdDirectPrivate(this, \"pendingPullIntos\");\n" \
+ " const firstDescriptor = pending.peek();\n" \
+ " if (firstDescriptor) {\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" \
+ "\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..123874f1b
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableByteStreamInternalsBuiltins.cpp
@@ -0,0 +1,945 @@
+/*
+ * 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 = 2344;
+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\", @createFIFO());\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 = 398;
+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" \
+ " var first = pendingPullIntos.peek();\n" \
+ " if (first)\n" \
+ " first.bytesFilled = 0;\n" \
+ "\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 = 809;
+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 first = @getByIdDirectPrivate(controller, \"pendingPullIntos\")?.peek();\n" \
+ " if (first) {\n" \
+ " if (first.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 = 347;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @readableByteStreamControllerInvalidateBYOBRequest(controller);\n" \
+ " var existing = @getByIdDirectPrivate(controller, \"pendingPullIntos\");\n" \
+ " if (existing !== @undefined) {\n" \
+ " existing.clear();\n" \
+ " } else {\n" \
+ " @putByIdDirectPrivate(controller, \"pendingPullIntos\", @createFIFO());\n" \
+ " }\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 = 1598;
+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" \
+ " 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 = @createUninitializedArrayBuffer(@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" \
+ " @getByIdDirectPrivate(controller, \"pendingPullIntos\").push(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 = 872;
+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" \
+ " const reader = @getByIdDirectPrivate(stream, \"reader\");\n" \
+ " if (reader && (@getByIdDirectPrivate(reader, \"readRequests\")?.isNotEmpty() || !!@getByIdDirectPrivate(reader, \"bunNativePtr\")))\n" \
+ " return true;\n" \
+ " if (@readableStreamHasBYOBReader(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readIntoRequests\")?.isNotEmpty())\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_readableByteStreamInternalsReadableStreamReaderKindCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamReaderKindCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableStreamReaderKindCodeLength = 266;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamReaderKindCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableStreamReaderKindCode =
+ "(function (reader) {\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ "\n" \
+ " if (!!@getByIdDirectPrivate(reader, \"readRequests\"))\n" \
+ " return @getByIdDirectPrivate(reader, \"bunNativePtr\") ? 3 : 1;\n" \
+ "\n" \
+ " if (!!@getByIdDirectPrivate(reader, \"readIntoRequests\"))\n" \
+ " return 2;\n" \
+ "\n" \
+ " return 0;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength = 1690;
+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" \
+ "\n" \
+ "\n" \
+ " switch (@getByIdDirectPrivate(stream, \"reader\") ? @readableStreamReaderKind(@getByIdDirectPrivate(stream, \"reader\")) : 0) {\n" \
+ " \n" \
+ " case 1: {\n" \
+ " if (!@getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\")?.isNotEmpty())\n" \
+ " @readableByteStreamControllerEnqueueChunk(controller, @transferBufferToCurrentRealm(chunk.buffer), chunk.byteOffset, chunk.byteLength);\n" \
+ " else {\n" \
+ " @assert(!@getByIdDirectPrivate(controller, \"queue\").content.size());\n" \
+ " const transferredView = chunk.constructor === @Uint8Array ? chunk : new @Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);\n" \
+ " @readableStreamFulfillReadRequest(stream, transferredView, false);\n" \
+ " }\n" \
+ " break;\n" \
+ " }\n" \
+ "\n" \
+ " \n" \
+ " case 2: {\n" \
+ " @readableByteStreamControllerEnqueueChunk(controller, @transferBufferToCurrentRealm(chunk.buffer), chunk.byteOffset, chunk.byteLength);\n" \
+ " @readableByteStreamControllerProcessPullDescriptors(controller);\n" \
+ " break;\n" \
+ " }\n" \
+ "\n" \
+ " \n" \
+ " case 3: {\n" \
+ " //\n" \
+ "\n" \
+ " break;\n" \
+ " }\n" \
+ "\n" \
+ " default: {\n" \
+ " @assert(!@isReadableStreamLocked(stream));\n" \
+ " @readableByteStreamControllerEnqueueChunk(controller, @transferBufferToCurrentRealm(chunk.buffer), chunk.byteOffset, chunk.byteLength);\n" \
+ " break;\n" \
+ " }\n" \
+ " }\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 303;
+static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode =
+ "(function (controller, buffer, byteOffset, byteLength)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @getByIdDirectPrivate(controller, \"queue\").content.push({\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 = 619;
+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\").isNotEmpty());\n" \
+ "\n" \
+ " let firstDescriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\").peek();\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 = 411;
+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\").isNotEmpty());\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 = 712;
+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\").peek();\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 = 1440;
+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\").isEmpty() || @getByIdDirectPrivate(controller, \"pendingPullIntos\").peek() === 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 = 730;
+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\")?.isNotEmpty()) {\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 = 712;
+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\").isNotEmpty()) {\n" \
+ " if (@getByIdDirectPrivate(controller, \"queue\").size === 0)\n" \
+ " return;\n" \
+ " let pullIntoDescriptor = @getByIdDirectPrivate(controller, \"pendingPullIntos\").peek();\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 = 2359;
+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.peek();\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\").isEmpty() || @getByIdDirectPrivate(controller, \"pendingPullIntos\").peek() === 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 = 222;
+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 = 243;
+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 = 2190;
+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" \
+ " var pending = @getByIdDirectPrivate(controller, \"pendingPullIntos\");\n" \
+ " if (pending?.isNotEmpty()) {\n" \
+ " pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);\n" \
+ " pending.push(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" \
+ " @getByIdDirectPrivate(controller, \"pendingPullIntos\").push(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 = 430;
+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" \
+ " @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readIntoRequests\").push(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..e805cee42
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableByteStreamInternalsBuiltins.h
@@ -0,0 +1,436 @@
+/*
+ * 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_readableByteStreamInternalsReadableStreamReaderKindCode;
+extern const int s_readableByteStreamInternalsReadableStreamReaderKindCodeLength;
+extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamReaderKindCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamReaderKindCodeConstructorKind;
+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(readableStreamReaderKind, readableByteStreamInternalsReadableStreamReaderKind, 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_READABLESTREAMREADERKIND 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(readableByteStreamInternalsReadableStreamReaderKindCode, readableStreamReaderKind, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamReaderKindCodeLength) \
+ 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(readableStreamReaderKind) \
+ 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..81486dffe
--- /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 = 585;
+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\", @createFIFO());\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 = 447;
+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\")?.isNotEmpty())\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..c7d9470c2
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamBuiltins.cpp
@@ -0,0 +1,640 @@
+/*
+ * 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_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamReadableStreamToArrayCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamReadableStreamToArrayCodeLength = 884;
+static const JSC::Intrinsic s_readableStreamReadableStreamToArrayCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamReadableStreamToArrayCode =
+ "(function (stream) {\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!stream || @getByIdDirectPrivate(stream, \"state\") === @streamClosed) {\n" \
+ " return null;\n" \
+ " }\n" \
+ " var reader = stream.getReader();\n" \
+ "\n" \
+ " var manyResult = reader.readMany();\n" \
+ " \n" \
+ " async function processManyResult(result) {\n" \
+ " \n" \
+ " if (result.done) {\n" \
+ " return null;\n" \
+ " }\n" \
+ "\n" \
+ " var chunks = result.value || [];\n" \
+ " \n" \
+ " while (true) {\n" \
+ " var thisResult = await reader.read();\n" \
+ " \n" \
+ " if (thisResult.done) {\n" \
+ " return chunks;\n" \
+ " }\n" \
+ " \n" \
+ " chunks.push(thisResult.value);\n" \
+ " }\n" \
+ "\n" \
+ " return chunks;\n" \
+ " };\n" \
+ "\n" \
+ "\n" \
+ " if (manyResult && @isPromise(manyResult)) {\n" \
+ " return manyResult.@then(processManyResult);\n" \
+ " }\n" \
+ "\n" \
+ " if (manyResult && manyResult.done) {\n" \
+ " return null;\n" \
+ " }\n" \
+ "\n" \
+ " return processManyResult(manyResult);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamReadableStreamToArrayPublicCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamReadableStreamToArrayPublicCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamReadableStreamToArrayPublicCodeLength = 841;
+static const JSC::Intrinsic s_readableStreamReadableStreamToArrayPublicCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamReadableStreamToArrayPublicCode =
+ "(function (stream) {\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(stream, \"state\") === @streamClosed) {\n" \
+ " return [];\n" \
+ " }\n" \
+ " var reader = stream.getReader();\n" \
+ "\n" \
+ " var manyResult = reader.readMany();\n" \
+ "\n" \
+ " var processManyResult = (0, (async function(result) {\n" \
+ " if (result.done) {\n" \
+ " return [];\n" \
+ " }\n" \
+ "\n" \
+ " var chunks = result.value || [];\n" \
+ " \n" \
+ " while (true) {\n" \
+ " var thisResult = await reader.read();\n" \
+ " if (thisResult.done) {\n" \
+ " return chunks;\n" \
+ " }\n" \
+ "\n" \
+ " chunks.push(thisResult.value);\n" \
+ " }\n" \
+ "\n" \
+ " return chunks;\n" \
+ " }));\n" \
+ "\n" \
+ "\n" \
+ " if (manyResult && @isPromise(manyResult)) {\n" \
+ " return manyResult.then(processManyResult);\n" \
+ " }\n" \
+ "\n" \
+ " if (manyResult && manyResult.done) {\n" \
+ " return [];\n" \
+ " }\n" \
+ "\n" \
+ " return processManyResult(manyResult);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamConsumeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamConsumeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamConsumeReadableStreamCodeLength = 3683;
+static const JSC::Intrinsic s_readableStreamConsumeReadableStreamCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamConsumeReadableStreamCode =
+ "(function (nativePtr, nativeType, inputStream) {\n" \
+ " \"use strict\";\n" \
+ " const symbol = Symbol.for(\"Bun.consumeReadableStreamPrototype\");\n" \
+ " var cached = globalThis[symbol];\n" \
+ " if (!cached) {\n" \
+ " cached = globalThis[symbol] = [];\n" \
+ " }\n" \
+ " var Prototype = cached[nativeType];\n" \
+ " if (Prototype === @undefined) {\n" \
+ " var [doRead, doError, doReadMany, doClose, onClose, deinit] = globalThis[Symbol.for(\"Bun.lazy\")](nativeType);\n" \
+ "\n" \
+ " Prototype = class NativeReadableStreamSink {\n" \
+ " constructor(reader, ptr) {\n" \
+ " this.#ptr = ptr;\n" \
+ " this.#reader = reader;\n" \
+ " this.#didClose = false;\n" \
+ "\n" \
+ " this.handleError = this._handleError.bind(this);\n" \
+ " this.handleClosed = this._handleClosed.bind(this);\n" \
+ " this.processResult = this._processResult.bind(this);\n" \
+ "\n" \
+ " reader.closed.then(this.handleClosed, this.handleError);\n" \
+ " }\n" \
+ "\n" \
+ " handleError;\n" \
+ " handleClosed;\n" \
+ " _handleClosed() {\n" \
+ " if (this.#didClose) return;\n" \
+ " this.#didClose = true;\n" \
+ " var ptr = this.#ptr;\n" \
+ " this.#ptr = 0;\n" \
+ " doClose(ptr);\n" \
+ " deinit(ptr);\n" \
+ " }\n" \
+ "\n" \
+ " _handleError(error) {\n" \
+ " if (this.#didClose) return;\n" \
+ " this.#didClose = true;\n" \
+ " var ptr = this.#ptr;\n" \
+ " this.#ptr = 0;\n" \
+ " doError(ptr, error);\n" \
+ " deinit(ptr);\n" \
+ " }\n" \
+ "\n" \
+ " #ptr;\n" \
+ " #didClose = false;\n" \
+ " #reader;\n" \
+ "\n" \
+ " _handleReadMany({value, done, size}) {\n" \
+ " if (done) {\n" \
+ " this.handleClosed();\n" \
+ " return;\n" \
+ " }\n" \
+ "\n" \
+ " if (this.#didClose) return;\n" \
+ " \n" \
+ "\n" \
+ " doReadMany(this.#ptr, value, done, size);\n" \
+ " }\n" \
+ " \n" \
+ "\n" \
+ " read() {\n" \
+ " if (!this.#ptr) return @throwTypeError(\"ReadableStreamSink is already closed\");\n" \
+ " \n" \
+ " return this.processResult(this.#reader.read());\n" \
+ " \n" \
+ " }\n" \
+ "\n" \
+ " _processResult(result) {\n" \
+ " if (result && @isPromise(result)) {\n" \
+ " const flags = @getPromiseInternalField(result, @promiseFieldFlags);\n" \
+ " if (flags & @promiseStateFulfilled) {\n" \
+ " const fulfilledValue = @getPromiseInternalField(result, @promiseFieldReactionsOrResult);\n" \
+ " if (fulfilledValue) {\n" \
+ " result = fulfilledValue;\n" \
+ " }\n" \
+ " }\n" \
+ " }\n" \
+ "\n" \
+ " if (result && @isPromise(result)) {\n" \
+ " result.then(this.processResult, this.handleError);\n" \
+ " return null;\n" \
+ " }\n" \
+ "\n" \
+ " if (result.done) {\n" \
+ " this.handleClosed();\n" \
+ " return 0;\n" \
+ " } else if (result.value) {\n" \
+ " return result.value;\n" \
+ " } else {\n" \
+ " return -1;\n" \
+ " }\n" \
+ " }\n" \
+ "\n" \
+ " readMany() {\n" \
+ " if (!this.#ptr) return @throwTypeError(\"ReadableStreamSink is already closed\");\n" \
+ " return this.processResult(this.#reader.readMany());\n" \
+ " }\n" \
+ " };\n" \
+ "\n" \
+ " const minlength = nativeType + 1;\n" \
+ " if (cached.length < minlength) {\n" \
+ " cached.length = minlength;\n" \
+ " }\n" \
+ " @putByValDirect(cached, nativeType, Prototype);\n" \
+ " }\n" \
+ "\n" \
+ " if (@isReadableStreamLocked(inputStream)) {\n" \
+ " @throwTypeError(\"Cannot start reading from a locked stream\");\n" \
+ " }\n" \
+ "\n" \
+ " return new Prototype(inputStream.getReader(), nativePtr);\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamCreateEmptyReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamCreateEmptyReadableStreamCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamCreateEmptyReadableStreamCodeLength = 178;
+static const JSC::Intrinsic s_readableStreamCreateEmptyReadableStreamCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamCreateEmptyReadableStreamCode =
+ "(function () {\n" \
+ " var stream = new @ReadableStream({\n" \
+ " pull() {},\n" \
+ " start() {},\n" \
+ " cancel() {},\n" \
+ " });\n" \
+ " @readableStreamClose(stream);\n" \
+ " return stream;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_readableStreamCreateNativeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamCreateNativeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamCreateNativeReadableStreamCodeLength = 2955;
+static const JSC::Intrinsic s_readableStreamCreateNativeReadableStreamCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamCreateNativeReadableStreamCode =
+ "(function (nativePtr, nativeType, autoAllocateChunkSize) {\n" \
+ " \"use strict\";\n" \
+ " var cached = globalThis[Symbol.for(\"Bun.nativeReadableStreamPrototype\")] ||= new @Map;\n" \
+ " var Prototype = cached.@get(nativeType);\n" \
+ " if (Prototype === @undefined) {\n" \
+ " var [pull, start, cancel, setClose, deinit] = globalThis[Symbol.for(\"Bun.lazy\")](nativeType);\n" \
+ " var closer = [false];\n" \
+ " var handleResult;\n" \
+ " function handleNativeReadableStreamPromiseResult(val) {\n" \
+ " \"use strict\";\n" \
+ " var {c, v} = this;\n" \
+ " this.c = @undefined;\n" \
+ " this.v = @undefined;\n" \
+ " handleResult(val, c, v);\n" \
+ " }\n" \
+ " \n" \
+ " handleResult = function handleResult(result, controller, view) {\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (result && @isPromise(result)) {\n" \
+ " return result.then(handleNativeReadableStreamPromiseResult.bind({c: controller, v: view}), (err) => controller.error(err));\n" \
+ " } else if (result !== false) {\n" \
+ " if (view && view.byteLength === result) {\n" \
+ " controller.byobRequest.respondWithNewView(view);\n" \
+ " } else {\n" \
+ " controller.byobRequest.respond(result);\n" \
+ " }\n" \
+ " }\n" \
+ "\n" \
+ " if (closer[0] || result === false) {\n" \
+ " @enqueueJob(() => controller.close());\n" \
+ " closer[0] = false;\n" \
+ " }\n" \
+ " };\n" \
+ "\n" \
+ " Prototype = class NativeReadableStreamSource {\n" \
+ " constructor(tag, autoAllocateChunkSize) {\n" \
+ " this.pull = this.pull_.bind(tag);\n" \
+ " this.cancel = this.cancel_.bind(tag);\n" \
+ " this.autoAllocateChunkSize = autoAllocateChunkSize;\n" \
+ " }\n" \
+ "\n" \
+ " pull;\n" \
+ " cancel;\n" \
+ "\n" \
+ " type = \"bytes\";\n" \
+ " autoAllocateChunkSize = 0;\n" \
+ "\n" \
+ " static startSync = start;\n" \
+ " \n" \
+ " pull_(controller) {\n" \
+ " closer[0] = false;\n" \
+ " var result;\n" \
+ "\n" \
+ " const view = controller.byobRequest.view;\n" \
+ " try {\n" \
+ " result = pull(this, view, closer);\n" \
+ " } catch(err) {\n" \
+ " return controller.error(err);\n" \
+ " }\n" \
+ "\n" \
+ " return handleResult(result, controller, view);\n" \
+ " }\n" \
+ "\n" \
+ " cancel_(reason) {\n" \
+ " cancel(this, reason);\n" \
+ " }\n" \
+ "\n" \
+ " static registry = new FinalizationRegistry(deinit);\n" \
+ " }\n" \
+ " cached.@set(nativeType, Prototype);\n" \
+ " }\n" \
+ " \n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " const chunkSize = Prototype.startSync(nativePtr, autoAllocateChunkSize);\n" \
+ "\n" \
+ " //\n" \
+ " if (chunkSize === 0) {\n" \
+ " return @createEmptyReadableStream();\n" \
+ " }\n" \
+ "\n" \
+ " var instance = new Prototype(nativePtr, chunkSize);\n" \
+ " Prototype.registry.register(instance, nativePtr);\n" \
+ " var stream = new @ReadableStream(instance);\n" \
+ " @putByIdDirectPrivate(stream, \"bunNativeType\", nativeType);\n" \
+ " @putByIdDirectPrivate(stream, \"bunNativePtr\", nativePtr);\n" \
+ " return stream;\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 = 481;
+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" \
+ " \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..7733d4d0c
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamBuiltins.h
@@ -0,0 +1,215 @@
+/*
+ * 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_readableStreamReadableStreamToArrayCode;
+extern const int s_readableStreamReadableStreamToArrayCodeLength;
+extern const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamReadableStreamToArrayCodeConstructorKind;
+extern const char* const s_readableStreamReadableStreamToArrayPublicCode;
+extern const int s_readableStreamReadableStreamToArrayPublicCodeLength;
+extern const JSC::ConstructAbility s_readableStreamReadableStreamToArrayPublicCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamReadableStreamToArrayPublicCodeConstructorKind;
+extern const char* const s_readableStreamConsumeReadableStreamCode;
+extern const int s_readableStreamConsumeReadableStreamCodeLength;
+extern const JSC::ConstructAbility s_readableStreamConsumeReadableStreamCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamConsumeReadableStreamCodeConstructorKind;
+extern const char* const s_readableStreamCreateEmptyReadableStreamCode;
+extern const int s_readableStreamCreateEmptyReadableStreamCodeLength;
+extern const JSC::ConstructAbility s_readableStreamCreateEmptyReadableStreamCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamCreateEmptyReadableStreamCodeConstructorKind;
+extern const char* const s_readableStreamCreateNativeReadableStreamCode;
+extern const int s_readableStreamCreateNativeReadableStreamCodeLength;
+extern const JSC::ConstructAbility s_readableStreamCreateNativeReadableStreamCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamCreateNativeReadableStreamCodeConstructorKind;
+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(readableStreamToArray, readableStreamReadableStreamToArray, 1) \
+ macro(readableStreamToArrayPublic, readableStreamReadableStreamToArrayPublic, 1) \
+ macro(consumeReadableStream, readableStreamConsumeReadableStream, 3) \
+ macro(createEmptyReadableStream, readableStreamCreateEmptyReadableStream, 0) \
+ macro(createNativeReadableStream, readableStreamCreateNativeReadableStream, 3) \
+ 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_READABLESTREAMTOARRAY 1
+#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOARRAYPUBLIC 1
+#define WEBCORE_BUILTIN_READABLESTREAM_CONSUMEREADABLESTREAM 1
+#define WEBCORE_BUILTIN_READABLESTREAM_CREATEEMPTYREADABLESTREAM 1
+#define WEBCORE_BUILTIN_READABLESTREAM_CREATENATIVEREADABLESTREAM 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(readableStreamReadableStreamToArrayCode, readableStreamToArray, ASCIILiteral(), s_readableStreamReadableStreamToArrayCodeLength) \
+ macro(readableStreamReadableStreamToArrayPublicCode, readableStreamToArrayPublic, ASCIILiteral(), s_readableStreamReadableStreamToArrayPublicCodeLength) \
+ macro(readableStreamConsumeReadableStreamCode, consumeReadableStream, ASCIILiteral(), s_readableStreamConsumeReadableStreamCodeLength) \
+ macro(readableStreamCreateEmptyReadableStreamCode, createEmptyReadableStream, ASCIILiteral(), s_readableStreamCreateEmptyReadableStreamCodeLength) \
+ macro(readableStreamCreateNativeReadableStreamCode, createNativeReadableStream, ASCIILiteral(), s_readableStreamCreateNativeReadableStreamCodeLength) \
+ 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(consumeReadableStream) \
+ macro(createEmptyReadableStream) \
+ macro(createNativeReadableStream) \
+ macro(getReader) \
+ macro(initializeReadableStream) \
+ macro(locked) \
+ macro(pipeThrough) \
+ macro(pipeTo) \
+ macro(readableStreamToArray) \
+ macro(readableStreamToArrayPublic) \
+ 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..839550857
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamDefaultReaderBuiltins.cpp
@@ -0,0 +1,237 @@
+/*
+ * 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 = 393;
+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\", @createFIFO());\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_readableStreamDefaultReaderReadManyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_readableStreamDefaultReaderReadManyCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_readableStreamDefaultReaderReadManyCodeLength = 2683;
+static const JSC::Intrinsic s_readableStreamDefaultReaderReadManyCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamDefaultReaderReadManyCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " if (!@isReadableStreamDefaultReader(this))\n" \
+ " @throwTypeError(\"ReadableStreamDefaultReader.readMany() should not be called directly\");\n" \
+ "\n" \
+ " const stream = @getByIdDirectPrivate(this, \"ownerReadableStream\");\n" \
+ " if (!stream)\n" \
+ " @throwTypeError(\"readMany() called on a reader owned by no readable stream\");\n" \
+ "\n" \
+ " const state = @getByIdDirectPrivate(stream, \"state\");\n" \
+ " @putByIdDirectPrivate(stream, \"disturbed\", true);\n" \
+ " if (state === @streamClosed)\n" \
+ " return {value: [], size: 0, done: true};\n" \
+ " else if (state === @streamErrored) {\n" \
+ " throw @getByIdDirectPrivate(stream, \"storedError\");\n" \
+ " }\n" \
+ "\n" \
+ " \n" \
+ " var controller = @getByIdDirectPrivate(stream, \"readableStreamController\");\n" \
+ "\n" \
+ " const content = @getByIdDirectPrivate(controller, \"queue\").content;\n" \
+ " var size = @getByIdDirectPrivate(controller, \"queue\").size;\n" \
+ " var values = content.toArray(false);\n" \
+ " var length = values.length;\n" \
+ " \n" \
+ "\n" \
+ " if (length > 0) {\n" \
+ " \n" \
+ " @resetQueue(@getByIdDirectPrivate(controller, \"queue\"));\n" \
+ "\n" \
+ " \n" \
+ " if (@getByIdDirectPrivate(controller, \"closeRequested\"))\n" \
+ " @readableStreamClose(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\n" \
+ " else if (@isReadableStreamDefaultController(controller)) \n" \
+ " @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \
+ " else if (@isReadableByteStreamController(controller))\n" \
+ " @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
+ "\n" \
+ " return {value: values, size, done: false};\n" \
+ " }\n" \
+ "\n" \
+ " var onPullMany = (result) => {\n" \
+ " if (result.done) {\n" \
+ " return {value: [], size: 0, done: true};\n" \
+ " }\n" \
+ " var controller = @getByIdDirectPrivate(stream, \"readableStreamController\");\n" \
+ " \n" \
+ " var queue = @getByIdDirectPrivate(controller, \"queue\");\n" \
+ " var value = [result.value].concat(queue.content.toArray(false));\n" \
+ " var size = queue.size;\n" \
+ " @resetQueue(queue);\n" \
+ "\n" \
+ " if (@getByIdDirectPrivate(controller, \"closeRequested\"))\n" \
+ " @readableStreamClose(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\n" \
+ " else if (@isReadableStreamDefaultController(controller)) \n" \
+ " @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \
+ " else if (@isReadableByteStreamController(controller))\n" \
+ " @readableByteStreamControllerCallPullIfNeeded(controller);\n" \
+ " \n" \
+ "\n" \
+ " \n" \
+ " return {value: value, size: size, done: false};\n" \
+ " };\n" \
+ " \n" \
+ " var pullResult = controller.@pull(controller);\n" \
+ " if (pullResult && @isPromise(pullResult)) {\n" \
+ " return pullResult.@then(onPullMany);\n" \
+ " }\n" \
+ "\n" \
+ " return onPullMany(pullResult);\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 = 449;
+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\")?.isNotEmpty())\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..1dc33a831
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamDefaultReaderBuiltins.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 {
+
+/* 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_readableStreamDefaultReaderReadManyCode;
+extern const int s_readableStreamDefaultReaderReadManyCodeLength;
+extern const JSC::ConstructAbility s_readableStreamDefaultReaderReadManyCodeConstructAbility;
+extern const JSC::ConstructorKind s_readableStreamDefaultReaderReadManyCodeConstructorKind;
+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(readMany, readableStreamDefaultReaderReadMany, 0) \
+ 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_READMANY 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(readableStreamDefaultReaderReadManyCode, readMany, ASCIILiteral(), s_readableStreamDefaultReaderReadManyCodeLength) \
+ 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(readMany) \
+ 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..9a048cde3
--- /dev/null
+++ b/src/javascript/jsc/bindings/ReadableStreamInternalsBuiltins.cpp
@@ -0,0 +1,1092 @@
+/*
+ * 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 = 3213;
+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 to a readable bytestream 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 = 1266;
+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" \
+ " 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\", @createFIFO());\n" \
+ " for (var request = requests.shift(); request; request = requests.shift())\n" \
+ " @rejectPromise(request, error);\n" \
+ " } else {\n" \
+ " @assert(@isReadableStreamBYOBReader(reader));\n" \
+ " const requests = @getByIdDirectPrivate(reader, \"readIntoRequests\");\n" \
+ " @putByIdDirectPrivate(reader, \"readIntoRequests\", @createFIFO());\n" \
+ " for (var request = requests.shift(); request; request = requests.shift())\n" \
+ " @rejectPromise(request, 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 = 659;
+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\")?.isNotEmpty()) && @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 = 1246;
+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\")?.isNotEmpty()) && @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 = 758;
+static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerPullCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode =
+ "(function (controller)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " var queue = @getByIdDirectPrivate(controller, \"queue\");\n" \
+ " if (queue.content.isNotEmpty()) {\n" \
+ " const chunk = @dequeueValue(queue);\n" \
+ " if (@getByIdDirectPrivate(controller, \"closeRequested\") && queue.content.isEmpty())\n" \
+ " @readableStreamClose(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\n" \
+ " else\n" \
+ " @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \
+ "\n" \
+ " return @createFulfilledPromise({ value: chunk, done: false });\n" \
+ " }\n" \
+ " const pendingPromise = @readableStreamAddReadRequest(@getByIdDirectPrivate(controller, \"controlledReadableStream\"));\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 = 351;
+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?.isEmpty())\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 = 875;
+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" \
+ " if (!@getByIdDirectPrivate(stream, \"reader\"))\n" \
+ " return;\n" \
+ "\n" \
+ " if (@isReadableStreamDefaultReader(@getByIdDirectPrivate(stream, \"reader\"))) {\n" \
+ " const requests = @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\");\n" \
+ " if (requests.isNotEmpty()) {\n" \
+ " @putByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\", @createFIFO());\n" \
+ " \n" \
+ " for (var request = requests.shift(); request; request = requests.shift())\n" \
+ " @fulfillPromise(request, { value: @undefined, done: true });\n" \
+ " }\n" \
+ " }\n" \
+ "\n" \
+ " @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"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 = 231;
+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 = 993;
+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" \
+ " //\n" \
+ " @assert(@readableStreamDefaultControllerCanCloseOrEnqueue(controller));\n" \
+ "\n" \
+ " if (@isReadableStreamLocked(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\")?.isNotEmpty()) {\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 = 373;
+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" \
+ " \n" \
+ " @getByIdDirectPrivate(@getByIdDirectPrivate(stream, \"reader\"), \"readRequests\").push(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..2203ed2f2
--- /dev/null
+++ b/src/javascript/jsc/bindings/StreamInternalsBuiltins.cpp
@@ -0,0 +1,464 @@
+/*
+ * 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 = 430;
+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 newHighWaterMark = @toNumber(highWaterMark);\n" \
+ "\n" \
+ " if (@isNaN(newHighWaterMark) || newHighWaterMark < 0)\n" \
+ " @throwRangeError(\"highWaterMark value is negative or not a number\");\n" \
+ "\n" \
+ " return { size: size, highWaterMark: newHighWaterMark };\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsCreateFIFOCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsCreateFIFOCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsCreateFIFOCodeLength = 2764;
+static const JSC::Intrinsic s_streamInternalsCreateFIFOCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsCreateFIFOCode =
+ "(function () {\n" \
+ " \"use strict\";\n" \
+ " class Denqueue {\n" \
+ " constructor() {\n" \
+ " this._head = 0;\n" \
+ " this._tail = 0;\n" \
+ " //\n" \
+ " this._capacityMask = 0x3;\n" \
+ " this._list = @newArrayWithSize(4);\n" \
+ " }\n" \
+ " \n" \
+ " size() {\n" \
+ " if (this._head === this._tail) return 0;\n" \
+ " if (this._head < this._tail) return this._tail - this._head;\n" \
+ " else return this._capacityMask + 1 - (this._head - this._tail);\n" \
+ " }\n" \
+ "\n" \
+ " isEmpty() {\n" \
+ " return this.size() == 0;\n" \
+ " }\n" \
+ "\n" \
+ " isNotEmpty() {\n" \
+ " return this.size() > 0;\n" \
+ " }\n" \
+ " \n" \
+ " shift() {\n" \
+ " var head = this._head;\n" \
+ " if (head === this._tail) return @undefined;\n" \
+ " var item = this._list[head];\n" \
+ " @putByValDirect(this._list, head, @undefined);\n" \
+ " this._head = (head + 1) & this._capacityMask;\n" \
+ " if (head < 2 && this._tail > 10000 && this._tail <= this._list.length >>> 2) this._shrinkArray();\n" \
+ " return item;\n" \
+ " }\n" \
+ "\n" \
+ " peek() {\n" \
+ " if (this._head === this._tail) return @undefined;\n" \
+ " return this._list[this._head];\n" \
+ " }\n" \
+ " \n" \
+ " push(item) {\n" \
+ " var tail = this._tail;\n" \
+ " @putByValDirect(this._list, tail, item);\n" \
+ " this._tail = (tail + 1) & this._capacityMask;\n" \
+ " if (this._tail === this._head) {\n" \
+ " this._growArray();\n" \
+ " }\n" \
+ " //\n" \
+ " //\n" \
+ " //\n" \
+ " }\n" \
+ " \n" \
+ " toArray(fullCopy) {\n" \
+ " var list = this._list;\n" \
+ " var len = @toLength(list.length);\n" \
+ " \n" \
+ " if (fullCopy || this._head > this._tail) {\n" \
+ " var _head = @toLength(this._head);\n" \
+ " var _tail = @toLength(this._tail);\n" \
+ " var total = @toLength((len - _head) + _tail);\n" \
+ " var array = @newArrayWithSize(total);\n" \
+ " var j = 0;\n" \
+ " for (var i = _head; i < len; i++) @putByValDirect(array, j++, list[i]);\n" \
+ " for (var i = 0; i < _tail; i++) @putByValDirect(array, j++, list[i]);\n" \
+ " return array;\n" \
+ " } else {\n" \
+ " return @Array.prototype.slice.@call(list, this._head, this._tail);\n" \
+ " }\n" \
+ " }\n" \
+ " \n" \
+ " clear() {\n" \
+ " this._head = 0;\n" \
+ " this._tail = 0;\n" \
+ " this._list.fill(undefined);\n" \
+ " }\n" \
+ "\n" \
+ " _growArray() {\n" \
+ " if (this._head) {\n" \
+ " //\n" \
+ " this._list = this.toArray(true);\n" \
+ " this._head = 0;\n" \
+ " }\n" \
+ " \n" \
+ " //\n" \
+ " this._tail = @toLength(this._list.length);\n" \
+ " \n" \
+ " this._list.length <<= 1;\n" \
+ " this._capacityMask = (this._capacityMask << 1) | 1;\n" \
+ " }\n" \
+ " \n" \
+ " shrinkArray() {\n" \
+ " this._list.length >>>= 1;\n" \
+ " this._capacityMask >>>= 1;\n" \
+ " }\n" \
+ " }\n" \
+ "\n" \
+ " \n" \
+ " return new Denqueue();\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsNewQueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsNewQueueCodeLength = 85;
+static const JSC::Intrinsic s_streamInternalsNewQueueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsNewQueueCode =
+ "(function ()\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " return { content: @createFIFO(), size: 0 };\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsDequeueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsDequeueValueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsDequeueValueCodeLength = 195;
+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 = 248;
+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" \
+ " \n" \
+ " queue.content.push({ 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 = 115;
+static const JSC::Intrinsic s_streamInternalsPeekQueueValueCodeIntrinsic = JSC::NoIntrinsic;
+const char* const s_streamInternalsPeekQueueValueCode =
+ "(function (queue)\n" \
+ "{\n" \
+ " \"use strict\";\n" \
+ "\n" \
+ " @assert(queue.content.isNotEmpty());\n" \
+ "\n" \
+ " return queue.peek().value;\n" \
+ "})\n" \
+;
+
+const JSC::ConstructAbility s_streamInternalsResetQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct;
+const JSC::ConstructorKind s_streamInternalsResetQueueCodeConstructorKind = JSC::ConstructorKind::None;
+const int s_streamInternalsResetQueueCodeLength = 152;
+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.clear();\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..61fb36b0e
--- /dev/null
+++ b/src/javascript/jsc/bindings/StreamInternalsBuiltins.h
@@ -0,0 +1,308 @@
+/*
+ * 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_streamInternalsCreateFIFOCode;
+extern const int s_streamInternalsCreateFIFOCodeLength;
+extern const JSC::ConstructAbility s_streamInternalsCreateFIFOCodeConstructAbility;
+extern const JSC::ConstructorKind s_streamInternalsCreateFIFOCodeConstructorKind;
+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(createFIFO, streamInternalsCreateFIFO, 0) \
+ 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_CREATEFIFO 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(streamInternalsCreateFIFOCode, createFIFO, ASCIILiteral(), s_streamInternalsCreateFIFOCodeLength) \
+ 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(createFIFO) \
+ 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/URLDecomposition.cpp b/src/javascript/jsc/bindings/URLDecomposition.cpp
index eb21e36c8..84e734528 100644
--- a/src/javascript/jsc/bindings/URLDecomposition.cpp
+++ b/src/javascript/jsc/bindings/URLDecomposition.cpp
@@ -57,7 +57,7 @@ String URLDecomposition::username() const
void URLDecomposition::setUsername(StringView user)
{
auto fullURL = this->fullURL();
- if (fullURL.host().isEmpty() || fullURL.cannotBeABaseURL() || fullURL.protocolIs("file"))
+ if (fullURL.host().isEmpty() || fullURL.cannotBeABaseURL() || fullURL.protocolIs("file"_s))
return;
fullURL.setUser(user);
setFullURL(fullURL);
@@ -71,7 +71,7 @@ String URLDecomposition::password() const
void URLDecomposition::setPassword(StringView password)
{
auto fullURL = this->fullURL();
- if (fullURL.host().isEmpty() || fullURL.cannotBeABaseURL() || fullURL.protocolIs("file"))
+ if (fullURL.host().isEmpty() || fullURL.cannotBeABaseURL() || fullURL.protocolIs("file"_s))
return;
fullURL.setPassword(password);
setFullURL(fullURL);
@@ -95,7 +95,7 @@ static unsigned countASCIIDigits(StringView string)
void URLDecomposition::setHost(StringView value)
{
auto fullURL = this->fullURL();
- if (value.isEmpty() && !fullURL.protocolIs("file") && fullURL.hasSpecialScheme())
+ if (value.isEmpty() && !fullURL.protocolIs("file"_s) && fullURL.hasSpecialScheme())
return;
size_t separator = value.reverseFind(':');
@@ -148,7 +148,7 @@ void URLDecomposition::setHostname(StringView value)
{
auto fullURL = this->fullURL();
auto host = removeAllLeadingSolidusCharacters(value);
- if (host.isEmpty() && !fullURL.protocolIs("file") && fullURL.hasSpecialScheme())
+ if (host.isEmpty() && !fullURL.protocolIs("file"_s) && fullURL.hasSpecialScheme())
return;
if (fullURL.cannotBeABaseURL() || !fullURL.canSetHostOrPort())
return;
@@ -195,7 +195,7 @@ static std::optional<std::optional<uint16_t>> parsePort(StringView string, Strin
void URLDecomposition::setPort(StringView value)
{
auto fullURL = this->fullURL();
- if (fullURL.host().isEmpty() || fullURL.cannotBeABaseURL() || fullURL.protocolIs("file") || !fullURL.canSetHostOrPort())
+ if (fullURL.host().isEmpty() || fullURL.cannotBeABaseURL() || fullURL.protocolIs("file"_s) || !fullURL.canSetHostOrPort())
return;
auto port = parsePort(value, fullURL.protocol());
if (!port)
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..98674f442
--- /dev/null
+++ b/src/javascript/jsc/bindings/WritableStreamInternalsBuiltins.cpp
@@ -0,0 +1,1103 @@
+/*
+ * 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 = 745;
+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\", @createFIFO());\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 = 372;
+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" \
+ " writeRequests.push(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 = 1556;
+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 (var request = requests.shift(); request; request = requests.shift())\n" \
+ " request.@reject.@call(@undefined, storedError);\n" \
+ "\n" \
+ " //\n" \
+ " @putByIdDirectPrivate(stream, \"writeRequests\", @createFIFO());\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 = 344;
+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.isNotEmpty());\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 = 872;
+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?.isEmpty() ?? false)\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 = 628;
+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?.isEmpty());\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..7d745b896 100644
--- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp
+++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp
@@ -97,6 +97,8 @@
#include "napi.h"
#include "JSZigGlobalObjectBuiltins.h"
#include "JSSQLStatement.h"
+#include "ReadableStreamBuiltins.h"
+#include "BunJSCModule.h"
using JSGlobalObject = JSC::JSGlobalObject;
using Exception = JSC::Exception;
@@ -112,6 +114,28 @@ 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 "JSTextEncoder.h"
+#include "StructuredClone.h"
+
+#include "ReadableStream.h"
// #include <iostream>
static bool has_loaded_jsc = false;
@@ -143,6 +167,8 @@ extern "C" void JSCInitialize()
}
}
+extern "C" void* Bun__getVM();
+
extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* globalObjectClass, int count,
void* console_client)
{
@@ -159,7 +185,7 @@ extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* globalObje
JSC::JSLockHolder locker(vm);
Zig::GlobalObject* globalObject = Zig::GlobalObject::create(vm, Zig::GlobalObject::createStructure(vm, JSC::JSGlobalObject::create(vm, JSC::JSGlobalObject::createStructure(vm, JSC::jsNull())), JSC::jsNull()));
globalObject->setConsole(globalObject);
-
+ globalObject->isThreadLocalDefaultGlobalObject = true;
if (count > 0) {
globalObject->installAPIGlobals(globalObjectClass, count, vm);
}
@@ -303,10 +329,18 @@ GlobalObject::GlobalObject(JSC::VM& vm, JSC::Structure* structure)
, m_builtinInternalFunctions(vm)
{
+ m_bunVM = Bun__getVM();
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;
@@ -351,6 +385,17 @@ JSC_DEFINE_CUSTOM_GETTER(JSBuffer_getter,
WebCore::JSBuffer::getConstructor(JSC::getVM(lexicalGlobalObject), thisObject));
}
+JSC_DECLARE_CUSTOM_GETTER(JSTextEncoder_getter);
+
+JSC_DEFINE_CUSTOM_GETTER(JSTextEncoder_getter,
+ (JSC::JSGlobalObject * lexicalGlobalObject, JSC::EncodedJSValue thisValue,
+ JSC::PropertyName))
+{
+ Zig::GlobalObject* thisObject = JSC::jsCast<Zig::GlobalObject*>(lexicalGlobalObject);
+ return JSC::JSValue::encode(
+ WebCore::JSTextEncoder::getConstructor(JSC::getVM(lexicalGlobalObject), thisObject));
+}
+
JSC_DECLARE_CUSTOM_GETTER(JSDOMURL_getter);
JSC_DEFINE_CUSTOM_GETTER(JSDOMURL_getter,
@@ -674,7 +719,7 @@ static JSC_DEFINE_HOST_FUNCTION(functionATOB,
const WTF::String& encodedString = callFrame->argument(0).toWTFString(globalObject);
if (encodedString.isNull()) {
- return JSC::JSValue::encode(JSC::jsString(vm, ""));
+ return JSC::JSValue::encode(JSC::jsEmptyString(vm));
}
auto decodedData = WTF::base64Decode(encodedString, {
@@ -827,6 +872,39 @@ static JSC_DEFINE_HOST_FUNCTION(functionReportError,
return JSC::JSValue::encode(JSC::jsUndefined());
}
+JSC_DECLARE_HOST_FUNCTION(functionCreateUninitializedArrayBuffer);
+JSC_DEFINE_HOST_FUNCTION(functionCreateUninitializedArrayBuffer,
+ (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ size_t len = static_cast<size_t>(JSC__JSValue__toInt64(JSC::JSValue::encode(callFrame->argument(0))));
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ auto arrayBuffer = JSC::ArrayBuffer::tryCreateUninitialized(len, 1);
+
+ if (UNLIKELY(!arrayBuffer)) {
+ JSC::throwOutOfMemoryError(globalObject, scope);
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
+
+ RELEASE_AND_RETURN(scope, JSValue::encode(JSC::JSArrayBuffer::create(globalObject->vm(), globalObject->arrayBufferStructure(JSC::ArrayBufferSharingMode::Default), WTFMove(arrayBuffer))));
+}
+
+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,7 +921,33 @@ JSC:
}
default: {
static NeverDestroyed<const String> sqliteString(MAKE_STATIC_STRING_IMPL("sqlite"));
+ static NeverDestroyed<const String> bunJSCString(MAKE_STATIC_STRING_IMPL("bun:jsc"));
+ static NeverDestroyed<const String> noopString(MAKE_STATIC_STRING_IMPL("noop"));
JSC::JSValue moduleName = callFrame->argument(0);
+ if (moduleName.isNumber()) {
+ switch (moduleName.toInt32(globalObject)) {
+ case 0: {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "lazyLoad expects a string"_s);
+ scope.release();
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
+
+ case 1: {
+ return ByteBlob__JSReadableStreamSource__load(globalObject);
+ }
+ case 2: {
+ return FileBlobLoader__JSReadableStreamSource__load(globalObject);
+ }
+ default: {
+ auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
+ JSC::throwTypeError(globalObject, scope, "lazyLoad expects a string"_s);
+ scope.release();
+ return JSC::JSValue::encode(JSC::JSValue {});
+ }
+ }
+ }
+
auto string = moduleName.toWTFString(globalObject);
if (string.isNull()) {
auto scope = DECLARE_THROW_SCOPE(globalObject->vm());
@@ -856,6 +960,18 @@ JSC:
return JSC::JSValue::encode(JSSQLStatementConstructor::create(vm, globalObject, JSSQLStatementConstructor::createStructure(vm, globalObject, globalObject->m_functionPrototype.get())));
}
+ if (string == bunJSCString) {
+ return JSC::JSValue::encode(createJSCModule(globalObject));
+ }
+
+ 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 +979,582 @@ 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)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSByteLengthQueuingStrategy::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ByteLengthQueuingStrategyConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ByteLengthQueuingStrategyConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsServiceWorkerGlobalScope_CountQueuingStrategyConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSCountQueuingStrategy::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_CountQueuingStrategyConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_CountQueuingStrategyConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSReadableByteStreamController::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<Zig::GlobalObject>::get<jsServiceWorkerGlobalScope_ReadableByteStreamControllerConstructorGetter>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+static inline JSValue jsServiceWorkerGlobalScope_ReadableStreamConstructorGetter(JSGlobalObject& lexicalGlobalObject, Zig::GlobalObject& thisObject)
+{
+ UNUSED_PARAM(lexicalGlobalObject);
+ return JSReadableStream::getConstructor(JSC::getVM(&lexicalGlobalObject), &thisObject);
+}
+
+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>()));
+}
+
+extern "C" bool ReadableStream__isDisturbed(JSC__JSValue possibleReadableStream, Zig::GlobalObject* globalObject);
+extern "C" bool ReadableStream__isDisturbed(JSC__JSValue possibleReadableStream, Zig::GlobalObject* globalObject)
+{
+ ASSERT(globalObject);
+ return ReadableStream::isDisturbed(globalObject, jsDynamicCast<WebCore::JSReadableStream*>(JSC::JSValue::decode(possibleReadableStream)));
+}
+
+extern "C" bool ReadableStream__isLocked(JSC__JSValue possibleReadableStream, Zig::GlobalObject* globalObject);
+extern "C" bool ReadableStream__isLocked(JSC__JSValue possibleReadableStream, Zig::GlobalObject* globalObject)
+{
+ ASSERT(globalObject);
+ WebCore::JSReadableStream* stream = jsDynamicCast<WebCore::JSReadableStream*>(JSValue::decode(possibleReadableStream));
+ return stream != nullptr && ReadableStream::isLocked(globalObject, stream);
+}
+
+extern "C" int32_t ReadableStreamTag__tagged(Zig::GlobalObject* globalObject, JSC__JSValue possibleReadableStream, JSValue* ptr);
+extern "C" int32_t ReadableStreamTag__tagged(Zig::GlobalObject* globalObject, JSC__JSValue possibleReadableStream, JSValue* ptr)
+{
+ ASSERT(globalObject);
+ JSC::JSObject* object = JSValue::decode(possibleReadableStream).getObject();
+ if (!object || !object->inherits<JSReadableStream>()) {
+ *ptr = JSC::JSValue();
+ return -1;
+ }
+
+ auto* readableStream = jsCast<JSReadableStream*>(object);
+ auto& vm = globalObject->vm();
+ auto& builtinNames = WebCore::clientData(vm)->builtinNames();
+
+ JSValue numberValue = readableStream->getDirect(vm, builtinNames.bunNativeTypePrivateName());
+ int32_t num = numberValue.toInt32(globalObject);
+ if (numberValue.isUndefined() || num == 0) {
+ *ptr = JSC::JSValue();
+ return 0;
+ }
+
+ // If this type is outside the expected range, it means something is wrong.
+ if (UNLIKELY(!(num > 0 && num < 5))) {
+ *ptr = JSC::JSValue();
+ return 0;
+ }
+
+ *ptr = readableStream->getDirect(vm, builtinNames.bunNativePtrPrivateName());
+ return num;
+}
+
+extern "C" JSC__JSValue ReadableStream__consume(Zig::GlobalObject* globalObject, JSC__JSValue stream, JSC__JSValue nativeType, JSC__JSValue nativePtr);
+extern "C" JSC__JSValue ReadableStream__consume(Zig::GlobalObject* globalObject, JSC__JSValue stream, JSC__JSValue nativeType, JSC__JSValue nativePtr)
+{
+ ASSERT(globalObject);
+
+ auto& vm = globalObject->vm();
+ auto scope = DECLARE_CATCH_SCOPE(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 + 11);
- int i = 0;
- for (; i < constructor_count; i++) {
- auto* object = JSC::jsDynamicCast<JSC::JSCallbackConstructor*>(JSC::JSValue::decode(constructors[i]).asCell()->getObject());
+ auto& builtinNames = WebCore::builtinNames(vm);
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo { JSC::Identifier::fromString(vm, object->get(this, vm.propertyNames->name).toWTFString(this)),
- JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 });
+ auto function = globalObject->getDirect(vm, builtinNames.consumeReadableStreamPrivateName()).getObject();
+ JSC::MarkedArgumentBuffer arguments = JSC::MarkedArgumentBuffer();
+ arguments.append(JSValue::decode(nativePtr));
+ arguments.append(JSValue::decode(nativeType));
+ arguments.append(JSValue::decode(stream));
+
+ auto callData = JSC::getCallData(function);
+ return JSC::JSValue::encode(call(globalObject, function, callData, JSC::jsUndefined(), arguments));
+}
+
+extern "C" JSC__JSValue ZigGlobalObject__createNativeReadableStream(Zig::GlobalObject* globalObject, JSC__JSValue nativeType, JSC__JSValue nativePtr);
+extern "C" JSC__JSValue ZigGlobalObject__createNativeReadableStream(Zig::GlobalObject* globalObject, JSC__JSValue nativeType, JSC__JSValue nativePtr)
+{
+ auto& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ auto clientData = WebCore::clientData(vm);
+ auto& builtinNames = WebCore::builtinNames(vm);
+
+ auto function = globalObject->getDirect(vm, builtinNames.createNativeReadableStreamPrivateName()).getObject();
+ JSC::MarkedArgumentBuffer arguments = JSC::MarkedArgumentBuffer();
+ arguments.append(JSValue::decode(nativeType));
+ arguments.append(JSValue::decode(nativePtr));
+
+ auto callData = JSC::getCallData(function);
+ return JSC::JSValue::encode(call(globalObject, function, callData, JSC::jsUndefined(), arguments));
+}
+
+static inline EncodedJSValue flattenArrayOfBuffersIntoArrayBuffer(JSGlobalObject* lexicalGlobalObject, JSValue arrayValue)
+{
+ auto& vm = lexicalGlobalObject->vm();
+
+ auto clientData = WebCore::clientData(vm);
+ if (arrayValue.isUndefinedOrNull() || !arrayValue) {
+ return JSC::JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), JSC::ArrayBuffer::create(static_cast<size_t>(0), 1)));
}
- 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);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
- extraStaticGlobals.uncheckedAppend(
- GlobalPropertyInfo { JSC::Identifier::fromString(vm, jsClass->className()),
- JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 });
+ auto array = JSC::jsDynamicCast<JSC::JSArray*>(arrayValue);
+ if (UNLIKELY(!array)) {
+ throwTypeError(lexicalGlobalObject, throwScope, "Argument must be an array"_s);
+ return JSValue::encode(jsUndefined());
}
- // The last one must be "process.env"
- // Runtime-support is for if they change
- dot_env_class_ref = globals[j];
+ size_t arrayLength = array->length();
+ if (arrayLength < 1) {
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), JSC::ArrayBuffer::create(static_cast<size_t>(0), 1))));
+ }
- // // The last one must be "process.env"
- // // Runtime-support is for if they change
- // {
- // auto jsClass = globals[i];
+ size_t byteLength = 0;
+ bool any_buffer = false;
+ bool any_typed = false;
- // JSC::JSCallbackObject<JSNonFinalObject> *object =
- // JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(),
- // jsClass, nullptr);
- // if (JSObject *prototype = jsClass->prototype(this)) object->setPrototypeDirect(vm,
- // prototype);
+ for (size_t i = 0; i < arrayLength; i++) {
+ auto element = array->getIndex(lexicalGlobalObject, i);
+ RETURN_IF_EXCEPTION(throwScope, {});
- // process->putDirect(this->vm, JSC::Identifier::fromString(this->vm, "env"),
- // JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0);
- // }
+ if (auto* typedArray = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(element)) {
+ if (UNLIKELY(typedArray->isDetached())) {
+ throwTypeError(lexicalGlobalObject, throwScope, "ArrayBufferView is detached"_s);
+ return JSValue::encode(jsUndefined());
+ }
+ byteLength += typedArray->byteLength();
+ any_typed = true;
+ } else if (auto* arrayBuffer = JSC::jsDynamicCast<JSC::JSArrayBuffer*>(element)) {
+ auto* impl = arrayBuffer->impl();
+ if (UNLIKELY(!impl)) {
+ throwTypeError(lexicalGlobalObject, throwScope, "ArrayBuffer is detached"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ byteLength += impl->byteLength();
+ any_buffer = true;
+ } else {
+ throwTypeError(lexicalGlobalObject, throwScope, "Expected TypedArray"_s);
+ return JSValue::encode(jsUndefined());
+ }
+ }
+
+ if (byteLength == 0) {
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), JSC::ArrayBuffer::create(static_cast<size_t>(0), 1))));
+ }
+
+ auto buffer = JSC::ArrayBuffer::tryCreateUninitialized(byteLength, 1);
+ if (UNLIKELY(!buffer)) {
+ throwTypeError(lexicalGlobalObject, throwScope, "Failed to allocate ArrayBuffer"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ size_t remain = byteLength;
+ auto* head = reinterpret_cast<char*>(buffer->data());
+
+ if (!any_buffer) {
+ for (size_t i = 0; i < arrayLength && remain > 0; i++) {
+ auto element = array->getIndex(lexicalGlobalObject, i);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ auto* view = JSC::jsCast<JSC::JSArrayBufferView*>(element);
+ size_t length = std::min(remain, view->byteLength());
+ memcpy(head, view->vector(), length);
+ remain -= length;
+ head += length;
+ }
+ } else if (!any_typed) {
+ for (size_t i = 0; i < arrayLength && remain > 0; i++) {
+ auto element = array->getIndex(lexicalGlobalObject, i);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ auto* view = JSC::jsCast<JSC::JSArrayBuffer*>(element);
+ size_t length = std::min(remain, view->impl()->byteLength());
+ memcpy(head, view->impl()->data(), length);
+ remain -= length;
+ head += length;
+ }
+ } else {
+ for (size_t i = 0; i < arrayLength && remain > 0; i++) {
+ auto element = array->getIndex(lexicalGlobalObject, i);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ size_t length = 0;
+ if (auto* view = JSC::jsDynamicCast<JSC::JSArrayBuffer*>(element)) {
+ length = std::min(remain, view->impl()->byteLength());
+ memcpy(head, view->impl()->data(), length);
+ } else {
+ auto* typedArray = JSC::jsCast<JSC::JSArrayBufferView*>(element);
+ length = std::min(remain, typedArray->byteLength());
+ memcpy(head, typedArray->vector(), length);
+ }
+
+ remain -= length;
+ head += length;
+ }
+ }
+
+ RELEASE_AND_RETURN(throwScope, JSValue::encode(JSC::JSArrayBuffer::create(vm, lexicalGlobalObject->arrayBufferStructure(), WTFMove(buffer))));
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionConcatTypedArrays);
+
+JSC_DEFINE_HOST_FUNCTION(functionConcatTypedArrays, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ auto& vm = globalObject->vm();
+
+ if (UNLIKELY(callFrame->argumentCount() < 1)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwTypeError(globalObject, throwScope, "Expected at least one argument"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ auto arrayValue = callFrame->uncheckedArgument(0);
+
+ return flattenArrayOfBuffersIntoArrayBuffer(globalObject, arrayValue);
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionConcatTypedArraysFromIterator);
+
+JSC_DEFINE_HOST_FUNCTION(functionConcatTypedArraysFromIterator, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ auto& vm = globalObject->vm();
+
+ if (UNLIKELY(callFrame->argumentCount() < 1)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwTypeError(globalObject, throwScope, "Expected at least one argument"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ auto arrayValue = callFrame->uncheckedArgument(0);
+ if (UNLIKELY(!arrayValue.isObject())) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwTypeError(globalObject, throwScope, "Expected an object"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ auto* iter = JSC::jsCast<JSC::JSObject*>(arrayValue);
+
+ return flattenArrayOfBuffersIntoArrayBuffer(globalObject, iter->getDirect(vm, vm.propertyNames->value));
+}
+
+static inline JSC__JSValue ZigGlobalObject__readableStreamToArrayBufferBody(Zig::GlobalObject* globalObject, JSC__JSValue readableStreamValue);
+static inline JSC__JSValue ZigGlobalObject__readableStreamToArrayBufferBody(Zig::GlobalObject* globalObject, JSC__JSValue readableStreamValue)
+{
+ auto& vm = globalObject->vm();
+
+ auto clientData = WebCore::clientData(vm);
+ auto& builtinNames = WebCore::builtinNames(vm);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+
+ auto function = globalObject->getDirect(vm, builtinNames.readableStreamToArrayPrivateName()).getObject();
+ JSC::MarkedArgumentBuffer arguments = JSC::MarkedArgumentBuffer();
+ arguments.append(JSValue::decode(readableStreamValue));
+
+ auto callData = JSC::getCallData(function);
+ JSValue result = call(globalObject, function, callData, JSC::jsUndefined(), arguments);
+
+ JSC::JSObject* object = result.getObject();
+
+ if (UNLIKELY(!result || result.isUndefinedOrNull()))
+ return JSValue::encode(result);
+
+ if (UNLIKELY(!object)) {
+
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwTypeError(globalObject, throwScope, "Expected object"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ JSC::JSPromise* promise = JSC::jsDynamicCast<JSC::JSPromise*>(object);
+ if (UNLIKELY(!promise)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwTypeError(globalObject, throwScope, "Expected promise"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ auto afterOngoingPromiseCapability = JSC::JSPromise::createNewPromiseCapability(globalObject, globalObject->promiseConstructor());
+ auto data = JSC::JSPromise::convertCapabilityToDeferredData(globalObject, afterOngoingPromiseCapability);
+
+ if (auto resolve = globalObject->m_readableStreamToArrayBufferResolve.get()) {
+ promise->performPromiseThen(globalObject, resolve, data.reject, afterOngoingPromiseCapability);
+ } else {
+ JSFunction* resolveFunction = JSFunction::create(vm, globalObject, 1, String(), functionConcatTypedArrays, NoIntrinsic);
+ globalObject->m_readableStreamToArrayBufferResolve.set(vm, globalObject, resolveFunction);
+ promise->performPromiseThen(globalObject, resolveFunction, data.reject, afterOngoingPromiseCapability);
+ }
+
+ RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(data.promise));
+}
+
+extern "C" JSC__JSValue ZigGlobalObject__readableStreamToArrayBuffer(Zig::GlobalObject* globalObject, JSC__JSValue readableStreamValue);
+extern "C" JSC__JSValue ZigGlobalObject__readableStreamToArrayBuffer(Zig::GlobalObject* globalObject, JSC__JSValue readableStreamValue)
+{
+ return ZigGlobalObject__readableStreamToArrayBufferBody(reinterpret_cast<Zig::GlobalObject*>(globalObject), readableStreamValue);
+}
+
+JSC_DECLARE_HOST_FUNCTION(functionReadableStreamToArrayBuffer);
+JSC_DEFINE_HOST_FUNCTION(functionReadableStreamToArrayBuffer, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ auto& vm = globalObject->vm();
+
+ if (UNLIKELY(callFrame->argumentCount() < 1)) {
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ throwTypeError(globalObject, throwScope, "Expected at least one argument"_s);
+ return JSValue::encode(jsUndefined());
+ }
+
+ auto readableStreamValue = callFrame->uncheckedArgument(0);
+ return ZigGlobalObject__readableStreamToArrayBufferBody(reinterpret_cast<Zig::GlobalObject*>(globalObject), JSValue::encode(readableStreamValue));
+}
+
+void GlobalObject::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+ addBuiltinGlobals(vm);
+
+ RELEASE_ASSERT(classInfo());
+}
+
+extern "C" EncodedJSValue Bun__escapeHTML(JSGlobalObject* globalObject, CallFrame* callFrame);
+
+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(28);
JSC::Identifier queueMicrotaskIdentifier = JSC::Identifier::fromString(vm, "queueMicrotask"_s);
extraStaticGlobals.uncheckedAppend(
@@ -977,17 +1619,34 @@ 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 });
+ 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));
+
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()));
- });
+ extraStaticGlobals.releaseBuffer();
- m_JSFFIFunctionStructure.initLater(
- [](LazyClassStructure::Initializer& init) {
- init.setStructure(Zig::JSFFIFunction::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()));
- });
+ putDirectBuiltinFunction(vm, this, builtinNames.createFIFOPrivateName(), streamInternalsCreateFIFOCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
+ putDirectBuiltinFunction(vm, this, builtinNames.createNativeReadableStreamPrivateName(), readableStreamCreateNativeReadableStreamCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
+ putDirectBuiltinFunction(vm, this, builtinNames.createEmptyReadableStreamPrivateName(), readableStreamCreateEmptyReadableStreamCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
+ putDirectBuiltinFunction(vm, this, builtinNames.consumeReadableStreamPrivateName(), readableStreamConsumeReadableStreamCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
+ putDirectBuiltinFunction(vm, this, builtinNames.readableStreamToArrayPrivateName(), readableStreamReadableStreamToArrayCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
+
+ putDirectNativeFunction(vm, this, builtinNames.createUninitializedArrayBufferPrivateName(), 1, functionCreateUninitializedArrayBuffer, NoIntrinsic, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::Function);
putDirectCustomAccessor(vm, JSC::Identifier::fromString(vm, "process"_s), JSC::CustomGetterSetter::create(vm, property_lazyProcessGetter, property_lazyProcessSetter),
JSC::PropertyAttribute::CustomAccessor | 0);
@@ -1024,6 +1683,139 @@ 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, JSC::Identifier::fromString(vm, "TextEncoder"_s), JSC::CustomGetterSetter::create(vm, JSTextEncoder_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);
+
+ // putDirect(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().nativeReadableStreamPrototypePrivateName(), jsUndefined(), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::DontEnum | 0);
+}
+
+// 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;
+ auto& builtinNames = clientData->builtinNames();
+ 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;
+ {
+ // first one is Bun object
+ 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);
+
+ {
+ JSC::Identifier identifier = JSC::Identifier::fromString(vm, "escapeHTML"_s);
+ object->putDirectNativeFunction(vm, this, identifier, 1, Bun__escapeHTML, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ }
+
+ {
+ JSC::Identifier identifier = JSC::Identifier::fromString(vm, "readableStreamToArrayBuffer"_s);
+ object->putDirectNativeFunction(vm, this, identifier, 1, functionReadableStreamToArrayBuffer, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ }
+
+ {
+ JSC::Identifier identifier = JSC::Identifier::fromString(vm, "concatArrayBuffers"_s);
+ object->putDirectNativeFunction(vm, this, identifier, 1, functionConcatTypedArrays, NoIntrinsic,
+ JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DontDelete | 0);
+ }
+
+ {
+ JSC::Identifier identifier = JSC::Identifier::fromString(vm, "readableStreamToArray"_s);
+ object->putDirectBuiltinFunction(vm, this, builtinNames.readableStreamToArrayPublicName(), readableStreamReadableStreamToArrayCodeGenerator(vm), PropertyAttribute::Builtin | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
+ }
+
+ extraStaticGlobals.uncheckedAppend(
+ GlobalPropertyInfo { JSC::Identifier::fromString(vm, jsClass->className()),
+ JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 });
+ }
+
+ for (j = 1; 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,15 +1842,17 @@ 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);
+ visitor.append(thisObject->m_readableStreamToArrayBufferResolve);
+ visitor.append(thisObject->m_readableStreamToTextResolve);
ScriptExecutionContext* context = thisObject->scriptExecutionContext();
visitor.addOpaqueRoot(context);
}
@@ -1161,7 +1955,7 @@ JSC::JSInternalPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalOb
auto moduleKey = key.toWTFString(globalObject);
RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope));
- if (moduleKey.endsWith(".node")) {
+ if (moduleKey.endsWith(".node"_s)) {
return rejectWithError(createTypeError(globalObject, "To load Node-API modules, use require() or process.dlopen instead of import."_s));
}
@@ -1281,9 +2075,14 @@ JSC::JSValue GlobalObject::moduleLoaderEvaluate(JSGlobalObject* globalObject,
void GlobalObject::queueMicrotaskToEventLoop(JSC::JSGlobalObject& global,
Ref<JSC::Microtask>&& task)
{
-
- Zig__GlobalObject__queueMicrotaskToEventLoop(
- &global, &JSMicrotaskCallback::create(global, WTFMove(task)).leakRef());
+ auto& globalObject = reinterpret_cast<GlobalObject&>(global);
+ if (globalObject.isThreadLocalDefaultGlobalObject) {
+ Zig__GlobalObject__queueMicrotaskToEventLoop(
+ &global, reinterpret_cast<JSMicrotaskCallback*>(&JSMicrotaskCallbackDefaultGlobal::create(WTFMove(task)).leakRef()));
+ } else {
+ Zig__GlobalObject__queueMicrotaskToEventLoop(
+ &global, &JSMicrotaskCallback::create(global, WTFMove(task)).leakRef());
+ }
}
} // namespace Zig
diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.h b/src/javascript/jsc/bindings/ZigGlobalObject.h
index 70740a2c4..ffed48909 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);
@@ -131,8 +149,15 @@ public:
JSC::Structure* FFIFunctionStructure() { return m_JSFFIFunctionStructure.getInitializedOnMainThread(this); }
JSC::Structure* NapiClassStructure() { return m_NapiClassStructure.getInitializedOnMainThread(this); }
+ void* bunVM() { return m_bunVM; }
+ bool isThreadLocalDefaultGlobalObject = false;
+
+ mutable WriteBarrier<JSFunction> m_readableStreamToArrayBufferResolve;
+ mutable WriteBarrier<JSFunction> m_readableStreamToTextResolve;
+
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,9 +169,38 @@ private:
Ref<WebCore::DOMWrapperWorld> m_world;
LazyClassStructure m_JSFFIFunctionStructure;
LazyClassStructure m_NapiClassStructure;
+
+ DOMGuardedObjectSet m_guardedObjects WTF_GUARDED_BY_LOCK(m_gcLock);
+ void* m_bunVM;
+};
+
+class JSMicrotaskCallbackDefaultGlobal final : public RefCounted<JSMicrotaskCallbackDefaultGlobal> {
+public:
+ static Ref<JSMicrotaskCallbackDefaultGlobal> create(Ref<JSC::Microtask>&& task)
+ {
+ return adoptRef(*new JSMicrotaskCallbackDefaultGlobal(WTFMove(task).leakRef()));
+ }
+
+ void call(JSC::JSGlobalObject* globalObject)
+ {
+
+ JSC::VM& vm = globalObject->vm();
+ auto task = &m_task.leakRef();
+ task->run(globalObject);
+
+ delete this;
+ }
+
+private:
+ JSMicrotaskCallbackDefaultGlobal(Ref<JSC::Microtask>&& task)
+ : m_task { WTFMove(task) }
+ {
+ }
+
+ Ref<JSC::Microtask> m_task;
};
-class JSMicrotaskCallback : public RefCounted<JSMicrotaskCallback> {
+class JSMicrotaskCallback final : public RefCounted<JSMicrotaskCallback> {
public:
static Ref<JSMicrotaskCallback> create(JSC::JSGlobalObject& globalObject,
Ref<JSC::Microtask>&& task)
@@ -156,21 +210,27 @@ public:
void call()
{
+ auto* globalObject = m_globalObject.get();
+ if (UNLIKELY(!globalObject)) {
+ delete this;
+ return;
+ }
+
JSC::VM& vm = m_globalObject->vm();
auto task = &m_task.leakRef();
- task->run(m_globalObject.get());
+ task->run(globalObject);
- task->~Microtask();
+ delete this;
}
private:
JSMicrotaskCallback(JSC::JSGlobalObject& globalObject, Ref<JSC::Microtask>&& task)
- : m_globalObject { globalObject.vm(), &globalObject }
+ : m_globalObject { &globalObject }
, m_task { WTFMove(task) }
{
}
- JSC::Strong<JSC::JSGlobalObject> m_globalObject;
+ JSC::Weak<JSC::JSGlobalObject> m_globalObject;
Ref<JSC::Microtask> m_task;
};
diff --git a/src/javascript/jsc/bindings/bindings.cpp b/src/javascript/jsc/bindings/bindings.cpp
index ce21b8108..f289f40c9 100644
--- a/src/javascript/jsc/bindings/bindings.cpp
+++ b/src/javascript/jsc/bindings/bindings.cpp
@@ -73,18 +73,6 @@
#include "JSDOMOperation.h"
#include "JSDOMWrapperCache.h"
-template<typename WebCoreType, typename OutType>
-OutType* WebCoreCast(JSC__JSValue JSValue0, JSC::VM* vm)
-{
- // we must use jsDynamicCast here so that we check that the type is correct
- WebCoreType* jsdomURL = JSC::jsDynamicCast<WebCoreType*>(JSC::JSValue::decode(JSValue0));
- if (jsdomURL == nullptr) {
- return nullptr;
- }
-
- return reinterpret_cast<OutType*>(&jsdomURL->wrapped());
-}
-
template<typename UWSResponse>
static void copyToUWS(WebCore::FetchHeaders* headers, UWSResponse* res)
{
@@ -98,6 +86,50 @@ static void copyToUWS(WebCore::FetchHeaders* headers, UWSResponse* res)
}
}
+template<typename PromiseType, bool isInternal>
+static void handlePromise(PromiseType* promise, JSC__JSGlobalObject* globalObject, void* ctx, void (*ArgFn3)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3), void (*ArgFn4)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3))
+{
+ JSC::Strong<PromiseType> strongValue = { globalObject->vm(), promise };
+ JSC::JSNativeStdFunction* resolverFunction = JSC::JSNativeStdFunction::create(
+ globalObject->vm(), globalObject, 1, String(), [&strongValue, ctx, ArgFn3](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -> const JSC::EncodedJSValue {
+ auto argCount = static_cast<uint16_t>(callFrame->argumentCount());
+
+ WTF::Vector<JSC::EncodedJSValue, 16> arguments;
+ arguments.reserveInitialCapacity(argCount);
+ if (argCount) {
+ for (uint16_t i = 0; i < argCount; ++i) {
+ arguments.uncheckedAppend(JSC::JSValue::encode(callFrame->uncheckedArgument(i)));
+ }
+ }
+
+ ArgFn3(globalObject, ctx, reinterpret_cast<void**>(arguments.data()), argCount);
+ strongValue.clear();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ });
+ JSC::JSNativeStdFunction* rejecterFunction = JSC::JSNativeStdFunction::create(
+ globalObject->vm(), globalObject, 1, String(),
+ [&strongValue, ctx, ArgFn4](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -> JSC::EncodedJSValue {
+ auto argCount = static_cast<uint16_t>(callFrame->argumentCount());
+ WTF::Vector<JSC::EncodedJSValue, 16> arguments;
+ arguments.reserveInitialCapacity(argCount);
+ if (argCount) {
+ for (uint16_t i = 0; i < argCount; ++i) {
+ arguments.uncheckedAppend(JSC::JSValue::encode(callFrame->uncheckedArgument(i)));
+ }
+ }
+
+ ArgFn4(globalObject, ctx, reinterpret_cast<void**>(arguments.data()), argCount);
+ strongValue.clear();
+ return JSC::JSValue::encode(JSC::jsUndefined());
+ });
+
+ if constexpr (!isInternal) {
+ promise->performPromiseThen(globalObject, resolverFunction, rejecterFunction, JSC::jsUndefined());
+ } else {
+ promise->then(globalObject, resolverFunction, rejecterFunction);
+ }
+}
+
extern "C" {
void WebCore__FetchHeaders__toUWSResponse(WebCore__FetchHeaders* arg0, bool is_ssl, void* arg2)
@@ -120,7 +152,7 @@ void WebCore__FetchHeaders__append(WebCore__FetchHeaders* headers, const ZigStri
}
WebCore__FetchHeaders* WebCore__FetchHeaders__cast_(JSC__JSValue JSValue0, JSC__VM* vm)
{
- return WebCoreCast<WebCore::JSFetchHeaders, WebCore__FetchHeaders>(JSValue0, vm);
+ return WebCoreCast<WebCore::JSFetchHeaders, WebCore__FetchHeaders>(JSValue0);
}
using namespace WebCore;
@@ -274,7 +306,7 @@ void WebCore__FetchHeaders__remove(WebCore__FetchHeaders* headers, const ZigStri
WebCore__DOMURL* WebCore__DOMURL__cast_(JSC__JSValue JSValue0, JSC::VM* vm)
{
- return WebCoreCast<WebCore::JSDOMURL, WebCore__DOMURL>(JSValue0, vm);
+ return WebCoreCast<WebCore::JSDOMURL, WebCore__DOMURL>(JSValue0);
}
void WebCore__DOMURL__href_(WebCore__DOMURL* domURL, ZigString* arg1)
@@ -306,10 +338,8 @@ JSC__JSValue SystemError__toErrorInstance(const SystemError* arg0,
JSC::JSValue options = JSC::jsUndefined();
- Structure* errorStructure = JSC_GET_DERIVED_STRUCTURE(vm, errorStructure, globalObject->errorPrototype(), globalObject->errorPrototype());
-
JSC::JSObject* result
- = JSC::ErrorInstance::create(globalObject, errorStructure, message, options);
+ = JSC::ErrorInstance::create(globalObject, JSC::ErrorInstance::createStructure(vm, globalObject, globalObject->errorPrototype()), message, options);
auto clientData = WebCore::clientData(vm);
@@ -507,50 +537,15 @@ JSC__JSPromise* JSC__JSPromise__create(JSC__JSGlobalObject* arg0)
}
// TODO: prevent this from allocating so much memory
-void JSC__JSValue___then(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, void* ctx, void (*ArgFn3)(JSC__JSGlobalObject* arg0, void* arg1, JSC__JSValue arg2, size_t arg3), void (*ArgFn4)(JSC__JSGlobalObject* arg0, void* arg1, JSC__JSValue arg2, size_t arg3))
+void JSC__JSValue___then(JSC__JSValue JSValue0, JSC__JSGlobalObject* globalObject, void* ctx, void (*ArgFn3)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3), void (*ArgFn4)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3))
{
- globalObject->vm().drainMicrotasks();
auto* cell = JSC::JSValue::decode(JSValue0).asCell();
- JSC::Strong<JSC::Unknown> promiseValue = { globalObject->vm(), cell };
-
- JSC::JSNativeStdFunction* resolverFunction = JSC::JSNativeStdFunction::create(
- globalObject->vm(), globalObject, 1, String(), [&promiseValue, ctx, ArgFn3](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -> JSC::EncodedJSValue {
- auto argCount = static_cast<uint16_t>(callFrame->argumentCount());
-
- WTF::Vector<JSC::EncodedJSValue, 16> arguments;
- arguments.reserveInitialCapacity(argCount);
- if (argCount) {
- for (uint16_t i = 0; i < argCount; ++i) {
- arguments.uncheckedAppend(JSC::JSValue::encode(callFrame->uncheckedArgument(i)));
- }
- }
-
- ArgFn3(globalObject, ctx, reinterpret_cast<JSC__JSValue>(arguments.data()), argCount);
-
- return JSC::JSValue::encode(JSC::jsUndefined());
- });
- JSC::JSNativeStdFunction* rejecterFunction = JSC::JSNativeStdFunction::create(
- globalObject->vm(), globalObject, 1, String(),
- [&promiseValue, ctx, ArgFn4](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame) -> JSC::EncodedJSValue {
- auto argCount = static_cast<uint16_t>(callFrame->argumentCount());
- WTF::Vector<JSC::EncodedJSValue, 16> arguments;
- arguments.reserveInitialCapacity(argCount);
- if (argCount) {
- for (uint16_t i = 0; i < argCount; ++i) {
- arguments.uncheckedAppend(JSC::JSValue::encode(callFrame->uncheckedArgument(i)));
- }
- }
-
- ArgFn4(globalObject, ctx, reinterpret_cast<JSC__JSValue>(arguments.data()), argCount);
-
- return JSC::JSValue::encode(JSC::jsUndefined());
- });
if (JSC::JSPromise* promise = JSC::jsDynamicCast<JSC::JSPromise*>(cell)) {
- promise->performPromiseThen(globalObject, resolverFunction, rejecterFunction, JSC::jsUndefined());
+ handlePromise<JSC::JSPromise, false>(promise, globalObject, ctx, ArgFn3, ArgFn4);
} else if (JSC::JSInternalPromise* promise = JSC::jsDynamicCast<JSC::JSInternalPromise*>(cell)) {
- promise->then(globalObject, resolverFunction, rejecterFunction);
+ handlePromise<JSC::JSInternalPromise, true>(promise, globalObject, ctx, ArgFn3, ArgFn4);
}
}
@@ -808,6 +803,11 @@ void Microtask__run(void* microtask, void* global)
reinterpret_cast<Zig::JSMicrotaskCallback*>(microtask)->call();
}
+void Microtask__run_default(void* microtask, void* global)
+{
+ reinterpret_cast<Zig::JSMicrotaskCallbackDefaultGlobal*>(microtask)->call(reinterpret_cast<Zig::GlobalObject*>(global));
+}
+
bool JSC__JSModuleLoader__checkSyntax(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1,
bool arg2)
{
@@ -877,6 +877,14 @@ static JSC::JSValue doLink(JSC__JSGlobalObject* globalObject, JSC::JSValue modul
return JSC::linkAndEvaluateModule(globalObject, moduleKey, JSC::JSValue());
}
+JSC__JSValue ReadableStream__empty(Zig::GlobalObject* globalObject)
+{
+ auto& vm = globalObject->vm();
+ auto clientData = WebCore::clientData(vm);
+ auto* function = globalObject->getDirect(vm, clientData->builtinNames().createEmptyReadableStreamPrivateName()).getObject();
+ return JSValue::encode(JSC::call(globalObject, function, JSC::ArgList(), "ReadableStream.create"_s));
+}
+
JSC__JSValue JSC__JSValue__createRangeError(const ZigString* message, const ZigString* arg1,
JSC__JSGlobalObject* globalObject)
{
@@ -967,15 +975,12 @@ bool JSC__JSValue__asArrayBuffer_(JSC__JSValue JSValue0, JSC__JSGlobalObject* ar
JSC::JSObject* object = value.getObject();
if (JSC::JSArrayBufferView* typedArray = JSC::jsDynamicCast<JSC::JSArrayBufferView*>(object)) {
- if (JSC::ArrayBuffer* buffer = typedArray->possiblySharedBuffer()) {
- buffer->pinAndLock();
- arg2->ptr = reinterpret_cast<char*>(buffer->data());
- arg2->len = typedArray->length();
- arg2->byte_len = buffer->byteLength();
- arg2->offset = typedArray->byteOffset();
- arg2->cell_type = typedArray->type();
- return true;
- }
+ arg2->ptr = reinterpret_cast<char*>(typedArray->vector());
+ arg2->len = typedArray->length();
+ arg2->byte_len = typedArray->byteLength();
+ arg2->offset = typedArray->byteOffset();
+ arg2->cell_type = typedArray->type();
+ return true;
}
if (JSC::ArrayBuffer* buffer = JSC::toPossiblySharedArrayBuffer(vm, value)) {
@@ -1084,23 +1089,31 @@ static void free_global_string(void* str, void* ptr, unsigned len)
JSC__JSValue ZigString__toExternalU16(const uint16_t* arg0, size_t len, JSC__JSGlobalObject* global)
{
- return JSC::JSValue::encode(JSC::JSValue(JSC::jsOwnedString(
- global->vm(),
- ExternalStringImpl::create(reinterpret_cast<const UChar*>(arg0), len, nullptr, free_global_string))));
+ auto ref = String(ExternalStringImpl::create(reinterpret_cast<const UChar*>(arg0), len, nullptr, free_global_string));
+
+ return JSC::JSValue::encode(JSC::JSValue(JSC::jsString(
+ global->vm(), WTFMove(ref))));
}
// This must be a globally allocated string
JSC__JSValue ZigString__toExternalValue(const ZigString* arg0, JSC__JSGlobalObject* arg1)
{
ZigString str = *arg0;
if (Zig::isTaggedUTF16Ptr(str.ptr)) {
- return JSC::JSValue::encode(JSC::JSValue(JSC::jsOwnedString(
+ auto ref = String(ExternalStringImpl::create(reinterpret_cast<const UChar*>(Zig::untag(str.ptr)), str.len, nullptr, free_global_string));
+
+ return JSC::JSValue::encode(JSC::JSValue(JSC::jsString(
+ arg1->vm(), WTFMove(ref))));
+ } else {
+ auto ref = String(ExternalStringImpl::create(Zig::untag(str.ptr), str.len, nullptr, free_global_string));
+ return JSC::JSValue::encode(JSC::JSValue(JSC::jsString(
arg1->vm(),
- ExternalStringImpl::create(reinterpret_cast<const UChar*>(Zig::untag(str.ptr)), str.len, nullptr, free_global_string))));
+ WTFMove(ref))));
}
+}
- return JSC::JSValue::encode(JSC::JSValue(JSC::jsOwnedString(
- arg1->vm(),
- ExternalStringImpl::create(Zig::untag(str.ptr), str.len, nullptr, free_global_string))));
+VirtualMachine* JSC__JSGlobalObject__bunVM(JSC__JSGlobalObject* arg0)
+{
+ return reinterpret_cast<VirtualMachine*>(reinterpret_cast<Zig::GlobalObject*>(arg0)->bunVM());
}
JSC__JSValue ZigString__toValueGC(const ZigString* arg0, JSC__JSGlobalObject* arg1)
@@ -1432,116 +1445,6 @@ void JSC__SourceCode__fromString(JSC__SourceCode* arg0, const WTF__String* arg1,
const JSC__SourceOrigin* arg2, WTF__String* arg3,
unsigned char SourceType4) {}
-#pragma mark - JSC::JSFunction
-
-// JSC__JSValue JSC__JSFunction__callWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1,
-// JSC__JSValue* arg2, size_t arg3,
-// JSC__Exception** arg4, const unsigned char* arg5)
-// {
-// auto args = makeArgs(arg2, arg3);
-// return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0),
-// JSC::JSValue::decode(JSValue0), args, (const char*)arg5));
-// }
-// JSC__JSValue JSC__JSFunction__callWithArgumentsAndThis(JSC__JSValue JSValue0, JSC__JSValue JSValue1,
-// JSC__JSGlobalObject* arg2,
-// JSC__JSValue* arg3, size_t arg4,
-// JSC__Exception** arg5,
-// const unsigned char* arg6)
-// {
-// auto args = makeArgs(arg3, arg4);
-// return JSC::JSValue::encode(JSC::call(arg2, JSC::JSValue::decode(JSValue0),
-// JSC::JSValue::decode(JSValue1), args, (const char*)arg6));
-// }
-// JSC__JSValue JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSC__JSValue JSValue0,
-// JSC__JSGlobalObject* arg1,
-// JSC__Exception** arg2,
-// const unsigned char* arg3)
-// {
-// return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0),
-// JSC::JSValue::decode(JSValue0), JSC::ArgList(),
-// (const char*)arg3));
-// }
-// JSC__JSValue JSC__JSFunction__callWithThis(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1,
-// JSC__JSValue JSValue2, JSC__Exception** arg3,
-// const unsigned char* arg4)
-// {
-// return JSC::JSValue::encode(JSC::call(arg1, JSC::JSValue::decode(JSValue0),
-// JSC::JSValue::decode(JSValue2), JSC::ArgList(),
-// (const char*)arg4));
-// }
-// JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSValue JSValue0,
-// JSC__JSGlobalObject* arg1, JSC__JSValue* arg2,
-// size_t arg3, JSC__Exception** arg4,
-// const unsigned char* arg5)
-// {
-// auto args = makeArgs(arg2, arg3);
-// return JSC::JSValue::encode(
-// JSC::construct(arg1, JSC::JSValue::decode(JSValue0), args, (const char*)arg5));
-// }
-
-// JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(
-// JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3,
-// size_t arg4, JSC__Exception** arg5, const unsigned char* arg6)
-// {
-// auto args = makeArgs(arg3, arg4);
-// return JSC::JSValue::encode(JSC::construct(arg2, JSC::JSValue::decode(JSValue0),
-// JSC::JSValue::decode(JSValue0), args,
-// (const char*)arg6));
-// }
-// JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSValue JSValue0,
-// JSC__JSGlobalObject* arg1,
-// JSC__JSValue JSValue2, JSC__Exception** arg3,
-// const unsigned char* arg4)
-// {
-// return JSC::JSValue::encode(JSC::construct(arg1, JSC::JSValue::decode(JSValue0),
-// JSC::JSValue::decode(JSValue2), JSC::ArgList(),
-// (const char*)arg4));
-// }
-// JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSValue JSValue0,
-// JSC__JSGlobalObject* arg1,
-// JSC__Exception** arg2,
-// const unsigned char* arg3)
-// {
-// return JSC::JSValue::encode(
-// JSC::construct(arg1, JSC::JSValue::decode(JSValue0), JSC::ArgList(), (const char*)arg3));
-// }
-
-JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, uint16_t arg1,
- const WTF__String* arg2, void* ctx,
- NativeCallbackFunction callback)
-{
- return JSC::JSNativeStdFunction::create(
- reinterpret_cast<JSC::VM&>(arg0->vm()), arg0, arg1, arg2 != nullptr ? *arg2 : WTF::String(),
- [ctx, callback](JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame)
- -> JSC::EncodedJSValue { return callback(ctx, globalObject, callFrame); });
-}
-// JSC__JSFunction* JSC__JSFunction__createFromSourceCode(
-// JSC__JSGlobalObject* arg0,
-// const unsigned char* arg1,
-// uint16_t arg2,
-// JSC__JSValue arg3,
-// uint16_t arg4,
-// const JSC__SourceCode* source,
-// JSC__SourceOrigin* origin,
-// JSC__JSObject** exception
-// ) {
-// JSC::VM& vm = reinterpret_cast<JSC::VM&>(arg0->vm());
-// JSC::Identifier functionName = JSC::Identifier::fromString(vm, arg2 &&
-// arg1 != nullptr ? WTF::StringImpl(static_cast<const LChar*>(arg1), arg2)
-// : vm->propertyNames->anonymous.impl());
-
-// JSC::FunctionExecutable* function =
-// JSC::FunctionExecutable::fromGlobalCode(
-// functionName,
-// arg0,
-// source,
-// exception,
-// 0,
-// nullptr,
-// );
-
-// }
-
bWTF__String JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1)
{
auto wrap = Wrap<WTF::String, bWTF__String>(arg0->displayName(reinterpret_cast<JSC::VM&>(arg1)));
@@ -2426,7 +2329,12 @@ void exceptionFromString(ZigException* except, JSC::JSValue value, JSC::JSGlobal
ref->ref();
}
-static WTF::StringView function_string_view = WTF::StringView("Function");
+void JSC__VM__releaseWeakRefs(JSC__VM* arg0)
+{
+ arg0->finalizeSynchronousJSExecution();
+}
+
+static auto function_string_view = MAKE_STATIC_STRING_IMPL("Function");
void JSC__JSValue__getClassName(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2)
{
JSC::JSCell* cell = JSC::JSValue::decode(JSValue0).asCell();
@@ -2436,10 +2344,10 @@ void JSC__JSValue__getClassName(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1
}
const char* ptr = cell->className();
- auto view = WTF::StringView(ptr);
+ auto view = WTF::StringView(ptr, strlen(ptr));
// Fallback to .name if className is empty
- if (view.length() == 0 || view == function_string_view) {
+ if (view.length() == 0 || StringView(String(function_string_view)) == view) {
JSC__JSValue__getNameProperty(JSValue0, arg1, arg2);
return;
} else {
@@ -2544,12 +2452,16 @@ JSC__JSValue JSC__VM__runGC(JSC__VM* vm, bool sync)
{
JSC::JSLockHolder lock(vm);
+ vm->finalizeSynchronousJSExecution();
+
if (sync) {
vm->heap.collectNow(JSC::Sync, JSC::CollectionScope::Full);
} else {
vm->heap.collectSync(JSC::CollectionScope::Full);
}
+ vm->finalizeSynchronousJSExecution();
+
return JSC::JSValue::encode(JSC::jsNumber(vm->heap.sizeAfterLastFullCollection()));
}
@@ -2587,6 +2499,11 @@ void JSC__VM__holdAPILock(JSC__VM* arg0, void* ctx, void (*callback)(void* arg0)
callback(ctx);
}
+void JSC__JSString__iterator(JSC__JSString* arg0, JSC__JSGlobalObject* arg1, void* arg2)
+{
+ jsstring_iterator* iter = (jsstring_iterator*)arg2;
+ arg0->value(iter);
+}
void JSC__VM__deferGC(JSC__VM* vm, void* ctx, void (*callback)(void* arg0))
{
JSC::GCDeferralContext deferralContext(reinterpret_cast<JSC__VM&>(vm));
@@ -2623,13 +2540,14 @@ bool JSC__VM__isEntered(JSC__VM* arg0) { return (*arg0).isEntered(); }
void JSC__VM__setExecutionForbidden(JSC__VM* arg0, bool arg1) { (*arg0).setExecutionForbidden(); }
-bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowScope* arg2,
- const unsigned char* arg3, size_t arg4)
+void JSC__VM__throwError(JSC__VM* vm_, JSC__JSGlobalObject* arg1, JSC__JSValue value)
{
- auto scope = arg2;
- auto global = arg1;
- const String& message = WTF::String(arg3, arg4);
- return JSC::throwException(global, (*scope), createError(global, message));
+ JSC::VM& vm = *reinterpret_cast<JSC::VM*>(vm_);
+
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ JSC::JSObject* error = JSC::JSValue::decode(value).getObject();
+ JSC::Exception* exception = JSC::Exception::create(vm, error);
+ scope.throwException(arg1, exception);
}
#pragma mark - JSC::ThrowScope
@@ -2662,27 +2580,6 @@ bJSC__CatchScope JSC__CatchScope__declare(JSC__VM* arg0, unsigned char* arg1, un
}
JSC__Exception* JSC__CatchScope__exception(JSC__CatchScope* arg0) { return arg0->exception(); }
-#pragma mark - JSC::CallFrame
-
-JSC__JSValue JSC__CallFrame__argument(const JSC__CallFrame* arg0, uint16_t arg1)
-{
- return JSC::JSValue::encode(arg0->argument(arg1));
-};
-size_t JSC__CallFrame__argumentsCount(const JSC__CallFrame* arg0) { return arg0->argumentCount(); }
-JSC__JSObject* JSC__CallFrame__jsCallee(const JSC__CallFrame* arg0) { return arg0->jsCallee(); }
-JSC__JSValue JSC__CallFrame__newTarget(const JSC__CallFrame* arg0)
-{
- return JSC::JSValue::encode(arg0->newTarget());
-};
-JSC__JSValue JSC__CallFrame__thisValue(const JSC__CallFrame* arg0)
-{
- return JSC::JSValue::encode(arg0->thisValue());
-}
-JSC__JSValue JSC__CallFrame__uncheckedArgument(const JSC__CallFrame* arg0, uint16_t arg1)
-{
- return JSC::JSValue::encode(arg0->uncheckedArgument(arg1));
-}
-
#pragma mark - JSC::Identifier
void JSC__Identifier__deinit(const JSC__Identifier* arg0)
@@ -2997,4 +2894,10 @@ JSC__JSValue JSC__JSPromise__resolvedPromiseValue(JSC__JSGlobalObject* arg0,
return JSC::JSValue::encode(
JSC::JSPromise::resolvedPromise(arg0, JSC::JSValue::decode(JSValue1)));
}
+}
+
+JSC__JSValue JSC__JSValue__createUninitializedUint8Array(JSC__JSGlobalObject* arg0, size_t arg1)
+{
+ JSC::JSValue value = JSC::JSUint8Array::createUninitialized(arg0, arg0->m_typedArrayUint8.get(arg0), arg1);
+ return JSC::JSValue::encode(value);
} \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig
index 96d3ab17c..f20fa2253 100644
--- a/src/javascript/jsc/bindings/bindings.zig
+++ b/src/javascript/jsc/bindings/bindings.zig
@@ -1,4 +1,3 @@
-pub const Shimmer = @import("./shimmer.zig").Shimmer;
const std = @import("std");
const bun = @import("../../../global.zig");
const string = bun.string;
@@ -15,6 +14,7 @@ const ZigStackTrace = Exports.ZigStackTrace;
const is_bindgen: bool = std.meta.globalOption("bindgen", bool) orelse false;
const ArrayBuffer = @import("../base.zig").ArrayBuffer;
const JSC = @import("../../../jsc.zig");
+const Shimmer = JSC.Shimmer;
pub const JSObject = extern struct {
pub const shim = Shimmer("JSC", "JSObject", @This());
bytes: shim.Bytes,
@@ -809,6 +809,10 @@ pub const JSString = extern struct {
return shim.cppFn("value", .{ this, globalObject });
}
+ pub fn iterator(this: *JSString, globalObject: *JSGlobalObject, iter: *anyopaque) void {
+ return shim.cppFn("iterator", .{ this, globalObject, iter });
+ }
+
pub fn length(this: *const JSString) usize {
return shim.cppFn("length", .{
this,
@@ -833,7 +837,20 @@ pub const JSString = extern struct {
});
}
- pub const Extern = [_][]const u8{ "toObject", "eql", "value", "length", "is8Bit", "createFromOwnedString", "createFromString" };
+ pub const JStringIteratorAppend8Callback = fn (*Iterator, [*]const u8, u32) callconv(.C) void;
+ pub const JStringIteratorAppend16Callback = fn (*Iterator, [*]const u16, u32) callconv(.C) void;
+ pub const JStringIteratorWrite8Callback = fn (*Iterator, [*]const u8, u32, u32) callconv(.C) void;
+ pub const JStringIteratorWrite16Callback = fn (*Iterator, [*]const u16, u32, u32) callconv(.C) void;
+ pub const Iterator = extern struct {
+ data: ?*anyopaque,
+ stop: u8,
+ append8: ?JStringIteratorAppend8Callback,
+ append16: ?JStringIteratorAppend16Callback,
+ write8: ?JStringIteratorWrite8Callback,
+ write16: ?JStringIteratorWrite16Callback,
+ };
+
+ pub const Extern = [_][]const u8{ "iterator", "toObject", "eql", "value", "length", "is8Bit", "createFromOwnedString", "createFromString" };
};
pub const JSPromiseRejectionOperation = enum(u32) {
@@ -1060,6 +1077,13 @@ pub const JSModuleRecord = extern struct {
};
};
+pub fn Async(comptime ReturnType: type) type {
+ return struct {
+ promise: *?*JSPromise,
+ continuation: anyframe->ReturnType,
+ };
+}
+
pub const JSPromise = extern struct {
pub const shim = Shimmer("JSC", "JSPromise", @This());
bytes: shim.Bytes,
@@ -1408,8 +1432,6 @@ pub const JSFunction = extern struct {
pub const name = "JSC::JSFunction";
pub const namespace = "JSC";
- pub const NativeFunctionCallback = fn (ctx: ?*anyopaque, global: [*c]JSGlobalObject, call_frame: [*c]CallFrame) callconv(.C) JSValue;
-
// pub fn createFromSourceCode(
// global: *JSGlobalObject,
// function_name: ?[*]const u8,
@@ -1431,15 +1453,7 @@ pub const JSFunction = extern struct {
// exception,
// });
// }
- pub fn createFromNative(
- global: *JSGlobalObject,
- argument_count: u16,
- name_: ?*const String,
- ctx: ?*anyopaque,
- func: NativeFunctionCallback,
- ) *JSFunction {
- return cppFn("createFromNative", .{ global, argument_count, name_, ctx, func });
- }
+
pub fn getName(this: *JSFunction, vm: *VM) String {
return cppFn("getName", .{ this, vm });
}
@@ -1453,152 +1467,13 @@ pub const JSFunction = extern struct {
// return cppFn("toString", .{ this, globalThis });
// }
- pub fn callWithArgumentsAndThis(
- function: JSValue,
- thisValue: JSValue,
- globalThis: *JSGlobalObject,
- arguments_ptr: [*]JSValue,
- arguments_len: usize,
- exception: ReturnableException,
- error_message: [*c]const u8,
- ) JSValue {
- return cppFn("callWithArgumentsAndThis", .{
- function,
- thisValue,
- globalThis,
- arguments_ptr,
- arguments_len,
- exception,
- error_message,
- });
- }
-
- pub fn callWithArguments(
- function: JSValue,
- globalThis: *JSGlobalObject,
- arguments_ptr: [*]JSValue,
- arguments_len: usize,
- exception: ReturnableException,
- error_message: [*c]const u8,
- ) JSValue {
- return cppFn("callWithArguments", .{
- function,
- globalThis,
- arguments_ptr,
- arguments_len,
- exception,
- error_message,
- });
- }
-
- pub fn callWithThis(
- function: JSValue,
- globalThis: *JSGlobalObject,
- thisValue: JSValue,
- exception: ReturnableException,
- error_message: [*c]const u8,
- ) JSValue {
- return cppFn("callWithThis", .{
- function,
- globalThis,
- thisValue,
- exception,
- error_message,
- });
- }
-
- pub fn callWithoutAnyArgumentsOrThis(
- function: JSValue,
- globalThis: *JSGlobalObject,
- exception: ReturnableException,
- error_message: [*c]const u8,
- ) JSValue {
- return cppFn("callWithoutAnyArgumentsOrThis", .{ function, globalThis, exception, error_message });
- }
-
- pub fn constructWithArgumentsAndNewTarget(
- function: JSValue,
- newTarget: JSValue,
- globalThis: *JSGlobalObject,
- arguments_ptr: [*]JSValue,
- arguments_len: usize,
- exception: ReturnableException,
- error_message: [*c]const u8,
- ) JSValue {
- return cppFn("constructWithArgumentsAndNewTarget", .{
- function,
- newTarget,
- globalThis,
- arguments_ptr,
- arguments_len,
- exception,
- error_message,
- });
- }
-
- pub fn constructWithArguments(
- function: JSValue,
- globalThis: *JSGlobalObject,
- arguments_ptr: [*]JSValue,
- arguments_len: usize,
- exception: ReturnableException,
- error_message: [*c]const u8,
- ) JSValue {
- return cppFn("constructWithArguments", .{
- function,
- globalThis,
- arguments_ptr,
- arguments_len,
- exception,
- error_message,
- });
- }
-
- pub fn constructWithNewTarget(
- function: JSValue,
- globalThis: *JSGlobalObject,
- newTarget: JSValue,
- exception: ReturnableException,
- error_message: [*c]const u8,
- ) JSValue {
- return cppFn("constructWithNewTarget", .{
- function,
- globalThis,
- newTarget,
- exception,
- error_message,
- });
- }
-
- pub fn constructWithoutAnyArgumentsOrNewTarget(
- function: JSValue,
- globalThis: *JSGlobalObject,
- exception: ReturnableException,
- error_message: [*c]const u8,
- ) JSValue {
- return cppFn("constructWithoutAnyArgumentsOrNewTarget", .{
- function,
- globalThis,
- exception,
- error_message,
- });
- }
-
pub const Extern = [_][]const u8{
"fromString",
// "createFromSourceCode",
- "createFromNative",
+
"getName",
"displayName",
"calculatedDisplayName",
- "callWithArgumentsAndThis",
- "callWithArguments",
- "callWithThis",
- "callWithoutAnyArgumentsOrThis",
- "constructWithArgumentsAndNewTarget",
- "constructWithArguments",
- "constructWithNewTarget",
- "constructWithoutAnyArgumentsOrNewTarget",
};
};
@@ -1631,6 +1506,10 @@ pub const JSGlobalObject = extern struct {
}
pub const ctx = ref;
+ pub inline fn ptr(this: *JSGlobalObject) *JSGlobalObject {
+ return this;
+ }
+
pub fn objectPrototype(this: *JSGlobalObject) *ObjectPrototype {
return cppFn("objectPrototype", .{this});
}
@@ -1728,7 +1607,27 @@ pub const JSGlobalObject = extern struct {
return cppFn("deleteModuleRegistryEntry", .{ this, name_ });
}
+ pub fn bunVM_(this: *JSGlobalObject) *anyopaque {
+ return cppFn("bunVM", .{this});
+ }
+
+ pub fn bunVM(this: *JSGlobalObject) *JSC.VirtualMachine {
+ if (comptime bun.Environment.allow_assert) {
+ std.debug.assert(this.bunVM_() == @ptrCast(*anyopaque, JSC.VirtualMachine.vm));
+ }
+
+ return @ptrCast(*JSC.VirtualMachine, @alignCast(std.meta.alignment(JSC.VirtualMachine), this.bunVM_()));
+ }
+
+ extern fn ZigGlobalObject__readableStreamToArrayBuffer(*JSGlobalObject, JSValue) JSValue;
+
+ pub fn readableStreamToArrayBuffer(this: *JSGlobalObject, value: JSValue) JSValue {
+ if (comptime is_bindgen) unreachable;
+ return ZigGlobalObject__readableStreamToArrayBuffer(this, value);
+ }
+
pub const Extern = [_][]const u8{
+ "bunVM",
"putCachedObject",
"getCachedObject",
"createAggregateError",
@@ -2012,19 +1911,27 @@ pub const String = extern struct {
};
};
-pub const JSValue = enum(u64) {
+pub const JSValue = enum(i64) {
@"undefined" = 0xa,
_,
pub const shim = Shimmer("JSC", "JSValue", @This());
pub const is_pointer = false;
- pub const Type = u64;
+ pub const Type = i64;
const cppFn = shim.cppFn;
+ pub const Encoded = extern union {
+ asInt64: i64,
+ ptr: *JSCell,
+ asBits: extern struct { payload: i32, tag: i32 },
+ asPtr: *anyopaque,
+ asDouble: f64,
+ };
+
pub const include = "JavaScriptCore/JSValue.h";
pub const name = "JSC::JSValue";
pub const namespace = "JSC";
- pub const zero = @intToEnum(JSValue, @as(u64, 0));
+ pub const zero = @intToEnum(JSValue, @as(i64, 0));
pub const JSType = enum(u8) {
// The Cell value must come before any JS that is a JSCell.
Cell,
@@ -2289,6 +2196,20 @@ pub const JSValue = enum(u64) {
return JSC.C.JSValueIsInstanceOfConstructor(global.ref(), this.asObjectRef(), constructor.asObjectRef(), null);
}
+ pub fn call(this: JSValue, globalThis: *JSGlobalObject, args: []const JSC.JSValue) JSC.JSValue {
+ return callWithThis(this, globalThis, JSC.JSValue.zero, args);
+ }
+
+ pub fn callWithThis(this: JSValue, globalThis: *JSGlobalObject, thisValue: JSC.JSValue, args: []const JSC.JSValue) JSC.JSValue {
+ return JSC.C.JSObjectCallAsFunctionReturnValue(
+ globalThis.ref(),
+ this.asObjectRef(),
+ thisValue.asObjectRef(),
+ args.len,
+ @ptrCast([*]const JSC.C.JSValueRef, args.ptr),
+ );
+ }
+
pub fn jsType(
this: JSValue,
) JSType {
@@ -2345,6 +2266,16 @@ pub const JSValue = enum(u64) {
return JSC.GetJSPrivateData(ZigType, value.asObjectRef());
}
+ pub fn protect(this: JSValue) void {
+ if (this.isEmptyOrUndefinedOrNull() or this.isNumber()) return;
+ JSC.C.JSValueProtect(JSC.VirtualMachine.vm.global, this.asObjectRef());
+ }
+
+ pub fn unprotect(this: JSValue) void {
+ if (this.isEmptyOrUndefinedOrNull() or this.isNumber()) return;
+ JSC.C.JSValueUnprotect(JSC.VirtualMachine.vm.global, this.asObjectRef());
+ }
+
/// Create an object with exactly two properties
pub fn createObject2(global: *JSGlobalObject, key1: *const ZigString, key2: *const ZigString, value1: JSValue, value2: JSValue) JSValue {
return cppFn("createObject2", .{ global, key1, key2, value1, value2 });
@@ -2369,6 +2300,11 @@ pub const JSValue = enum(u64) {
}
}
+ pub fn createUninitializedUint8Array(globalObject: *JSGlobalObject, len: usize) JSValue {
+ if (comptime JSC.is_bindgen) unreachable;
+ return shim.cppFn("createUninitializedUint8Array", .{ globalObject, len });
+ }
+
pub fn createBufferWithCtx(globalObject: *JSGlobalObject, slice: []u8, ptr: ?*anyopaque, func: JSC.C.JSTypedArrayBytesDeallocator) JSValue {
if (comptime JSC.is_bindgen) unreachable;
@setRuntimeSafety(false);
@@ -2527,15 +2463,23 @@ pub const JSValue = enum(u64) {
pub fn isUInt32AsAnyInt(this: JSValue) bool {
return cppFn("isUInt32AsAnyInt", .{this});
}
+
+ pub fn asEncoded(this: JSValue) Encoded {
+ return @bitCast(Encoded, this);
+ }
+
pub fn isInt32(this: JSValue) bool {
- return cppFn("isInt32", .{this});
+ return (@bitCast(c_ulonglong, @enumToInt(this)) & @as(c_ulonglong, 18446181123756130304)) == @as(c_ulonglong, 18446181123756130304);
}
+
pub fn isInt32AsAnyInt(this: JSValue) bool {
return cppFn("isInt32AsAnyInt", .{this});
}
+
pub fn isNumber(this: JSValue) bool {
- return cppFn("isNumber", .{this});
+ return (@bitCast(c_ulonglong, @enumToInt(this)) & @as(c_ulonglong, 18446181123756130304)) != 0;
}
+
pub fn isError(this: JSValue) bool {
return cppFn("isError", .{this});
}
@@ -2707,7 +2651,7 @@ pub const JSValue = enum(u64) {
const Thenable = fn (
global: [*c]JSGlobalObject,
ctx: ?*anyopaque,
- arguments_ptr: JSC.JSValue,
+ arguments_ptr: [*c]*anyopaque,
arguments_len: usize,
) callconv(.C) void;
pub fn _then(this: JSValue, global: *JSGlobalObject, ctx: ?*anyopaque, resolve: Thenable, reject: Thenable) void {
@@ -2718,23 +2662,21 @@ pub const JSValue = enum(u64) {
fn resolve(
globalThis: [*c]JSGlobalObject,
ptr: ?*anyopaque,
- arguments_ptr_: JSC.JSValue,
+ arguments_ptr: [*c]*anyopaque,
arguments_len: usize,
) callconv(.C) void {
@setRuntimeSafety(false);
- var arguments_ptr = @intToPtr([*]const JSC.JSValue, @enumToInt(arguments_ptr_));
- onResolve(bun.cast(*Then, ptr.?), globalThis, arguments_ptr[0..arguments_len]);
+ onResolve(bun.cast(*Then, ptr.?), globalThis, @ptrCast([*]const JSC.JSValue, arguments_ptr)[0..arguments_len]);
}
pub fn reject(
globalThis: [*c]JSGlobalObject,
ptr: ?*anyopaque,
- arguments_ptr_: JSC.JSValue,
+ arguments_ptr: [*c]*anyopaque,
arguments_len: usize,
) callconv(.C) void {
@setRuntimeSafety(false);
- var arguments_ptr = @intToPtr([*]const JSC.JSValue, @enumToInt(arguments_ptr_));
- onReject(bun.cast(*Then, ptr.?), globalThis, arguments_ptr[0..arguments_len]);
+ onReject(bun.cast(*Then, ptr.?), globalThis, @ptrCast([*]const JSC.JSValue, arguments_ptr)[0..arguments_len]);
}
};
@@ -2815,23 +2757,71 @@ pub const JSValue = enum(u64) {
}
pub fn asNumber(this: JSValue) f64 {
+ if (this.isInt32()) {
+ return @intToFloat(f64, this.toInt32());
+ }
+
+ if (isNumber(this)) {
+ return asDouble(this);
+ }
+
+ if (this.isUndefinedOrNull()) {
+ return 0.0;
+ } else if (this.isBoolean()) {
+ return if (asBoolean(this)) 1.0 else 0.0;
+ }
+
return cppFn("asNumber", .{
this,
});
}
+ pub fn asDouble(this: JSValue) f64 {
+ return @bitCast(f64, @enumToInt(this) - comptime (@as(c_longlong, 1) << @intCast(@import("std").math.Log2Int(c_longlong), 49)));
+ }
+
+ pub fn asPtr(this: JSValue, comptime Pointer: type) *Pointer {
+ return @intToPtr(*Pointer, @bitCast(usize, this.asDouble()));
+ }
+
+ pub fn fromPtrAddress(addr: anytype) JSValue {
+ return jsNumber(@bitCast(f64, @as(usize, addr)));
+ }
+
+ pub fn fromPtr(addr: anytype) JSValue {
+ return fromPtrAddress(@ptrToInt(addr));
+ }
+
pub fn toBoolean(this: JSValue) bool {
- return cppFn("toBoolean", .{
- this,
- });
+ if (isUndefinedOrNull(this)) {
+ return false;
+ }
+
+ return asBoolean(this);
+ }
+
+ pub fn asBoolean(this: JSValue) bool {
+ return @enumToInt(this) == @bitCast(c_longlong, @as(c_longlong, (@as(c_int, 2) | @as(c_int, 4)) | @as(c_int, 1)));
}
pub fn toInt32(this: JSValue) i32 {
+ if (this.isInt32()) {
+ return asInt32(this);
+ }
+
+ if (this.isNumber()) {
+ return @truncate(i32, @floatToInt(i64, asDouble(this)));
+ }
+
return cppFn("toInt32", .{
this,
});
}
+ pub fn asInt32(this: JSValue) i32 {
+ return @bitCast(i32, @truncate(c_int, @enumToInt(this)));
+ }
+
pub inline fn toU16(this: JSValue) u16 {
return @intCast(u16, this.toInt32());
}
@@ -2875,15 +2865,15 @@ pub const JSValue = enum(u64) {
}
pub inline fn asRef(this: JSValue) C_API.JSValueRef {
- return @intToPtr(C_API.JSValueRef, @intCast(usize, @enumToInt(this)));
+ return @intToPtr(C_API.JSValueRef, @bitCast(usize, @enumToInt(this)));
}
pub inline fn c(this: C_API.JSValueRef) JSValue {
- return @intToEnum(JSValue, @ptrToInt(this));
+ return @intToEnum(JSValue, @bitCast(JSValue.Type, @ptrToInt(this)));
}
pub inline fn fromRef(this: C_API.JSValueRef) JSValue {
- return @intToEnum(JSValue, @ptrToInt(this));
+ return @intToEnum(JSValue, @bitCast(JSValue.Type, @ptrToInt(this)));
}
pub inline fn asObjectRef(this: JSValue) C_API.JSObjectRef {
@@ -2894,6 +2884,7 @@ pub const JSValue = enum(u64) {
/// It knows not to free it
/// This mimicks the implementation in JavaScriptCore's C++
pub inline fn ensureStillAlive(this: JSValue) void {
+ if (this.isEmpty() or this.isNumber() or this.isBoolean() or this.isUndefinedOrNull()) return;
std.mem.doNotOptimizeAway(@ptrCast(C_API.JSObjectRef, this.asVoid()));
}
@@ -2903,13 +2894,14 @@ pub const JSValue = enum(u64) {
@panic("JSValue is null");
}
}
- return @intToPtr(*anyopaque, @enumToInt(this));
+ return @intToPtr(*anyopaque, @bitCast(usize, @enumToInt(this)));
}
- pub const Extern = [_][]const u8{ "fromInt64NoTruncate", "fromUInt64NoTruncate", "toUInt64NoTruncate", "asPromise", "toInt64", "_then", "put", "makeWithNameAndPrototype", "parseJSON", "symbolKeyFor", "symbolFor", "getSymbolDescription", "createInternalPromise", "asInternalPromise", "asArrayBuffer_", "getReadableStreamState", "getWritableStreamState", "fromEntries", "createTypeError", "createRangeError", "createObject2", "getIfPropertyExistsImpl", "jsType", "jsonStringify", "kind_", "isTerminationException", "isSameValue", "getLengthOfArray", "toZigString", "createStringArray", "createEmptyObject", "putRecord", "asPromise", "isClass", "getNameProperty", "getClassName", "getErrorsProperty", "toInt32", "toBoolean", "isInt32", "isIterable", "forEach", "isAggregateError", "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "getIfExists", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell", "isCallable" };
+ pub const Extern = [_][]const u8{ "createUninitializedUint8Array", "fromInt64NoTruncate", "fromUInt64NoTruncate", "toUInt64NoTruncate", "asPromise", "toInt64", "_then", "put", "makeWithNameAndPrototype", "parseJSON", "symbolKeyFor", "symbolFor", "getSymbolDescription", "createInternalPromise", "asInternalPromise", "asArrayBuffer_", "getReadableStreamState", "getWritableStreamState", "fromEntries", "createTypeError", "createRangeError", "createObject2", "getIfPropertyExistsImpl", "jsType", "jsonStringify", "kind_", "isTerminationException", "isSameValue", "getLengthOfArray", "toZigString", "createStringArray", "createEmptyObject", "putRecord", "asPromise", "isClass", "getNameProperty", "getClassName", "getErrorsProperty", "toInt32", "toBoolean", "isInt32", "isIterable", "forEach", "isAggregateError", "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "getIfExists", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell", "isCallable" };
};
extern "c" fn Microtask__run(*Microtask, *JSGlobalObject) void;
+extern "c" fn Microtask__run_default(*MicrotaskForDefaultGlobalObject, *JSGlobalObject) void;
pub const Microtask = opaque {
pub const name = "Zig::JSMicrotaskCallback";
@@ -2924,6 +2916,16 @@ pub const Microtask = opaque {
}
};
+pub const MicrotaskForDefaultGlobalObject = opaque {
+ pub fn run(this: *MicrotaskForDefaultGlobalObject, global_object: *JSGlobalObject) void {
+ if (comptime is_bindgen) {
+ return;
+ }
+
+ return Microtask__run_default(this, global_object);
+ }
+};
+
pub const PropertyName = extern struct {
pub const shim = Shimmer("JSC", "PropertyName", @This());
bytes: shim.Bytes,
@@ -3103,18 +3105,18 @@ pub const VM = extern struct {
});
}
- pub fn throwError(vm: *VM, global_object: *JSGlobalObject, scope: *ThrowScope, message: [*]const u8, len: usize) bool {
+ pub fn throwError(vm: *VM, global_object: *JSGlobalObject, value: JSValue) void {
return cppFn("throwError", .{
vm,
-
global_object,
- scope,
-
- message,
- len,
+ value,
});
}
+ pub fn releaseWeakRefs(vm: *VM) void {
+ return cppFn("releaseWeakRefs", .{vm});
+ }
+
pub fn drainMicrotasks(
vm: *VM,
) void {
@@ -3130,7 +3132,7 @@ pub const VM = extern struct {
vm,
});
}
- pub const Extern = [_][]const u8{ "doWork", "deferGC", "holdAPILock", "runGC", "generateHeapSnapshot", "isJITEnabled", "deleteAllCode", "create", "deinit", "setExecutionForbidden", "executionForbidden", "isEntered", "throwError", "drainMicrotasks", "whenIdle", "shrinkFootprint", "setExecutionTimeLimit", "clearExecutionTimeLimit" };
+ pub const Extern = [_][]const u8{ "releaseWeakRefs", "throwError", "doWork", "deferGC", "holdAPILock", "runGC", "generateHeapSnapshot", "isJITEnabled", "deleteAllCode", "create", "deinit", "setExecutionForbidden", "executionForbidden", "isEntered", "throwError", "drainMicrotasks", "whenIdle", "shrinkFootprint", "setExecutionTimeLimit", "clearExecutionTimeLimit" };
};
pub const ThrowScope = extern struct {
@@ -3206,59 +3208,39 @@ pub const CatchScope = extern struct {
};
};
-pub const CallFrame = extern struct {
- pub const shim = Shimmer("JSC", "CallFrame", @This());
- bytes: shim.Bytes,
- const cppFn = shim.cppFn;
-
- pub const include = "JavaScriptCore/CallFrame.h";
- pub const name = "JSC::CallFrame";
- pub const namespace = "JSC";
+pub const CallFrame = opaque {
+ /// The value is generated in `make sizegen`
+ /// The value is 6.
+ /// On ARM64_32, the value is something else but it really doesn't matter for our case
+ /// However, I don't want this to subtly break amidst future upgrades to JavaScriptCore
+ const arguments_offset = 6;
+ const thisValue_offset = arguments_offset - 1;
+ const argumentsCount_offset = thisValue_offset - 1;
+ const alignment = std.meta.alignment([]const JSC.JSValue);
- pub inline fn argumentsCount(call_frame: *const CallFrame) usize {
- return cppFn("argumentsCount", .{
- call_frame,
- });
- }
- pub inline fn uncheckedArgument(call_frame: *const CallFrame, i: u16) JSValue {
- return cppFn("uncheckedArgument", .{ call_frame, i });
- }
- pub inline fn argument(call_frame: *const CallFrame, i: u16) JSValue {
- return cppFn("argument", .{
- call_frame,
- i,
- });
+ pub fn argumentsPtr(self: *const CallFrame) [*]const JSC.JSValue {
+ return @ptrCast([*]const JSC.JSValue, @alignCast(alignment, self)) + arguments_offset;
}
- pub inline fn thisValue(call_frame: *const CallFrame) ?JSValue {
- return cppFn("thisValue", .{
- call_frame,
- });
+
+ pub fn callee(self: *const CallFrame) JSC.JSValue {
+ return (@ptrCast([*]const JSC.JSValue, @alignCast(alignment, self)) + arguments_offset - 1)[0];
}
- pub inline fn setThisValue(call_frame: *CallFrame, new_this: JSValue) ?JSValue {
- return cppFn("setThisValue", .{
- call_frame,
- new_this,
- });
+ pub fn arguments(self: *const CallFrame) []const JSC.JSValue {
+ return self.argumentsPtr()[0..self.argumentsCount()];
}
- pub inline fn newTarget(call_frame: *const CallFrame) ?JSValue {
- return cppFn("newTarget", .{
- call_frame,
- });
+
+ pub fn argument(self: *const CallFrame, comptime i: comptime_int) JSC.JSValue {
+ return self.argumentsPtr()[i];
}
- pub inline fn setNewTarget(call_frame: *CallFrame, target: JSValue) ?JSValue {
- return cppFn("setNewTarget", .{
- call_frame,
- target,
- });
+ pub fn this(self: *const CallFrame) JSC.JSValue {
+ return (@ptrCast([*]const JSC.JSValue, @alignCast(alignment, self)) + thisValue_offset)[0];
}
- pub inline fn jsCallee(call_frame: *const CallFrame) *JSObject {
- return cppFn("jsCallee", .{
- call_frame,
- });
+
+ pub fn argumentsCount(self: *const CallFrame) usize {
+ return (@ptrCast([*]const usize, @alignCast(alignment, self)) + argumentsCount_offset)[0];
}
- pub const Extern = [_][]const u8{ "argumentsCount", "uncheckedArgument", "argument", "thisValue", "newTarget", "jsCallee", "setNewTarget", "setThisValue" };
};
// pub const WellKnownSymbols = extern struct {
@@ -3478,6 +3460,47 @@ pub const ExternalStringImpl = extern struct {
};
};
+pub const JSArray = struct {
+ pub fn from(globalThis: *JSGlobalObject, arguments: []const JSC.JSValue) JSValue {
+ return JSC.JSValue.c(JSC.C.JSObjectMakeArray(globalThis.ref(), arguments.len, @ptrCast([*]const JSC.C.JSObjectRef, arguments.ptr), null));
+ }
+};
+
+const private = struct {
+ pub extern fn Bun__CreateFFIFunction(
+ globalObject: *JSGlobalObject,
+ symbolName: ?*const ZigString,
+ argCount: u32,
+ functionPointer: *const anyopaque,
+ ) *anyopaque;
+
+ pub extern fn Bun__CreateFFIFunctionValue(
+ globalObject: *JSGlobalObject,
+ symbolName: ?*const ZigString,
+ argCount: u32,
+ functionPointer: *const anyopaque,
+ ) JSValue;
+};
+pub fn NewFunctionPtr(
+ globalObject: *JSGlobalObject,
+ symbolName: ?*const ZigString,
+ argCount: u32,
+ functionPointer: anytype,
+) *anyopaque {
+ if (comptime JSC.is_bindgen) unreachable;
+ return private.Bun__CreateFFIFunction(globalObject, symbolName, argCount, @ptrCast(*const anyopaque, functionPointer));
+}
+
+pub fn NewFunction(
+ globalObject: *JSGlobalObject,
+ symbolName: ?*const ZigString,
+ argCount: u32,
+ functionPointer: anytype,
+) JSValue {
+ if (comptime JSC.is_bindgen) unreachable;
+ return private.Bun__CreateFFIFunctionValue(globalObject, symbolName, argCount, @ptrCast(*const anyopaque, functionPointer));
+}
+
pub const ObjectPrototype = _JSCellStub("ObjectPrototype");
pub const FunctionPrototype = _JSCellStub("FunctionPrototype");
pub const ArrayPrototype = _JSCellStub("ArrayPrototype");
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..0b47d730c
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableByteStreamController.js
@@ -0,0 +1,117 @@
+/*
+ * 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");
+
+
+ var request = @getByIdDirectPrivate(this, "byobRequest");
+ if (request === @undefined) {
+ var pending = @getByIdDirectPrivate(this, "pendingPullIntos");
+ const firstDescriptor = pending.peek();
+ if (firstDescriptor) {
+ 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..d9d70ae28
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableByteStreamInternals.js
@@ -0,0 +1,705 @@
+/*
+ * 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", @createFIFO());
+
+ 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");
+ var first = pendingPullIntos.peek();
+ if (first)
+ first.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 first = @getByIdDirectPrivate(controller, "pendingPullIntos")?.peek();
+ if (first) {
+ if (first.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);
+ var existing = @getByIdDirectPrivate(controller, "pendingPullIntos");
+ if (existing !== @undefined) {
+ existing.clear();
+ } else {
+ @putByIdDirectPrivate(controller, "pendingPullIntos", @createFIFO());
+ }
+}
+
+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) {
+ 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 = @createUninitializedArrayBuffer(@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'
+ };
+ @getByIdDirectPrivate(controller, "pendingPullIntos").push(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;
+ const reader = @getByIdDirectPrivate(stream, "reader");
+
+ if (reader && (@getByIdDirectPrivate(reader, "readRequests")?.isNotEmpty() || !!@getByIdDirectPrivate(reader, "bunNativePtr")))
+ return true;
+ if (@readableStreamHasBYOBReader(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readIntoRequests")?.isNotEmpty())
+ 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 readableStreamReaderKind(reader) {
+ "use strict";
+
+
+ if (!!@getByIdDirectPrivate(reader, "readRequests"))
+ return @getByIdDirectPrivate(reader, "bunNativePtr") ? 3 : 1;
+
+ if (!!@getByIdDirectPrivate(reader, "readIntoRequests"))
+ return 2;
+
+ return 0;
+}
+function readableByteStreamControllerEnqueue(controller, chunk)
+{
+ "use strict";
+
+ const stream = @getByIdDirectPrivate(controller, "controlledReadableStream");
+ @assert(!@getByIdDirectPrivate(controller, "closeRequested"));
+ @assert(@getByIdDirectPrivate(stream, "state") === @streamReadable);
+
+
+ switch (@getByIdDirectPrivate(stream, "reader") ? @readableStreamReaderKind(@getByIdDirectPrivate(stream, "reader")) : 0) {
+ /* default reader */
+ case 1: {
+ if (!@getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests")?.isNotEmpty())
+ @readableByteStreamControllerEnqueueChunk(controller, @transferBufferToCurrentRealm(chunk.buffer), chunk.byteOffset, chunk.byteLength);
+ else {
+ @assert(!@getByIdDirectPrivate(controller, "queue").content.size());
+ const transferredView = chunk.constructor === @Uint8Array ? chunk : new @Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);
+ @readableStreamFulfillReadRequest(stream, transferredView, false);
+ }
+ break;
+ }
+
+ /* BYOB */
+ case 2: {
+ @readableByteStreamControllerEnqueueChunk(controller, @transferBufferToCurrentRealm(chunk.buffer), chunk.byteOffset, chunk.byteLength);
+ @readableByteStreamControllerProcessPullDescriptors(controller);
+ break;
+ }
+
+ /* NativeReader */
+ case 3: {
+ // reader.@enqueueNative(@getByIdDirectPrivate(reader, "bunNativePtr"), chunk);
+
+ break;
+ }
+
+ default: {
+ @assert(!@isReadableStreamLocked(stream));
+ @readableByteStreamControllerEnqueueChunk(controller, @transferBufferToCurrentRealm(chunk.buffer), chunk.byteOffset, chunk.byteLength);
+ break;
+ }
+ }
+}
+
+// Spec name: readableByteStreamControllerEnqueueChunkToQueue.
+function readableByteStreamControllerEnqueueChunk(controller, buffer, byteOffset, byteLength)
+{
+ "use strict";
+
+ @getByIdDirectPrivate(controller, "queue").content.push({
+ buffer: buffer,
+ byteOffset: byteOffset,
+ byteLength: byteLength
+ });
+ @getByIdDirectPrivate(controller, "queue").size += byteLength;
+}
+
+function readableByteStreamControllerRespondWithNewView(controller, view)
+{
+ "use strict";
+
+ @assert(@getByIdDirectPrivate(controller, "pendingPullIntos").isNotEmpty());
+
+ let firstDescriptor = @getByIdDirectPrivate(controller, "pendingPullIntos").peek();
+
+ 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").isNotEmpty());
+
+ @readableByteStreamControllerRespondInternal(controller, bytesWritten);
+}
+
+function readableByteStreamControllerRespondInternal(controller, bytesWritten)
+{
+ "use strict";
+
+ let firstDescriptor = @getByIdDirectPrivate(controller, "pendingPullIntos").peek();
+ 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").isEmpty() || @getByIdDirectPrivate(controller, "pendingPullIntos").peek() === 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")?.isNotEmpty()) {
+ 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").isNotEmpty()) {
+ if (@getByIdDirectPrivate(controller, "queue").size === 0)
+ return;
+ let pullIntoDescriptor = @getByIdDirectPrivate(controller, "pendingPullIntos").peek();
+ 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.peek();
+ 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").isEmpty() || @getByIdDirectPrivate(controller, "pendingPullIntos").peek() === 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'
+ };
+
+ var pending = @getByIdDirectPrivate(controller, "pendingPullIntos");
+ if (pending?.isNotEmpty()) {
+ pullIntoDescriptor.buffer = @transferBufferToCurrentRealm(pullIntoDescriptor.buffer);
+ pending.push(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);
+ @getByIdDirectPrivate(controller, "pendingPullIntos").push(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();
+ @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readIntoRequests").push(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..9695b0d82
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableStream.js
@@ -0,0 +1,540 @@
+/*
+ * 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;
+}
+
+@globalPrivate
+function readableStreamToArray(stream) {
+ "use strict";
+
+ if (!stream || @getByIdDirectPrivate(stream, "state") === @streamClosed) {
+ return null;
+ }
+ var reader = stream.getReader();
+
+ var manyResult = reader.readMany();
+
+ async function processManyResult(result) {
+
+ if (result.done) {
+ return null;
+ }
+
+ var chunks = result.value || [];
+
+ while (true) {
+ var thisResult = await reader.read();
+
+ if (thisResult.done) {
+ return chunks;
+ }
+
+ chunks.push(thisResult.value);
+ }
+
+ return chunks;
+ };
+
+
+ if (manyResult && @isPromise(manyResult)) {
+ return manyResult.@then(processManyResult);
+ }
+
+ if (manyResult && manyResult.done) {
+ return null;
+ }
+
+ return processManyResult(manyResult);
+}
+
+@globalPrivate
+function readableStreamToArrayPublic(stream) {
+ "use strict";
+
+ if (@getByIdDirectPrivate(stream, "state") === @streamClosed) {
+ return [];
+ }
+ var reader = stream.getReader();
+
+ var manyResult = reader.readMany();
+
+ var processManyResult = (0, (async function(result) {
+ if (result.done) {
+ return [];
+ }
+
+ var chunks = result.value || [];
+
+ while (true) {
+ var thisResult = await reader.read();
+ if (thisResult.done) {
+ return chunks;
+ }
+
+ chunks.push(thisResult.value);
+ }
+
+ return chunks;
+ }));
+
+
+ if (manyResult && @isPromise(manyResult)) {
+ return manyResult.then(processManyResult);
+ }
+
+ if (manyResult && manyResult.done) {
+ return [];
+ }
+
+ return processManyResult(manyResult);
+}
+
+
+
+@globalPrivate
+function consumeReadableStream(nativePtr, nativeType, inputStream) {
+ "use strict";
+ const symbol = Symbol.for("Bun.consumeReadableStreamPrototype");
+ var cached = globalThis[symbol];
+ if (!cached) {
+ cached = globalThis[symbol] = [];
+ }
+ var Prototype = cached[nativeType];
+ if (Prototype === @undefined) {
+ var [doRead, doError, doReadMany, doClose, onClose, deinit] = globalThis[Symbol.for("Bun.lazy")](nativeType);
+
+ Prototype = class NativeReadableStreamSink {
+ constructor(reader, ptr) {
+ this.#ptr = ptr;
+ this.#reader = reader;
+ this.#didClose = false;
+
+ this.handleError = this._handleError.bind(this);
+ this.handleClosed = this._handleClosed.bind(this);
+ this.processResult = this._processResult.bind(this);
+
+ reader.closed.then(this.handleClosed, this.handleError);
+ }
+
+ handleError;
+ handleClosed;
+ _handleClosed() {
+ if (this.#didClose) return;
+ this.#didClose = true;
+ var ptr = this.#ptr;
+ this.#ptr = 0;
+ doClose(ptr);
+ deinit(ptr);
+ }
+
+ _handleError(error) {
+ if (this.#didClose) return;
+ this.#didClose = true;
+ var ptr = this.#ptr;
+ this.#ptr = 0;
+ doError(ptr, error);
+ deinit(ptr);
+ }
+
+ #ptr;
+ #didClose = false;
+ #reader;
+
+ _handleReadMany({value, done, size}) {
+ if (done) {
+ this.handleClosed();
+ return;
+ }
+
+ if (this.#didClose) return;
+
+
+ doReadMany(this.#ptr, value, done, size);
+ }
+
+
+ read() {
+ if (!this.#ptr) return @throwTypeError("ReadableStreamSink is already closed");
+
+ return this.processResult(this.#reader.read());
+
+ }
+
+ _processResult(result) {
+ if (result && @isPromise(result)) {
+ const flags = @getPromiseInternalField(result, @promiseFieldFlags);
+ if (flags & @promiseStateFulfilled) {
+ const fulfilledValue = @getPromiseInternalField(result, @promiseFieldReactionsOrResult);
+ if (fulfilledValue) {
+ result = fulfilledValue;
+ }
+ }
+ }
+
+ if (result && @isPromise(result)) {
+ result.then(this.processResult, this.handleError);
+ return null;
+ }
+
+ if (result.done) {
+ this.handleClosed();
+ return 0;
+ } else if (result.value) {
+ return result.value;
+ } else {
+ return -1;
+ }
+ }
+
+ readMany() {
+ if (!this.#ptr) return @throwTypeError("ReadableStreamSink is already closed");
+ return this.processResult(this.#reader.readMany());
+ }
+ };
+
+ const minlength = nativeType + 1;
+ if (cached.length < minlength) {
+ cached.length = minlength;
+ }
+ @putByValDirect(cached, nativeType, Prototype);
+ }
+
+ if (@isReadableStreamLocked(inputStream)) {
+ @throwTypeError("Cannot start reading from a locked stream");
+ }
+
+ return new Prototype(inputStream.getReader(), nativePtr);
+}
+
+@globalPrivate
+function createEmptyReadableStream() {
+ var stream = new @ReadableStream({
+ pull() {},
+ start() {},
+ cancel() {},
+ });
+ @readableStreamClose(stream);
+ return stream;
+}
+
+@globalPrivate
+function createNativeReadableStream(nativePtr, nativeType, autoAllocateChunkSize) {
+ "use strict";
+ var cached = globalThis[Symbol.for("Bun.nativeReadableStreamPrototype")] ||= new @Map;
+ var Prototype = cached.@get(nativeType);
+ if (Prototype === @undefined) {
+ var [pull, start, cancel, setClose, deinit] = globalThis[Symbol.for("Bun.lazy")](nativeType);
+ var closer = [false];
+ var handleResult;
+ function handleNativeReadableStreamPromiseResult(val) {
+ "use strict";
+ var {c, v} = this;
+ this.c = @undefined;
+ this.v = @undefined;
+ handleResult(val, c, v);
+ }
+
+ handleResult = function handleResult(result, controller, view) {
+ "use strict";
+
+ if (result && @isPromise(result)) {
+ return result.then(handleNativeReadableStreamPromiseResult.bind({c: controller, v: view}), (err) => controller.error(err));
+ } else if (result !== false) {
+ if (view && view.byteLength === result) {
+ controller.byobRequest.respondWithNewView(view);
+ } else {
+ controller.byobRequest.respond(result);
+ }
+ }
+
+ if (closer[0] || result === false) {
+ @enqueueJob(() => controller.close());
+ closer[0] = false;
+ }
+ };
+
+ Prototype = class NativeReadableStreamSource {
+ constructor(tag, autoAllocateChunkSize) {
+ this.pull = this.pull_.bind(tag);
+ this.cancel = this.cancel_.bind(tag);
+ this.autoAllocateChunkSize = autoAllocateChunkSize;
+ }
+
+ pull;
+ cancel;
+
+ type = "bytes";
+ autoAllocateChunkSize = 0;
+
+ static startSync = start;
+
+ pull_(controller) {
+ closer[0] = false;
+ var result;
+
+ const view = controller.byobRequest.view;
+ try {
+ result = pull(this, view, closer);
+ } catch(err) {
+ return controller.error(err);
+ }
+
+ return handleResult(result, controller, view);
+ }
+
+ cancel_(reason) {
+ cancel(this, reason);
+ }
+
+ static registry = new FinalizationRegistry(deinit);
+ }
+ cached.@set(nativeType, Prototype);
+ }
+
+ // either returns the chunk size
+ // or throws an error
+ // should never return a Promise
+ const chunkSize = Prototype.startSync(nativePtr, autoAllocateChunkSize);
+
+ // empty file, no need for native back-and-forth on this
+ if (chunkSize === 0) {
+ return @createEmptyReadableStream();
+ }
+
+ var instance = new Prototype(nativePtr, chunkSize);
+ Prototype.registry.register(instance, nativePtr);
+ var stream = new @ReadableStream(instance);
+ @putByIdDirectPrivate(stream, "bunNativeType", nativeType);
+ @putByIdDirectPrivate(stream, "bunNativePtr", nativePtr);
+ return stream;
+}
+
+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..16e4ebce5
--- /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", @createFIFO());
+
+ 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")?.isNotEmpty())
+ @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..118376ffb
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableStreamDefaultReader.js
@@ -0,0 +1,165 @@
+/*
+ * 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", @createFIFO());
+
+ 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 readMany()
+{
+ "use strict";
+
+ if (!@isReadableStreamDefaultReader(this))
+ @throwTypeError("ReadableStreamDefaultReader.readMany() should not be called directly");
+
+ const stream = @getByIdDirectPrivate(this, "ownerReadableStream");
+ if (!stream)
+ @throwTypeError("readMany() called on a reader owned by no readable stream");
+
+ const state = @getByIdDirectPrivate(stream, "state");
+ @putByIdDirectPrivate(stream, "disturbed", true);
+ if (state === @streamClosed)
+ return {value: [], size: 0, done: true};
+ else if (state === @streamErrored) {
+ throw @getByIdDirectPrivate(stream, "storedError");
+ }
+
+
+ var controller = @getByIdDirectPrivate(stream, "readableStreamController");
+
+ const content = @getByIdDirectPrivate(controller, "queue").content;
+ var size = @getByIdDirectPrivate(controller, "queue").size;
+ var values = content.toArray(false);
+ var length = values.length;
+
+
+ if (length > 0) {
+
+ @resetQueue(@getByIdDirectPrivate(controller, "queue"));
+
+
+ if (@getByIdDirectPrivate(controller, "closeRequested"))
+ @readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
+ else if (@isReadableStreamDefaultController(controller))
+ @readableStreamDefaultControllerCallPullIfNeeded(controller);
+ else if (@isReadableByteStreamController(controller))
+ @readableByteStreamControllerCallPullIfNeeded(controller);
+
+ return {value: values, size, done: false};
+ }
+
+ var onPullMany = (result) => {
+ if (result.done) {
+ return {value: [], size: 0, done: true};
+ }
+ var controller = @getByIdDirectPrivate(stream, "readableStreamController");
+
+ var queue = @getByIdDirectPrivate(controller, "queue");
+ var value = [result.value].concat(queue.content.toArray(false));
+ var size = queue.size;
+ @resetQueue(queue);
+
+ if (@getByIdDirectPrivate(controller, "closeRequested"))
+ @readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
+ else if (@isReadableStreamDefaultController(controller))
+ @readableStreamDefaultControllerCallPullIfNeeded(controller);
+ else if (@isReadableByteStreamController(controller))
+ @readableByteStreamControllerCallPullIfNeeded(controller);
+
+
+
+ return {value: value, size: size, done: false};
+ };
+
+ var pullResult = controller.@pull(controller);
+ if (pullResult && @isPromise(pullResult)) {
+ return pullResult.@then(onPullMany);
+ }
+
+ return onPullMany(pullResult);
+}
+
+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")?.isNotEmpty())
+ @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..45611a0e4
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/ReadableStreamInternals.js
@@ -0,0 +1,818 @@
+/*
+ * 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 to a readable bytestream 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);
+
+ const reader = @getByIdDirectPrivate(stream, "reader");
+
+ if (!reader)
+ return;
+
+ if (@isReadableStreamDefaultReader(reader)) {
+ const requests = @getByIdDirectPrivate(reader, "readRequests");
+ @putByIdDirectPrivate(reader, "readRequests", @createFIFO());
+ for (var request = requests.shift(); request; request = requests.shift())
+ @rejectPromise(request, error);
+ } else {
+ @assert(@isReadableStreamBYOBReader(reader));
+ const requests = @getByIdDirectPrivate(reader, "readIntoRequests");
+ @putByIdDirectPrivate(reader, "readIntoRequests", @createFIFO());
+ for (var request = requests.shift(); request; request = requests.shift())
+ @rejectPromise(request, 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")?.isNotEmpty()) && @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")?.isNotEmpty()) && @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";
+
+ var queue = @getByIdDirectPrivate(controller, "queue");
+ if (queue.content.isNotEmpty()) {
+ const chunk = @dequeueValue(queue);
+ if (@getByIdDirectPrivate(controller, "closeRequested") && queue.content.isEmpty())
+ @readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
+ else
+ @readableStreamDefaultControllerCallPullIfNeeded(controller);
+
+ return @createFulfilledPromise({ value: chunk, done: false });
+ }
+ const pendingPromise = @readableStreamAddReadRequest(@getByIdDirectPrivate(controller, "controlledReadableStream"));
+ @readableStreamDefaultControllerCallPullIfNeeded(controller);
+ return pendingPromise;
+}
+
+function readableStreamDefaultControllerClose(controller)
+{
+ "use strict";
+
+ @assert(@readableStreamDefaultControllerCanCloseOrEnqueue(controller));
+ @putByIdDirectPrivate(controller, "closeRequested", true);
+ if (@getByIdDirectPrivate(controller, "queue")?.content?.isEmpty())
+ @readableStreamClose(@getByIdDirectPrivate(controller, "controlledReadableStream"));
+}
+
+function readableStreamClose(stream)
+{
+ "use strict";
+
+ @assert(@getByIdDirectPrivate(stream, "state") === @streamReadable);
+ @putByIdDirectPrivate(stream, "state", @streamClosed);
+ if (!@getByIdDirectPrivate(stream, "reader"))
+ return;
+
+ if (@isReadableStreamDefaultReader(@getByIdDirectPrivate(stream, "reader"))) {
+ const requests = @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests");
+ if (requests.isNotEmpty()) {
+ @putByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests", @createFIFO());
+
+ for (var request = requests.shift(); request; request = requests.shift())
+ @fulfillPromise(request, { value: @undefined, done: true });
+ }
+ }
+
+ @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "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");
+ // this is checked by callers
+ @assert(@readableStreamDefaultControllerCanCloseOrEnqueue(controller));
+
+ if (@isReadableStreamLocked(stream) && @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests")?.isNotEmpty()) {
+ @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();
+
+ @getByIdDirectPrivate(@getByIdDirectPrivate(stream, "reader"), "readRequests").push(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..c2ca3f5b5
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/StreamInternals.js
@@ -0,0 +1,317 @@
+/*
+ * 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 newHighWaterMark = @toNumber(highWaterMark);
+
+ if (@isNaN(newHighWaterMark) || newHighWaterMark < 0)
+ @throwRangeError("highWaterMark value is negative or not a number");
+
+ return { size: size, highWaterMark: newHighWaterMark };
+}
+
+@globalPrivate
+function createFIFO() {
+ "use strict";
+ class Denqueue {
+ constructor() {
+ this._head = 0;
+ this._tail = 0;
+ // this._capacity = 0;
+ this._capacityMask = 0x3;
+ this._list = @newArrayWithSize(4);
+ }
+
+ size() {
+ if (this._head === this._tail) return 0;
+ if (this._head < this._tail) return this._tail - this._head;
+ else return this._capacityMask + 1 - (this._head - this._tail);
+ }
+
+ isEmpty() {
+ return this.size() == 0;
+ }
+
+ isNotEmpty() {
+ return this.size() > 0;
+ }
+
+ shift() {
+ var head = this._head;
+ if (head === this._tail) return @undefined;
+ var item = this._list[head];
+ @putByValDirect(this._list, head, @undefined);
+ this._head = (head + 1) & this._capacityMask;
+ if (head < 2 && this._tail > 10000 && this._tail <= this._list.length >>> 2) this._shrinkArray();
+ return item;
+ }
+
+ peek() {
+ if (this._head === this._tail) return @undefined;
+ return this._list[this._head];
+ }
+
+ push(item) {
+ var tail = this._tail;
+ @putByValDirect(this._list, tail, item);
+ this._tail = (tail + 1) & this._capacityMask;
+ if (this._tail === this._head) {
+ this._growArray();
+ }
+ // if (this._capacity && this.size() > this._capacity) {
+ // this.shift();
+ // }
+ }
+
+ toArray(fullCopy) {
+ var list = this._list;
+ var len = @toLength(list.length);
+
+ if (fullCopy || this._head > this._tail) {
+ var _head = @toLength(this._head);
+ var _tail = @toLength(this._tail);
+ var total = @toLength((len - _head) + _tail);
+ var array = @newArrayWithSize(total);
+ var j = 0;
+ for (var i = _head; i < len; i++) @putByValDirect(array, j++, list[i]);
+ for (var i = 0; i < _tail; i++) @putByValDirect(array, j++, list[i]);
+ return array;
+ } else {
+ return @Array.prototype.slice.@call(list, this._head, this._tail);
+ }
+ }
+
+ clear() {
+ this._head = 0;
+ this._tail = 0;
+ this._list.fill(undefined);
+ }
+
+ _growArray() {
+ if (this._head) {
+ // copy existing data, head to end, then beginning to tail.
+ this._list = this.toArray(true);
+ this._head = 0;
+ }
+
+ // head is at 0 and array is now full, safe to extend
+ this._tail = @toLength(this._list.length);
+
+ this._list.length <<= 1;
+ this._capacityMask = (this._capacityMask << 1) | 1;
+ }
+
+ shrinkArray() {
+ this._list.length >>>= 1;
+ this._capacityMask >>>= 1;
+ }
+ }
+
+
+ return new Denqueue();
+}
+
+function newQueue()
+{
+ "use strict";
+
+ return { content: @createFIFO(), 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");
+
+ queue.content.push({ value, size });
+ queue.size += size;
+}
+
+function peekQueueValue(queue)
+{
+ "use strict";
+
+ @assert(queue.content.isNotEmpty());
+
+ return queue.peek().value;
+}
+
+function resetQueue(queue)
+{
+ "use strict";
+
+ @assert("content" in queue);
+ @assert("size" in queue);
+ queue.content.clear();
+ 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..6b2b3cf90
--- /dev/null
+++ b/src/javascript/jsc/bindings/builtins/js/WritableStreamInternals.js
@@ -0,0 +1,782 @@
+/*
+ * 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", @createFIFO());
+ @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");
+ writeRequests.push(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 (var request = requests.shift(); request; request = requests.shift())
+ request.@reject.@call(@undefined, storedError);
+
+ // TODO: is this still necessary?
+ @putByIdDirectPrivate(stream, "writeRequests", @createFIFO());
+
+ 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.isNotEmpty());
+
+ 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?.isEmpty() ?? false)
+ 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?.isEmpty());
+
+ 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/exports.zig b/src/javascript/jsc/bindings/exports.zig
index e1b7d38b9..8a35883ba 100644
--- a/src/javascript/jsc/bindings/exports.zig
+++ b/src/javascript/jsc/bindings/exports.zig
@@ -177,9 +177,12 @@ pub const ZigErrorType = extern struct {
pub const NodeReadableStream = JSC.Node.Readable.State;
/// do not use this reference directly, use JSC.Node.Writable
pub const NodeWritableStream = JSC.Node.Writable.State;
-
pub const NodePath = JSC.Node.Path;
+// Web Streams
+pub const JSReadableStreamBlob = JSC.WebCore.ByteBlobLoader.Source.JSReadableStreamSource;
+pub const JSReadableStreamFile = JSC.WebCore.FileBlobLoader.Source.JSReadableStreamSource;
+
pub fn Errorable(comptime Type: type) type {
return extern struct {
result: Result,
@@ -2503,6 +2506,8 @@ comptime {
std.testing.refAllDecls(Bun.Timer);
std.testing.refAllDecls(NodeWritableStream);
std.testing.refAllDecls(NodePath);
+ std.testing.refAllDecls(JSReadableStreamBlob);
+ std.testing.refAllDecls(JSReadableStreamFile);
_ = ZigString__free;
_ = ZigString__free_global;
}
diff --git a/src/javascript/jsc/bindings/headers-cpp.h b/src/javascript/jsc/bindings/headers-cpp.h
new file mode 100644
index 000000000..28db16511
--- /dev/null
+++ b/src/javascript/jsc/bindings/headers-cpp.h
@@ -0,0 +1,263 @@
+//-- AUTOGENERATED FILE -- 1654055796
+// clang-format off
+#pragma once
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "root.h"
+
+#ifndef INCLUDED_JavaScriptCore_JSObject_h
+#define INCLUDED_JavaScriptCore_JSObject_h
+#include "JavaScriptCore/JSObject.h"
+#endif
+
+extern "C" const size_t JSC__JSObject_object_size_ = sizeof(JSC::JSObject);
+extern "C" const size_t JSC__JSObject_object_align_ = alignof(JSC::JSObject);
+
+#ifndef INCLUDED_FetchHeaders_h
+#define INCLUDED_FetchHeaders_h
+#include "FetchHeaders.h"
+#endif
+
+extern "C" const size_t WebCore__FetchHeaders_object_size_ = sizeof(WebCore::FetchHeaders);
+extern "C" const size_t WebCore__FetchHeaders_object_align_ = alignof(WebCore::FetchHeaders);
+
+#ifndef INCLUDED_JavaScriptCore_JSCell_h
+#define INCLUDED_JavaScriptCore_JSCell_h
+#include "JavaScriptCore/JSCell.h"
+#endif
+
+extern "C" const size_t JSC__JSCell_object_size_ = sizeof(JSC::JSCell);
+extern "C" const size_t JSC__JSCell_object_align_ = alignof(JSC::JSCell);
+
+#ifndef INCLUDED_JavaScriptCore_JSString_h
+#define INCLUDED_JavaScriptCore_JSString_h
+#include "JavaScriptCore/JSString.h"
+#endif
+
+extern "C" const size_t JSC__JSString_object_size_ = sizeof(JSC::JSString);
+extern "C" const size_t JSC__JSString_object_align_ = alignof(JSC::JSString);
+
+#ifndef INCLUDED_JavaScriptCore_ScriptArguments_h
+#define INCLUDED_JavaScriptCore_ScriptArguments_h
+#include "JavaScriptCore/ScriptArguments.h"
+#endif
+
+extern "C" const size_t Inspector__ScriptArguments_object_size_ = sizeof(Inspector::ScriptArguments);
+extern "C" const size_t Inspector__ScriptArguments_object_align_ = alignof(Inspector::ScriptArguments);
+
+#ifndef INCLUDED_JavaScriptCore_JSModuleLoader_h
+#define INCLUDED_JavaScriptCore_JSModuleLoader_h
+#include "JavaScriptCore/JSModuleLoader.h"
+#endif
+
+extern "C" const size_t JSC__JSModuleLoader_object_size_ = sizeof(JSC::JSModuleLoader);
+extern "C" const size_t JSC__JSModuleLoader_object_align_ = alignof(JSC::JSModuleLoader);
+
+#ifndef INCLUDED_JavaScriptCore_JSModuleRecord_h
+#define INCLUDED_JavaScriptCore_JSModuleRecord_h
+#include "JavaScriptCore/JSModuleRecord.h"
+#endif
+
+extern "C" const size_t JSC__JSModuleRecord_object_size_ = sizeof(JSC::JSModuleRecord);
+extern "C" const size_t JSC__JSModuleRecord_object_align_ = alignof(JSC::JSModuleRecord);
+
+#ifndef INCLUDED_JavaScriptCore_JSPromise_h
+#define INCLUDED_JavaScriptCore_JSPromise_h
+#include "JavaScriptCore/JSPromise.h"
+#endif
+
+extern "C" const size_t JSC__JSPromise_object_size_ = sizeof(JSC::JSPromise);
+extern "C" const size_t JSC__JSPromise_object_align_ = alignof(JSC::JSPromise);
+
+#ifndef INCLUDED_JavaScriptCore_JSInternalPromise_h
+#define INCLUDED_JavaScriptCore_JSInternalPromise_h
+#include "JavaScriptCore/JSInternalPromise.h"
+#endif
+
+extern "C" const size_t JSC__JSInternalPromise_object_size_ = sizeof(JSC::JSInternalPromise);
+extern "C" const size_t JSC__JSInternalPromise_object_align_ = alignof(JSC::JSInternalPromise);
+
+#ifndef INCLUDED_JavaScriptCore_SourceOrigin_h
+#define INCLUDED_JavaScriptCore_SourceOrigin_h
+#include "JavaScriptCore/SourceOrigin.h"
+#endif
+
+extern "C" const size_t JSC__SourceOrigin_object_size_ = sizeof(JSC::SourceOrigin);
+extern "C" const size_t JSC__SourceOrigin_object_align_ = alignof(JSC::SourceOrigin);
+
+#ifndef INCLUDED_JavaScriptCore_SourceProvider_h
+#define INCLUDED_JavaScriptCore_SourceProvider_h
+#include "JavaScriptCore/SourceProvider.h"
+#endif
+
+extern "C" const size_t JSC__SourceCode_object_size_ = sizeof(JSC::SourceCode);
+extern "C" const size_t JSC__SourceCode_object_align_ = alignof(JSC::SourceCode);
+
+#ifndef INCLUDED_JavaScriptCore_JSFunction_h
+#define INCLUDED_JavaScriptCore_JSFunction_h
+#include "JavaScriptCore/JSFunction.h"
+#endif
+
+extern "C" const size_t JSC__JSFunction_object_size_ = sizeof(JSC::JSFunction);
+extern "C" const size_t JSC__JSFunction_object_align_ = alignof(JSC::JSFunction);
+
+#ifndef INCLUDED_JavaScriptCore_JSGlobalObject_h
+#define INCLUDED_JavaScriptCore_JSGlobalObject_h
+#include "JavaScriptCore/JSGlobalObject.h"
+#endif
+
+extern "C" const size_t JSC__JSGlobalObject_object_size_ = sizeof(JSC::JSGlobalObject);
+extern "C" const size_t JSC__JSGlobalObject_object_align_ = alignof(JSC::JSGlobalObject);
+
+#ifndef INCLUDED_wtf_URL_h
+#define INCLUDED_wtf_URL_h
+#include "wtf/URL.h"
+#endif
+
+extern "C" const size_t WTF__URL_object_size_ = sizeof(WTF::URL);
+extern "C" const size_t WTF__URL_object_align_ = alignof(WTF::URL);
+
+#ifndef INCLUDED_wtf_text_WTFString_h
+#define INCLUDED_wtf_text_WTFString_h
+#include "wtf/text/WTFString.h"
+#endif
+
+extern "C" const size_t WTF__String_object_size_ = sizeof(WTF::String);
+extern "C" const size_t WTF__String_object_align_ = alignof(WTF::String);
+
+#ifndef INCLUDED_JavaScriptCore_JSValue_h
+#define INCLUDED_JavaScriptCore_JSValue_h
+#include "JavaScriptCore/JSValue.h"
+#endif
+
+extern "C" const size_t JSC__JSValue_object_size_ = sizeof(JSC::JSValue);
+extern "C" const size_t JSC__JSValue_object_align_ = alignof(JSC::JSValue);
+
+#ifndef INCLUDED_JavaScriptCore_PropertyName_h
+#define INCLUDED_JavaScriptCore_PropertyName_h
+#include "JavaScriptCore/PropertyName.h"
+#endif
+
+extern "C" const size_t JSC__PropertyName_object_size_ = sizeof(JSC::PropertyName);
+extern "C" const size_t JSC__PropertyName_object_align_ = alignof(JSC::PropertyName);
+
+#ifndef INCLUDED_JavaScriptCore_Exception_h
+#define INCLUDED_JavaScriptCore_Exception_h
+#include "JavaScriptCore/Exception.h"
+#endif
+
+extern "C" const size_t JSC__Exception_object_size_ = sizeof(JSC::Exception);
+extern "C" const size_t JSC__Exception_object_align_ = alignof(JSC::Exception);
+
+#ifndef INCLUDED_JavaScriptCore_VM_h
+#define INCLUDED_JavaScriptCore_VM_h
+#include "JavaScriptCore/VM.h"
+#endif
+
+extern "C" const size_t JSC__VM_object_size_ = sizeof(JSC::VM);
+extern "C" const size_t JSC__VM_object_align_ = alignof(JSC::VM);
+
+#ifndef INCLUDED_JavaScriptCore_ThrowScope_h
+#define INCLUDED_JavaScriptCore_ThrowScope_h
+#include "JavaScriptCore/ThrowScope.h"
+#endif
+
+extern "C" const size_t JSC__ThrowScope_object_size_ = sizeof(JSC::ThrowScope);
+extern "C" const size_t JSC__ThrowScope_object_align_ = alignof(JSC::ThrowScope);
+
+#ifndef INCLUDED_JavaScriptCore_CatchScope_h
+#define INCLUDED_JavaScriptCore_CatchScope_h
+#include "JavaScriptCore/CatchScope.h"
+#endif
+
+extern "C" const size_t JSC__CatchScope_object_size_ = sizeof(JSC::CatchScope);
+extern "C" const size_t JSC__CatchScope_object_align_ = alignof(JSC::CatchScope);
+
+#ifndef INCLUDED_JavaScriptCore_Identifier_h
+#define INCLUDED_JavaScriptCore_Identifier_h
+#include "JavaScriptCore/Identifier.h"
+#endif
+
+extern "C" const size_t JSC__Identifier_object_size_ = sizeof(JSC::Identifier);
+extern "C" const size_t JSC__Identifier_object_align_ = alignof(JSC::Identifier);
+
+#ifndef INCLUDED_wtf_text_StringImpl_h
+#define INCLUDED_wtf_text_StringImpl_h
+#include "wtf/text/StringImpl.h"
+#endif
+
+extern "C" const size_t WTF__StringImpl_object_size_ = sizeof(WTF::StringImpl);
+extern "C" const size_t WTF__StringImpl_object_align_ = alignof(WTF::StringImpl);
+
+#ifndef INCLUDED_wtf_text_ExternalStringImpl_h
+#define INCLUDED_wtf_text_ExternalStringImpl_h
+#include "wtf/text/ExternalStringImpl.h"
+#endif
+
+extern "C" const size_t WTF__ExternalStringImpl_object_size_ = sizeof(WTF::ExternalStringImpl);
+extern "C" const size_t WTF__ExternalStringImpl_object_align_ = alignof(WTF::ExternalStringImpl);
+
+#ifndef INCLUDED_wtf_text_StringView_h
+#define INCLUDED_wtf_text_StringView_h
+#include "wtf/text/StringView.h"
+#endif
+
+extern "C" const size_t WTF__StringView_object_size_ = sizeof(WTF::StringView);
+extern "C" const size_t WTF__StringView_object_align_ = alignof(WTF::StringView);
+
+#ifndef INCLUDED__ZigGlobalObject_h_
+#define INCLUDED__ZigGlobalObject_h_
+#include ""ZigGlobalObject.h""
+#endif
+
+extern "C" const size_t Zig__GlobalObject_object_size_ = sizeof(Zig::GlobalObject);
+extern "C" const size_t Zig__GlobalObject_object_align_ = alignof(Zig::GlobalObject);
+
+#ifndef INCLUDED_BunStream_h
+#define INCLUDED_BunStream_h
+#include "BunStream.h"
+#endif
+
+extern "C" const size_t Bun__Readable_object_size_ = sizeof(Bun__Readable);
+extern "C" const size_t Bun__Readable_object_align_ = alignof(Bun__Readable);
+
+#ifndef INCLUDED_BunStream_h
+#define INCLUDED_BunStream_h
+#include "BunStream.h"
+#endif
+
+extern "C" const size_t Bun__Writable_object_size_ = sizeof(Bun__Writable);
+extern "C" const size_t Bun__Writable_object_align_ = alignof(Bun__Writable);
+
+#ifndef INCLUDED_Path_h
+#define INCLUDED_Path_h
+#include "Path.h"
+#endif
+
+extern "C" const size_t Bun__Path_object_size_ = sizeof(Bun__Path);
+extern "C" const size_t Bun__Path_object_align_ = alignof(Bun__Path);
+
+#ifndef INCLUDED__ZigConsoleClient_h_
+#define INCLUDED__ZigConsoleClient_h_
+#include ""ZigConsoleClient.h""
+#endif
+
+extern "C" const size_t Zig__ConsoleClient_object_size_ = sizeof(Zig::ConsoleClient);
+extern "C" const size_t Zig__ConsoleClient_object_align_ = alignof(Zig::ConsoleClient);
+
+#ifndef INCLUDED_
+#define INCLUDED_
+#include ""
+#endif
+
+extern "C" const size_t Bun__Timer_object_size_ = sizeof(Bun__Timer);
+extern "C" const size_t Bun__Timer_object_align_ = alignof(Bun__Timer);
+
+const size_t sizes[31] = {sizeof(JSC::JSObject), sizeof(WebCore::DOMURL), sizeof(WebCore::FetchHeaders), sizeof(SystemError), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(Inspector::ScriptArguments), sizeof(JSC::JSModuleLoader), sizeof(JSC::JSModuleRecord), sizeof(JSC::JSPromise), sizeof(JSC::JSInternalPromise), sizeof(JSC::SourceOrigin), sizeof(JSC::SourceCode), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(WTF::URL), sizeof(WTF::String), sizeof(JSC::JSValue), sizeof(JSC::PropertyName), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::CatchScope), sizeof(JSC::Identifier), sizeof(WTF::StringImpl), sizeof(WTF::ExternalStringImpl), sizeof(WTF::StringView), sizeof(Zig::GlobalObject), sizeof(Bun__Readable), sizeof(Bun__Writable), sizeof(Bun__Path)};
+
+const char* names[31] = {"JSC__JSObject", "WebCore__DOMURL", "WebCore__FetchHeaders", "SystemError", "JSC__JSCell", "JSC__JSString", "Inspector__ScriptArguments", "JSC__JSModuleLoader", "JSC__JSModuleRecord", "JSC__JSPromise", "JSC__JSInternalPromise", "JSC__SourceOrigin", "JSC__SourceCode", "JSC__JSFunction", "JSC__JSGlobalObject", "WTF__URL", "WTF__String", "JSC__JSValue", "JSC__PropertyName", "JSC__Exception", "JSC__VM", "JSC__ThrowScope", "JSC__CatchScope", "JSC__Identifier", "WTF__StringImpl", "WTF__ExternalStringImpl", "WTF__StringView", "Zig__GlobalObject", "Bun__Readable", "Bun__Writable", "Bun__Path"};
+
+const size_t aligns[31] = {alignof(JSC::JSObject), alignof(WebCore::DOMURL), alignof(WebCore::FetchHeaders), alignof(SystemError), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(Inspector::ScriptArguments), alignof(JSC::JSModuleLoader), alignof(JSC::JSModuleRecord), alignof(JSC::JSPromise), alignof(JSC::JSInternalPromise), alignof(JSC::SourceOrigin), alignof(JSC::SourceCode), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(WTF::URL), alignof(WTF::String), alignof(JSC::JSValue), alignof(JSC::PropertyName), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::CatchScope), alignof(JSC::Identifier), alignof(WTF::StringImpl), alignof(WTF::ExternalStringImpl), alignof(WTF::StringView), alignof(Zig::GlobalObject), alignof(Bun__Readable), alignof(Bun__Writable), alignof(Bun__Path)};
diff --git a/src/javascript/jsc/bindings/headers-handwritten.h b/src/javascript/jsc/bindings/headers-handwritten.h
index 710e9290d..7409427ac 100644
--- a/src/javascript/jsc/bindings/headers-handwritten.h
+++ b/src/javascript/jsc/bindings/headers-handwritten.h
@@ -1,6 +1,7 @@
#pragma once
typedef uint16_t ZigErrorCode;
+typedef struct VirtualMachine VirtualMachine;
typedef struct ZigString {
const unsigned char* ptr;
@@ -190,6 +191,7 @@ extern "C" ZigErrorCode Zig_ErrorCodeParserError;
extern "C" void ZigString__free(const unsigned char* ptr, size_t len, void* allocator);
extern "C" void Microtask__run(void* ptr, void* global);
+extern "C" void Microtask__run_default(void* ptr, void* global);
// Used in process.version
extern "C" const char* Bun__version;
diff --git a/src/javascript/jsc/bindings/headers-replacements.zig b/src/javascript/jsc/bindings/headers-replacements.zig
index c503d3288..fb5cf1496 100644
--- a/src/javascript/jsc/bindings/headers-replacements.zig
+++ b/src/javascript/jsc/bindings/headers-replacements.zig
@@ -62,3 +62,4 @@ 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;
+pub const struct_VirtualMachine = bindings.VirtualMachine;
diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h
new file mode 100644
index 000000000..217fdd884
--- /dev/null
+++ b/src/javascript/jsc/bindings/headers.h
@@ -0,0 +1,775 @@
+// clang-format: off
+//-- AUTOGENERATED FILE -- 1654055796
+#pragma once
+
+#include <stddef.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+ #define AUTO_EXTERN_C extern "C"
+ #define AUTO_EXTERN_C_ZIG extern "C" __attribute__((weak))
+#else
+ #define AUTO_EXTERN_C
+ #define AUTO_EXTERN_C_ZIG __attribute__((weak))
+#endif
+#define ZIG_DECL AUTO_EXTERN_C_ZIG
+#define CPP_DECL AUTO_EXTERN_C
+#define CPP_SIZE AUTO_EXTERN_C
+
+#ifndef __cplusplus
+typedef void* JSClassRef;
+#endif
+
+#ifdef __cplusplus
+#include "root.h"
+#include "JavaScriptCore/JSClassRef.h"
+#endif
+#include "headers-handwritten.h"
+ typedef struct bJSC__SourceCode { unsigned char bytes[24]; } bJSC__SourceCode;
+ typedef char* bJSC__SourceCode_buf;
+ typedef struct bWTF__URL { unsigned char bytes[40]; } bWTF__URL;
+ typedef char* bWTF__URL_buf;
+ typedef struct bJSC__JSModuleRecord { unsigned char bytes[216]; } bJSC__JSModuleRecord;
+ typedef char* bJSC__JSModuleRecord_buf;
+ typedef struct bJSC__ThrowScope { unsigned char bytes[8]; } bJSC__ThrowScope;
+ typedef char* bJSC__ThrowScope_buf;
+ typedef struct bJSC__PropertyName { unsigned char bytes[8]; } bJSC__PropertyName;
+ typedef char* bJSC__PropertyName_buf;
+ typedef struct bJSC__JSFunction { unsigned char bytes[32]; } bJSC__JSFunction;
+ typedef char* bJSC__JSFunction_buf;
+ typedef struct bJSC__JSGlobalObject { unsigned char bytes[2312]; } bJSC__JSGlobalObject;
+ typedef char* bJSC__JSGlobalObject_buf;
+ typedef struct bJSC__JSCell { unsigned char bytes[8]; } bJSC__JSCell;
+ typedef char* bJSC__JSCell_buf;
+ typedef struct bJSC__CatchScope { unsigned char bytes[8]; } bJSC__CatchScope;
+ typedef char* bJSC__CatchScope_buf;
+ typedef struct bWTF__String { unsigned char bytes[8]; } bWTF__String;
+ typedef char* bWTF__String_buf;
+ typedef struct bWTF__StringView { unsigned char bytes[16]; } bWTF__StringView;
+ typedef char* bWTF__StringView_buf;
+ typedef struct bJSC__JSModuleLoader { unsigned char bytes[16]; } bJSC__JSModuleLoader;
+ typedef char* bJSC__JSModuleLoader_buf;
+ typedef struct bInspector__ScriptArguments { unsigned char bytes[32]; } bInspector__ScriptArguments;
+ typedef char* bInspector__ScriptArguments_buf;
+ typedef struct bJSC__Exception { unsigned char bytes[40]; } bJSC__Exception;
+ typedef char* bJSC__Exception_buf;
+ typedef struct bJSC__VM { unsigned char bytes[52168]; } bJSC__VM;
+ typedef char* bJSC__VM_buf;
+ typedef struct bJSC__JSString { unsigned char bytes[16]; } bJSC__JSString;
+ typedef char* bJSC__JSString_buf;
+ typedef struct bJSC__SourceOrigin { unsigned char bytes[48]; } bJSC__SourceOrigin;
+ typedef char* bJSC__SourceOrigin_buf;
+ typedef struct bWTF__ExternalStringImpl { unsigned char bytes[40]; } bWTF__ExternalStringImpl;
+ typedef char* bWTF__ExternalStringImpl_buf;
+ typedef struct bJSC__JSInternalPromise { unsigned char bytes[32]; } bJSC__JSInternalPromise;
+ typedef char* bJSC__JSInternalPromise_buf;
+ typedef struct bWTF__StringImpl { unsigned char bytes[24]; } bWTF__StringImpl;
+ typedef char* bWTF__StringImpl_buf;
+ typedef struct bJSC__JSPromise { unsigned char bytes[32]; } bJSC__JSPromise;
+ typedef char* bJSC__JSPromise_buf;
+ typedef struct bJSC__JSObject { unsigned char bytes[16]; } bJSC__JSObject;
+ typedef char* bJSC__JSObject_buf;
+ typedef struct bJSC__Identifier { unsigned char bytes[8]; } bJSC__Identifier;
+ typedef char* bJSC__Identifier_buf;
+
+#ifndef __cplusplus
+ typedef bJSC__CatchScope JSC__CatchScope; // JSC::CatchScope
+ typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype
+ typedef struct JSC__ArrayIteratorPrototype JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype
+ typedef ErrorableResolvedSource ErrorableResolvedSource;
+ typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype
+ typedef ErrorableZigString ErrorableZigString;
+ typedef bJSC__PropertyName JSC__PropertyName; // JSC::PropertyName
+ typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject
+ typedef bWTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl
+ typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype
+ typedef bJSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader
+ typedef struct JSC__AsyncGeneratorPrototype JSC__AsyncGeneratorPrototype; // JSC::AsyncGeneratorPrototype
+ typedef struct JSC__AsyncGeneratorFunctionPrototype JSC__AsyncGeneratorFunctionPrototype; // JSC::AsyncGeneratorFunctionPrototype
+ typedef bJSC__Identifier JSC__Identifier; // JSC::Identifier
+ typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype
+ typedef struct Zig__JSMicrotaskCallback Zig__JSMicrotaskCallback; // Zig::JSMicrotaskCallback
+ typedef bJSC__JSPromise JSC__JSPromise; // JSC::JSPromise
+ typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype
+ typedef SystemError SystemError;
+ typedef bJSC__JSCell JSC__JSCell; // JSC::JSCell
+ typedef bJSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin
+ typedef Bun__Writable Bun__Writable;
+ typedef bJSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord
+ typedef bWTF__String WTF__String; // WTF::String
+ typedef bWTF__URL WTF__URL; // WTF::URL
+ typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype
+ typedef bJSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise
+ typedef Bun__Readable Bun__Readable;
+ typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype
+ typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype
+ typedef struct WebCore__FetchHeaders WebCore__FetchHeaders; // WebCore::FetchHeaders
+ typedef bWTF__StringView WTF__StringView; // WTF::StringView
+ typedef bJSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope
+ typedef bWTF__StringImpl WTF__StringImpl; // WTF::StringImpl
+ typedef bJSC__VM JSC__VM; // JSC::VM
+ typedef JSClassRef JSClassRef;
+ typedef Bun__ArrayBuffer Bun__ArrayBuffer;
+ typedef bJSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject
+ typedef bJSC__JSFunction JSC__JSFunction; // JSC::JSFunction
+ typedef struct JSC__AsyncFunctionPrototype JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype
+ typedef ZigException ZigException;
+ typedef bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode
+ typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype
+ typedef struct JSC__GeneratorFunctionPrototype JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype
+ typedef ZigString ZigString;
+ typedef struct WebCore__DOMURL WebCore__DOMURL; // WebCore::DOMURL
+ typedef int64_t JSC__JSValue;
+ typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype
+ typedef bInspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments
+ typedef bJSC__Exception JSC__Exception; // JSC::Exception
+ typedef bJSC__JSString JSC__JSString; // JSC::JSString
+ typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype
+ typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype
+
+#endif
+
+#ifdef __cplusplus
+ namespace JSC {
+ class JSCell;
+ class Exception;
+ class JSPromisePrototype;
+ class StringPrototype;
+ class GeneratorFunctionPrototype;
+ class ArrayPrototype;
+ class JSString;
+ class JSObject;
+ class AsyncIteratorPrototype;
+ class AsyncGeneratorFunctionPrototype;
+ class Identifier;
+ class JSPromise;
+ class RegExpPrototype;
+ class AsyncFunctionPrototype;
+ class CatchScope;
+ class VM;
+ class BigIntPrototype;
+ class SourceOrigin;
+ class ThrowScope;
+ class SetIteratorPrototype;
+ class AsyncGeneratorPrototype;
+ class PropertyName;
+ class MapIteratorPrototype;
+ class JSModuleRecord;
+ class JSInternalPromise;
+ class ArrayIteratorPrototype;
+ class JSFunction;
+ class JSModuleLoader;
+ class GeneratorPrototype;
+ class JSGlobalObject;
+ class SourceCode;
+ class FunctionPrototype;
+ class IteratorPrototype;
+ class ObjectPrototype;
+ }
+ namespace WTF {
+ class URL;
+ class StringImpl;
+ class String;
+ class StringView;
+ class ExternalStringImpl;
+ }
+ namespace Zig {
+ class JSMicrotaskCallback;
+ }
+ namespace WebCore {
+ class DOMURL;
+ class FetchHeaders;
+ }
+ namespace Inspector {
+ class ScriptArguments;
+ }
+
+ typedef ErrorableResolvedSource ErrorableResolvedSource;
+ typedef ErrorableZigString ErrorableZigString;
+ typedef SystemError SystemError;
+ typedef Bun__Writable Bun__Writable;
+ typedef Bun__Readable Bun__Readable;
+ typedef JSClassRef JSClassRef;
+ typedef Bun__ArrayBuffer Bun__ArrayBuffer;
+ typedef ZigException ZigException;
+ typedef ZigString ZigString;
+ typedef int64_t JSC__JSValue;
+ using JSC__JSCell = JSC::JSCell;
+ using JSC__Exception = JSC::Exception;
+ using JSC__JSPromisePrototype = JSC::JSPromisePrototype;
+ using JSC__StringPrototype = JSC::StringPrototype;
+ using JSC__GeneratorFunctionPrototype = JSC::GeneratorFunctionPrototype;
+ using JSC__ArrayPrototype = JSC::ArrayPrototype;
+ using JSC__JSString = JSC::JSString;
+ using JSC__JSObject = JSC::JSObject;
+ using JSC__AsyncIteratorPrototype = JSC::AsyncIteratorPrototype;
+ using JSC__AsyncGeneratorFunctionPrototype = JSC::AsyncGeneratorFunctionPrototype;
+ using JSC__Identifier = JSC::Identifier;
+ using JSC__JSPromise = JSC::JSPromise;
+ using JSC__RegExpPrototype = JSC::RegExpPrototype;
+ using JSC__AsyncFunctionPrototype = JSC::AsyncFunctionPrototype;
+ using JSC__CatchScope = JSC::CatchScope;
+ using JSC__VM = JSC::VM;
+ using JSC__BigIntPrototype = JSC::BigIntPrototype;
+ using JSC__SourceOrigin = JSC::SourceOrigin;
+ using JSC__ThrowScope = JSC::ThrowScope;
+ using JSC__SetIteratorPrototype = JSC::SetIteratorPrototype;
+ using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype;
+ using JSC__PropertyName = JSC::PropertyName;
+ using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype;
+ using JSC__JSModuleRecord = JSC::JSModuleRecord;
+ using JSC__JSInternalPromise = JSC::JSInternalPromise;
+ using JSC__ArrayIteratorPrototype = JSC::ArrayIteratorPrototype;
+ using JSC__JSFunction = JSC::JSFunction;
+ using JSC__JSModuleLoader = JSC::JSModuleLoader;
+ using JSC__GeneratorPrototype = JSC::GeneratorPrototype;
+ using JSC__JSGlobalObject = JSC::JSGlobalObject;
+ using JSC__SourceCode = JSC::SourceCode;
+ using JSC__FunctionPrototype = JSC::FunctionPrototype;
+ using JSC__IteratorPrototype = JSC::IteratorPrototype;
+ using JSC__ObjectPrototype = JSC::ObjectPrototype;
+ using WTF__URL = WTF::URL;
+ using WTF__StringImpl = WTF::StringImpl;
+ using WTF__String = WTF::String;
+ using WTF__StringView = WTF::StringView;
+ using WTF__ExternalStringImpl = WTF::ExternalStringImpl;
+ using Zig__JSMicrotaskCallback = Zig::JSMicrotaskCallback;
+ using WebCore__DOMURL = WebCore::DOMURL;
+ using WebCore__FetchHeaders = WebCore::FetchHeaders;
+ using Inspector__ScriptArguments = Inspector::ScriptArguments;
+
+#endif
+
+
+#pragma mark - JSC::JSObject
+
+CPP_DECL JSC__JSValue JSC__JSObject__create(JSC__JSGlobalObject* arg0, size_t arg1, void* arg2, void (* ArgFn3)(void* arg0, JSC__JSObject* arg1, JSC__JSGlobalObject* arg2));
+CPP_DECL size_t JSC__JSObject__getArrayLength(JSC__JSObject* arg0);
+CPP_DECL JSC__JSValue JSC__JSObject__getDirect(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, const ZigString* arg2);
+CPP_DECL JSC__JSValue JSC__JSObject__getIndex(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, uint32_t arg2);
+CPP_DECL void JSC__JSObject__putRecord(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, ZigString* arg2, ZigString* arg3, size_t arg4);
+CPP_DECL JSC__JSValue ZigString__external(const ZigString* arg0, JSC__JSGlobalObject* arg1, void* arg2, void (* ArgFn3)(void* arg0, void* arg1, size_t arg2));
+CPP_DECL JSC__JSValue ZigString__to16BitValue(const ZigString* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL JSC__JSValue ZigString__toErrorInstance(const ZigString* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL JSC__JSValue ZigString__toExternalU16(const uint16_t* arg0, size_t arg1, JSC__JSGlobalObject* arg2);
+CPP_DECL JSC__JSValue ZigString__toExternalValue(const ZigString* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL JSC__JSValue ZigString__toExternalValueWithCallback(const ZigString* arg0, JSC__JSGlobalObject* arg1, void (* ArgFn2)(void* arg0, void* arg1, size_t arg2));
+CPP_DECL JSC__JSValue ZigString__toValue(const ZigString* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL JSC__JSValue ZigString__toValueGC(const ZigString* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL WebCore__DOMURL* WebCore__DOMURL__cast_(JSC__JSValue JSValue0, JSC__VM* arg1);
+CPP_DECL void WebCore__DOMURL__href_(WebCore__DOMURL* arg0, ZigString* arg1);
+CPP_DECL void WebCore__DOMURL__pathname_(WebCore__DOMURL* arg0, ZigString* arg1);
+
+#pragma mark - WebCore::FetchHeaders
+
+CPP_DECL void WebCore__FetchHeaders__append(WebCore__FetchHeaders* arg0, const ZigString* arg1, const ZigString* arg2);
+CPP_DECL WebCore__FetchHeaders* WebCore__FetchHeaders__cast_(JSC__JSValue JSValue0, JSC__VM* arg1);
+CPP_DECL JSC__JSValue WebCore__FetchHeaders__clone(WebCore__FetchHeaders* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL WebCore__FetchHeaders* WebCore__FetchHeaders__cloneThis(WebCore__FetchHeaders* arg0);
+CPP_DECL void WebCore__FetchHeaders__copyTo(WebCore__FetchHeaders* arg0, StringPointer* arg1, StringPointer* arg2, unsigned char* arg3);
+CPP_DECL void WebCore__FetchHeaders__count(WebCore__FetchHeaders* arg0, uint32_t* arg1, uint32_t* arg2);
+CPP_DECL WebCore__FetchHeaders* WebCore__FetchHeaders__createEmpty();
+CPP_DECL WebCore__FetchHeaders* WebCore__FetchHeaders__createFromJS(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
+CPP_DECL WebCore__FetchHeaders* WebCore__FetchHeaders__createFromPicoHeaders_(JSC__JSGlobalObject* arg0, const void* arg1);
+CPP_DECL WebCore__FetchHeaders* WebCore__FetchHeaders__createFromUWS(JSC__JSGlobalObject* arg0, void* arg1);
+CPP_DECL JSC__JSValue WebCore__FetchHeaders__createValue(JSC__JSGlobalObject* arg0, StringPointer* arg1, StringPointer* arg2, const ZigString* arg3, uint32_t arg4);
+CPP_DECL void WebCore__FetchHeaders__deref(WebCore__FetchHeaders* arg0);
+CPP_DECL void WebCore__FetchHeaders__get_(WebCore__FetchHeaders* arg0, const ZigString* arg1, ZigString* arg2);
+CPP_DECL bool WebCore__FetchHeaders__has(WebCore__FetchHeaders* arg0, const ZigString* arg1);
+CPP_DECL void WebCore__FetchHeaders__put_(WebCore__FetchHeaders* arg0, const ZigString* arg1, const ZigString* arg2);
+CPP_DECL void WebCore__FetchHeaders__remove(WebCore__FetchHeaders* arg0, const ZigString* arg1);
+CPP_DECL JSC__JSValue WebCore__FetchHeaders__toJS(WebCore__FetchHeaders* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL void WebCore__FetchHeaders__toUWSResponse(WebCore__FetchHeaders* arg0, bool arg1, void* arg2);
+CPP_DECL JSC__JSValue SystemError__toErrorInstance(const SystemError* arg0, JSC__JSGlobalObject* arg1);
+
+#pragma mark - JSC::JSCell
+
+CPP_DECL JSC__JSObject* JSC__JSCell__getObject(JSC__JSCell* arg0);
+CPP_DECL bWTF__String JSC__JSCell__getString(JSC__JSCell* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL unsigned char JSC__JSCell__getType(JSC__JSCell* arg0);
+
+#pragma mark - JSC::JSString
+
+CPP_DECL JSC__JSString* JSC__JSString__createFromOwnedString(JSC__VM* arg0, const WTF__String* arg1);
+CPP_DECL JSC__JSString* JSC__JSString__createFromString(JSC__VM* arg0, const WTF__String* arg1);
+CPP_DECL bool JSC__JSString__eql(const JSC__JSString* arg0, JSC__JSGlobalObject* arg1, JSC__JSString* arg2);
+CPP_DECL bool JSC__JSString__is8Bit(const JSC__JSString* arg0);
+CPP_DECL void JSC__JSString__iterator(JSC__JSString* arg0, JSC__JSGlobalObject* arg1, void* arg2);
+CPP_DECL size_t JSC__JSString__length(const JSC__JSString* arg0);
+CPP_DECL JSC__JSObject* JSC__JSString__toObject(JSC__JSString* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL bWTF__String JSC__JSString__value(JSC__JSString* arg0, JSC__JSGlobalObject* arg1);
+
+#pragma mark - Inspector::ScriptArguments
+
+CPP_DECL JSC__JSValue Inspector__ScriptArguments__argumentAt(Inspector__ScriptArguments* arg0, size_t arg1);
+CPP_DECL size_t Inspector__ScriptArguments__argumentCount(Inspector__ScriptArguments* arg0);
+CPP_DECL bWTF__String Inspector__ScriptArguments__getFirstArgumentAsString(Inspector__ScriptArguments* arg0);
+CPP_DECL bool Inspector__ScriptArguments__isEqual(Inspector__ScriptArguments* arg0, Inspector__ScriptArguments* arg1);
+CPP_DECL void Inspector__ScriptArguments__release(Inspector__ScriptArguments* arg0);
+
+#pragma mark - JSC::JSModuleLoader
+
+CPP_DECL bool JSC__JSModuleLoader__checkSyntax(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1, bool arg2);
+CPP_DECL JSC__JSValue JSC__JSModuleLoader__evaluate(JSC__JSGlobalObject* arg0, const unsigned char* arg1, size_t arg2, const unsigned char* arg3, size_t arg4, JSC__JSValue JSValue5, JSC__JSValue* arg6);
+CPP_DECL JSC__JSInternalPromise* JSC__JSModuleLoader__importModule(JSC__JSGlobalObject* arg0, const JSC__Identifier* arg1);
+CPP_DECL JSC__JSValue JSC__JSModuleLoader__linkAndEvaluateModule(JSC__JSGlobalObject* arg0, const JSC__Identifier* arg1);
+CPP_DECL JSC__JSInternalPromise* JSC__JSModuleLoader__loadAndEvaluateModule(JSC__JSGlobalObject* arg0, const ZigString* arg1);
+CPP_DECL JSC__JSInternalPromise* JSC__JSModuleLoader__loadAndEvaluateModuleEntryPoint(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1);
+
+#pragma mark - JSC::JSModuleRecord
+
+CPP_DECL bJSC__SourceCode JSC__JSModuleRecord__sourceCode(JSC__JSModuleRecord* arg0);
+
+#pragma mark - JSC::JSPromise
+
+CPP_DECL JSC__JSValue JSC__JSPromise__asValue(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL JSC__JSPromise* JSC__JSPromise__create(JSC__JSGlobalObject* arg0);
+CPP_DECL bool JSC__JSPromise__isHandled(const JSC__JSPromise* arg0, JSC__VM* arg1);
+CPP_DECL void JSC__JSPromise__reject(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2);
+CPP_DECL void JSC__JSPromise__rejectAsHandled(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2);
+CPP_DECL void JSC__JSPromise__rejectAsHandledException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2);
+CPP_DECL JSC__JSPromise* JSC__JSPromise__rejectedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
+CPP_DECL JSC__JSValue JSC__JSPromise__rejectedPromiseValue(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
+CPP_DECL void JSC__JSPromise__rejectWithCaughtException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, bJSC__ThrowScope arg2);
+CPP_DECL void JSC__JSPromise__resolve(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2);
+CPP_DECL JSC__JSPromise* JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
+CPP_DECL JSC__JSValue JSC__JSPromise__resolvedPromiseValue(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
+CPP_DECL JSC__JSValue JSC__JSPromise__result(const JSC__JSPromise* arg0, JSC__VM* arg1);
+CPP_DECL uint32_t JSC__JSPromise__status(const JSC__JSPromise* arg0, JSC__VM* arg1);
+
+#pragma mark - JSC::JSInternalPromise
+
+CPP_DECL JSC__JSInternalPromise* JSC__JSInternalPromise__create(JSC__JSGlobalObject* arg0);
+CPP_DECL bool JSC__JSInternalPromise__isHandled(const JSC__JSInternalPromise* arg0, JSC__VM* arg1);
+CPP_DECL void JSC__JSInternalPromise__reject(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2);
+CPP_DECL void JSC__JSInternalPromise__rejectAsHandled(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2);
+CPP_DECL void JSC__JSInternalPromise__rejectAsHandledException(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2);
+CPP_DECL JSC__JSInternalPromise* JSC__JSInternalPromise__rejectedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
+CPP_DECL void JSC__JSInternalPromise__rejectWithCaughtException(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, bJSC__ThrowScope arg2);
+CPP_DECL void JSC__JSInternalPromise__resolve(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2);
+CPP_DECL JSC__JSInternalPromise* JSC__JSInternalPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
+CPP_DECL JSC__JSValue JSC__JSInternalPromise__result(const JSC__JSInternalPromise* arg0, JSC__VM* arg1);
+CPP_DECL uint32_t JSC__JSInternalPromise__status(const JSC__JSInternalPromise* arg0, JSC__VM* arg1);
+
+#pragma mark - JSC::SourceOrigin
+
+CPP_DECL bJSC__SourceOrigin JSC__SourceOrigin__fromURL(const WTF__URL* arg0);
+
+#pragma mark - JSC::SourceCode
+
+CPP_DECL void JSC__SourceCode__fromString(JSC__SourceCode* arg0, const WTF__String* arg1, const JSC__SourceOrigin* arg2, WTF__String* arg3, unsigned char SourceType4);
+
+#pragma mark - JSC::JSFunction
+
+CPP_DECL bWTF__String JSC__JSFunction__calculatedDisplayName(JSC__JSFunction* arg0, JSC__VM* arg1);
+CPP_DECL bWTF__String JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1);
+CPP_DECL bWTF__String JSC__JSFunction__getName(JSC__JSFunction* arg0, JSC__VM* arg1);
+
+#pragma mark - JSC::JSGlobalObject
+
+CPP_DECL JSC__ArrayIteratorPrototype* JSC__JSGlobalObject__arrayIteratorPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__ArrayPrototype* JSC__JSGlobalObject__arrayPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__AsyncFunctionPrototype* JSC__JSGlobalObject__asyncFunctionPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__AsyncGeneratorFunctionPrototype* JSC__JSGlobalObject__asyncGeneratorFunctionPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__AsyncGeneratorPrototype* JSC__JSGlobalObject__asyncGeneratorPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__AsyncIteratorPrototype* JSC__JSGlobalObject__asyncIteratorPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__BigIntPrototype* JSC__JSGlobalObject__bigIntPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__JSObject* JSC__JSGlobalObject__booleanPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL VirtualMachine* JSC__JSGlobalObject__bunVM(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__JSValue JSC__JSGlobalObject__createAggregateError(JSC__JSGlobalObject* arg0, void** arg1, uint16_t arg2, const ZigString* arg3);
+CPP_DECL JSC__JSObject* JSC__JSGlobalObject__datePrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL void JSC__JSGlobalObject__deleteModuleRegistryEntry(JSC__JSGlobalObject* arg0, ZigString* arg1);
+CPP_DECL JSC__JSObject* JSC__JSGlobalObject__errorPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__FunctionPrototype* JSC__JSGlobalObject__functionPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__JSValue JSC__JSGlobalObject__generateHeapSnapshot(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__GeneratorFunctionPrototype* JSC__JSGlobalObject__generatorFunctionPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__GeneratorPrototype* JSC__JSGlobalObject__generatorPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__JSValue JSC__JSGlobalObject__getCachedObject(JSC__JSGlobalObject* arg0, const ZigString* arg1);
+CPP_DECL JSC__IteratorPrototype* JSC__JSGlobalObject__iteratorPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__JSObject* JSC__JSGlobalObject__jsSetPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__MapIteratorPrototype* JSC__JSGlobalObject__mapIteratorPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__JSObject* JSC__JSGlobalObject__mapPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__JSObject* JSC__JSGlobalObject__numberPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__ObjectPrototype* JSC__JSGlobalObject__objectPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__JSPromisePrototype* JSC__JSGlobalObject__promisePrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__JSValue JSC__JSGlobalObject__putCachedObject(JSC__JSGlobalObject* arg0, const ZigString* arg1, JSC__JSValue JSValue2);
+CPP_DECL JSC__RegExpPrototype* JSC__JSGlobalObject__regExpPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__SetIteratorPrototype* JSC__JSGlobalObject__setIteratorPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__StringPrototype* JSC__JSGlobalObject__stringPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__JSObject* JSC__JSGlobalObject__symbolPrototype(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__VM* JSC__JSGlobalObject__vm(JSC__JSGlobalObject* arg0);
+
+#pragma mark - WTF::URL
+
+CPP_DECL bWTF__StringView WTF__URL__encodedPassword(WTF__URL* arg0);
+CPP_DECL bWTF__StringView WTF__URL__encodedUser(WTF__URL* arg0);
+CPP_DECL bWTF__String WTF__URL__fileSystemPath(WTF__URL* arg0);
+CPP_DECL bWTF__StringView WTF__URL__fragmentIdentifier(WTF__URL* arg0);
+CPP_DECL bWTF__StringView WTF__URL__fragmentIdentifierWithLeadingNumberSign(WTF__URL* arg0);
+CPP_DECL void WTF__URL__fromFileSystemPath(WTF__URL* arg0, bWTF__StringView arg1);
+CPP_DECL bWTF__URL WTF__URL__fromString(bWTF__String arg0, bWTF__String arg1);
+CPP_DECL bWTF__StringView WTF__URL__host(WTF__URL* arg0);
+CPP_DECL bWTF__String WTF__URL__hostAndPort(WTF__URL* arg0);
+CPP_DECL bool WTF__URL__isEmpty(const WTF__URL* arg0);
+CPP_DECL bool WTF__URL__isValid(const WTF__URL* arg0);
+CPP_DECL bWTF__StringView WTF__URL__lastPathComponent(WTF__URL* arg0);
+CPP_DECL bWTF__String WTF__URL__password(WTF__URL* arg0);
+CPP_DECL bWTF__StringView WTF__URL__path(WTF__URL* arg0);
+CPP_DECL bWTF__StringView WTF__URL__protocol(WTF__URL* arg0);
+CPP_DECL bWTF__String WTF__URL__protocolHostAndPort(WTF__URL* arg0);
+CPP_DECL bWTF__StringView WTF__URL__query(WTF__URL* arg0);
+CPP_DECL bWTF__StringView WTF__URL__queryWithLeadingQuestionMark(WTF__URL* arg0);
+CPP_DECL void WTF__URL__setHost(WTF__URL* arg0, bWTF__StringView arg1);
+CPP_DECL void WTF__URL__setHostAndPort(WTF__URL* arg0, bWTF__StringView arg1);
+CPP_DECL void WTF__URL__setPassword(WTF__URL* arg0, bWTF__StringView arg1);
+CPP_DECL void WTF__URL__setPath(WTF__URL* arg0, bWTF__StringView arg1);
+CPP_DECL void WTF__URL__setProtocol(WTF__URL* arg0, bWTF__StringView arg1);
+CPP_DECL void WTF__URL__setQuery(WTF__URL* arg0, bWTF__StringView arg1);
+CPP_DECL void WTF__URL__setUser(WTF__URL* arg0, bWTF__StringView arg1);
+CPP_DECL bWTF__String WTF__URL__stringWithoutFragmentIdentifier(WTF__URL* arg0);
+CPP_DECL bWTF__StringView WTF__URL__stringWithoutQueryOrFragmentIdentifier(WTF__URL* arg0);
+CPP_DECL bWTF__URL WTF__URL__truncatedForUseAsBase(WTF__URL* arg0);
+CPP_DECL bWTF__String WTF__URL__user(WTF__URL* arg0);
+
+#pragma mark - WTF::String
+
+CPP_DECL const uint16_t* WTF__String__characters16(WTF__String* arg0);
+CPP_DECL const unsigned char* WTF__String__characters8(WTF__String* arg0);
+CPP_DECL bWTF__String WTF__String__createFromExternalString(bWTF__ExternalStringImpl arg0);
+CPP_DECL void WTF__String__createWithoutCopyingFromPtr(WTF__String* arg0, const unsigned char* arg1, size_t arg2);
+CPP_DECL bool WTF__String__eqlSlice(WTF__String* arg0, const unsigned char* arg1, size_t arg2);
+CPP_DECL bool WTF__String__eqlString(WTF__String* arg0, const WTF__String* arg1);
+CPP_DECL const WTF__StringImpl* WTF__String__impl(WTF__String* arg0);
+CPP_DECL bool WTF__String__is16Bit(WTF__String* arg0);
+CPP_DECL bool WTF__String__is8Bit(WTF__String* arg0);
+CPP_DECL bool WTF__String__isEmpty(WTF__String* arg0);
+CPP_DECL bool WTF__String__isExternal(WTF__String* arg0);
+CPP_DECL bool WTF__String__isStatic(WTF__String* arg0);
+CPP_DECL size_t WTF__String__length(WTF__String* arg0);
+
+#pragma mark - JSC::JSValue
+
+CPP_DECL void JSC__JSValue___then(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void* arg2, void (* ArgFn3)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3), void (* ArgFn4)(JSC__JSGlobalObject* arg0, void* arg1, void** arg2, size_t arg3));
+CPP_DECL bool JSC__JSValue__asArrayBuffer_(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, Bun__ArrayBuffer* arg2);
+CPP_DECL JSC__JSCell* JSC__JSValue__asCell(JSC__JSValue JSValue0);
+CPP_DECL JSC__JSInternalPromise* JSC__JSValue__asInternalPromise(JSC__JSValue JSValue0);
+CPP_DECL double JSC__JSValue__asNumber(JSC__JSValue JSValue0);
+CPP_DECL bJSC__JSObject JSC__JSValue__asObject(JSC__JSValue JSValue0);
+CPP_DECL JSC__JSPromise* JSC__JSValue__asPromise(JSC__JSValue JSValue0);
+CPP_DECL JSC__JSPromise* JSC__JSValue__asPromise(JSC__JSValue JSValue0);
+CPP_DECL JSC__JSString* JSC__JSValue__asString(JSC__JSValue JSValue0);
+CPP_DECL JSC__JSValue JSC__JSValue__createEmptyObject(JSC__JSGlobalObject* arg0, size_t arg1);
+CPP_DECL JSC__JSValue JSC__JSValue__createInternalPromise(JSC__JSGlobalObject* arg0);
+CPP_DECL JSC__JSValue JSC__JSValue__createObject2(JSC__JSGlobalObject* arg0, const ZigString* arg1, const ZigString* arg2, JSC__JSValue JSValue3, JSC__JSValue JSValue4);
+CPP_DECL JSC__JSValue JSC__JSValue__createRangeError(const ZigString* arg0, const ZigString* arg1, JSC__JSGlobalObject* arg2);
+CPP_DECL JSC__JSValue JSC__JSValue__createStringArray(JSC__JSGlobalObject* arg0, ZigString* arg1, size_t arg2, bool arg3);
+CPP_DECL JSC__JSValue JSC__JSValue__createTypeError(const ZigString* arg0, const ZigString* arg1, JSC__JSGlobalObject* arg2);
+CPP_DECL JSC__JSValue JSC__JSValue__createUninitializedUint8Array(JSC__JSGlobalObject* arg0, size_t arg1);
+CPP_DECL bool JSC__JSValue__eqlCell(JSC__JSValue JSValue0, JSC__JSCell* arg1);
+CPP_DECL bool JSC__JSValue__eqlValue(JSC__JSValue JSValue0, JSC__JSValue JSValue1);
+CPP_DECL void JSC__JSValue__forEach(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, void* arg2, void (* ArgFn3)(JSC__VM* arg0, JSC__JSGlobalObject* arg1, void* arg2, JSC__JSValue JSValue3));
+CPP_DECL JSC__JSValue JSC__JSValue__fromEntries(JSC__JSGlobalObject* arg0, ZigString* arg1, ZigString* arg2, size_t arg3, bool arg4);
+CPP_DECL JSC__JSValue JSC__JSValue__fromInt64NoTruncate(JSC__JSGlobalObject* arg0, int64_t arg1);
+CPP_DECL JSC__JSValue JSC__JSValue__fromUInt64NoTruncate(JSC__JSGlobalObject* arg0, uint64_t arg1);
+CPP_DECL void JSC__JSValue__getClassName(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2);
+CPP_DECL JSC__JSValue JSC__JSValue__getErrorsProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL JSC__JSValue JSC__JSValue__getIfPropertyExistsImpl(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, uint32_t arg3);
+CPP_DECL uint32_t JSC__JSValue__getLengthOfArray(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL void JSC__JSValue__getNameProperty(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2);
+CPP_DECL JSC__JSValue JSC__JSValue__getPrototype(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL Bun__Readable* JSC__JSValue__getReadableStreamState(JSC__JSValue JSValue0, JSC__VM* arg1);
+CPP_DECL void JSC__JSValue__getSymbolDescription(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2);
+CPP_DECL Bun__Writable* JSC__JSValue__getWritableStreamState(JSC__JSValue JSValue0, JSC__VM* arg1);
+CPP_DECL bool JSC__JSValue__isAggregateError(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL bool JSC__JSValue__isAnyInt(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isBigInt(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isBigInt32(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isBoolean(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isCallable(JSC__JSValue JSValue0, JSC__VM* arg1);
+CPP_DECL bool JSC__JSValue__isCell(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isClass(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL bool JSC__JSValue__isCustomGetterSetter(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isError(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isException(JSC__JSValue JSValue0, JSC__VM* arg1);
+CPP_DECL bool JSC__JSValue__isGetterSetter(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isHeapBigInt(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isInt32(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isInt32AsAnyInt(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isIterable(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL bool JSC__JSValue__isNumber(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isObject(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isPrimitive(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isSameValue(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2);
+CPP_DECL bool JSC__JSValue__isString(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isSymbol(JSC__JSValue JSValue0);
+CPP_DECL bool JSC__JSValue__isTerminationException(JSC__JSValue JSValue0, JSC__VM* arg1);
+CPP_DECL bool JSC__JSValue__isUInt32AsAnyInt(JSC__JSValue JSValue0);
+CPP_DECL JSC__JSValue JSC__JSValue__jsBoolean(bool arg0);
+CPP_DECL JSC__JSValue JSC__JSValue__jsDoubleNumber(double arg0);
+CPP_DECL JSC__JSValue JSC__JSValue__jsNull();
+CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromChar(unsigned char arg0);
+CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromDouble(double arg0);
+CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromInt32(int32_t arg0);
+CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromInt64(int64_t arg0);
+CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromU16(uint16_t arg0);
+CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromUint64(uint64_t arg0);
+CPP_DECL void JSC__JSValue__jsonStringify(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, uint32_t arg2, ZigString* arg3);
+CPP_DECL JSC__JSValue JSC__JSValue__jsTDZValue();
+CPP_DECL unsigned char JSC__JSValue__jsType(JSC__JSValue JSValue0);
+CPP_DECL JSC__JSValue JSC__JSValue__jsUndefined();
+CPP_DECL JSC__JSValue JSC__JSValue__makeWithNameAndPrototype(JSC__JSGlobalObject* arg0, void* arg1, void* arg2, const ZigString* arg3);
+CPP_DECL JSC__JSValue JSC__JSValue__parseJSON(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL void JSC__JSValue__put(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, const ZigString* arg2, JSC__JSValue JSValue3);
+CPP_DECL void JSC__JSValue__putRecord(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2, ZigString* arg3, size_t arg4);
+CPP_DECL JSC__JSValue JSC__JSValue__symbolFor(JSC__JSGlobalObject* arg0, ZigString* arg1);
+CPP_DECL bool JSC__JSValue__symbolKeyFor(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigString* arg2);
+CPP_DECL bool JSC__JSValue__toBoolean(JSC__JSValue JSValue0);
+CPP_DECL int32_t JSC__JSValue__toInt32(JSC__JSValue JSValue0);
+CPP_DECL int64_t JSC__JSValue__toInt64(JSC__JSValue JSValue0);
+CPP_DECL JSC__JSObject* JSC__JSValue__toObject(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL bJSC__Identifier JSC__JSValue__toPropertyKey(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL JSC__JSValue JSC__JSValue__toPropertyKeyValue(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL JSC__JSString* JSC__JSValue__toString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL JSC__JSString* JSC__JSValue__toString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL JSC__JSString* JSC__JSValue__toStringOrNull(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL uint64_t JSC__JSValue__toUInt64NoTruncate(JSC__JSValue JSValue0);
+CPP_DECL bWTF__String JSC__JSValue__toWTFString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1);
+CPP_DECL void JSC__JSValue__toZigException(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, ZigException* arg2);
+CPP_DECL void JSC__JSValue__toZigString(JSC__JSValue JSValue0, ZigString* arg1, JSC__JSGlobalObject* arg2);
+
+#pragma mark - JSC::PropertyName
+
+CPP_DECL bool JSC__PropertyName__eqlToIdentifier(JSC__PropertyName* arg0, const JSC__Identifier* arg1);
+CPP_DECL bool JSC__PropertyName__eqlToPropertyName(JSC__PropertyName* arg0, const JSC__PropertyName* arg1);
+CPP_DECL const WTF__StringImpl* JSC__PropertyName__publicName(JSC__PropertyName* arg0);
+CPP_DECL const WTF__StringImpl* JSC__PropertyName__uid(JSC__PropertyName* arg0);
+
+#pragma mark - JSC::Exception
+
+CPP_DECL JSC__Exception* JSC__Exception__create(JSC__JSGlobalObject* arg0, JSC__JSObject* arg1, unsigned char StackCaptureAction2);
+CPP_DECL void JSC__Exception__getStackTrace(JSC__Exception* arg0, ZigStackTrace* arg1);
+CPP_DECL JSC__JSValue JSC__Exception__value(JSC__Exception* arg0);
+
+#pragma mark - JSC::VM
+
+CPP_DECL void JSC__VM__clearExecutionTimeLimit(JSC__VM* arg0);
+CPP_DECL JSC__VM* JSC__VM__create(unsigned char HeapType0);
+CPP_DECL void JSC__VM__deferGC(JSC__VM* arg0, void* arg1, void (* ArgFn2)(void* arg0));
+CPP_DECL void JSC__VM__deinit(JSC__VM* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL void JSC__VM__deleteAllCode(JSC__VM* arg0, JSC__JSGlobalObject* arg1);
+CPP_DECL void JSC__VM__doWork(JSC__VM* arg0);
+CPP_DECL void JSC__VM__drainMicrotasks(JSC__VM* arg0);
+CPP_DECL bool JSC__VM__executionForbidden(JSC__VM* arg0);
+CPP_DECL void JSC__VM__holdAPILock(JSC__VM* arg0, void* arg1, void (* ArgFn2)(void* arg0));
+CPP_DECL bool JSC__VM__isEntered(JSC__VM* arg0);
+CPP_DECL bool JSC__VM__isJITEnabled();
+CPP_DECL void JSC__VM__releaseWeakRefs(JSC__VM* arg0);
+CPP_DECL JSC__JSValue JSC__VM__runGC(JSC__VM* arg0, bool arg1);
+CPP_DECL void JSC__VM__setExecutionForbidden(JSC__VM* arg0, bool arg1);
+CPP_DECL void JSC__VM__setExecutionTimeLimit(JSC__VM* arg0, double arg1);
+CPP_DECL void JSC__VM__shrinkFootprint(JSC__VM* arg0);
+CPP_DECL void JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2);
+CPP_DECL void JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2);
+CPP_DECL void JSC__VM__whenIdle(JSC__VM* arg0, void (* ArgFn1)());
+
+#pragma mark - JSC::ThrowScope
+
+CPP_DECL void JSC__ThrowScope__clearException(JSC__ThrowScope* arg0);
+CPP_DECL bJSC__ThrowScope JSC__ThrowScope__declare(JSC__VM* arg0, unsigned char* arg1, unsigned char* arg2, size_t arg3);
+CPP_DECL JSC__Exception* JSC__ThrowScope__exception(JSC__ThrowScope* arg0);
+CPP_DECL void JSC__ThrowScope__release(JSC__ThrowScope* arg0);
+
+#pragma mark - JSC::CatchScope
+
+CPP_DECL void JSC__CatchScope__clearException(JSC__CatchScope* arg0);
+CPP_DECL bJSC__CatchScope JSC__CatchScope__declare(JSC__VM* arg0, unsigned char* arg1, unsigned char* arg2, size_t arg3);
+CPP_DECL JSC__Exception* JSC__CatchScope__exception(JSC__CatchScope* arg0);
+
+#pragma mark - JSC::Identifier
+
+CPP_DECL void JSC__Identifier__deinit(const JSC__Identifier* arg0);
+CPP_DECL bool JSC__Identifier__eqlIdent(const JSC__Identifier* arg0, const JSC__Identifier* arg1);
+CPP_DECL bool JSC__Identifier__eqlStringImpl(const JSC__Identifier* arg0, const WTF__StringImpl* arg1);
+CPP_DECL bool JSC__Identifier__eqlUTF8(const JSC__Identifier* arg0, const unsigned char* arg1, size_t arg2);
+CPP_DECL bJSC__Identifier JSC__Identifier__fromSlice(JSC__VM* arg0, const unsigned char* arg1, size_t arg2);
+CPP_DECL bJSC__Identifier JSC__Identifier__fromString(JSC__VM* arg0, const WTF__String* arg1);
+CPP_DECL bool JSC__Identifier__isEmpty(const JSC__Identifier* arg0);
+CPP_DECL bool JSC__Identifier__isNull(const JSC__Identifier* arg0);
+CPP_DECL bool JSC__Identifier__isPrivateName(const JSC__Identifier* arg0);
+CPP_DECL bool JSC__Identifier__isSymbol(const JSC__Identifier* arg0);
+CPP_DECL size_t JSC__Identifier__length(const JSC__Identifier* arg0);
+CPP_DECL bool JSC__Identifier__neqlIdent(const JSC__Identifier* arg0, const JSC__Identifier* arg1);
+CPP_DECL bool JSC__Identifier__neqlStringImpl(const JSC__Identifier* arg0, const WTF__StringImpl* arg1);
+CPP_DECL bWTF__String JSC__Identifier__toString(const JSC__Identifier* arg0);
+
+#pragma mark - WTF::StringImpl
+
+CPP_DECL const uint16_t* WTF__StringImpl__characters16(const WTF__StringImpl* arg0);
+CPP_DECL const unsigned char* WTF__StringImpl__characters8(const WTF__StringImpl* arg0);
+CPP_DECL bool WTF__StringImpl__is16Bit(const WTF__StringImpl* arg0);
+CPP_DECL bool WTF__StringImpl__is8Bit(const WTF__StringImpl* arg0);
+CPP_DECL bool WTF__StringImpl__isEmpty(const WTF__StringImpl* arg0);
+CPP_DECL bool WTF__StringImpl__isExternal(const WTF__StringImpl* arg0);
+CPP_DECL bool WTF__StringImpl__isStatic(const WTF__StringImpl* arg0);
+CPP_DECL size_t WTF__StringImpl__length(const WTF__StringImpl* arg0);
+
+#pragma mark - WTF::ExternalStringImpl
+
+CPP_DECL const uint16_t* WTF__ExternalStringImpl__characters16(const WTF__ExternalStringImpl* arg0);
+CPP_DECL const unsigned char* WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl* arg0);
+CPP_DECL bWTF__ExternalStringImpl WTF__ExternalStringImpl__create(const unsigned char* arg0, size_t arg1, void (* ArgFn2)(void* arg0, unsigned char* arg1, size_t arg2));
+CPP_DECL bool WTF__ExternalStringImpl__is16Bit(const WTF__ExternalStringImpl* arg0);
+CPP_DECL bool WTF__ExternalStringImpl__is8Bit(const WTF__ExternalStringImpl* arg0);
+CPP_DECL bool WTF__ExternalStringImpl__isEmpty(const WTF__ExternalStringImpl* arg0);
+CPP_DECL size_t WTF__ExternalStringImpl__length(const WTF__ExternalStringImpl* arg0);
+
+#pragma mark - WTF::StringView
+
+CPP_DECL const uint16_t* WTF__StringView__characters16(const WTF__StringView* arg0);
+CPP_DECL const unsigned char* WTF__StringView__characters8(const WTF__StringView* arg0);
+CPP_DECL void WTF__StringView__from8Bit(WTF__StringView* arg0, const unsigned char* arg1, size_t arg2);
+CPP_DECL bool WTF__StringView__is16Bit(const WTF__StringView* arg0);
+CPP_DECL bool WTF__StringView__is8Bit(const WTF__StringView* arg0);
+CPP_DECL bool WTF__StringView__isEmpty(const WTF__StringView* arg0);
+CPP_DECL size_t WTF__StringView__length(const WTF__StringView* arg0);
+
+#pragma mark - Zig::GlobalObject
+
+CPP_DECL JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* arg0, int32_t arg1, void* arg2);
+CPP_DECL void* Zig__GlobalObject__getModuleRegistryMap(JSC__JSGlobalObject* arg0);
+CPP_DECL bool Zig__GlobalObject__resetModuleRegistryMap(JSC__JSGlobalObject* arg0, void* arg1);
+
+#ifdef __cplusplus
+
+ZIG_DECL JSC__JSValue Zig__GlobalObject__createImportMetaProperties(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSModuleRecord* arg3, JSC__JSValue JSValue4);
+ZIG_DECL void Zig__GlobalObject__fetch(ErrorableResolvedSource* arg0, JSC__JSGlobalObject* arg1, ZigString* arg2, ZigString* arg3);
+ZIG_DECL ErrorableZigString Zig__GlobalObject__import(JSC__JSGlobalObject* arg0, ZigString* arg1, ZigString* arg2);
+ZIG_DECL void Zig__GlobalObject__onCrash();
+ZIG_DECL JSC__JSValue Zig__GlobalObject__promiseRejectionTracker(JSC__JSGlobalObject* arg0, JSC__JSPromise* arg1, uint32_t JSPromiseRejectionOperation2);
+ZIG_DECL void Zig__GlobalObject__queueMicrotaskToEventLoop(JSC__JSGlobalObject* arg0, Zig__JSMicrotaskCallback* arg1);
+ZIG_DECL JSC__JSValue Zig__GlobalObject__reportUncaughtException(JSC__JSGlobalObject* arg0, JSC__Exception* arg1);
+ZIG_DECL void Zig__GlobalObject__resolve(ErrorableZigString* arg0, JSC__JSGlobalObject* arg1, ZigString* arg2, ZigString* arg3);
+
+#endif
+
+#ifdef __cplusplus
+
+ZIG_DECL bool Zig__ErrorType__isPrivateData(void* arg0);
+
+#endif
+
+#pragma mark - Bun__Readable
+
+CPP_DECL JSC__JSValue Bun__Readable__create(Bun__Readable* arg0, JSC__JSGlobalObject* arg1);
+
+#ifdef __cplusplus
+
+ZIG_DECL void Bun__Readable__addEventListener(Bun__Readable* arg0, JSC__JSGlobalObject* arg1, unsigned char Events2, JSC__JSValue JSValue3, bool arg4);
+ZIG_DECL void Bun__Readable__deinit(Bun__Readable* arg0);
+ZIG_DECL JSC__JSValue Bun__Readable__pause(Bun__Readable* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Readable__pipe(Bun__Readable* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL void Bun__Readable__prependEventListener(Bun__Readable* arg0, JSC__JSGlobalObject* arg1, unsigned char Events2, JSC__JSValue JSValue3, bool arg4);
+ZIG_DECL JSC__JSValue Bun__Readable__read(Bun__Readable* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL bool Bun__Readable__removeEventListener(Bun__Readable* arg0, JSC__JSGlobalObject* arg1, unsigned char Events2, JSC__JSValue JSValue3);
+ZIG_DECL JSC__JSValue Bun__Readable__resume(Bun__Readable* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Readable__unpipe(Bun__Readable* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Readable__unshift(Bun__Readable* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, uint16_t arg3);
+
+#endif
+
+#pragma mark - Bun__Writable
+
+CPP_DECL JSC__JSValue Bun__Writable__create(Bun__Writable* arg0, JSC__JSGlobalObject* arg1);
+
+#ifdef __cplusplus
+
+ZIG_DECL void Bun__Writable__addEventListener(Bun__Writable* arg0, JSC__JSGlobalObject* arg1, unsigned char Events2, JSC__JSValue JSValue3, bool arg4);
+ZIG_DECL JSC__JSValue Bun__Writable__close(Bun__Writable* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Writable__cork(Bun__Writable* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL void Bun__Writable__deinit(Bun__Writable* arg0);
+ZIG_DECL JSC__JSValue Bun__Writable__destroy(Bun__Writable* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Writable__end(Bun__Writable* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL void Bun__Writable__prependEventListener(Bun__Writable* arg0, JSC__JSGlobalObject* arg1, unsigned char Events2, JSC__JSValue JSValue3, bool arg4);
+ZIG_DECL bool Bun__Writable__removeEventListener(Bun__Writable* arg0, JSC__JSGlobalObject* arg1, unsigned char Events2, JSC__JSValue JSValue3);
+ZIG_DECL JSC__JSValue Bun__Writable__uncork(Bun__Writable* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Writable__write(Bun__Writable* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, uint16_t arg3);
+
+#endif
+
+#pragma mark - Bun__Path
+
+CPP_DECL JSC__JSValue Bun__Path__create(JSC__JSGlobalObject* arg0, bool arg1);
+
+#ifdef __cplusplus
+
+ZIG_DECL JSC__JSValue Bun__Path__basename(JSC__JSGlobalObject* arg0, bool arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Path__dirname(JSC__JSGlobalObject* arg0, bool arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Path__extname(JSC__JSGlobalObject* arg0, bool arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Path__format(JSC__JSGlobalObject* arg0, bool arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Path__isAbsolute(JSC__JSGlobalObject* arg0, bool arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Path__join(JSC__JSGlobalObject* arg0, bool arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Path__normalize(JSC__JSGlobalObject* arg0, bool arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Path__parse(JSC__JSGlobalObject* arg0, bool arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Path__relative(JSC__JSGlobalObject* arg0, bool arg1, JSC__JSValue* arg2, uint16_t arg3);
+ZIG_DECL JSC__JSValue Bun__Path__resolve(JSC__JSGlobalObject* arg0, bool arg1, JSC__JSValue* arg2, uint16_t arg3);
+
+#endif
+
+#ifdef __cplusplus
+
+ZIG_DECL JSC__JSValue ByteBlob__JSReadableStreamSource__load(JSC__JSGlobalObject* arg0);
+
+#endif
+
+#ifdef __cplusplus
+
+ZIG_DECL JSC__JSValue FileBlobLoader__JSReadableStreamSource__load(JSC__JSGlobalObject* arg0);
+
+#endif
+
+#ifdef __cplusplus
+
+ZIG_DECL void Bun__Process__exit(JSC__JSGlobalObject* arg0, int32_t arg1);
+ZIG_DECL JSC__JSValue Bun__Process__getArgv(JSC__JSGlobalObject* arg0);
+ZIG_DECL JSC__JSValue Bun__Process__getCwd(JSC__JSGlobalObject* arg0);
+ZIG_DECL void Bun__Process__getTitle(JSC__JSGlobalObject* arg0, ZigString* arg1);
+ZIG_DECL JSC__JSValue Bun__Process__setCwd(JSC__JSGlobalObject* arg0, ZigString* arg1);
+ZIG_DECL JSC__JSValue Bun__Process__setTitle(JSC__JSGlobalObject* arg0, ZigString* arg1);
+
+#endif
+CPP_DECL ZigException ZigException__fromException(JSC__Exception* arg0);
+
+#pragma mark - Zig::ConsoleClient
+
+
+#ifdef __cplusplus
+
+ZIG_DECL void Zig__ConsoleClient__count(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3);
+ZIG_DECL void Zig__ConsoleClient__countReset(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3);
+ZIG_DECL void Zig__ConsoleClient__messageWithTypeAndLevel(void* arg0, uint32_t MessageType1, uint32_t MessageLevel2, JSC__JSGlobalObject* arg3, JSC__JSValue* arg4, size_t arg5);
+ZIG_DECL void Zig__ConsoleClient__profile(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3);
+ZIG_DECL void Zig__ConsoleClient__profileEnd(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3);
+ZIG_DECL void Zig__ConsoleClient__record(void* arg0, JSC__JSGlobalObject* arg1, Inspector__ScriptArguments* arg2);
+ZIG_DECL void Zig__ConsoleClient__recordEnd(void* arg0, JSC__JSGlobalObject* arg1, Inspector__ScriptArguments* arg2);
+ZIG_DECL void Zig__ConsoleClient__screenshot(void* arg0, JSC__JSGlobalObject* arg1, Inspector__ScriptArguments* arg2);
+ZIG_DECL void Zig__ConsoleClient__takeHeapSnapshot(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3);
+ZIG_DECL void Zig__ConsoleClient__time(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3);
+ZIG_DECL void Zig__ConsoleClient__timeEnd(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3);
+ZIG_DECL void Zig__ConsoleClient__timeLog(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3, Inspector__ScriptArguments* arg4);
+ZIG_DECL void Zig__ConsoleClient__timeStamp(void* arg0, JSC__JSGlobalObject* arg1, Inspector__ScriptArguments* arg2);
+
+#endif
+
+#pragma mark - Bun__Timer
+
+
+#ifdef __cplusplus
+
+ZIG_DECL JSC__JSValue Bun__Timer__clearInterval(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
+ZIG_DECL JSC__JSValue Bun__Timer__clearTimeout(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1);
+ZIG_DECL int32_t Bun__Timer__getNextID();
+ZIG_DECL JSC__JSValue Bun__Timer__setInterval(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue JSValue2);
+ZIG_DECL JSC__JSValue Bun__Timer__setTimeout(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue JSValue2);
+
+#endif
diff --git a/src/javascript/jsc/bindings/headers.zig b/src/javascript/jsc/bindings/headers.zig
index 3b74bd4cd..ce7cbee1e 100644
--- a/src/javascript/jsc/bindings/headers.zig
+++ b/src/javascript/jsc/bindings/headers.zig
@@ -62,6 +62,7 @@ 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;
+pub const struct_VirtualMachine = bindings.VirtualMachine;
// GENERATED CODE - DO NOT MODIFY BY HAND
pub const ptrdiff_t = c_long;
@@ -76,6 +77,8 @@ pub const __mbstate_t = extern union {
_mbstateL: c_longlong,
};
+pub const VirtualMachine = struct_VirtualMachine;
+
pub const JSC__GeneratorPrototype = struct_JSC__GeneratorPrototype;
pub const JSC__ArrayIteratorPrototype = struct_JSC__ArrayIteratorPrototype;
@@ -108,10 +111,9 @@ 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 JSC__MapIteratorPrototype = struct_JSC__MapIteratorPrototype;
pub const WebCore__FetchHeaders = struct_WebCore__FetchHeaders;
pub const WTF__StringView = bWTF__StringView;
@@ -180,6 +182,7 @@ pub extern fn JSC__JSString__createFromOwnedString(arg0: [*c]JSC__VM, arg1: [*c]
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__iterator(arg0: [*c]JSC__JSString, arg1: [*c]JSC__JSGlobalObject, arg2: ?*anyopaque) void;
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;
@@ -223,15 +226,6 @@ pub extern fn JSC__JSInternalPromise__status(arg0: [*c]const JSC__JSInternalProm
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;
@@ -242,6 +236,7 @@ pub extern fn JSC__JSGlobalObject__asyncGeneratorPrototype(arg0: [*c]JSC__JSGlob
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__bunVM(arg0: [*c]JSC__JSGlobalObject) ?*VirtualMachine;
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;
@@ -306,7 +301,7 @@ 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___then(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject, arg2: ?*anyopaque, ArgFn3: ?fn ([*c]JSC__JSGlobalObject, ?*anyopaque, [*c]*anyopaque, usize) callconv(.C) void, ArgFn4: ?fn ([*c]JSC__JSGlobalObject, ?*anyopaque, [*c]*anyopaque, 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;
@@ -320,6 +315,7 @@ pub extern fn JSC__JSValue__createObject2(arg0: [*c]JSC__JSGlobalObject, arg1: [
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__createUninitializedUint8Array(arg0: [*c]JSC__JSGlobalObject, arg1: usize) 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;
@@ -408,11 +404,12 @@ 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__releaseWeakRefs(arg0: [*c]JSC__VM) void;
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__throwError(arg0: [*c]JSC__VM, arg1: [*c]JSC__JSGlobalObject, JSValue2: JSC__JSValue) void;
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;
@@ -421,14 +418,6 @@ 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;
diff --git a/src/javascript/jsc/bindings/helpers.h b/src/javascript/jsc/bindings/helpers.h
index 7b72b3566..8523aadbf 100644
--- a/src/javascript/jsc/bindings/helpers.h
+++ b/src/javascript/jsc/bindings/helpers.h
@@ -58,9 +58,6 @@ template<class To, class From> To ccast(From v)
return *static_cast<const To*>(static_cast<const void*>(v));
}
-typedef JSC__JSValue (*NativeCallbackFunction)(void* arg0, JSC__JSGlobalObject* arg1,
- JSC__CallFrame* arg2);
-
static const JSC::ArgList makeArgs(JSC__JSValue* v, size_t count)
{
JSC::MarkedArgumentBuffer args = JSC::MarkedArgumentBuffer();
@@ -295,3 +292,15 @@ static JSC::JSValue getErrorInstance(const ZigString* str, JSC__JSGlobalObject*
}
}; // namespace Zig
+
+template<typename WebCoreType, typename OutType>
+OutType* WebCoreCast(JSC__JSValue JSValue0)
+{
+ // we must use jsDynamicCast here so that we check that the type is correct
+ WebCoreType* jsdomURL = JSC::jsDynamicCast<WebCoreType*>(JSC::JSValue::decode(JSValue0));
+ if (jsdomURL == nullptr) {
+ return nullptr;
+ }
+
+ return reinterpret_cast<OutType*>(&jsdomURL->wrapped());
+}
diff --git a/src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp b/src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp
index c39e2961e..7f740ae66 100644
--- a/src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp
+++ b/src/javascript/jsc/bindings/sqlite/JSSQLStatement.cpp
@@ -855,15 +855,15 @@ JSC_DEFINE_HOST_FUNCTION(jsSQLStatementCloseStatementFunction, (JSC::JSGlobalObj
/* Hash table for constructor */
static const HashTableValue JSSQLStatementConstructorTableValues[] = {
- { "open", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementOpenStatementFunction), (intptr_t)(2) } },
- { "close", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementCloseStatementFunction), (intptr_t)(1) } },
- { "prepare", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementPrepareStatementFunction), (intptr_t)(2) } },
- { "run", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementExecuteFunction), (intptr_t)(3) } },
- { "isInTransaction", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementIsInTransactionFunction), (intptr_t)(1) } },
- { "loadExtension", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementLoadExtensionFunction), (intptr_t)(2) } },
- { "setCustomSQLite", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementSetCustomSQLite), (intptr_t)(1) } },
- { "serialize", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementSerialize), (intptr_t)(1) } },
- { "deserialize", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementDeserialize), (intptr_t)(2) } },
+ { "open"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementOpenStatementFunction), (intptr_t)(2) } },
+ { "close"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementCloseStatementFunction), (intptr_t)(1) } },
+ { "prepare"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementPrepareStatementFunction), (intptr_t)(2) } },
+ { "run"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementExecuteFunction), (intptr_t)(3) } },
+ { "isInTransaction"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementIsInTransactionFunction), (intptr_t)(1) } },
+ { "loadExtension"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementLoadExtensionFunction), (intptr_t)(2) } },
+ { "setCustomSQLite"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementSetCustomSQLite), (intptr_t)(1) } },
+ { "serialize"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementSerialize), (intptr_t)(1) } },
+ { "deserialize"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementDeserialize), (intptr_t)(2) } },
};
const ClassInfo JSSQLStatementConstructor::s_info = { "SQLStatement"_s, nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(JSSQLStatementConstructor) };
@@ -1358,15 +1358,15 @@ const ClassInfo JSSQLStatement::s_info = { "SQLStatement"_s, nullptr, nullptr, n
/* Hash table for prototype */
static const HashTableValue JSSQLStatementTableValues[] = {
- { "run", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementExecuteStatementFunctionRun), (intptr_t)(1) } },
- { "get", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementExecuteStatementFunctionGet), (intptr_t)(1) } },
- { "all", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementExecuteStatementFunctionAll), (intptr_t)(1) } },
- { "values", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementExecuteStatementFunctionRows), (intptr_t)(1) } },
- { "finalize", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementFunctionFinalize), (intptr_t)(0) } },
- { "toString", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementToStringFunction), (intptr_t)(0) } },
- { "columns", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsSqlStatementGetColumnNames), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "columnsCount", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsSqlStatementGetColumnCount), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "paramsCount", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsSqlStatementGetParamCount), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "run"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementExecuteStatementFunctionRun), (intptr_t)(1) } },
+ { "get"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementExecuteStatementFunctionGet), (intptr_t)(1) } },
+ { "all"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementExecuteStatementFunctionAll), (intptr_t)(1) } },
+ { "values"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementExecuteStatementFunctionRows), (intptr_t)(1) } },
+ { "finalize"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementFunctionFinalize), (intptr_t)(0) } },
+ { "toString"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsSQLStatementToStringFunction), (intptr_t)(0) } },
+ { "columns"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsSqlStatementGetColumnNames), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "columnsCount"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsSqlStatementGetColumnCount), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "paramsCount"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsSqlStatementGetParamCount), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
};
void JSSQLStatement::finishCreation(VM& vm)
diff --git a/src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h b/src/javascript/jsc/bindings/webcore/DOMClientIsoSubspaces.h
index c4ab49dd2..14e748a9a 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;
@@ -452,7 +450,7 @@ public:
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextDecoder;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextDecoderStream;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextDecoderStreamDecoder;
- // std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextEncoder;
+ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextEncoder;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextEncoderStream;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextEncoderStreamEncoder;
// std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextEvent;
@@ -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..b434ff771 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;
@@ -444,7 +443,7 @@ public:
// std::unique_ptr<IsoSubspace> m_subspaceForTextDecoder;
// std::unique_ptr<IsoSubspace> m_subspaceForTextDecoderStream;
// std::unique_ptr<IsoSubspace> m_subspaceForTextDecoderStreamDecoder;
- // std::unique_ptr<IsoSubspace> m_subspaceForTextEncoder;
+ std::unique_ptr<IsoSubspace> m_subspaceForTextEncoder;
// std::unique_ptr<IsoSubspace> m_subspaceForTextEncoderStream;
// std::unique_ptr<IsoSubspace> m_subspaceForTextEncoderStreamEncoder;
// std::unique_ptr<IsoSubspace> m_subspaceForTextEvent;
@@ -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/HTTPParsers.cpp b/src/javascript/jsc/bindings/webcore/HTTPParsers.cpp
index d49e7d820..335afcec1 100644
--- a/src/javascript/jsc/bindings/webcore/HTTPParsers.cpp
+++ b/src/javascript/jsc/bindings/webcore/HTTPParsers.cpp
@@ -400,7 +400,7 @@ StringView extractCharsetFromMediaType(StringView mediaType)
unsigned length = mediaType.length();
while (pos < length) {
- pos = mediaType.findIgnoringASCIICase("charset", pos);
+ pos = mediaType.findIgnoringASCIICase("charset"_s, pos);
if (pos == notFound || pos == 0) {
charsetLen = 0;
break;
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/JSAbortController.cpp b/src/javascript/jsc/bindings/webcore/JSAbortController.cpp
index 4411d07bd..b2ba038e3 100644
--- a/src/javascript/jsc/bindings/webcore/JSAbortController.cpp
+++ b/src/javascript/jsc/bindings/webcore/JSAbortController.cpp
@@ -139,9 +139,9 @@ template<> void JSAbortControllerDOMConstructor::initializeProperties(VM& vm, JS
/* Hash table for prototype */
static const HashTableValue JSAbortControllerPrototypeTableValues[] = {
- { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortControllerConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "signal", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortController_signal), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "abort", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortControllerPrototypeFunction_abort), (intptr_t)(0) } },
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortControllerConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "signal"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortController_signal), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "abort"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortControllerPrototypeFunction_abort), (intptr_t)(0) } },
};
const ClassInfo JSAbortControllerPrototype::s_info = { "AbortController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAbortControllerPrototype) };
diff --git a/src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp b/src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp
index ba7b3c69f..bce823102 100644
--- a/src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp
+++ b/src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp
@@ -109,9 +109,9 @@ using JSAbortSignalDOMConstructor = JSDOMConstructorNotConstructable<JSAbortSign
/* Hash table for constructor */
static const HashTableValue JSAbortSignalConstructorTableValues[] = {
- { "whenSignalAborted", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortSignalConstructorFunction_whenSignalAborted), (intptr_t)(2) } },
- { "abort", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortSignalConstructorFunction_abort), (intptr_t)(0) } },
- { "timeout", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortSignalConstructorFunction_timeout), (intptr_t)(1) } },
+ { "whenSignalAborted"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortSignalConstructorFunction_whenSignalAborted), (intptr_t)(2) } },
+ { "abort"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortSignalConstructorFunction_abort), (intptr_t)(0) } },
+ { "timeout"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortSignalConstructorFunction_timeout), (intptr_t)(1) } },
};
template<> const ClassInfo JSAbortSignalDOMConstructor::s_info = { "AbortSignal"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAbortSignalDOMConstructor) };
@@ -140,11 +140,11 @@ template<> void JSAbortSignalDOMConstructor::initializeProperties(VM& vm, JSDOMG
/* Hash table for prototype */
static const HashTableValue JSAbortSignalPrototypeTableValues[] = {
- { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortSignalConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "aborted", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortSignal_aborted), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "reason", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortSignal_reason), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "onabort", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortSignal_onabort), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAbortSignal_onabort) } },
- { "throwIfAborted", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortSignalPrototypeFunction_throwIfAborted), (intptr_t)(0) } },
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortSignalConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "aborted"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortSignal_aborted), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "reason"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortSignal_reason), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "onabort"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortSignal_onabort), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAbortSignal_onabort) } },
+ { "throwIfAborted"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortSignalPrototypeFunction_throwIfAborted), (intptr_t)(0) } },
};
const ClassInfo JSAbortSignalPrototype::s_info = { "AbortSignal"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAbortSignalPrototype) };
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/JSCustomEvent.cpp b/src/javascript/jsc/bindings/webcore/JSCustomEvent.cpp
index 843211d8d..383688c42 100644
--- a/src/javascript/jsc/bindings/webcore/JSCustomEvent.cpp
+++ b/src/javascript/jsc/bindings/webcore/JSCustomEvent.cpp
@@ -202,9 +202,9 @@ template<> void JSCustomEventDOMConstructor::initializeProperties(VM& vm, JSDOMG
/* Hash table for prototype */
static const HashTableValue JSCustomEventPrototypeTableValues[] = {
- { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsCustomEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "detail", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsCustomEvent_detail), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "initCustomEvent", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsCustomEventPrototypeFunction_initCustomEvent), (intptr_t)(1) } },
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsCustomEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "detail"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsCustomEvent_detail), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "initCustomEvent"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsCustomEventPrototypeFunction_initCustomEvent), (intptr_t)(1) } },
};
const ClassInfo JSCustomEventPrototype::s_info = { "CustomEvent"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCustomEventPrototype) };
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/JSDOMException.cpp b/src/javascript/jsc/bindings/webcore/JSDOMException.cpp
index 9847b3d51..5dde2de4e 100644
--- a/src/javascript/jsc/bindings/webcore/JSDOMException.cpp
+++ b/src/javascript/jsc/bindings/webcore/JSDOMException.cpp
@@ -93,31 +93,31 @@ using JSDOMExceptionDOMConstructor = JSDOMConstructor<JSDOMException>;
/* Hash table for constructor */
static const HashTableValue JSDOMExceptionConstructorTableValues[] = {
- { "INDEX_SIZE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
- { "DOMSTRING_SIZE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
- { "HIERARCHY_REQUEST_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } },
- { "WRONG_DOCUMENT_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } },
- { "INVALID_CHARACTER_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } },
- { "NO_DATA_ALLOWED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } },
- { "NO_MODIFICATION_ALLOWED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } },
- { "NOT_FOUND_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } },
- { "NOT_SUPPORTED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } },
- { "INUSE_ATTRIBUTE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } },
- { "INVALID_STATE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } },
- { "SYNTAX_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } },
- { "INVALID_MODIFICATION_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(13) } },
- { "NAMESPACE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(14) } },
- { "INVALID_ACCESS_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(15) } },
- { "VALIDATION_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(16) } },
- { "TYPE_MISMATCH_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(17) } },
- { "SECURITY_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(18) } },
- { "NETWORK_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(19) } },
- { "ABORT_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(20) } },
- { "URL_MISMATCH_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(21) } },
- { "QUOTA_EXCEEDED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(22) } },
- { "TIMEOUT_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(23) } },
- { "INVALID_NODE_TYPE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(24) } },
- { "DATA_CLONE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(25) } },
+ { "INDEX_SIZE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
+ { "DOMSTRING_SIZE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
+ { "HIERARCHY_REQUEST_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } },
+ { "WRONG_DOCUMENT_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } },
+ { "INVALID_CHARACTER_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } },
+ { "NO_DATA_ALLOWED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } },
+ { "NO_MODIFICATION_ALLOWED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } },
+ { "NOT_FOUND_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } },
+ { "NOT_SUPPORTED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } },
+ { "INUSE_ATTRIBUTE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } },
+ { "INVALID_STATE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } },
+ { "SYNTAX_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } },
+ { "INVALID_MODIFICATION_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(13) } },
+ { "NAMESPACE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(14) } },
+ { "INVALID_ACCESS_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(15) } },
+ { "VALIDATION_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(16) } },
+ { "TYPE_MISMATCH_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(17) } },
+ { "SECURITY_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(18) } },
+ { "NETWORK_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(19) } },
+ { "ABORT_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(20) } },
+ { "URL_MISMATCH_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(21) } },
+ { "QUOTA_EXCEEDED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(22) } },
+ { "TIMEOUT_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(23) } },
+ { "INVALID_NODE_TYPE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(24) } },
+ { "DATA_CLONE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(25) } },
};
template<> EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSDOMExceptionDOMConstructor::construct(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
@@ -166,35 +166,35 @@ template<> void JSDOMExceptionDOMConstructor::initializeProperties(VM& vm, JSDOM
/* Hash table for prototype */
static const HashTableValue JSDOMExceptionPrototypeTableValues[] = {
- { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMExceptionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "code", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMException_code), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "name", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMException_name), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "message", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMException_message), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "INDEX_SIZE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
- { "DOMSTRING_SIZE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
- { "HIERARCHY_REQUEST_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } },
- { "WRONG_DOCUMENT_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } },
- { "INVALID_CHARACTER_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } },
- { "NO_DATA_ALLOWED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } },
- { "NO_MODIFICATION_ALLOWED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } },
- { "NOT_FOUND_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } },
- { "NOT_SUPPORTED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } },
- { "INUSE_ATTRIBUTE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } },
- { "INVALID_STATE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } },
- { "SYNTAX_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } },
- { "INVALID_MODIFICATION_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(13) } },
- { "NAMESPACE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(14) } },
- { "INVALID_ACCESS_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(15) } },
- { "VALIDATION_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(16) } },
- { "TYPE_MISMATCH_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(17) } },
- { "SECURITY_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(18) } },
- { "NETWORK_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(19) } },
- { "ABORT_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(20) } },
- { "URL_MISMATCH_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(21) } },
- { "QUOTA_EXCEEDED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(22) } },
- { "TIMEOUT_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(23) } },
- { "INVALID_NODE_TYPE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(24) } },
- { "DATA_CLONE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(25) } },
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMExceptionConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "code"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMException_code), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "name"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMException_name), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "message"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMException_message), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "INDEX_SIZE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
+ { "DOMSTRING_SIZE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
+ { "HIERARCHY_REQUEST_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } },
+ { "WRONG_DOCUMENT_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } },
+ { "INVALID_CHARACTER_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } },
+ { "NO_DATA_ALLOWED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } },
+ { "NO_MODIFICATION_ALLOWED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } },
+ { "NOT_FOUND_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } },
+ { "NOT_SUPPORTED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } },
+ { "INUSE_ATTRIBUTE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } },
+ { "INVALID_STATE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } },
+ { "SYNTAX_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } },
+ { "INVALID_MODIFICATION_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(13) } },
+ { "NAMESPACE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(14) } },
+ { "INVALID_ACCESS_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(15) } },
+ { "VALIDATION_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(16) } },
+ { "TYPE_MISMATCH_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(17) } },
+ { "SECURITY_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(18) } },
+ { "NETWORK_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(19) } },
+ { "ABORT_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(20) } },
+ { "URL_MISMATCH_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(21) } },
+ { "QUOTA_EXCEEDED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(22) } },
+ { "TIMEOUT_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(23) } },
+ { "INVALID_NODE_TYPE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(24) } },
+ { "DATA_CLONE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(25) } },
};
const ClassInfo JSDOMExceptionPrototype::s_info = { "DOMException"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMExceptionPrototype) };
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..0c9f83ef7
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMPromiseDeferred.cpp
@@ -0,0 +1,311 @@
+/*
+ * 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(JSC::JSValue value, RejectAsHandled rejectAsHandled)
+{
+ if (shouldIgnoreRequestToFulfill())
+ return;
+ ASSERT(deferred());
+ ASSERT(m_globalObject);
+ auto& lexicalGlobalObject = *m_globalObject;
+ JSC::JSLockHolder locker(&lexicalGlobalObject);
+ reject(lexicalGlobalObject, value, 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..701608677
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSDOMPromiseDeferred.h
@@ -0,0 +1,377 @@
+/*
+ * 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(JSC::JSValue, 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/JSDOMURL.cpp b/src/javascript/jsc/bindings/webcore/JSDOMURL.cpp
index fcf6d5b72..95bf264dd 100644
--- a/src/javascript/jsc/bindings/webcore/JSDOMURL.cpp
+++ b/src/javascript/jsc/bindings/webcore/JSDOMURL.cpp
@@ -129,8 +129,8 @@ using JSDOMURLDOMConstructor = JSDOMConstructor<JSDOMURL>;
/* Hash table for constructor */
static const HashTableValue JSDOMURLConstructorTableValues[] = {
- { "createObjectURL", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsDOMURLConstructorFunction_createObjectURL), (intptr_t)(1) } },
- { "revokeObjectURL", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsDOMURLConstructorFunction_revokeObjectURL), (intptr_t)(1) } },
+ { "createObjectURL"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsDOMURLConstructorFunction_createObjectURL), (intptr_t)(1) } },
+ { "revokeObjectURL"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsDOMURLConstructorFunction_revokeObjectURL), (intptr_t)(1) } },
};
static inline EncodedJSValue constructJSDOMURL1(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
@@ -223,21 +223,21 @@ template<> void JSDOMURLDOMConstructor::initializeProperties(VM& vm, JSDOMGlobal
/* Hash table for prototype */
static const HashTableValue JSDOMURLPrototypeTableValues[] = {
- { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURLConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "href", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_href), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_href) } },
- { "origin", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_origin), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "protocol", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_protocol), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_protocol) } },
- { "username", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_username), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_username) } },
- { "password", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_password), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_password) } },
- { "host", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_host), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_host) } },
- { "hostname", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_hostname), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_hostname) } },
- { "port", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_port), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_port) } },
- { "pathname", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_pathname), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_pathname) } },
- { "hash", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_hash), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_hash) } },
- { "search", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_search), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_search) } },
- { "searchParams", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_searchParams), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "toJSON", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsDOMURLPrototypeFunction_toJSON), (intptr_t)(0) } },
- { "toString", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsDOMURLPrototypeFunction_toString), (intptr_t)(0) } },
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURLConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "href"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_href), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_href) } },
+ { "origin"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_origin), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "protocol"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_protocol), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_protocol) } },
+ { "username"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_username), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_username) } },
+ { "password"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_password), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_password) } },
+ { "host"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_host), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_host) } },
+ { "hostname"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_hostname), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_hostname) } },
+ { "port"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_port), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_port) } },
+ { "pathname"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_pathname), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_pathname) } },
+ { "hash"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_hash), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_hash) } },
+ { "search"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_search), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMURL_search) } },
+ { "searchParams"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsDOMURL_searchParams), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "toJSON"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsDOMURLPrototypeFunction_toJSON), (intptr_t)(0) } },
+ { "toString"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsDOMURLPrototypeFunction_toString), (intptr_t)(0) } },
};
const ClassInfo JSDOMURLPrototype::s_info = { "URL"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMURLPrototype) };
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/JSErrorEvent.cpp b/src/javascript/jsc/bindings/webcore/JSErrorEvent.cpp
index be909421c..73010ffcb 100644
--- a/src/javascript/jsc/bindings/webcore/JSErrorEvent.cpp
+++ b/src/javascript/jsc/bindings/webcore/JSErrorEvent.cpp
@@ -250,12 +250,12 @@ template<> void JSErrorEventDOMConstructor::initializeProperties(VM& vm, JSDOMGl
/* Hash table for prototype */
static const HashTableValue JSErrorEventPrototypeTableValues[] = {
- { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsErrorEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "message", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsErrorEvent_message), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "filename", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsErrorEvent_filename), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "lineno", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsErrorEvent_lineno), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "colno", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsErrorEvent_colno), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "error", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsErrorEvent_error), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsErrorEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "message"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsErrorEvent_message), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "filename"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsErrorEvent_filename), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "lineno"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsErrorEvent_lineno), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "colno"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsErrorEvent_colno), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "error"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsErrorEvent_error), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
};
const ClassInfo JSErrorEventPrototype::s_info = { "ErrorEvent"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSErrorEventPrototype) };
diff --git a/src/javascript/jsc/bindings/webcore/JSEvent.cpp b/src/javascript/jsc/bindings/webcore/JSEvent.cpp
index 058298923..fc729b4c8 100644
--- a/src/javascript/jsc/bindings/webcore/JSEvent.cpp
+++ b/src/javascript/jsc/bindings/webcore/JSEvent.cpp
@@ -128,17 +128,17 @@ static const struct CompactHashIndex JSEventTableIndex[2] = {
};
static const HashTableValue JSEventTableValues[] = {
- { "isTrusted", static_cast<unsigned>(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_isTrusted), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "isTrusted"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_isTrusted), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
};
static const HashTable JSEventTable = { 1, 1, true, JSEvent::info(), JSEventTableValues, JSEventTableIndex };
/* Hash table for constructor */
static const HashTableValue JSEventConstructorTableValues[] = {
- { "NONE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } },
- { "CAPTURING_PHASE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
- { "AT_TARGET", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
- { "BUBBLING_PHASE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } },
+ { "NONE"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } },
+ { "CAPTURING_PHASE"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
+ { "AT_TARGET"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
+ { "BUBBLING_PHASE"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } },
};
static_assert(Event::NONE == 0, "NONE in Event does not match value from IDL");
@@ -194,28 +194,28 @@ template<> void JSEventDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalO
/* Hash table for prototype */
static const HashTableValue JSEventPrototypeTableValues[] = {
- { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "type", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_type), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "target", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_target), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "currentTarget", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_currentTarget), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "eventPhase", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_eventPhase), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "cancelBubble", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_cancelBubble), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSEvent_cancelBubble) } },
- { "bubbles", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_bubbles), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "cancelable", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_cancelable), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "defaultPrevented", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_defaultPrevented), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "composed", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_composed), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "timeStamp", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_timeStamp), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "srcElement", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_srcElement), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "returnValue", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_returnValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSEvent_returnValue) } },
- { "composedPath", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventPrototypeFunction_composedPath), (intptr_t)(0) } },
- { "stopPropagation", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventPrototypeFunction_stopPropagation), (intptr_t)(0) } },
- { "stopImmediatePropagation", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventPrototypeFunction_stopImmediatePropagation), (intptr_t)(0) } },
- { "preventDefault", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventPrototypeFunction_preventDefault), (intptr_t)(0) } },
- { "initEvent", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventPrototypeFunction_initEvent), (intptr_t)(1) } },
- { "NONE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } },
- { "CAPTURING_PHASE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
- { "AT_TARGET", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
- { "BUBBLING_PHASE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } },
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "type"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_type), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "target"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_target), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "currentTarget"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_currentTarget), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "eventPhase"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_eventPhase), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "cancelBubble"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_cancelBubble), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSEvent_cancelBubble) } },
+ { "bubbles"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_bubbles), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "cancelable"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_cancelable), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "defaultPrevented"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_defaultPrevented), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "composed"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_composed), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "timeStamp"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_timeStamp), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "srcElement"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_srcElement), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "returnValue"_s, static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEvent_returnValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSEvent_returnValue) } },
+ { "composedPath"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventPrototypeFunction_composedPath), (intptr_t)(0) } },
+ { "stopPropagation"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventPrototypeFunction_stopPropagation), (intptr_t)(0) } },
+ { "stopImmediatePropagation"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventPrototypeFunction_stopImmediatePropagation), (intptr_t)(0) } },
+ { "preventDefault"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventPrototypeFunction_preventDefault), (intptr_t)(0) } },
+ { "initEvent"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventPrototypeFunction_initEvent), (intptr_t)(1) } },
+ { "NONE"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } },
+ { "CAPTURING_PHASE"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } },
+ { "AT_TARGET"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } },
+ { "BUBBLING_PHASE"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } },
};
const ClassInfo JSEventPrototype::s_info = { "Event"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSEventPrototype) };
diff --git a/src/javascript/jsc/bindings/webcore/JSEventTarget.cpp b/src/javascript/jsc/bindings/webcore/JSEventTarget.cpp
index fb5a35a48..15f282ef8 100644
--- a/src/javascript/jsc/bindings/webcore/JSEventTarget.cpp
+++ b/src/javascript/jsc/bindings/webcore/JSEventTarget.cpp
@@ -148,10 +148,10 @@ template<> void JSEventTargetDOMConstructor::initializeProperties(VM& vm, JSDOMG
/* Hash table for prototype */
static const HashTableValue JSEventTargetPrototypeTableValues[] = {
- { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEventTargetConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "addEventListener", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventTargetPrototypeFunction_addEventListener), (intptr_t)(2) } },
- { "removeEventListener", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventTargetPrototypeFunction_removeEventListener), (intptr_t)(2) } },
- { "dispatchEvent", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventTargetPrototypeFunction_dispatchEvent), (intptr_t)(1) } },
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsEventTargetConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "addEventListener"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventTargetPrototypeFunction_addEventListener), (intptr_t)(2) } },
+ { "removeEventListener"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventTargetPrototypeFunction_removeEventListener), (intptr_t)(2) } },
+ { "dispatchEvent"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsEventTargetPrototypeFunction_dispatchEvent), (intptr_t)(1) } },
};
const ClassInfo JSEventTargetPrototype::s_info = { "EventTarget"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSEventTargetPrototype) };
diff --git a/src/javascript/jsc/bindings/webcore/JSFetchHeaders.cpp b/src/javascript/jsc/bindings/webcore/JSFetchHeaders.cpp
index 9ac6cd9f8..8ea72b567 100644
--- a/src/javascript/jsc/bindings/webcore/JSFetchHeaders.cpp
+++ b/src/javascript/jsc/bindings/webcore/JSFetchHeaders.cpp
@@ -151,16 +151,16 @@ template<> void JSFetchHeadersDOMConstructor::initializeProperties(VM& vm, JSDOM
/* Hash table for prototype */
static const HashTableValue JSFetchHeadersPrototypeTableValues[] = {
- { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsFetchHeadersConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "append", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_append), (intptr_t)(2) } },
- { "delete", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_delete), (intptr_t)(1) } },
- { "get", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_get), (intptr_t)(1) } },
- { "has", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_has), (intptr_t)(1) } },
- { "set", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_set), (intptr_t)(2) } },
- { "entries", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_entries), (intptr_t)(0) } },
- { "keys", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_keys), (intptr_t)(0) } },
- { "values", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_values), (intptr_t)(0) } },
- { "forEach", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_forEach), (intptr_t)(1) } },
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsFetchHeadersConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "append"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_append), (intptr_t)(2) } },
+ { "delete"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_delete), (intptr_t)(1) } },
+ { "get"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_get), (intptr_t)(1) } },
+ { "has"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_has), (intptr_t)(1) } },
+ { "set"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_set), (intptr_t)(2) } },
+ { "entries"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_entries), (intptr_t)(0) } },
+ { "keys"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_keys), (intptr_t)(0) } },
+ { "values"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_values), (intptr_t)(0) } },
+ { "forEach"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsFetchHeadersPrototypeFunction_forEach), (intptr_t)(1) } },
};
const ClassInfo JSFetchHeadersPrototype::s_info = { "Headers"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFetchHeadersPrototype) };
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..7934bf004
--- /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);
+ auto clientData = WebCore::clientData(vm);
+ this->putDirect(vm, clientData->builtinNames().bunNativePtrPrivateName(), jsNumber(0), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | 0);
+ this->putDirect(vm, clientData->builtinNames().bunNativeTypePrivateName(), jsNumber(0), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | 0);
+ 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..137efe15d
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStream.h
@@ -0,0 +1,63 @@
+/*
+ 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..d1080c17e
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamDefaultReader.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 "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) } },
+ { "readMany"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t) static_cast<BuiltinGenerator>(readableStreamDefaultReaderReadManyCodeGenerator), (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..af62fd511
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.cpp
@@ -0,0 +1,268 @@
+/*
+ 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);
+ // -- BUN ADDITION --
+ auto clientData = WebCore::clientData(vm);
+ this->putDirect(vm, clientData->builtinNames().bunNativePtrPrivateName(), jsNumber(0), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | 0);
+ this->putDirect(vm, clientData->builtinNames().bunNativeTypePrivateName(), jsNumber(0), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | 0);
+ // -- BUN ADDITION --
+
+ 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/JSTextEncoder.cpp b/src/javascript/jsc/bindings/webcore/JSTextEncoder.cpp
new file mode 100644
index 000000000..c12c94d56
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSTextEncoder.cpp
@@ -0,0 +1,423 @@
+/*
+ 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 "root.h"
+
+#include "JSTextEncoder.h"
+
+#include "JavaScriptCore/JavaScript.h"
+#include "JavaScriptCore/APICast.h"
+
+#include "JavaScriptCore/FunctionPrototype.h"
+#include "JavaScriptCore/HeapAnalyzer.h"
+#include "JavaScriptCore/JSDestructibleObjectHeapCellType.h"
+#include "JavaScriptCore/ObjectConstructor.h"
+#include "JavaScriptCore/SlotVisitorMacros.h"
+#include "JavaScriptCore/SubspaceInlines.h"
+#include "wtf/GetPtr.h"
+#include "wtf/PointerPreparations.h"
+#include "wtf/URL.h"
+// #include "JavaScriptCore/JSTypedArrays.h"
+
+#include "GCDefferalContext.h"
+#include "ActiveDOMObject.h"
+#include "ExtendedDOMClientIsoSubspaces.h"
+#include "ExtendedDOMIsoSubspaces.h"
+#include "JSDOMAttribute.h"
+// #include "JSDOMBinding.h"
+#include "JSDOMConstructor.h"
+// #include "JSDOMConvertBufferSource.h"
+#include "JSDOMConvertInterface.h"
+#include "JSDOMConvertNumbers.h"
+#include "JSDOMConvertStrings.h"
+// #include "JSDOMExceptionHandling.h"
+// #include "JSDOMGlobalObject.h"
+#include "JSDOMGlobalObjectInlines.h"
+#include "JSDOMOperation.h"
+#include "JSDOMWrapperCache.h"
+// #include "ScriptExecutionContext.h"
+// #include "WebCoreJSClientData.h"
+
+namespace WebCore {
+using namespace JSC;
+
+template<> TextEncoder::EncodeIntoResult convertDictionary<TextEncoder::EncodeIntoResult>(JSGlobalObject& lexicalGlobalObject, JSValue value)
+{
+ VM& vm = JSC::getVM(&lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ bool isNullOrUndefined = value.isUndefinedOrNull();
+ auto* object = isNullOrUndefined ? nullptr : value.getObject();
+ if (UNLIKELY(!isNullOrUndefined && !object)) {
+ throwTypeError(&lexicalGlobalObject, throwScope);
+ return {};
+ }
+ TextEncoder::EncodeIntoResult result;
+ JSValue readValue;
+ if (isNullOrUndefined)
+ readValue = jsUndefined();
+ else {
+ readValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "read"_s));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ }
+ if (!readValue.isUndefined()) {
+ result.read = convert<IDLUnsignedLongLong>(lexicalGlobalObject, readValue);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ }
+ JSValue writtenValue;
+ if (isNullOrUndefined)
+ writtenValue = jsUndefined();
+ else {
+ writtenValue = object->get(&lexicalGlobalObject, Identifier::fromString(vm, "written"_s));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ }
+ if (!writtenValue.isUndefined()) {
+ result.written = convert<IDLUnsignedLongLong>(lexicalGlobalObject, writtenValue);
+ RETURN_IF_EXCEPTION(throwScope, {});
+ }
+ return result;
+}
+
+JSC::JSObject* convertDictionaryToJS(JSC::JSGlobalObject& lexicalGlobalObject, JSDOMGlobalObject& globalObject, const TextEncoder::EncodeIntoResult& dictionary)
+{
+ auto& vm = JSC::getVM(&lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+
+ auto result = constructEmptyObject(&lexicalGlobalObject, globalObject.objectPrototype());
+
+ if (!IDLUnsignedLongLong::isNullValue(dictionary.read)) {
+ auto readValue = toJS<IDLUnsignedLongLong>(lexicalGlobalObject, throwScope, IDLUnsignedLongLong::extractValueFromNullable(dictionary.read));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ result->putDirect(vm, JSC::Identifier::fromString(vm, "read"_s), readValue);
+ }
+ if (!IDLUnsignedLongLong::isNullValue(dictionary.written)) {
+ auto writtenValue = toJS<IDLUnsignedLongLong>(lexicalGlobalObject, throwScope, IDLUnsignedLongLong::extractValueFromNullable(dictionary.written));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ result->putDirect(vm, JSC::Identifier::fromString(vm, "written"_s), writtenValue);
+ }
+ return result;
+}
+
+// Functions
+
+static JSC_DECLARE_HOST_FUNCTION(jsTextEncoderPrototypeFunction_encode);
+static JSC_DECLARE_HOST_FUNCTION(jsTextEncoderPrototypeFunction_encodeInto);
+
+// Attributes
+
+static JSC_DECLARE_CUSTOM_GETTER(jsTextEncoderConstructor);
+static JSC_DECLARE_CUSTOM_GETTER(jsTextEncoder_encoding);
+
+class JSTextEncoderPrototype final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSTextEncoderPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSTextEncoderPrototype* ptr = new (NotNull, JSC::allocateCell<JSTextEncoderPrototype>(vm)) JSTextEncoderPrototype(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(JSTextEncoderPrototype, 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:
+ JSTextEncoderPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM&);
+};
+STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTextEncoderPrototype, JSTextEncoderPrototype::Base);
+
+using JSTextEncoderDOMConstructor = JSDOMConstructor<JSTextEncoder>;
+
+template<> EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSTextEncoderDOMConstructor::construct(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
+{
+ VM& vm = lexicalGlobalObject->vm();
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* castedThis = jsCast<JSTextEncoderDOMConstructor*>(callFrame->jsCallee());
+ ASSERT(castedThis);
+ auto object = TextEncoder::create();
+ if constexpr (IsExceptionOr<decltype(object)>)
+ RETURN_IF_EXCEPTION(throwScope, {});
+ static_assert(TypeOrExceptionOrUnderlyingType<decltype(object)>::isRef);
+ auto jsValue = toJSNewlyCreated<IDLInterface<TextEncoder>>(*lexicalGlobalObject, *castedThis->globalObject(), throwScope, WTFMove(object));
+ if constexpr (IsExceptionOr<decltype(object)>)
+ RETURN_IF_EXCEPTION(throwScope, {});
+ setSubclassStructureIfNeeded<TextEncoder>(lexicalGlobalObject, callFrame, asObject(jsValue));
+ RETURN_IF_EXCEPTION(throwScope, {});
+ return JSValue::encode(jsValue);
+}
+JSC_ANNOTATE_HOST_FUNCTION(JSTextEncoderDOMConstructorConstruct, JSTextEncoderDOMConstructor::construct);
+
+template<> const ClassInfo JSTextEncoderDOMConstructor::s_info = { "TextEncoder"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextEncoderDOMConstructor) };
+
+template<> JSValue JSTextEncoderDOMConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
+{
+ UNUSED_PARAM(vm);
+ return globalObject.functionPrototype();
+}
+
+template<> void JSTextEncoderDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ JSString* nameString = jsNontrivialString(vm, "TextEncoder"_s);
+ m_originalName.set(vm, this, nameString);
+ putDirect(vm, vm.propertyNames->name, nameString, JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
+ putDirect(vm, vm.propertyNames->prototype, JSTextEncoder::prototype(vm, globalObject), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete);
+}
+
+/* Hash table for prototype */
+
+static const HashTableValue JSTextEncoderPrototypeTableValues[] = {
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsTextEncoderConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "encoding"_s, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsTextEncoder_encoding), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "encode"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsTextEncoderPrototypeFunction_encode), (intptr_t)(0) } },
+ { "encodeInto"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsTextEncoderPrototypeFunction_encodeInto), (intptr_t)(2) } },
+};
+
+const ClassInfo JSTextEncoderPrototype::s_info = { "TextEncoder"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextEncoderPrototype) };
+
+void JSTextEncoderPrototype::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ reifyStaticProperties(vm, JSTextEncoder::info(), JSTextEncoderPrototypeTableValues, *this);
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
+}
+
+const ClassInfo JSTextEncoder::s_info = { "TextEncoder"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTextEncoder) };
+
+JSTextEncoder::JSTextEncoder(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TextEncoder>&& impl)
+ : JSDOMWrapper<TextEncoder>(structure, globalObject, WTFMove(impl))
+{
+}
+
+void JSTextEncoder::finishCreation(VM& vm)
+{
+ Base::finishCreation(vm);
+ ASSERT(inherits(info()));
+
+ // static_assert(!std::is_base_of<ActiveDOMObject, TextEncoder>::value, "Interface is not marked as [ActiveDOMObject] even though implementation class subclasses ActiveDOMObject.");
+}
+
+JSObject* JSTextEncoder::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return JSTextEncoderPrototype::create(vm, &globalObject, JSTextEncoderPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
+}
+
+JSObject* JSTextEncoder::prototype(VM& vm, JSDOMGlobalObject& globalObject)
+{
+ return getDOMPrototype<JSTextEncoder>(vm, globalObject);
+}
+
+JSValue JSTextEncoder::getConstructor(VM& vm, const JSGlobalObject* globalObject)
+{
+ return getDOMConstructor<JSTextEncoderDOMConstructor, DOMConstructorID::TextEncoder>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
+}
+
+void JSTextEncoder::destroy(JSC::JSCell* cell)
+{
+ JSTextEncoder* thisObject = static_cast<JSTextEncoder*>(cell);
+ thisObject->JSTextEncoder::~JSTextEncoder();
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsTextEncoderConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto* prototype = jsDynamicCast<JSTextEncoderPrototype*>(JSValue::decode(thisValue));
+ if (UNLIKELY(!prototype))
+ return throwVMTypeError(lexicalGlobalObject, throwScope);
+ return JSValue::encode(JSTextEncoder::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
+}
+
+static inline JSValue jsTextEncoder_encodingGetter(JSGlobalObject& lexicalGlobalObject, JSTextEncoder& thisObject)
+{
+ auto& vm = JSC::getVM(&lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ auto& impl = thisObject.wrapped();
+ RELEASE_AND_RETURN(throwScope, (toJS<IDLDOMString>(lexicalGlobalObject, throwScope, impl.encoding())));
+}
+
+JSC_DEFINE_CUSTOM_GETTER(jsTextEncoder_encoding, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName))
+{
+ return IDLAttribute<JSTextEncoder>::get<jsTextEncoder_encodingGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName);
+}
+
+extern "C" JSC::EncodedJSValue TextEncoder__encode(JSC::JSGlobalObject* lexicalGlobalObject, const ZigString*);
+extern "C" JSC::EncodedJSValue TextEncoder__encodeInto(JSC::JSGlobalObject* lexicalGlobalObject, const ZigString*, void* ptr, size_t len);
+extern "C" JSC::EncodedJSValue TextEncoder__encodeRopeString(JSC::JSGlobalObject* lexicalGlobalObject, JSC::JSString* str);
+
+static inline JSC::EncodedJSValue jsTextEncoderPrototypeFunction_encodeBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTextEncoder>::ClassParameter castedThis)
+{
+ auto& vm = JSC::getVM(lexicalGlobalObject);
+ auto throwScope = DECLARE_THROW_SCOPE(vm);
+ UNUSED_PARAM(throwScope);
+ UNUSED_PARAM(callFrame);
+ EnsureStillAliveScope argument0 = callFrame->argument(0);
+ JSC::JSString* input = argument0.value().toStringOrNull(lexicalGlobalObject);
+ if (input && input->is8Bit() && input->isRope()) {
+ auto encodedValue = TextEncoder__encodeRopeString(lexicalGlobalObject, input);
+ if (!JSC::JSValue::decode(encodedValue).isUndefined()) {
+ RELEASE_AND_RETURN(throwScope, encodedValue);
+ }
+ }
+
+ auto str = Zig::toZigString(input->tryGetValue(lexicalGlobalObject));
+ auto res = TextEncoder__encode(lexicalGlobalObject, &str);
+ if (UNLIKELY(JSC::JSValue::decode(res).isObject() && JSC::JSValue::decode(res).getObject()->isErrorInstance())) {
+ throwScope.throwException(lexicalGlobalObject, JSC::JSValue::decode(res));
+ return encodedJSValue();
+ }
+ RELEASE_AND_RETURN(throwScope, res);
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsTextEncoderPrototypeFunction_encode, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperation<JSTextEncoder>::call<jsTextEncoderPrototypeFunction_encodeBody>(*lexicalGlobalObject, *callFrame, "encode");
+}
+
+static inline JSC::EncodedJSValue jsTextEncoderPrototypeFunction_encodeIntoBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTextEncoder>::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() < 2))
+ return throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject));
+ EnsureStillAliveScope argument0 = callFrame->uncheckedArgument(0);
+ auto source = argument0.value().toWTFString(lexicalGlobalObject);
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ EnsureStillAliveScope argument1 = callFrame->uncheckedArgument(1);
+ auto* destination = JSC::jsDynamicCast<JSC::JSUint8Array*>(argument1.value());
+ if (!destination) {
+ throwVMTypeError(lexicalGlobalObject, throwScope, "Expected Uint8Array"_s);
+ return encodedJSValue();
+ }
+
+ RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ auto str = Zig::toZigString(WTFMove(source));
+ auto res = TextEncoder__encodeInto(lexicalGlobalObject, &str, destination->vector(), destination->length());
+ if (UNLIKELY(JSC::JSValue::decode(res).isObject() && JSC::JSValue::decode(res).getObject()->isErrorInstance())) {
+ throwScope.throwException(lexicalGlobalObject, JSC::JSValue::decode(res));
+ return encodedJSValue();
+ }
+
+ RELEASE_AND_RETURN(throwScope, res);
+}
+
+JSC_DEFINE_HOST_FUNCTION(jsTextEncoderPrototypeFunction_encodeInto, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame))
+{
+ return IDLOperation<JSTextEncoder>::call<jsTextEncoderPrototypeFunction_encodeIntoBody>(*lexicalGlobalObject, *callFrame, "encodeInto");
+}
+
+JSC::GCClient::IsoSubspace* JSTextEncoder::subspaceForImpl(JSC::VM& vm)
+{
+ return WebCore::subspaceForImpl<JSTextEncoder, UseCustomHeapCellType::No>(
+ vm,
+ [](auto& spaces) { return spaces.m_clientSubspaceForTextEncoder.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForTextEncoder = WTFMove(space); },
+ [](auto& spaces) { return spaces.m_subspaceForTextEncoder.get(); },
+ [](auto& spaces, auto&& space) { spaces.m_subspaceForTextEncoder = WTFMove(space); });
+}
+
+void JSTextEncoder::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
+{
+ auto* thisObject = jsCast<JSTextEncoder*>(cell);
+ analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
+ if (thisObject->scriptExecutionContext())
+ analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
+ Base::analyzeHeap(cell, analyzer);
+}
+
+bool JSTextEncoderOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, AbstractSlotVisitor& visitor, const char** reason)
+{
+ UNUSED_PARAM(handle);
+ UNUSED_PARAM(visitor);
+ UNUSED_PARAM(reason);
+ return false;
+}
+
+void JSTextEncoderOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
+{
+ auto* jsTextEncoder = static_cast<JSTextEncoder*>(handle.slot()->asCell());
+ auto& world = *static_cast<DOMWrapperWorld*>(context);
+ uncacheWrapper(world, &jsTextEncoder->wrapped(), jsTextEncoder);
+}
+
+#if ENABLE(BINDING_INTEGRITY)
+#if PLATFORM(WIN)
+#pragma warning(disable : 4483)
+extern "C" {
+extern void (*const __identifier("??_7TextEncoder@WebCore@@6B@")[])();
+}
+#else
+extern "C" {
+extern void* _ZTVN7WebCore11TextEncoderE[];
+}
+#endif
+#endif
+
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<TextEncoder>&& impl)
+{
+
+ if constexpr (std::is_polymorphic_v<TextEncoder>) {
+#if ENABLE(BINDING_INTEGRITY)
+ const void* actualVTablePointer = getVTablePointer(impl.ptr());
+#if PLATFORM(WIN)
+ void* expectedVTablePointer = __identifier("??_7TextEncoder@WebCore@@6B@");
+#else
+ void* expectedVTablePointer = &_ZTVN7WebCore11TextEncoderE[2];
+#endif
+
+ // If you hit this assertion you either have a use after free bug, or
+ // TextEncoder has subclasses. If TextEncoder has subclasses that get passed
+ // to toJS() we currently require TextEncoder you to opt out of binding hardening
+ // by adding the SkipVTableValidation attribute to the interface IDL definition
+ RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
+#endif
+ }
+ return createWrapper<TextEncoder>(globalObject, WTFMove(impl));
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, TextEncoder& impl)
+{
+ return wrap(lexicalGlobalObject, globalObject, impl);
+}
+
+TextEncoder* JSTextEncoder::toWrapped(JSC::VM&, JSC::JSValue value)
+{
+ if (auto* wrapper = jsDynamicCast<JSTextEncoder*>(value))
+ return &wrapper->wrapped();
+ return nullptr;
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/JSTextEncoder.dep b/src/javascript/jsc/bindings/webcore/JSTextEncoder.dep
new file mode 100644
index 000000000..bdb1dfb7c
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSTextEncoder.dep
@@ -0,0 +1 @@
+JSTextEncoder.h :
diff --git a/src/javascript/jsc/bindings/webcore/JSTextEncoder.h b/src/javascript/jsc/bindings/webcore/JSTextEncoder.h
new file mode 100644
index 000000000..e37b96256
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/JSTextEncoder.h
@@ -0,0 +1,100 @@
+/*
+ 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 "root.h"
+
+#include "JSDOMConvertDictionary.h"
+#include "JSDOMWrapper.h"
+#include "TextEncoder.h"
+#include <wtf/NeverDestroyed.h>
+
+namespace WebCore {
+
+class JSTextEncoder : public JSDOMWrapper<TextEncoder> {
+public:
+ using Base = JSDOMWrapper<TextEncoder>;
+ static JSTextEncoder* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<TextEncoder>&& impl)
+ {
+ JSTextEncoder* ptr = new (NotNull, JSC::allocateCell<JSTextEncoder>(globalObject->vm())) JSTextEncoder(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 TextEncoder* 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&);
+
+protected:
+ JSTextEncoder(JSC::Structure*, JSDOMGlobalObject&, Ref<TextEncoder>&&);
+
+ void finishCreation(JSC::VM&);
+};
+
+class JSTextEncoderOwner 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&, TextEncoder*)
+{
+ static NeverDestroyed<JSTextEncoderOwner> owner;
+ return &owner.get();
+}
+
+inline void* wrapperKey(TextEncoder* wrappableObject)
+{
+ return wrappableObject;
+}
+
+JSC::JSValue toJS(JSC::JSGlobalObject*, JSDOMGlobalObject*, TextEncoder&);
+inline JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, TextEncoder* impl) { return impl ? toJS(lexicalGlobalObject, globalObject, *impl) : JSC::jsNull(); }
+JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject*, Ref<TextEncoder>&&);
+inline JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, RefPtr<TextEncoder>&& impl) { return impl ? toJSNewlyCreated(lexicalGlobalObject, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
+
+template<> struct JSDOMWrapperConverterTraits<TextEncoder> {
+ using WrapperClass = JSTextEncoder;
+ using ToWrappedReturnType = TextEncoder*;
+};
+template<> TextEncoder::EncodeIntoResult convertDictionary<TextEncoder::EncodeIntoResult>(JSC::JSGlobalObject&, JSC::JSValue);
+
+JSC::JSObject* convertDictionaryToJS(JSC::JSGlobalObject&, JSDOMGlobalObject&, const TextEncoder::EncodeIntoResult&);
+
+} // namespace WebCore
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/JSURLSearchParams.cpp b/src/javascript/jsc/bindings/webcore/JSURLSearchParams.cpp
index 038731371..e132aecf8 100644
--- a/src/javascript/jsc/bindings/webcore/JSURLSearchParams.cpp
+++ b/src/javascript/jsc/bindings/webcore/JSURLSearchParams.cpp
@@ -155,19 +155,19 @@ template<> void JSURLSearchParamsDOMConstructor::initializeProperties(VM& vm, JS
/* Hash table for prototype */
static const HashTableValue JSURLSearchParamsPrototypeTableValues[] = {
- { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsURLSearchParamsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
- { "append", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_append), (intptr_t)(2) } },
- { "delete", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_delete), (intptr_t)(1) } },
- { "get", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_get), (intptr_t)(1) } },
- { "getAll", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_getAll), (intptr_t)(1) } },
- { "has", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_has), (intptr_t)(1) } },
- { "set", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_set), (intptr_t)(2) } },
- { "sort", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_sort), (intptr_t)(0) } },
- { "entries", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_entries), (intptr_t)(0) } },
- { "keys", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_keys), (intptr_t)(0) } },
- { "values", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_values), (intptr_t)(0) } },
- { "forEach", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_forEach), (intptr_t)(1) } },
- { "toString", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_toString), (intptr_t)(0) } },
+ { "constructor"_s, static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsURLSearchParamsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
+ { "append"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_append), (intptr_t)(2) } },
+ { "delete"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_delete), (intptr_t)(1) } },
+ { "get"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_get), (intptr_t)(1) } },
+ { "getAll"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_getAll), (intptr_t)(1) } },
+ { "has"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_has), (intptr_t)(1) } },
+ { "set"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_set), (intptr_t)(2) } },
+ { "sort"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_sort), (intptr_t)(0) } },
+ { "entries"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_entries), (intptr_t)(0) } },
+ { "keys"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_keys), (intptr_t)(0) } },
+ { "values"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_values), (intptr_t)(0) } },
+ { "forEach"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_forEach), (intptr_t)(1) } },
+ { "toString"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunction_toString), (intptr_t)(0) } },
};
const ClassInfo JSURLSearchParamsPrototype::s_info = { "URLSearchParams"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSURLSearchParamsPrototype) };
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..0a85942b9
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStream.cpp
@@ -0,0 +1,220 @@
+/*
+ * 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()));
+}
+
+ExceptionOr<Ref<ReadableStream>> ReadableStream::create(JSC::JSGlobalObject& lexicalGlobalObject, RefPtr<ReadableStreamSource>&& source, JSC::JSValue nativePtr)
+{
+ auto& builtinNames = WebCore::builtinNames(lexicalGlobalObject.vm());
+ RELEASE_ASSERT(source != nullptr);
+
+ auto objectOrException = invokeConstructor(lexicalGlobalObject, builtinNames.ReadableStreamPrivateName(), [&source, nativePtr](auto& args, auto& lexicalGlobalObject, auto& globalObject) {
+ auto sourceStream = toJSNewlyCreated(&lexicalGlobalObject, &globalObject, source.releaseNonNull());
+ auto tag = WebCore::clientData(lexicalGlobalObject.vm())->builtinNames().bunNativePtrPrivateName();
+ sourceStream.getObject()->putDirect(lexicalGlobalObject.vm(), tag, nativePtr, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::DontEnum);
+ args.append(sourceStream);
+ });
+
+ 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::isLocked(JSGlobalObject* globalObject, JSReadableStream* readableStream)
+{
+ auto* dom = reinterpret_cast<JSDOMGlobalObject*>(globalObject);
+ return checkReadableStream(*dom, readableStream, dom->builtinInternalFunctions().readableStreamInternals().m_isReadableStreamLockedFunction.get());
+}
+
+bool ReadableStream::isDisturbed(JSGlobalObject* globalObject, JSReadableStream* readableStream)
+{
+ auto* dom = reinterpret_cast<JSDOMGlobalObject*>(globalObject);
+ return checkReadableStream(*dom, readableStream, dom->builtinInternalFunctions().readableStreamInternals().m_isReadableStreamDisturbedFunction.get());
+}
+
+bool ReadableStream::isDisturbed() const
+{
+ 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..f50185865
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStream.h
@@ -0,0 +1,105 @@
+/*
+ * 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>&&);
+ static ExceptionOr<Ref<ReadableStream>> create(JSC::JSGlobalObject& lexicalGlobalObject, RefPtr<ReadableStreamSource>&& source, JSC::JSValue nativePtr);
+
+ WEBCORE_EXPORT static bool isDisturbed(JSC::JSGlobalObject*, JSReadableStream*);
+ WEBCORE_EXPORT static bool isLocked(JSC::JSGlobalObject*, JSReadableStream*);
+
+ 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..229a02d38
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStreamDefaultController.cpp
@@ -0,0 +1,154 @@
+/*
+ * 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>
+#include <JavaScriptCore/JSCInlines.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);
+}
+
+void ReadableStreamDefaultController::error(JSC::JSValue error)
+{
+ JSC::JSGlobalObject& lexicalGlobalObject = this->globalObject();
+ auto& vm = lexicalGlobalObject.vm();
+ JSC::JSLockHolder lock(vm);
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ auto value = JSC::Exception::create(vm, error);
+
+ 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 value = JSC::JSUint8Array::create(&lexicalGlobalObject, lexicalGlobalObject.typedArrayStructure(JSC::TypeUint8), WTFMove(buffer), 0, length);
+
+ 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..bb3bc9409
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStreamDefaultController.h
@@ -0,0 +1,75 @@
+/*
+ * 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 error(JSC::JSValue error);
+ void close();
+ JSDOMGlobalObject& globalObject() const;
+ JSReadableStreamDefaultController& jsController() const;
+ // The owner of ReadableStreamDefaultController is responsible to keep uncollected the JSReadableStreamDefaultController.
+ JSReadableStreamDefaultController* m_jsController { nullptr };
+
+private:
+};
+
+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..f969c84b1
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStreamSource.cpp
@@ -0,0 +1,112 @@
+/*
+ * 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 ReadableStreamSource::error(JSC::JSValue value)
+{
+ if (m_promise) {
+ m_promise->reject(value, RejectAsHandled::Yes);
+ m_promise = nullptr;
+ setInactive();
+ } else {
+ controller().error(value);
+ }
+}
+
+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..0886ab423
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/ReadableStreamSource.h
@@ -0,0 +1,94 @@
+/*
+ * 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);
+ void error(JSC::JSValue error);
+
+ bool hasController() const { return !!m_controller; }
+
+ 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;
+
+ std::unique_ptr<DOMPromiseDeferred<void>> m_promise;
+
+private:
+ 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/TextEncoder.cpp b/src/javascript/jsc/bindings/webcore/TextEncoder.cpp
new file mode 100644
index 000000000..1942694cc
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/TextEncoder.cpp
@@ -0,0 +1,74 @@
+/*
+ * 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,
+ * 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 "TextEncoder.h"
+
+#include <JavaScriptCore/GenericTypedArrayViewInlines.h>
+#include <JavaScriptCore/JSCInlines.h>
+
+namespace WebCore {
+
+String TextEncoder::encoding() const
+{
+ return "utf-8"_s;
+}
+
+RefPtr<Uint8Array> TextEncoder::encode(String&& input) const
+{
+ // THIS CODE SHOULD NEVER BE REACHED IN BUN
+ RELEASE_ASSERT(1);
+ return nullptr;
+}
+
+auto TextEncoder::encodeInto(String&& input, Ref<Uint8Array>&& array) -> EncodeIntoResult
+{
+ // THIS CODE SHOULD NEVER BE REACHED IN BUN
+ RELEASE_ASSERT(1);
+
+ auto* destinationBytes = static_cast<uint8_t*>(array->baseAddress());
+ auto capacity = array->byteLength();
+
+ uint64_t read = 0;
+ uint64_t written = 0;
+
+ for (auto token : StringView(input).codePoints()) {
+ if (written >= capacity) {
+ ASSERT(written == capacity);
+ break;
+ }
+ UBool sawError = false;
+ U8_APPEND(destinationBytes, written, capacity, token, sawError);
+ if (sawError)
+ break;
+ if (U_IS_BMP(token))
+ read++;
+ else
+ read += 2;
+ }
+
+ return { read, written };
+}
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/TextEncoder.h b/src/javascript/jsc/bindings/webcore/TextEncoder.h
new file mode 100644
index 000000000..6a0145c78
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/TextEncoder.h
@@ -0,0 +1,54 @@
+/*
+ * 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,
+ * 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 <JavaScriptCore/Forward.h>
+#include <wtf/Ref.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
+
+// THIS FILE IS UNUSED
+// IT EXISTS TO MAKE THE BINDINGS HAPPY
+namespace WebCore {
+
+class TextEncoder : public RefCounted<TextEncoder> {
+public:
+ struct EncodeIntoResult {
+ uint64_t read { 0 };
+ uint64_t written { 0 };
+ };
+
+ static Ref<TextEncoder> create() { return adoptRef(*new TextEncoder); }
+ String encoding() const;
+ RefPtr<Uint8Array> encode(String&&) const;
+ EncodeIntoResult encodeInto(String&&, Ref<Uint8Array>&& destination);
+
+private:
+ TextEncoder() {};
+};
+
+}
diff --git a/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp b/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp
index f95b5f194..4c9660e26 100644
--- a/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp
+++ b/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp
@@ -35,11 +35,6 @@
#include "JavaScriptCore/JSArrayBuffer.h"
-namespace JSC {
-TypedArrayController::TypedArrayController() {}
-TypedArrayController::~TypedArrayController() {}
-}
-
namespace WebCore {
WebCoreTypedArrayController::WebCoreTypedArrayController(bool allowAtomicsWait)
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
diff --git a/src/javascript/jsc/bindings/webcore/weak_handle.cpp b/src/javascript/jsc/bindings/webcore/weak_handle.cpp
new file mode 100644
index 000000000..e210a5ba1
--- /dev/null
+++ b/src/javascript/jsc/bindings/webcore/weak_handle.cpp
@@ -0,0 +1,21 @@
+
+#include "weak_handle.h"
+#include "JavaScriptCore/WeakHandleOwner.h"
+
+namespace JSC {
+class SlotVisitor;
+template<typename T> class Handle;
+
+// WeakHandleOwner::~WeakHandleOwner()
+// {
+// }
+
+// bool WeakHandleOwner::isReachableFromOpaqueRoots(Handle<Unknown>, void*, AbstractSlotVisitor&, const char**)
+// {
+// return false;
+// }
+
+// void WeakHandleOwner::finalize(Handle<Unknown>, void*)
+// {
+// }
+} \ No newline at end of file
diff --git a/src/javascript/jsc/bindings/webcore/weak_handle.h b/src/javascript/jsc/bindings/webcore/weak_handle.h
index 2a0f8b5f8..22d6e702c 100644
--- a/src/javascript/jsc/bindings/webcore/weak_handle.h
+++ b/src/javascript/jsc/bindings/webcore/weak_handle.h
@@ -4,20 +4,4 @@
namespace JSC {
-class SlotVisitor;
-template<typename T> class Handle;
-
-WeakHandleOwner::~WeakHandleOwner()
-{
-}
-
-bool WeakHandleOwner::isReachableFromOpaqueRoots(Handle<Unknown>, void*, AbstractSlotVisitor&, const char**)
-{
- return false;
-}
-
-void WeakHandleOwner::finalize(Handle<Unknown>, void*)
-{
-}
-
} // namespace JSC
diff --git a/src/javascript/jsc/bun-jsc.exports.js b/src/javascript/jsc/bun-jsc.exports.js
new file mode 100644
index 000000000..3f288a8e6
--- /dev/null
+++ b/src/javascript/jsc/bun-jsc.exports.js
@@ -0,0 +1,23 @@
+const jsc = globalThis[Symbol.for("Bun.lazy")]("bun:jsc");
+
+export const describe = jsc.describe;
+export const describeArray = jsc.describeArray;
+export const gcAndSweep = jsc.gcAndSweep;
+export const fullGC = jsc.fullGC;
+export const edenGC = jsc.edenGC;
+export const heapSize = jsc.heapSize;
+export const heapStats = jsc.heapStats;
+export const memoryUsage = jsc.memoryUsage;
+export const getRandomSeed = jsc.getRandomSeed;
+export const setRandomSeed = jsc.setRandomSeed;
+export const isRope = jsc.isRope;
+export const callerSourceOrigin = jsc.callerSourceOrigin;
+export const noFTL = jsc.noFTL;
+export const noOSRExitFuzzing = jsc.noOSRExitFuzzing;
+export const optimizeNextInvocation = jsc.optimizeNextInvocation;
+export const numberOfDFGCompiles = jsc.numberOfDFGCompiles;
+export const releaseWeakRefs = jsc.releaseWeakRefs;
+export const totalCompileTime = jsc.totalCompileTime;
+export const reoptimizationRetryCount = jsc.reoptimizationRetryCount;
+export const drainMicrotasks = jsc.drainMicrotasks;
+export default jsc;
diff --git a/src/javascript/jsc/event_loop.zig b/src/javascript/jsc/event_loop.zig
new file mode 100644
index 000000000..209e9071d
--- /dev/null
+++ b/src/javascript/jsc/event_loop.zig
@@ -0,0 +1,612 @@
+const std = @import("std");
+const JSC = @import("javascript_core");
+const JSGlobalObject = JSC.JSGlobalObject;
+const VirtualMachine = JSC.VirtualMachine;
+const Lock = @import("../../lock.zig").Lock;
+const Microtask = JSC.Microtask;
+const bun = @import("../../global.zig");
+const Environment = bun.Environment;
+const Fetch = JSC.WebCore.Fetch;
+const WebCore = JSC.WebCore;
+const Bun = JSC.API.Bun;
+const TaggedPointerUnion = @import("../../tagged_pointer.zig").TaggedPointerUnion;
+const CopyFilePromiseTask = WebCore.Blob.Store.CopyFile.CopyFilePromiseTask;
+const AsyncTransformTask = @import("./api/transpiler.zig").TransformTask.AsyncTransformTask;
+const BunTimerTimeoutTask = Bun.Timer.Timeout.TimeoutTask;
+const ReadFileTask = WebCore.Blob.Store.ReadFile.ReadFileTask;
+const WriteFileTask = WebCore.Blob.Store.WriteFile.WriteFileTask;
+const napi_async_work = JSC.napi.napi_async_work;
+const FetchTasklet = Fetch.FetchTasklet;
+const JSValue = JSC.JSValue;
+const js = JSC.C;
+pub const WorkPool = @import("../../work_pool.zig").WorkPool;
+pub const WorkPoolTask = @import("../../work_pool.zig").Task;
+const NetworkThread = @import("http").NetworkThread;
+
+pub fn ConcurrentPromiseTask(comptime Context: type) type {
+ return struct {
+ const This = @This();
+ ctx: *Context,
+ task: WorkPoolTask = .{ .callback = runFromThreadPool },
+ event_loop: *JSC.EventLoop,
+ allocator: std.mem.Allocator,
+ promise: JSValue,
+ globalThis: *JSGlobalObject,
+
+ pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSGlobalObject, value: *Context) !*This {
+ var this = try allocator.create(This);
+ this.* = .{
+ .event_loop = VirtualMachine.vm.event_loop,
+ .ctx = value,
+ .allocator = allocator,
+ .promise = JSValue.createInternalPromise(globalThis),
+ .globalThis = globalThis,
+ };
+ js.JSValueProtect(globalThis.ref(), this.promise.asObjectRef());
+ VirtualMachine.vm.active_tasks +|= 1;
+ return this;
+ }
+
+ pub fn runFromThreadPool(task: *WorkPoolTask) void {
+ var this = @fieldParentPtr(This, "task", task);
+ Context.run(this.ctx);
+ this.onFinish();
+ }
+
+ pub fn runFromJS(this: This) void {
+ var promise_value = this.promise;
+ var promise = promise_value.asInternalPromise() orelse {
+ if (comptime @hasDecl(Context, "deinit")) {
+ @call(.{}, Context.deinit, .{this.ctx});
+ }
+ return;
+ };
+
+ var ctx = this.ctx;
+
+ js.JSValueUnprotect(this.globalThis.ref(), promise_value.asObjectRef());
+ ctx.then(promise);
+ }
+
+ pub fn schedule(this: *This) void {
+ WorkPool.schedule(&this.task);
+ }
+
+ pub fn onFinish(this: *This) void {
+ this.event_loop.enqueueTaskConcurrent(Task.init(this));
+ }
+
+ pub fn deinit(this: *This) void {
+ this.allocator.destroy(this);
+ }
+ };
+}
+
+pub fn SerialPromiseTask(comptime Context: type) type {
+ return struct {
+ const SerialWorkPool = @import("../../work_pool.zig").NewWorkPool(1);
+ const This = @This();
+
+ ctx: *Context,
+ task: WorkPoolTask = .{ .callback = runFromThreadPool },
+ event_loop: *JSC.EventLoop,
+ allocator: std.mem.Allocator,
+ promise: JSValue,
+ globalThis: *JSGlobalObject,
+
+ pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSGlobalObject, value: *Context) !*This {
+ var this = try allocator.create(This);
+ this.* = .{
+ .event_loop = VirtualMachine.vm.event_loop,
+ .ctx = value,
+ .allocator = allocator,
+ .promise = JSValue.createInternalPromise(globalThis),
+ .globalThis = globalThis,
+ };
+ js.JSValueProtect(globalThis.ref(), this.promise.asObjectRef());
+ VirtualMachine.vm.active_tasks +|= 1;
+ return this;
+ }
+
+ pub fn runFromThreadPool(task: *WorkPoolTask) void {
+ var this = @fieldParentPtr(This, "task", task);
+ Context.run(this.ctx);
+ this.onFinish();
+ }
+
+ pub fn runFromJS(this: This) void {
+ var promise_value = this.promise;
+ var promise = promise_value.asInternalPromise() orelse {
+ if (comptime @hasDecl(Context, "deinit")) {
+ @call(.{}, Context.deinit, .{this.ctx});
+ }
+ return;
+ };
+
+ var ctx = this.ctx;
+
+ js.JSValueUnprotect(this.globalThis.ref(), promise_value.asObjectRef());
+ ctx.then(promise, this.globalThis);
+ }
+
+ pub fn schedule(this: *This) void {
+ SerialWorkPool.schedule(&this.task);
+ }
+
+ pub fn onFinish(this: *This) void {
+ this.event_loop.enqueueTaskConcurrent(Task.init(this));
+ }
+
+ pub fn deinit(this: *This) void {
+ this.allocator.destroy(this);
+ }
+ };
+}
+
+pub fn IOTask(comptime Context: type) type {
+ return struct {
+ const This = @This();
+ ctx: *Context,
+ task: NetworkThread.Task = .{ .callback = runFromThreadPool },
+ event_loop: *JSC.EventLoop,
+ allocator: std.mem.Allocator,
+ globalThis: *JSGlobalObject,
+
+ pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSGlobalObject, value: *Context) !*This {
+ var this = try allocator.create(This);
+ this.* = .{
+ .event_loop = VirtualMachine.vm.eventLoop(),
+ .ctx = value,
+ .allocator = allocator,
+ .globalThis = globalThis,
+ };
+ return this;
+ }
+
+ pub fn runFromThreadPool(task: *NetworkThread.Task) void {
+ var this = @fieldParentPtr(This, "task", task);
+ Context.run(this.ctx, this);
+ }
+
+ pub fn runFromJS(this: This) void {
+ var ctx = this.ctx;
+ ctx.then(this.globalThis);
+ }
+
+ pub fn schedule(this: *This) void {
+ NetworkThread.init() catch return;
+ NetworkThread.global.pool.schedule(NetworkThread.Batch.from(&this.task));
+ }
+
+ pub fn onFinish(this: *This) void {
+ this.event_loop.enqueueTaskConcurrent(Task.init(this));
+ }
+
+ pub fn deinit(this: *This) void {
+ var allocator = this.allocator;
+ this.* = undefined;
+ allocator.destroy(this);
+ }
+ };
+}
+
+pub fn AsyncNativeCallbackTask(comptime Context: type) type {
+ return struct {
+ const This = @This();
+ ctx: *Context,
+ task: WorkPoolTask = .{ .callback = runFromThreadPool },
+ event_loop: *JSC.EventLoop,
+ allocator: std.mem.Allocator,
+ globalThis: *JSGlobalObject,
+
+ pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSGlobalObject, value: *Context) !*This {
+ var this = try allocator.create(This);
+ this.* = .{
+ .event_loop = VirtualMachine.vm.eventLoop(),
+ .ctx = value,
+ .allocator = allocator,
+ .globalThis = globalThis,
+ };
+ return this;
+ }
+
+ pub fn runFromThreadPool(task: *WorkPoolTask) void {
+ var this = @fieldParentPtr(This, "task", task);
+ Context.run(this.ctx, this);
+ }
+
+ pub fn runFromJS(this: This) void {
+ this.ctx.runFromJS(this.globalThis);
+ }
+
+ pub fn schedule(this: *This) void {
+ WorkPool.get().schedule(WorkPool.schedule(&this.task));
+ }
+
+ pub fn onFinish(this: *This) void {
+ this.event_loop.enqueueTaskConcurrent(Task.init(this));
+ }
+
+ pub fn deinit(this: *This) void {
+ var allocator = this.allocator;
+ this.* = undefined;
+ allocator.destroy(this);
+ }
+ };
+}
+
+pub const AnyTask = struct {
+ ctx: ?*anyopaque,
+ callback: fn (*anyopaque) void,
+
+ pub fn run(this: *AnyTask) void {
+ @setRuntimeSafety(false);
+ this.callback(this.ctx.?);
+ }
+
+ pub fn New(comptime Type: type, comptime Callback: anytype) type {
+ return struct {
+ pub fn init(ctx: *Type) AnyTask {
+ return AnyTask{
+ .callback = wrap,
+ .ctx = ctx,
+ };
+ }
+
+ pub fn wrap(this: ?*anyopaque) void {
+ Callback(@ptrCast(*Type, @alignCast(@alignOf(Type), this.?)));
+ }
+ };
+ }
+};
+const ThreadSafeFunction = JSC.napi.ThreadSafeFunction;
+const MicrotaskForDefaultGlobalObject = JSC.MicrotaskForDefaultGlobalObject;
+// const PromiseTask = JSInternalPromise.Completion.PromiseTask;
+pub const Task = TaggedPointerUnion(.{
+ FetchTasklet,
+ Microtask,
+ MicrotaskForDefaultGlobalObject,
+ AsyncTransformTask,
+ BunTimerTimeoutTask,
+ ReadFileTask,
+ CopyFilePromiseTask,
+ WriteFileTask,
+ AnyTask,
+ napi_async_work,
+ ThreadSafeFunction,
+ // PromiseTask,
+ // TimeoutTasklet,
+});
+
+pub const EventLoop = struct {
+ ready_tasks_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
+ pending_tasks_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
+ io_tasks_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
+ tasks: Queue = undefined,
+ concurrent_tasks: Queue = undefined,
+ concurrent_lock: Lock = Lock.init(),
+ global: *JSGlobalObject = undefined,
+ virtual_machine: *VirtualMachine = undefined,
+ pub const Queue = std.fifo.LinearFifo(Task, .Dynamic);
+
+ pub fn tickWithCount(this: *EventLoop) u32 {
+ var finished: u32 = 0;
+ var global = this.global;
+ var vm_ = this.virtual_machine;
+ while (this.tasks.readItem()) |task| {
+ switch (task.tag()) {
+ .Microtask => {
+ var micro: *Microtask = task.as(Microtask);
+ micro.run(global);
+ finished += 1;
+ },
+ .MicrotaskForDefaultGlobalObject => {
+ var micro: *MicrotaskForDefaultGlobalObject = task.as(MicrotaskForDefaultGlobalObject);
+ micro.run(global);
+ finished += 1;
+ },
+ .FetchTasklet => {
+ var fetch_task: *Fetch.FetchTasklet = task.get(Fetch.FetchTasklet).?;
+ fetch_task.onDone();
+ finished += 1;
+ vm_.active_tasks -|= 1;
+ },
+ @field(Task.Tag, @typeName(AsyncTransformTask)) => {
+ var transform_task: *AsyncTransformTask = task.get(AsyncTransformTask).?;
+ transform_task.*.runFromJS();
+ transform_task.deinit();
+ finished += 1;
+ vm_.active_tasks -|= 1;
+ },
+ @field(Task.Tag, @typeName(CopyFilePromiseTask)) => {
+ var transform_task: *CopyFilePromiseTask = task.get(CopyFilePromiseTask).?;
+ transform_task.*.runFromJS();
+ transform_task.deinit();
+ finished += 1;
+ vm_.active_tasks -|= 1;
+ },
+ @field(Task.Tag, @typeName(JSC.napi.napi_async_work)) => {
+ var transform_task: *JSC.napi.napi_async_work = task.get(JSC.napi.napi_async_work).?;
+ transform_task.*.runFromJS();
+ finished += 1;
+ vm_.active_tasks -|= 1;
+ },
+ @field(Task.Tag, @typeName(BunTimerTimeoutTask)) => {
+ var transform_task: *BunTimerTimeoutTask = task.get(BunTimerTimeoutTask).?;
+ transform_task.*.runFromJS();
+ finished += 1;
+ vm_.active_tasks -|= 1;
+ },
+ @field(Task.Tag, @typeName(ReadFileTask)) => {
+ var transform_task: *ReadFileTask = task.get(ReadFileTask).?;
+ transform_task.*.runFromJS();
+ transform_task.deinit();
+ finished += 1;
+ vm_.active_tasks -|= 1;
+ },
+ @field(Task.Tag, @typeName(WriteFileTask)) => {
+ var transform_task: *WriteFileTask = task.get(WriteFileTask).?;
+ transform_task.*.runFromJS();
+ transform_task.deinit();
+ finished += 1;
+ vm_.active_tasks -|= 1;
+ },
+ @field(Task.Tag, @typeName(AnyTask)) => {
+ var any: *AnyTask = task.get(AnyTask).?;
+ any.run();
+ finished += 1;
+ vm_.active_tasks -|= 1;
+ },
+ else => unreachable,
+ }
+ }
+
+ if (finished > 0) {
+ _ = this.pending_tasks_count.fetchSub(finished, .Monotonic);
+ }
+
+ return finished;
+ }
+
+ pub fn tickConcurrent(this: *EventLoop) void {
+ if (this.ready_tasks_count.load(.Monotonic) > 0) {
+ this.concurrent_lock.lock();
+ defer this.concurrent_lock.unlock();
+ const add: u32 = @truncate(u32, this.concurrent_tasks.readableLength());
+
+ // TODO: optimzie
+ this.tasks.ensureUnusedCapacity(add) catch unreachable;
+
+ {
+ this.tasks.writeAssumeCapacity(this.concurrent_tasks.readableSlice(0));
+ this.concurrent_tasks.discard(this.concurrent_tasks.count);
+ }
+
+ _ = this.pending_tasks_count.fetchAdd(add, .Monotonic);
+ _ = this.ready_tasks_count.fetchSub(add, .Monotonic);
+ }
+ }
+
+ // TODO: fix this technical debt
+ pub fn tick(this: *EventLoop) void {
+ var poller = &this.virtual_machine.poller;
+ while (true) {
+ this.tickConcurrent();
+
+ // this.global.vm().doWork();
+
+ while (this.tickWithCount() > 0) {}
+ poller.tick();
+
+ this.tickConcurrent();
+
+ if (this.tickWithCount() == 0) break;
+ }
+
+ this.global.vm().releaseWeakRefs();
+ }
+
+ // TODO: fix this technical debt
+ pub fn waitForPromise(this: *EventLoop, promise: *JSC.JSInternalPromise) void {
+ switch (promise.status(this.global.vm())) {
+ JSC.JSPromise.Status.Pending => {
+ while (promise.status(this.global.vm()) == .Pending) {
+ this.tick();
+ }
+ },
+ else => {},
+ }
+ }
+
+ pub fn waitForTasks(this: *EventLoop) void {
+ this.tick();
+ while (this.pending_tasks_count.load(.Monotonic) > 0) {
+ this.tick();
+ }
+ }
+
+ pub fn enqueueTask(this: *EventLoop, task: Task) void {
+ _ = this.pending_tasks_count.fetchAdd(1, .Monotonic);
+ this.tasks.writeItem(task) catch unreachable;
+ }
+
+ pub fn enqueueTaskConcurrent(this: *EventLoop, task: Task) void {
+ this.concurrent_lock.lock();
+ defer this.concurrent_lock.unlock();
+ this.concurrent_tasks.writeItem(task) catch unreachable;
+ if (this.virtual_machine.uws_event_loop) |loop| {
+ loop.nextTick(*EventLoop, this, EventLoop.tick);
+ }
+ _ = this.ready_tasks_count.fetchAdd(1, .Monotonic);
+ }
+};
+
+pub const Poller = struct {
+ /// kqueue() or epoll()
+ /// 0 == unset
+ watch_fd: i32 = 0,
+ active: u32 = 0,
+
+ pub const PlatformSpecificFlags = struct {};
+
+ const Completion = fn (ctx: ?*anyopaque, sizeOrOffset: i64, flags: u16) void;
+ const kevent64 = std.os.system.kevent64_s;
+ pub fn dispatchKQueueEvent(kqueue_event: *const kevent64) void {
+ if (comptime !Environment.isMac) {
+ unreachable;
+ }
+
+ const ptr = @intToPtr(?*anyopaque, kqueue_event.udata);
+ const callback: Completion = @intToPtr(Completion, kqueue_event.ext[0]);
+ callback(ptr, @bitCast(i64, kqueue_event.data), kqueue_event.flags);
+ }
+
+ const timeout = std.mem.zeroes(std.os.timespec);
+
+ pub fn watch(this: *Poller, fd: JSC.Node.FileDescriptor, flag: Flag, ctx: ?*anyopaque, completion: Completion) JSC.Maybe(void) {
+ if (comptime Environment.isLinux) {
+ std.debug.assert(this.watch_fd != 0);
+ } else if (comptime Environment.isMac) {
+ if (this.watch_fd == 0) {
+ this.watch_fd = std.c.kqueue();
+ if (this.watch_fd == -1) {
+ defer this.watch_fd = 0;
+ return JSC.Maybe(void).errnoSys(this.watch_fd, .kqueue).?;
+ }
+ }
+
+ var events_list = std.mem.zeroes([2]kevent64);
+ events_list[0] = switch (flag) {
+ .read => .{
+ .ident = @intCast(u64, fd),
+ .filter = std.os.system.EVFILT_READ,
+ .data = 0,
+ .fflags = 0,
+ .udata = @ptrToInt(ctx),
+ .flags = std.c.EV_ADD | std.c.EV_ENABLE | std.c.EV_ONESHOT,
+ .ext = .{ @ptrToInt(completion), 0 },
+ },
+ .write => .{
+ .ident = @intCast(u64, fd),
+ .filter = std.os.system.EVFILT_WRITE,
+ .data = 0,
+ .fflags = 0,
+ .udata = @ptrToInt(ctx),
+ .flags = std.c.EV_ADD | std.c.EV_ENABLE | std.c.EV_ONESHOT,
+ .ext = .{ @ptrToInt(completion), 0 },
+ },
+ };
+
+ // The kevent() system call returns the number of events placed in
+ // the eventlist, up to the value given by nevents. If the time
+ // limit expires, then kevent() returns 0.
+ const rc = std.os.system.kevent64(
+ this.watch_fd,
+ &events_list,
+ 1,
+ // The same array may be used for the changelist and eventlist.
+ &events_list,
+ 1,
+ 0,
+ &timeout,
+ );
+
+ // If an error occurs while
+ // processing an element of the changelist and there is enough room
+ // in the eventlist, then the event will be placed in the eventlist
+ // with EV_ERROR set in flags and the system error in data.
+ if (events_list[0].flags == std.c.EV_ERROR) {
+ return JSC.Maybe(void).errnoSys(events_list[0].data, .kevent).?;
+ // Otherwise, -1 will be returned, and errno will be set to
+ // indicate the error condition.
+ }
+
+ switch (rc) {
+ std.math.minInt(@TypeOf(rc))...-1 => return JSC.Maybe(void).errnoSys(@enumToInt(std.c.getErrno(rc)), .kevent).?,
+ 0 => {
+ this.active += 1;
+ return JSC.Maybe(void).success;
+ },
+ 1 => {
+ // if we immediately get an event, we can skip the reference counting
+ dispatchKQueueEvent(&events_list[0]);
+ return JSC.Maybe(void).success;
+ },
+ 2 => {
+ dispatchKQueueEvent(&events_list[0]);
+
+ this.active -= 1;
+ dispatchKQueueEvent(&events_list[1]);
+ return JSC.Maybe(void).success;
+ },
+ else => unreachable,
+ }
+ } else {
+ @compileError("TODO: Poller");
+ }
+ }
+
+ const kqueue_events_ = std.mem.zeroes([4]kevent64);
+ pub fn tick(this: *Poller) void {
+ if (comptime Environment.isMac) {
+ if (this.active == 0) return;
+
+ var events_list = kqueue_events_;
+ // ub extern "c" fn kevent64(
+ // kq: c_int,
+ // changelist: [*]const kevent64_s,
+ // nchanges: c_int,
+ // eventlist: [*]kevent64_s,
+ // nevents: c_int,
+ // flags: c_uint,
+ // timeout: ?*const timespec,
+ // ) c_int;
+ const rc = std.os.system.kevent64(
+ this.watch_fd,
+ &events_list,
+ 0,
+ // The same array may be used for the changelist and eventlist.
+ &events_list,
+ 4,
+ 0,
+ &timeout,
+ );
+
+ switch (rc) {
+ std.math.minInt(@TypeOf(rc))...-1 => {
+ // EINTR is fine
+ switch (std.c.getErrno(rc)) {
+ .INTR => return,
+ else => |errno| std.debug.panic("kevent64() failed: {d}", .{errno}),
+ }
+ },
+ 0 => {},
+ 1 => {
+ this.active -= 1;
+ dispatchKQueueEvent(&events_list[0]);
+ },
+ 2 => {
+ this.active -= 2;
+ dispatchKQueueEvent(&events_list[0]);
+ dispatchKQueueEvent(&events_list[1]);
+ },
+ 3 => {
+ this.active -= 3;
+ dispatchKQueueEvent(&events_list[0]);
+ dispatchKQueueEvent(&events_list[1]);
+ dispatchKQueueEvent(&events_list[2]);
+ },
+ 4 => {
+ this.active -= 4;
+ dispatchKQueueEvent(&events_list[0]);
+ dispatchKQueueEvent(&events_list[1]);
+ dispatchKQueueEvent(&events_list[2]);
+ dispatchKQueueEvent(&events_list[3]);
+ },
+ else => unreachable,
+ }
+ }
+ }
+
+ pub const Flag = enum { read, write };
+};
diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig
index 9de25b756..52f70a263 100644
--- a/src/javascript/jsc/javascript.zig
+++ b/src/javascript/jsc/javascript.zig
@@ -15,7 +15,7 @@ const StoredFileDescriptorType = bun.StoredFileDescriptorType;
const Arena = @import("../../mimalloc_arena.zig").Arena;
const C = bun.C;
const NetworkThread = @import("http").NetworkThread;
-
+const IO = @import("io");
pub fn zigCast(comptime Destination: type, value: anytype) *Destination {
return @ptrCast(*Destination, @alignCast(@alignOf(*Destination), value));
}
@@ -84,21 +84,23 @@ const Config = @import("./config.zig");
const URL = @import("../../url.zig").URL;
const Transpiler = @import("./api/transpiler.zig");
const Bun = JSC.API.Bun;
+const EventLoop = JSC.EventLoop;
const ThreadSafeFunction = JSC.napi.ThreadSafeFunction;
pub const GlobalConstructors = [_]type{
WebCore.Blob.Constructor,
WebCore.TextDecoder.Constructor,
- WebCore.TextEncoder.Constructor,
+ // WebCore.TextEncoder.Constructor,
Request.Constructor,
Response.Constructor,
JSC.Cloudflare.HTMLRewriter.Constructor,
};
pub const GlobalClasses = [_]type{
+ Bun.Class,
EventListenerMixin.addEventListener(VirtualMachine),
BuildError.Class,
ResolveError.Class,
- Bun.Class,
+
Fetch.Class,
js_ast.Macro.JSNode.BunJSXCallbackFunction,
WebCore.Performance.Class,
@@ -109,6 +111,8 @@ pub const GlobalClasses = [_]type{
// The last item in this array becomes "process.env"
Bun.EnvironmentVariables.Class,
};
+const TaggedPointerUnion = @import("../../tagged_pointer.zig").TaggedPointerUnion;
+const Task = JSC.Task;
const Blob = @import("../../blob.zig");
pub const Buffer = MarkedArrayBuffer;
const Lock = @import("../../lock.zig").Lock;
@@ -125,244 +129,6 @@ pub fn OpaqueWrap(comptime Context: type, comptime Function: fn (this: *Context)
const bun_file_import_path = "/node_modules.server.bun";
-const FetchTasklet = Fetch.FetchTasklet;
-const TaggedPointerUnion = @import("../../tagged_pointer.zig").TaggedPointerUnion;
-const WorkPool = @import("../../work_pool.zig").WorkPool;
-const WorkPoolTask = @import("../../work_pool.zig").Task;
-pub fn ConcurrentPromiseTask(comptime Context: type) type {
- return struct {
- const This = @This();
- ctx: *Context,
- task: WorkPoolTask = .{ .callback = runFromThreadPool },
- event_loop: *VirtualMachine.EventLoop,
- allocator: std.mem.Allocator,
- promise: JSValue,
- globalThis: *JSGlobalObject,
-
- pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSGlobalObject, value: *Context) !*This {
- var this = try allocator.create(This);
- this.* = .{
- .event_loop = VirtualMachine.vm.event_loop,
- .ctx = value,
- .allocator = allocator,
- .promise = JSValue.createInternalPromise(globalThis),
- .globalThis = globalThis,
- };
- js.JSValueProtect(globalThis.ref(), this.promise.asObjectRef());
- VirtualMachine.vm.active_tasks +|= 1;
- return this;
- }
-
- pub fn runFromThreadPool(task: *WorkPoolTask) void {
- var this = @fieldParentPtr(This, "task", task);
- Context.run(this.ctx);
- this.onFinish();
- }
-
- pub fn runFromJS(this: This) void {
- var promise_value = this.promise;
- var promise = promise_value.asInternalPromise() orelse {
- if (comptime @hasDecl(Context, "deinit")) {
- @call(.{}, Context.deinit, .{this.ctx});
- }
- return;
- };
-
- var ctx = this.ctx;
-
- js.JSValueUnprotect(this.globalThis.ref(), promise_value.asObjectRef());
- ctx.then(promise);
- }
-
- pub fn schedule(this: *This) void {
- WorkPool.schedule(&this.task);
- }
-
- pub fn onFinish(this: *This) void {
- this.event_loop.enqueueTaskConcurrent(Task.init(this));
- }
-
- pub fn deinit(this: *This) void {
- this.allocator.destroy(this);
- }
- };
-}
-
-pub fn SerialPromiseTask(comptime Context: type) type {
- return struct {
- const SerialWorkPool = @import("../../work_pool.zig").NewWorkPool(1);
- const This = @This();
-
- ctx: *Context,
- task: WorkPoolTask = .{ .callback = runFromThreadPool },
- event_loop: *VirtualMachine.EventLoop,
- allocator: std.mem.Allocator,
- promise: JSValue,
- globalThis: *JSGlobalObject,
-
- pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSGlobalObject, value: *Context) !*This {
- var this = try allocator.create(This);
- this.* = .{
- .event_loop = VirtualMachine.vm.event_loop,
- .ctx = value,
- .allocator = allocator,
- .promise = JSValue.createInternalPromise(globalThis),
- .globalThis = globalThis,
- };
- js.JSValueProtect(globalThis.ref(), this.promise.asObjectRef());
- VirtualMachine.vm.active_tasks +|= 1;
- return this;
- }
-
- pub fn runFromThreadPool(task: *WorkPoolTask) void {
- var this = @fieldParentPtr(This, "task", task);
- Context.run(this.ctx);
- this.onFinish();
- }
-
- pub fn runFromJS(this: This) void {
- var promise_value = this.promise;
- var promise = promise_value.asInternalPromise() orelse {
- if (comptime @hasDecl(Context, "deinit")) {
- @call(.{}, Context.deinit, .{this.ctx});
- }
- return;
- };
-
- var ctx = this.ctx;
-
- js.JSValueUnprotect(this.globalThis.ref(), promise_value.asObjectRef());
- ctx.then(promise, this.globalThis);
- }
-
- pub fn schedule(this: *This) void {
- SerialWorkPool.schedule(&this.task);
- }
-
- pub fn onFinish(this: *This) void {
- this.event_loop.enqueueTaskConcurrent(Task.init(this));
- }
-
- pub fn deinit(this: *This) void {
- this.allocator.destroy(this);
- }
- };
-}
-
-pub fn IOTask(comptime Context: type) type {
- return struct {
- const This = @This();
- ctx: *Context,
- task: NetworkThread.Task = .{ .callback = runFromThreadPool },
- event_loop: *VirtualMachine.EventLoop,
- allocator: std.mem.Allocator,
- globalThis: *JSGlobalObject,
-
- pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSGlobalObject, value: *Context) !*This {
- var this = try allocator.create(This);
- this.* = .{
- .event_loop = VirtualMachine.vm.eventLoop(),
- .ctx = value,
- .allocator = allocator,
- .globalThis = globalThis,
- };
- return this;
- }
-
- pub fn runFromThreadPool(task: *NetworkThread.Task) void {
- var this = @fieldParentPtr(This, "task", task);
- Context.run(this.ctx, this);
- }
-
- pub fn runFromJS(this: This) void {
- var ctx = this.ctx;
- ctx.then(this.globalThis);
- }
-
- pub fn schedule(this: *This) void {
- NetworkThread.init() catch return;
- NetworkThread.global.pool.schedule(NetworkThread.Batch.from(&this.task));
- }
-
- pub fn onFinish(this: *This) void {
- this.event_loop.enqueueTaskConcurrent(Task.init(this));
- }
-
- pub fn deinit(this: *This) void {
- var allocator = this.allocator;
- this.* = undefined;
- allocator.destroy(this);
- }
- };
-}
-
-pub fn AsyncNativeCallbackTask(comptime Context: type) type {
- return struct {
- const This = @This();
- ctx: *Context,
- task: WorkPoolTask = .{ .callback = runFromThreadPool },
- event_loop: *VirtualMachine.EventLoop,
- allocator: std.mem.Allocator,
- globalThis: *JSGlobalObject,
-
- pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSGlobalObject, value: *Context) !*This {
- var this = try allocator.create(This);
- this.* = .{
- .event_loop = VirtualMachine.vm.eventLoop(),
- .ctx = value,
- .allocator = allocator,
- .globalThis = globalThis,
- };
- return this;
- }
-
- pub fn runFromThreadPool(task: *WorkPoolTask) void {
- var this = @fieldParentPtr(This, "task", task);
- Context.run(this.ctx, this);
- }
-
- pub fn runFromJS(this: This) void {
- this.ctx.runFromJS(this.globalThis);
- }
-
- pub fn schedule(this: *This) void {
- WorkPool.get().schedule(WorkPool.schedule(&this.task));
- }
-
- pub fn onFinish(this: *This) void {
- this.event_loop.enqueueTaskConcurrent(Task.init(this));
- }
-
- pub fn deinit(this: *This) void {
- var allocator = this.allocator;
- this.* = undefined;
- allocator.destroy(this);
- }
- };
-}
-
-const CopyFilePromiseTask = WebCore.Blob.Store.CopyFile.CopyFilePromiseTask;
-const AsyncTransformTask = @import("./api/transpiler.zig").TransformTask.AsyncTransformTask;
-const BunTimerTimeoutTask = Bun.Timer.Timeout.TimeoutTask;
-const ReadFileTask = WebCore.Blob.Store.ReadFile.ReadFileTask;
-const WriteFileTask = WebCore.Blob.Store.WriteFile.WriteFileTask;
-const napi_async_work = JSC.napi.napi_async_work;
-// const PromiseTask = JSInternalPromise.Completion.PromiseTask;
-pub const Task = TaggedPointerUnion(.{
- FetchTasklet,
- Microtask,
- AsyncTransformTask,
- BunTimerTimeoutTask,
- ReadFileTask,
- CopyFilePromiseTask,
- WriteFileTask,
- AnyTask,
- napi_async_work,
- ThreadSafeFunction,
- // PromiseTask,
- // TimeoutTasklet,
-});
-
const SourceMap = @import("../../sourcemap/sourcemap.zig");
const MappingList = SourceMap.Mapping.List;
@@ -480,38 +246,23 @@ pub const SavedSourceMap = struct {
};
const uws = @import("uws");
-pub const AnyTask = struct {
- ctx: ?*anyopaque,
- callback: fn (*anyopaque) void,
-
- pub fn run(this: *AnyTask) void {
- @setRuntimeSafety(false);
- this.callback(this.ctx.?);
- }
-
- pub fn New(comptime Type: type, comptime Callback: anytype) type {
- return struct {
- pub fn init(ctx: *Type) AnyTask {
- return AnyTask{
- .callback = wrap,
- .ctx = ctx,
- };
- }
-
- pub fn wrap(this: ?*anyopaque) void {
- Callback(@ptrCast(*Type, @alignCast(@alignOf(Type), this.?)));
- }
- };
- }
-};
-
pub export fn Bun__getDefaultGlobal() *JSGlobalObject {
return JSC.VirtualMachine.vm.global;
}
+pub export fn Bun__getVM() *JSC.VirtualMachine {
+ return JSC.VirtualMachine.vm;
+}
+
+pub export fn Bun__drainMicrotasks() void {
+ JSC.VirtualMachine.vm.eventLoop().tick();
+}
+
comptime {
if (!JSC.is_bindgen) {
_ = Bun__getDefaultGlobal;
+ _ = Bun__getVM;
+ _ = Bun__drainMicrotasks;
}
}
@@ -575,6 +326,15 @@ pub const VirtualMachine = struct {
response_objects_pool: ?*Response.Pool = null,
rare_data: ?*JSC.RareData = null,
+ poller: JSC.Poller = JSC.Poller{},
+
+ pub fn io(this: *VirtualMachine) *IO {
+ if (this.io_ == null) {
+ this.io_ = IO.init(this) catch @panic("Failed to initialize IO");
+ }
+
+ return &this.io_.?;
+ }
pub inline fn nodeFS(this: *VirtualMachine) *Node.NodeFS {
return this.node_fs orelse brk: {
@@ -606,160 +366,6 @@ pub const VirtualMachine = struct {
}
}
- pub const EventLoop = struct {
- ready_tasks_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
- pending_tasks_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
- io_tasks_count: std.atomic.Atomic(u32) = std.atomic.Atomic(u32).init(0),
- tasks: Queue = undefined,
- concurrent_tasks: Queue = undefined,
- concurrent_lock: Lock = Lock.init(),
- global: *JSGlobalObject = undefined,
- virtual_machine: *VirtualMachine = undefined,
- pub const Queue = std.fifo.LinearFifo(Task, .Dynamic);
-
- pub fn tickWithCount(this: *EventLoop) u32 {
- var finished: u32 = 0;
- var global = this.global;
- var vm_ = this.virtual_machine;
- while (this.tasks.readItem()) |task| {
- switch (task.tag()) {
- .Microtask => {
- var micro: *Microtask = task.as(Microtask);
- micro.run(global);
- finished += 1;
- },
- .FetchTasklet => {
- var fetch_task: *Fetch.FetchTasklet = task.get(Fetch.FetchTasklet).?;
- fetch_task.onDone();
- finished += 1;
- vm_.active_tasks -|= 1;
- },
- @field(Task.Tag, @typeName(AsyncTransformTask)) => {
- var transform_task: *AsyncTransformTask = task.get(AsyncTransformTask).?;
- transform_task.*.runFromJS();
- transform_task.deinit();
- finished += 1;
- vm_.active_tasks -|= 1;
- },
- @field(Task.Tag, @typeName(CopyFilePromiseTask)) => {
- var transform_task: *CopyFilePromiseTask = task.get(CopyFilePromiseTask).?;
- transform_task.*.runFromJS();
- transform_task.deinit();
- finished += 1;
- vm_.active_tasks -|= 1;
- },
- @field(Task.Tag, @typeName(JSC.napi.napi_async_work)) => {
- var transform_task: *JSC.napi.napi_async_work = task.get(JSC.napi.napi_async_work).?;
- transform_task.*.runFromJS();
- finished += 1;
- vm_.active_tasks -|= 1;
- },
- @field(Task.Tag, @typeName(BunTimerTimeoutTask)) => {
- var transform_task: *BunTimerTimeoutTask = task.get(BunTimerTimeoutTask).?;
- transform_task.*.runFromJS();
- finished += 1;
- vm_.active_tasks -|= 1;
- },
- @field(Task.Tag, @typeName(ReadFileTask)) => {
- var transform_task: *ReadFileTask = task.get(ReadFileTask).?;
- transform_task.*.runFromJS();
- transform_task.deinit();
- finished += 1;
- vm_.active_tasks -|= 1;
- },
- @field(Task.Tag, @typeName(WriteFileTask)) => {
- var transform_task: *WriteFileTask = task.get(WriteFileTask).?;
- transform_task.*.runFromJS();
- transform_task.deinit();
- finished += 1;
- vm_.active_tasks -|= 1;
- },
- @field(Task.Tag, @typeName(AnyTask)) => {
- var any: *AnyTask = task.get(AnyTask).?;
- any.run();
- finished += 1;
- vm_.active_tasks -|= 1;
- },
- else => unreachable,
- }
- }
-
- if (finished > 0) {
- _ = this.pending_tasks_count.fetchSub(finished, .Monotonic);
- }
-
- return finished;
- }
-
- pub fn tickConcurrent(this: *EventLoop) void {
- if (this.ready_tasks_count.load(.Monotonic) > 0) {
- this.concurrent_lock.lock();
- defer this.concurrent_lock.unlock();
- const add: u32 = @truncate(u32, this.concurrent_tasks.readableLength());
-
- // TODO: optimzie
- this.tasks.ensureUnusedCapacity(add) catch unreachable;
-
- {
- this.tasks.writeAssumeCapacity(this.concurrent_tasks.readableSlice(0));
- this.concurrent_tasks.discard(this.concurrent_tasks.count);
- }
-
- _ = this.pending_tasks_count.fetchAdd(add, .Monotonic);
- _ = this.ready_tasks_count.fetchSub(add, .Monotonic);
- }
- }
-
- // TODO: fix this technical debt
- pub fn tick(this: *EventLoop) void {
- while (true) {
- this.tickConcurrent();
-
- // this.global.vm().doWork();
-
- while (this.tickWithCount() > 0) {}
-
- this.tickConcurrent();
-
- if (this.tickWithCount() == 0) break;
- }
- }
-
- // TODO: fix this technical debt
- pub fn waitForPromise(this: *EventLoop, promise: *JSC.JSInternalPromise) void {
- switch (promise.status(this.global.vm())) {
- JSC.JSPromise.Status.Pending => {
- while (promise.status(this.global.vm()) == .Pending) {
- this.tick();
- }
- },
- else => {},
- }
- }
-
- pub fn waitForTasks(this: *EventLoop) void {
- this.tick();
- while (this.pending_tasks_count.load(.Monotonic) > 0) {
- this.tick();
- }
- }
-
- pub fn enqueueTask(this: *EventLoop, task: Task) void {
- _ = this.pending_tasks_count.fetchAdd(1, .Monotonic);
- this.tasks.writeItem(task) catch unreachable;
- }
-
- pub fn enqueueTaskConcurrent(this: *EventLoop, task: Task) void {
- this.concurrent_lock.lock();
- defer this.concurrent_lock.unlock();
- this.concurrent_tasks.writeItem(task) catch unreachable;
- if (this.virtual_machine.uws_event_loop) |loop| {
- loop.nextTick(*EventLoop, this, EventLoop.tick);
- }
- _ = this.ready_tasks_count.fetchAdd(1, .Monotonic);
- }
- };
-
pub inline fn enqueueTask(this: *VirtualMachine, task: Task) void {
this.eventLoop().enqueueTask(task);
}
@@ -1128,6 +734,15 @@ pub const VirtualMachine = struct {
.hash = 0,
};
},
+ .@"bun:jsc" => {
+ return ResolvedSource{
+ .allocator = null,
+ .source_code = ZigString.init(@embedFile("bun-jsc.exports.js") ++ JSC.Node.fs.constants_string),
+ .specifier = ZigString.init("bun:jsc"),
+ .source_url = ZigString.init("bun:jsc"),
+ .hash = 0,
+ };
+ },
.@"node:fs" => {
return ResolvedSource{
.allocator = null,
@@ -1506,12 +1121,17 @@ pub const VirtualMachine = struct {
ret.path = result_path.text;
}
pub fn queueMicrotaskToEventLoop(
- _: *JSGlobalObject,
+ globalObject: *JSGlobalObject,
microtask: *Microtask,
) void {
std.debug.assert(VirtualMachine.vm_loaded);
- vm.enqueueTask(Task.init(microtask));
+ var vm_ = globalObject.bunVM();
+ if (vm_.global == globalObject) {
+ vm_.enqueueTask(Task.init(@ptrCast(*JSC.MicrotaskForDefaultGlobalObject, microtask)));
+ } else {
+ vm_.enqueueTask(Task.init(microtask));
+ }
}
pub fn resolveForAPI(res: *ErrorableZigString, global: *JSGlobalObject, specifier: ZigString, source: ZigString) void {
@@ -2914,6 +2534,7 @@ pub const HardcodedModule = enum {
@"node:path",
@"detect-libc",
@"bun:sqlite",
+ @"bun:jsc",
@"node:module",
pub const Map = bun.ComptimeStringMap(
@@ -2932,12 +2553,14 @@ pub const HardcodedModule = enum {
.{ "bun:sqlite", HardcodedModule.@"bun:sqlite" },
.{ "node:module", HardcodedModule.@"node:module" },
.{ "module", HardcodedModule.@"node:module" },
+ .{ "bun:jsc", HardcodedModule.@"bun:jsc" },
},
);
pub const LinkerMap = bun.ComptimeStringMap(
string,
.{
.{ "bun:ffi", "bun:ffi" },
+ .{ "bun:jsc", "bun:jsc" },
.{ "detect-libc", "detect-libc" },
.{ "detect-libc/lib/detect-libc.js", "detect-libc" },
.{ "ffi", "bun:ffi" },
diff --git a/src/javascript/jsc/javascript_core_c_api.zig b/src/javascript/jsc/javascript_core_c_api.zig
index 0ae0a10e9..c2bcc45cf 100644
--- a/src/javascript/jsc/javascript_core_c_api.zig
+++ b/src/javascript/jsc/javascript_core_c_api.zig
@@ -1,15 +1,19 @@
const cpp = @import("./bindings/bindings.zig");
const generic = opaque {
- pub inline fn ptr(this: *@This()) *cpp.JSGlobalObject {
- return @ptrCast(*cpp.JSGlobalObject, @alignCast(@alignOf(*cpp.JSGlobalObject), this));
+ pub fn value(this: *const @This()) cpp.JSValue {
+ return @bitCast(cpp.JSValue.Type, @ptrToInt(this));
+ }
+
+ pub inline fn bunVM(this: *@This()) *@import("javascript_core").VirtualMachine {
+ return this.ptr().bunVM();
}
};
pub const Private = anyopaque;
pub const struct_OpaqueJSContextGroup = generic;
pub const JSContextGroupRef = ?*const struct_OpaqueJSContextGroup;
pub const struct_OpaqueJSContext = generic;
-pub const JSContextRef = *struct_OpaqueJSContext;
-pub const JSGlobalContextRef = ?*struct_OpaqueJSContext;
+pub const JSContextRef = *cpp.JSGlobalObject;
+pub const JSGlobalContextRef = ?*cpp.JSGlobalObject;
pub const struct_OpaqueJSString = generic;
pub const JSStringRef = ?*struct_OpaqueJSString;
pub const struct_OpaqueJSClass = opaque {
@@ -26,7 +30,7 @@ pub const JSTypedArrayBytesDeallocator = ?fn (*anyopaque, *anyopaque) callconv(.
pub const OpaqueJSValue = generic;
pub const JSValueRef = ?*OpaqueJSValue;
pub const JSObjectRef = ?*OpaqueJSValue;
-pub extern fn JSEvaluateScript(ctx: JSContextRef, script: JSStringRef, thisObject: JSObjectRef, sourceURL: JSStringRef, startingLineNumber: c_int, exception: ExceptionRef) JSValueRef;
+pub extern fn JSEvaluateScript(ctx: JSContextRef, script: JSStringRef, thisObject: ?*anyopaque, sourceURL: JSStringRef, startingLineNumber: c_int, exception: ExceptionRef) JSValueRef;
pub extern fn JSCheckScriptSyntax(ctx: JSContextRef, script: JSStringRef, sourceURL: JSStringRef, startingLineNumber: c_int, exception: ExceptionRef) bool;
pub extern fn JSGarbageCollect(ctx: JSContextRef) void;
pub const JSType = enum(c_uint) {
diff --git a/src/javascript/jsc/node/dir_iterator.zig b/src/javascript/jsc/node/dir_iterator.zig
index f4c8b6d4a..3d28541e7 100644
--- a/src/javascript/jsc/node/dir_iterator.zig
+++ b/src/javascript/jsc/node/dir_iterator.zig
@@ -15,7 +15,7 @@ const PathString = JSC.PathString;
const IteratorError = error{ AccessDenied, SystemResources } || os.UnexpectedError;
const mem = std.mem;
const strings = @import("../../../global.zig").strings;
-const Maybe = JSC.Node.Maybe;
+const Maybe = JSC.Maybe;
const File = std.fs.File;
const Result = Maybe(?Entry);
diff --git a/src/javascript/jsc/node/node_fs.zig b/src/javascript/jsc/node/node_fs.zig
index 2bf1fb685..4a556f15c 100644
--- a/src/javascript/jsc/node/node_fs.zig
+++ b/src/javascript/jsc/node/node_fs.zig
@@ -12,7 +12,7 @@ const Environment = bun.Environment;
const C = bun.C;
const Flavor = JSC.Node.Flavor;
const system = std.os.system;
-const Maybe = JSC.Node.Maybe;
+const Maybe = JSC.Maybe;
const Encoding = JSC.Node.Encoding;
const Syscall = @import("./syscall.zig");
const Constants = @import("./node_fs_constant.zig").Constants;
@@ -3219,12 +3219,11 @@ pub const NodeFS = struct {
const size = @intCast(u64, @maximum(stat_.size, 0));
var buf = std.ArrayList(u8).init(bun.default_allocator);
- buf.ensureTotalCapacity(size + 16) catch unreachable;
+ buf.ensureTotalCapacityPrecise(size + 16) catch unreachable;
buf.expandToCapacity();
var total: usize = 0;
-
while (total < size) {
- switch (Syscall.read(fd, buf.items[total..])) {
+ switch (Syscall.read(fd, buf.items.ptr[total..buf.capacity])) {
.err => |err| return .{
.err = err,
},
@@ -3232,7 +3231,7 @@ pub const NodeFS = struct {
total += amt;
// There are cases where stat()'s size is wrong or out of date
if (total > size and amt != 0) {
- buf.ensureUnusedCapacity(512384) catch unreachable;
+ buf.ensureUnusedCapacity(8096) catch unreachable;
buf.expandToCapacity();
continue;
}
diff --git a/src/javascript/jsc/node/node_fs_binding.zig b/src/javascript/jsc/node/node_fs_binding.zig
index 59b58778a..9e689b929 100644
--- a/src/javascript/jsc/node/node_fs_binding.zig
+++ b/src/javascript/jsc/node/node_fs_binding.zig
@@ -3,7 +3,7 @@ const std = @import("std");
const Flavor = JSC.Node.Flavor;
const ArgumentsSlice = JSC.Node.ArgumentsSlice;
const system = std.os.system;
-const Maybe = JSC.Node.Maybe;
+const Maybe = JSC.Maybe;
const Encoding = JSC.Node.Encoding;
const FeatureFlags = @import("../../../global.zig").FeatureFlags;
const Args = JSC.Node.NodeFS.Arguments;
@@ -30,7 +30,7 @@ fn callSync(comptime FunctionEnum: NodeFSFunctionEnum) NodeFSFunction {
comptime if (function.args.len != 3) @compileError("Expected 3 arguments");
const Arguments = comptime function.args[1].arg_type.?;
const FormattedName = comptime [1]u8{std.ascii.toUpper(@tagName(FunctionEnum)[0])} ++ @tagName(FunctionEnum)[1..];
- const Result = comptime JSC.Node.Maybe(@field(JSC.Node.NodeFS.ReturnType, FormattedName));
+ const Result = comptime JSC.Maybe(@field(JSC.Node.NodeFS.ReturnType, FormattedName));
const NodeBindingClosure = struct {
pub fn bind(
@@ -41,7 +41,7 @@ fn callSync(comptime FunctionEnum: NodeFSFunctionEnum) NodeFSFunction {
arguments: []const JSC.C.JSValueRef,
exception: JSC.C.ExceptionRef,
) JSC.C.JSValueRef {
- var slice = ArgumentsSlice.init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
+ var slice = ArgumentsSlice.init(ctx.bunVM(), @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
defer slice.deinit();
const args = if (comptime Arguments != void)
diff --git a/src/javascript/jsc/node/syscall.zig b/src/javascript/jsc/node/syscall.zig
index 7d82336c4..ad4545aa9 100644
--- a/src/javascript/jsc/node/syscall.zig
+++ b/src/javascript/jsc/node/syscall.zig
@@ -9,13 +9,12 @@ const Environment = @import("../../../global.zig").Environment;
const default_allocator = @import("../../../global.zig").default_allocator;
const JSC = @import("../../../jsc.zig");
const SystemError = JSC.SystemError;
-const darwin = os.darwin;
const bun = @import("../../../global.zig");
const MAX_PATH_BYTES = bun.MAX_PATH_BYTES;
const fd_t = bun.FileDescriptorType;
const C = @import("../../../global.zig").C;
const linux = os.linux;
-const Maybe = JSC.Node.Maybe;
+const Maybe = JSC.Maybe;
pub const system = if (Environment.isLinux) linux else @import("io").darwin;
pub const S = struct {
@@ -93,6 +92,8 @@ pub const Tag = enum(u8) {
sendfile,
splice,
+ kevent,
+ kqueue,
pub var strings = std.EnumMap(Tag, JSC.C.JSStringRef).initFull(null);
};
const PathString = @import("../../../global.zig").PathString;
@@ -143,7 +144,7 @@ pub fn fstat(fd: JSC.Node.FileDescriptor) Maybe(os.Stat) {
pub fn mkdir(file_path: [:0]const u8, flags: JSC.Node.Mode) Maybe(void) {
if (comptime Environment.isMac) {
- return Maybe(void).errnoSysP(darwin.mkdir(file_path, flags), .mkdir, file_path) orelse Maybe(void).success;
+ return Maybe(void).errnoSysP(system.mkdir(file_path, flags), .mkdir, file_path) orelse Maybe(void).success;
}
if (comptime Environment.isLinux) {
@@ -187,7 +188,7 @@ pub fn open(file_path: [:0]const u8, flags: JSC.Node.Mode, perm: JSC.Node.Mode)
pub fn close(fd: std.os.fd_t) ?Syscall.Error {
if (comptime Environment.isMac) {
// This avoids the EINTR problem.
- return switch (darwin.getErrno(darwin.@"close$NOCANCEL"(fd))) {
+ return switch (system.getErrno(system.@"close$NOCANCEL"(fd))) {
.BADF => Syscall.Error{ .errno = @enumToInt(os.E.BADF), .syscall = .close },
else => null,
};
@@ -225,8 +226,10 @@ pub fn write(fd: os.fd_t, bytes: []const u8) Maybe(usize) {
const pread_sym = if (builtin.os.tag == .linux and builtin.link_libc)
sys.pread64
+else if (builtin.os.tag.isDarwin())
+ system.@"pread$NOCANCEL"
else
- sys.pread;
+ system.pread;
pub fn pread(fd: os.fd_t, buf: []u8, offset: i64) Maybe(usize) {
const adjusted_len = @minimum(buf.len, max_count);
@@ -266,27 +269,35 @@ pub fn pwrite(fd: os.fd_t, bytes: []const u8, offset: i64) Maybe(usize) {
pub fn read(fd: os.fd_t, buf: []u8) Maybe(usize) {
const adjusted_len = @minimum(buf.len, max_count);
- while (true) {
- const rc = sys.read(fd, buf.ptr, adjusted_len);
+ if (comptime Environment.isMac) {
+ const rc = system.@"read$NOCANCEL"(fd, buf.ptr, adjusted_len);
if (Maybe(usize).errnoSys(rc, .read)) |err| {
- if (err.getErrno() == .INTR) continue;
return err;
}
return Maybe(usize){ .result = @intCast(usize, rc) };
+ } else {
+ while (true) {
+ const rc = sys.read(fd, buf.ptr, adjusted_len);
+ if (Maybe(usize).errnoSys(rc, .read)) |err| {
+ if (err.getErrno() == .INTR) continue;
+ return err;
+ }
+ return Maybe(usize){ .result = @intCast(usize, rc) };
+ }
}
unreachable;
}
pub fn recv(fd: os.fd_t, buf: []u8, flag: u32) Maybe(usize) {
if (comptime Environment.isMac) {
- const rc = system.@"recvfrom$NOCANCEL"(fd, buf.ptr, bun.len, flag, null, null);
+ const rc = system.@"recvfrom$NOCANCEL"(fd, buf.ptr, buf.len, flag, null, null);
if (Maybe(usize).errnoSys(rc, .recv)) |err| {
return err;
}
return Maybe(usize){ .result = @intCast(usize, rc) };
} else {
while (true) {
- const rc = linux.recvfrom(fd, buf.ptr, bun.len, flag | os.SOCK.CLOEXEC | os.MSG.NOSIGNAL, null, null);
+ const rc = linux.recvfrom(fd, buf.ptr, buf.len, flag | os.SOCK.CLOEXEC | linux.MSG.CMSG_CLOEXEC, null, null);
if (Maybe(usize).errnoSys(rc, .recv)) |err| {
if (err.getErrno() == .INTR) continue;
return err;
@@ -395,7 +406,7 @@ pub fn fcopyfile(fd_in: std.os.fd_t, fd_out: std.os.fd_t, flags: u32) Maybe(void
if (comptime !Environment.isMac) @compileError("macOS only");
while (true) {
- if (Maybe(void).errnoSys(darwin.fcopyfile(fd_in, fd_out, null, flags), .fcopyfile)) |err| {
+ if (Maybe(void).errnoSys(system.fcopyfile(fd_in, fd_out, null, flags), .fcopyfile)) |err| {
if (err.getErrno() == .INTR) continue;
return err;
}
@@ -432,7 +443,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) Maybe([]u8) {
// On macOS, we can use F.GETPATH fcntl command to query the OS for
// the path to the file descriptor.
@memset(out_buffer, 0, MAX_PATH_BYTES);
- if (Maybe([]u8).errnoSys(darwin.fcntl(fd, os.F.GETPATH, out_buffer), .fcntl)) |err| {
+ if (Maybe([]u8).errnoSys(system.fcntl(fd, os.F.GETPATH, out_buffer), .fcntl)) |err| {
return err;
}
const len = mem.indexOfScalar(u8, out_buffer[0..], @as(u8, 0)) orelse MAX_PATH_BYTES;
@@ -540,6 +551,22 @@ pub const Error = struct {
syscall: Syscall.Tag = @intToEnum(Syscall.Tag, 0),
path: []const u8 = "",
+ pub fn fromCode(errno: os.E, syscall: Syscall.Tag) Error {
+ return .{ .errno = @truncate(Int, @enumToInt(errno)), .syscall = syscall };
+ }
+
+ pub const oom = fromCode(os.E.NOMEM, .read);
+
+ pub const retry = Error{
+ .errno = if (Environment.isLinux)
+ @intCast(Int, @enumToInt(os.E.AGAIN))
+ else if (Environment.isMac)
+ @intCast(Int, @enumToInt(os.E.WOULDBLOCK))
+ else
+ @intCast(Int, @enumToInt(os.E.INTR)),
+ .syscall = .retry,
+ };
+
pub inline fn getErrno(this: Error) os.E {
return @intToEnum(os.E, this.errno);
}
diff --git a/src/javascript/jsc/node/types.zig b/src/javascript/jsc/node/types.zig
index 8ba9a5901..3906da392 100644
--- a/src/javascript/jsc/node/types.zig
+++ b/src/javascript/jsc/node/types.zig
@@ -73,6 +73,10 @@ pub fn Maybe(comptime ResultType: type) type {
err: Syscall.Error,
result: ReturnType,
+ pub const retry: @This() = .{
+ .err = Syscall.Error.retry,
+ };
+
pub const Tag = enum { err, result };
pub const success: @This() = @This(){
@@ -452,6 +456,7 @@ pub const Valid = struct {
pub const ArgumentsSlice = struct {
remaining: []const JSC.JSValue,
+ vm: *JSC.VirtualMachine,
arena: std.heap.ArenaAllocator = std.heap.ArenaAllocator.init(bun.default_allocator),
all: []const JSC.JSValue,
threw: bool = false,
@@ -459,7 +464,7 @@ pub const ArgumentsSlice = struct {
pub fn unprotect(this: *ArgumentsSlice) void {
var iter = this.protected.iterator(.{});
- var ctx = JSC.VirtualMachine.vm.global.ref();
+ var ctx = this.vm.global.ref();
while (iter.next()) |i| {
JSC.C.JSValueUnprotect(ctx, this.all[i].asObjectRef());
}
@@ -475,24 +480,22 @@ pub const ArgumentsSlice = struct {
if (this.remaining.len == 0) return;
const index = this.all.len - this.remaining.len;
this.protected.set(index);
- JSC.C.JSValueProtect(JSC.VirtualMachine.vm.global.ref(), this.all[index].asObjectRef());
+ JSC.C.JSValueProtect(this.vm.global.ref(), this.all[index].asObjectRef());
this.eat();
}
pub fn protectEatNext(this: *ArgumentsSlice) ?JSC.JSValue {
if (this.remaining.len == 0) return null;
- const index = this.all.len - this.remaining.len;
- this.protected.set(index);
- JSC.C.JSValueProtect(JSC.VirtualMachine.vm.global.ref(), this.all[index].asObjectRef());
return this.nextEat();
}
- pub fn from(arguments: []const JSC.JSValueRef) ArgumentsSlice {
- return init(@ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
+ pub fn from(vm: *JSC.VirtualMachine, arguments: []const JSC.JSValueRef) ArgumentsSlice {
+ return init(vm, @ptrCast([*]const JSC.JSValue, arguments.ptr)[0..arguments.len]);
}
- pub fn init(arguments: []const JSC.JSValue) ArgumentsSlice {
+ pub fn init(vm: *JSC.VirtualMachine, arguments: []const JSC.JSValue) ArgumentsSlice {
return ArgumentsSlice{
.remaining = arguments,
+ .vm = vm,
.all = arguments,
};
}
@@ -2530,7 +2533,8 @@ pub const Path = struct {
pub const Process = struct {
pub fn getArgv(globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue {
- if (JSC.VirtualMachine.vm.argv.len == 0)
+ var vm = globalObject.bunVM();
+ if (vm.argv.len == 0)
return JSC.JSValue.createStringArray(globalObject, null, 0, false);
// Allocate up to 32 strings in stack
@@ -2542,12 +2546,12 @@ pub const Process = struct {
// If it was launched with bun run or bun test, skip it
const skip: usize = @as(usize, @boolToInt(
- JSC.VirtualMachine.vm.argv.len > 1 and (strings.eqlComptime(JSC.VirtualMachine.vm.argv[0], "run") or strings.eqlComptime(JSC.VirtualMachine.vm.argv[0], "wiptest")),
+ vm.argv.len > 1 and (strings.eqlComptime(vm.argv[0], "run") or strings.eqlComptime(vm.argv[0], "wiptest")),
));
var args = allocator.alloc(
JSC.ZigString,
- JSC.VirtualMachine.vm.argv.len + 1,
+ vm.argv.len + 1,
) catch unreachable;
var args_list = std.ArrayListUnmanaged(JSC.ZigString){ .items = args, .capacity = args.len };
args_list.items.len = 0;
@@ -2563,8 +2567,8 @@ pub const Process = struct {
}
}
- if (JSC.VirtualMachine.vm.argv.len > skip) {
- for (JSC.VirtualMachine.vm.argv[skip..]) |arg| {
+ if (vm.argv.len > skip) {
+ for (vm.argv[skip..]) |arg| {
var str = JSC.ZigString.init(arg);
str.setOutputEncoding();
args_list.appendAssumeCapacity(str);
diff --git a/src/javascript/jsc/test/jest.zig b/src/javascript/jsc/test/jest.zig
index a07a4bcac..4be2d63b6 100644
--- a/src/javascript/jsc/test/jest.zig
+++ b/src/javascript/jsc/test/jest.zig
@@ -367,7 +367,16 @@ pub const Expect = struct {
this.scope.tests.items[this.test_id].counter.actual += 1;
const left = JSValue.fromRef(arguments[0]);
const right = JSValue.fromRef(this.value);
+
if (!left.isSameValue(right, ctx.ptr())) {
+ if (left.isString() and right.isString()) {
+ var left_slice = left.toSlice(ctx, getAllocator(ctx));
+ defer left_slice.deinit();
+ var right_slice = right.toSlice(ctx, getAllocator(ctx));
+ defer right_slice.deinit();
+ std.debug.assert(!strings.eqlLong(left_slice.slice(), right_slice.slice(), true));
+ }
+
var lhs_formatter: JSC.ZigConsoleClient.Formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = ctx.ptr() };
var rhs_formatter: JSC.ZigConsoleClient.Formatter = JSC.ZigConsoleClient.Formatter{ .globalThis = ctx.ptr() };
@@ -381,8 +390,10 @@ pub const Expect = struct {
ctx,
exception,
);
+
return null;
}
+
return thisObject;
}
@@ -563,6 +574,7 @@ pub const ExpectPrototype = struct {
.scope = DescribeScope.active,
.test_id = DescribeScope.active.current_test_id,
};
+ expect_.value.?.value().ensureStillAlive();
return Expect.Class.make(ctx, expect_);
}
};
diff --git a/src/javascript/jsc/typescript.zig b/src/javascript/jsc/typescript.zig
index e6dd78ff7..8815071ee 100644
--- a/src/javascript/jsc/typescript.zig
+++ b/src/javascript/jsc/typescript.zig
@@ -40,7 +40,6 @@ pub fn main() anyerror!void {
JSC.WebCore.Fetch.Class.typescriptDeclaration(),
JSC.Performance.Class.typescriptDeclaration(),
JSC.Crypto.Class.typescriptDeclaration(),
- JSC.WebCore.TextEncoder.Class.typescriptDeclaration(),
JSC.WebCore.TextDecoder.Class.typescriptDeclaration(),
JSC.API.Transpiler.Class.typescriptDeclaration(),
};
diff --git a/src/javascript/jsc/webcore.zig b/src/javascript/jsc/webcore.zig
index 1a25c658d..1ed585018 100644
--- a/src/javascript/jsc/webcore.zig
+++ b/src/javascript/jsc/webcore.zig
@@ -1,5 +1,7 @@
pub usingnamespace @import("./webcore/response.zig");
pub usingnamespace @import("./webcore/encoding.zig");
+pub usingnamespace @import("./webcore/streams.zig");
+
const JSC = @import("../../jsc.zig");
const std = @import("std");
diff --git a/src/javascript/jsc/webcore/encoding.zig b/src/javascript/jsc/webcore/encoding.zig
index 245f6127d..b168e97ff 100644
--- a/src/javascript/jsc/webcore/encoding.zig
+++ b/src/javascript/jsc/webcore/encoding.zig
@@ -42,116 +42,128 @@ const picohttp = @import("picohttp");
pub const TextEncoder = struct {
filler: u32 = 0,
- var text_encoder: TextEncoder = TextEncoder{};
-
- pub const Constructor = JSC.NewConstructor(
- TextEncoder,
- .{
- .constructor = .{ .rfn = constructor },
- },
- .{},
- );
-
- pub const Class = NewClass(
- TextEncoder,
- .{
- .name = "TextEncoder",
- },
- .{
- .encode = .{
- .rfn = encode,
- },
- .encodeInto = .{
- .rfn = encodeInto,
- },
- },
- .{
- .encoding = .{
- .get = getEncoding,
- .readOnly = true,
- },
- },
- );
const utf8_string: string = "utf-8";
- pub fn getEncoding(
- _: *TextEncoder,
- ctx: js.JSContextRef,
- _: js.JSValueRef,
- _: js.JSStringRef,
- _: js.ExceptionRef,
- ) js.JSValueRef {
- return ZigString.init(utf8_string).toValue(ctx.ptr()).asObjectRef();
- }
-
- pub fn encode(
- _: *TextEncoder,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- args: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef {
- var arguments: []const JSC.JSValue = @ptrCast([*]const JSC.JSValue, args.ptr)[0..args.len];
-
- if (arguments.len < 1) {
- return JSC.C.JSObjectMakeTypedArray(ctx, JSC.C.JSTypedArrayType.kJSTypedArrayTypeUint8Array, 0, exception);
- }
-
- const value = arguments[0];
-
- var zig_str = value.getZigString(ctx.ptr());
- var array_buffer: ArrayBuffer = undefined;
+ pub export fn TextEncoder__encode(
+ globalThis: *JSGlobalObject,
+ zig_str: *const ZigString,
+ ) JSValue {
+ var ctx = globalThis.ref();
if (zig_str.is16Bit()) {
var bytes = strings.toUTF8AllocWithType(
default_allocator,
@TypeOf(zig_str.utf16Slice()),
zig_str.utf16Slice(),
) catch {
- JSC.throwInvalidArguments("Out of memory", .{}, ctx, exception);
- return null;
+ return JSC.toInvalidArguments("Out of memory", .{}, ctx);
};
- array_buffer = ArrayBuffer.fromBytes(bytes, .Uint8Array);
+ return ArrayBuffer.fromBytes(bytes, .Uint8Array).toJS(ctx, null);
} else {
- var bytes = strings.allocateLatin1IntoUTF8(default_allocator, []const u8, zig_str.slice()) catch {
- JSC.throwInvalidArguments("Out of memory", .{}, ctx, exception);
- return null;
- };
+ // latin1 always has the same length as utf-8
+ // so we can use the Gigacage to allocate the buffer
+ var array = JSC.JSValue.createUninitializedUint8Array(ctx.ptr(), zig_str.len);
+ var buffer = array.asArrayBuffer(ctx.ptr()) orelse
+ return JSC.toInvalidArguments("Out of memory", .{}, ctx);
+ const result = strings.copyLatin1IntoUTF8(buffer.slice(), []const u8, zig_str.slice());
+ std.debug.assert(result.written == zig_str.len);
+ return array;
+ }
- array_buffer = ArrayBuffer.fromBytes(bytes, .Uint8Array);
+ unreachable;
+ }
+
+ // This is a fast path for copying a Rope string into a Uint8Array.
+ // This keeps us from an extra string temporary allocation
+ const RopeStringEncoder = struct {
+ globalThis: *JSGlobalObject,
+ allocator: std.mem.Allocator,
+ buffer_value: JSC.JSValue,
+ slice: []u8,
+ tail: usize = 0,
+ any_utf16: bool = false,
+
+ pub fn append8(it: *JSC.JSString.Iterator, ptr: [*]const u8, len: u32) callconv(.C) void {
+ var this = bun.cast(*RopeStringEncoder, it.data.?);
+ // we use memcpy here instead of encoding
+ // SIMD only has an impact for long strings
+ // so in a case like this, the fastest path is to memcpy
+ // and then later, we can use the SIMD version
+ @memcpy(this.slice.ptr + this.tail, ptr, len);
+ this.tail += len;
+ }
+ pub fn append16(it: *JSC.JSString.Iterator, _: [*]const u16, _: u32) callconv(.C) void {
+ var this = bun.cast(*RopeStringEncoder, it.data.?);
+ this.any_utf16 = true;
+ it.stop = 1;
+ return;
+ }
+ pub fn write8(it: *JSC.JSString.Iterator, ptr: [*]const u8, len: u32, offset: u32) callconv(.C) void {
+ var this = bun.cast(*RopeStringEncoder, it.data.?);
+ // we use memcpy here instead of encoding
+ // SIMD only has an impact for long strings
+ // so in a case like this, the fastest path is to memcpy
+ // and then later, we can use the SIMD version
+ @memcpy(this.slice.ptr + offset, ptr, len);
+ }
+ pub fn write16(it: *JSC.JSString.Iterator, _: [*]const u16, _: u32, _: u32) callconv(.C) void {
+ var this = bun.cast(*RopeStringEncoder, it.data.?);
+ this.any_utf16 = true;
+ it.stop = 1;
+ return;
}
- return array_buffer.toJS(ctx, exception).asObjectRef();
- }
+ pub fn iter(this: *RopeStringEncoder) JSC.JSString.Iterator {
+ return .{
+ .data = this,
+ .stop = 0,
+ .append8 = append8,
+ .append16 = append16,
+ .write8 = write8,
+ .write16 = write16,
+ };
+ }
+ };
- const read_key = ZigString.init("read");
- const written_key = ZigString.init("written");
+ // This fast path is only suitable for Latin-1 strings.
+ // It's not suitable for UTF-16 strings, because getting the byteLength is unpredictable
+ pub export fn TextEncoder__encodeRopeString(
+ globalThis: *JSGlobalObject,
+ rope_str: *JSC.JSString,
+ ) JSValue {
+ var ctx = globalThis.ref();
+ if (comptime Environment.allow_assert) std.debug.assert(rope_str.is8Bit());
+ var array = JSC.JSValue.createUninitializedUint8Array(ctx.ptr(), rope_str.length());
+ var encoder = RopeStringEncoder{
+ .globalThis = globalThis,
+ .allocator = bun.default_allocator,
+ .buffer_value = array,
+ .slice = (array.asArrayBuffer(globalThis) orelse return JSC.JSValue.jsUndefined()).slice(),
+ };
+ var iter = encoder.iter();
+ rope_str.iterator(globalThis, &iter);
- pub fn encodeInto(
- _: *TextEncoder,
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: js.JSObjectRef,
- args: []const js.JSValueRef,
- exception: js.ExceptionRef,
- ) js.JSValueRef {
- var arguments: []const JSC.JSValue = @ptrCast([*]const JSC.JSValue, args.ptr)[0..args.len];
+ if (encoder.any_utf16) {
+ return JSC.JSValue.jsUndefined();
+ }
- if (arguments.len < 2) {
- JSC.throwInvalidArguments("TextEncoder.encodeInto expects (string, Uint8Array)", .{}, ctx, exception);
- return null;
+ if (comptime !bun.FeatureFlags.latin1_is_now_ascii) {
+ strings.replaceLatin1WithUTF8(encoder.slice);
}
- const value = arguments[0];
+ return array;
+ }
- const array_buffer = arguments[1].asArrayBuffer(ctx.ptr()) orelse {
- JSC.throwInvalidArguments("TextEncoder.encodeInto expects a Uint8Array", .{}, ctx, exception);
- return null;
- };
+ const read_key = ZigString.init("read");
+ const written_key = ZigString.init("written");
- var output = array_buffer.slice();
- const input = value.getZigString(ctx.ptr());
+ pub export fn TextEncoder__encodeInto(
+ globalThis: *JSC.JSGlobalObject,
+ input: *const ZigString,
+ buf_ptr: [*]u8,
+ buf_len: usize,
+ ) JSC.JSValue {
+ var output = buf_ptr[0..buf_len];
var result: strings.EncodeIntoResult = strings.EncodeIntoResult{ .read = 0, .written = 0 };
if (input.is16Bit()) {
const utf16_slice = input.utf16Slice();
@@ -159,18 +171,17 @@ pub const TextEncoder = struct {
} else {
result = strings.copyLatin1IntoUTF8(output, @TypeOf(input.slice()), input.slice());
}
- return JSC.JSValue.createObject2(ctx.ptr(), &read_key, &written_key, JSValue.jsNumber(result.read), JSValue.jsNumber(result.written)).asObjectRef();
+ return JSC.JSValue.createObject2(globalThis, &read_key, &written_key, JSValue.jsNumber(result.read), JSValue.jsNumber(result.written));
}
+};
- pub fn constructor(
- ctx: js.JSContextRef,
- _: js.JSObjectRef,
- _: []const js.JSValueRef,
- _: js.ExceptionRef,
- ) js.JSObjectRef {
- return TextEncoder.Class.make(ctx, &text_encoder);
+comptime {
+ if (!JSC.is_bindgen) {
+ _ = TextEncoder.TextEncoder__encode;
+ _ = TextEncoder.TextEncoder__encodeInto;
+ _ = TextEncoder.TextEncoder__encodeRopeString;
}
-};
+}
/// https://encoding.spec.whatwg.org/encodings.json
pub const EncodingLabel = enum {
@@ -731,51 +742,51 @@ pub const Encoder = struct {
export fn Bun__encoding__constructFromLatin1AsHex(globalObject: *JSGlobalObject, input: [*]const u8, len: usize) JSValue {
var slice = constructFromU8(input, len, .hex);
- return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
+ return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator);
}
export fn Bun__encoding__constructFromLatin1AsASCII(globalObject: *JSGlobalObject, input: [*]const u8, len: usize) JSValue {
var slice = constructFromU8(input, len, .ascii);
- return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
+ return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator);
}
export fn Bun__encoding__constructFromLatin1AsURLSafeBase64(globalObject: *JSGlobalObject, input: [*]const u8, len: usize) JSValue {
var slice = constructFromU8(input, len, .base64url);
- return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
+ return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator);
}
export fn Bun__encoding__constructFromLatin1AsUTF16(globalObject: *JSGlobalObject, input: [*]const u8, len: usize) JSValue {
var slice = constructFromU8(input, len, .utf16le);
- return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
+ return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator);
}
export fn Bun__encoding__constructFromLatin1AsUTF8(globalObject: *JSGlobalObject, input: [*]const u8, len: usize) JSValue {
var slice = constructFromU8(input, len, JSC.Node.Encoding.utf8);
- return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
+ return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator);
}
export fn Bun__encoding__constructFromLatin1AsBase64(globalObject: *JSGlobalObject, input: [*]const u8, len: usize) JSValue {
var slice = constructFromU8(input, len, .base64);
- return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
+ return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator);
}
export fn Bun__encoding__constructFromUTF16AsBase64(globalObject: *JSGlobalObject, input: [*]const u16, len: usize) JSValue {
var slice = constructFromU16(input, len, .base64);
- return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
+ return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator);
}
export fn Bun__encoding__constructFromUTF16AsHex(globalObject: *JSGlobalObject, input: [*]const u16, len: usize) JSValue {
var slice = constructFromU16(input, len, .hex);
- return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
+ return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator);
}
export fn Bun__encoding__constructFromUTF16AsURLSafeBase64(globalObject: *JSGlobalObject, input: [*]const u16, len: usize) JSValue {
var slice = constructFromU16(input, len, .base64url);
- return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
+ return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator);
}
export fn Bun__encoding__constructFromUTF16AsUTF16(globalObject: *JSGlobalObject, input: [*]const u16, len: usize) JSValue {
var slice = constructFromU16(input, len, JSC.Node.Encoding.utf16le);
- return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
+ return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator);
}
export fn Bun__encoding__constructFromUTF16AsUTF8(globalObject: *JSGlobalObject, input: [*]const u16, len: usize) JSValue {
var slice = constructFromU16(input, len, .utf8);
- return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
+ return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator);
}
export fn Bun__encoding__constructFromUTF16AsASCII(globalObject: *JSGlobalObject, input: [*]const u16, len: usize) JSValue {
var slice = constructFromU16(input, len, .utf8);
- return JSC.JSValue.createBuffer(globalObject, slice, VirtualMachine.vm.allocator);
+ return JSC.JSValue.createBuffer(globalObject, slice, globalObject.bunVM().allocator);
}
export fn Bun__encoding__toStringUTF16(input: [*]const u8, len: usize, globalObject: *JSC.JSGlobalObject) JSValue {
diff --git a/src/javascript/jsc/webcore/response.zig b/src/javascript/jsc/webcore/response.zig
index bd6d05bcc..19134b357 100644
--- a/src/javascript/jsc/webcore/response.zig
+++ b/src/javascript/jsc/webcore/response.zig
@@ -7,7 +7,7 @@ const ZigURL = @import("../../../url.zig").URL;
const HTTPClient = @import("http");
const NetworkThread = HTTPClient.NetworkThread;
const AsyncIO = NetworkThread.AsyncIO;
-const JSC = @import("../../../jsc.zig");
+const JSC = @import("javascript_core");
const js = JSC.C;
const Method = @import("../../../http/method.zig").Method;
@@ -38,11 +38,12 @@ const JSError = JSC.JSError;
const JSGlobalObject = JSC.JSGlobalObject;
const VirtualMachine = @import("../javascript.zig").VirtualMachine;
-const Task = @import("../javascript.zig").Task;
+const Task = JSC.Task;
const JSPrinter = @import("../../../js_printer.zig");
const picohttp = @import("picohttp");
const StringJoiner = @import("../../../string_joiner.zig");
const uws = @import("uws");
+
pub const Response = struct {
pub const Pool = struct {
response_objects_pool: [127]JSC.C.JSObjectRef = undefined,
@@ -92,6 +93,7 @@ pub const Response = struct {
},
.{},
);
+
pub const Class = NewClass(
Response,
.{ .name = "Response" },
@@ -317,7 +319,8 @@ pub const Response = struct {
pub fn makeMaybePooled(ctx: js.JSContextRef, ptr: *Response) JSC.C.JSObjectRef {
if (comptime JSC.is_bindgen)
unreachable;
- if (JSC.VirtualMachine.vm.response_objects_pool) |pool| {
+ var vm = ctx.bunVM();
+ if (vm.response_objects_pool) |pool| {
if (pool.get(ptr)) |object| {
JSC.C.JSValueUnprotect(ctx, object);
return object;
@@ -417,7 +420,7 @@ pub const Response = struct {
_: js.ExceptionRef,
) js.JSObjectRef {
// https://github.com/remix-run/remix/blob/db2c31f64affb2095e4286b91306b96435967969/packages/remix-server-runtime/responses.ts#L4
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
// var response = getAllocator(ctx).create(Response) catch unreachable;
var response = Response{
@@ -480,7 +483,7 @@ pub const Response = struct {
_: js.ExceptionRef,
) js.JSObjectRef {
// https://github.com/remix-run/remix/blob/db2c31f64affb2095e4286b91306b96435967969/packages/remix-server-runtime/responses.ts#L4
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
// var response = getAllocator(ctx).create(Response) catch unreachable;
var response = Response{
@@ -892,7 +895,7 @@ pub const Fetch = struct {
var headers: ?Headers = null;
var body: MutableString = MutableString.initEmpty(bun.default_allocator);
var method = Method.GET;
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
var url: ZigURL = undefined;
var first_arg = args.nextEat().?;
var blob_store: ?*Blob.Store = null;
@@ -1042,7 +1045,7 @@ pub const Headers = struct {
};
headers.entries.ensureTotalCapacity(allocator, header_count) catch unreachable;
headers.entries.len = header_count;
- headers.buf.ensureTotalCapacity(allocator, buf_len) catch unreachable;
+ headers.buf.ensureTotalCapacityPrecise(allocator, buf_len) catch unreachable;
headers.buf.items.len = buf_len;
var sliced = headers.entries.slice();
var names = sliced.items(.name);
@@ -1275,7 +1278,7 @@ pub const Blob = struct {
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) js.JSObjectRef {
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
// accept a path or a blob
var path_or_blob = PathOrBlob.fromJS(ctx, &args, exception) orelse {
exception.* = JSC.toInvalidArguments("Bun.write expects a path, file descriptor or a blob", .{}, ctx).asObjectRef();
@@ -1398,7 +1401,7 @@ pub const Blob = struct {
arguments: []const js.JSValueRef,
exception: js.ExceptionRef,
) js.JSObjectRef {
- var args = JSC.Node.ArgumentsSlice.from(arguments);
+ var args = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), arguments);
defer args.deinit();
var path = JSC.Node.PathOrFileDescriptor.fromJS(ctx, &args, exception) orelse {
@@ -1416,7 +1419,8 @@ pub const Blob = struct {
pub fn findOrCreateFileFromPath(path_: JSC.Node.PathOrFileDescriptor, globalThis: *JSGlobalObject) Blob {
var path = path_;
- if (VirtualMachine.vm.getFileBlob(path)) |blob| {
+ var vm = globalThis.bunVM();
+ if (vm.getFileBlob(path)) |blob| {
blob.ref();
return Blob.initWithStore(blob, globalThis);
}
@@ -1432,15 +1436,15 @@ pub const Blob = struct {
.fd => {
switch (path.fd) {
std.os.STDIN_FILENO => return Blob.initWithStore(
- VirtualMachine.vm.rareData().stdin(),
+ vm.rareData().stdin(),
globalThis,
),
std.os.STDERR_FILENO => return Blob.initWithStore(
- VirtualMachine.vm.rareData().stderr(),
+ vm.rareData().stderr(),
globalThis,
),
std.os.STDOUT_FILENO => return Blob.initWithStore(
- VirtualMachine.vm.rareData().stdout(),
+ vm.rareData().stdout(),
globalThis,
),
else => {},
@@ -1449,7 +1453,7 @@ pub const Blob = struct {
}
const result = Blob.initWithStore(Blob.Store.initFile(path, null, bun.default_allocator) catch unreachable, globalThis);
- VirtualMachine.vm.putFileBlob(path, result.store.?) catch unreachable;
+ vm.putFileBlob(path, result.store.?) catch unreachable;
return result;
}
@@ -2649,6 +2653,8 @@ pub const Blob = struct {
mime_type: HTTPClient.MimeType = HTTPClient.MimeType.other,
is_atty: ?bool = null,
mode: JSC.Node.Mode = 0,
+ seekable: ?bool = null,
+ max_size: SizeType = 0,
pub fn init(pathlike: JSC.Node.PathOrFileDescriptor, mime_type: ?HTTPClient.MimeType) FileStore {
return .{ .pathlike = pathlike, .mime_type = mime_type orelse HTTPClient.MimeType.other };
@@ -2705,21 +2711,17 @@ pub const Blob = struct {
pub const Class = NewClass(
Blob,
.{ .name = "Blob" },
- .{
- .finalize = finalize,
- .text = .{
- .rfn = getText,
- },
- .json = .{
- .rfn = getJSON,
- },
- .arrayBuffer = .{
- .rfn = getArrayBuffer,
- },
- .slice = .{
- .rfn = getSlice,
- },
- },
+ .{ .finalize = finalize, .text = .{
+ .rfn = getText,
+ }, .json = .{
+ .rfn = getJSON,
+ }, .arrayBuffer = .{
+ .rfn = getArrayBuffer,
+ }, .slice = .{
+ .rfn = getSlice,
+ }, .stream = .{
+ .rfn = getStream,
+ } },
.{
.@"type" = .{
.get = getType,
@@ -2732,6 +2734,30 @@ pub const Blob = struct {
},
);
+ pub fn getStream(
+ this: *Blob,
+ ctx: js.JSContextRef,
+ _: js.JSObjectRef,
+ _: js.JSObjectRef,
+ arguments: []const js.JSValueRef,
+ exception: js.ExceptionRef,
+ ) JSC.C.JSValueRef {
+ var recommended_chunk_size: SizeType = 0;
+ if (arguments.len > 0) {
+ if (!JSValue.c(arguments[0]).isNumber() and !JSValue.c(arguments[0]).isUndefinedOrNull()) {
+ JSC.throwInvalidArguments("chunkSize must be a number", .{}, ctx, exception);
+ return null;
+ }
+
+ recommended_chunk_size = @intCast(SizeType, @maximum(0, @truncate(i52, JSValue.c(arguments[0]).toInt64())));
+ }
+ return JSC.WebCore.ReadableStream.fromBlob(
+ ctx.ptr(),
+ this,
+ recommended_chunk_size,
+ ).asObjectRef();
+ }
+
fn promisified(
value: JSC.JSValue,
global: *JSGlobalObject,
@@ -2815,7 +2841,7 @@ pub const Blob = struct {
// If the optional end parameter is not used as a parameter when making this call, let relativeEnd be size.
var relativeEnd: i64 = @intCast(i64, this.size);
- var args_iter = JSC.Node.ArgumentsSlice.from(args);
+ var args_iter = JSC.Node.ArgumentsSlice.from(ctx.bunVM(), args);
if (args_iter.nextEat()) |start_| {
const start = start_.toInt64();
if (start < 0) {
@@ -3417,7 +3443,7 @@ pub const Blob = struct {
},
.ret = undefined,
};
- JSC.VirtualMachine.vm.global.vm().deferGC(&ctx, DeferCtx.run);
+ global.vm().deferGC(&ctx, DeferCtx.run);
return ctx.ret;
}
@@ -3488,6 +3514,7 @@ pub const Blob = struct {
JSC.JSValue.JSType.DataView,
=> {
var buf = try bun.default_allocator.dupe(u8, top_value.asArrayBuffer(global).?.byteSlice());
+
return Blob.init(buf, bun.default_allocator, global);
},
@@ -3518,6 +3545,7 @@ pub const Blob = struct {
var stack_mem_all = stack_allocator.get();
var stack: std.ArrayList(JSValue) = std.ArrayList(JSValue).init(stack_mem_all);
var joiner = StringJoiner{ .use_pool = false, .node_allocator = stack_mem_all };
+ var could_have_non_ascii = false;
defer if (stack_allocator.fixed_buffer_allocator.end_index >= 1024) stack.deinit();
@@ -3529,6 +3557,7 @@ pub const Blob = struct {
JSC.JSValue.JSType.DerivedStringObject,
=> {
var sliced = current.toSlice(global, bun.default_allocator);
+ could_have_non_ascii = could_have_non_ascii or sliced.allocated;
joiner.append(
sliced.slice(),
0,
@@ -3557,6 +3586,7 @@ pub const Blob = struct {
JSC.JSValue.JSType.DerivedStringObject,
=> {
var sliced = item.toSlice(global, bun.default_allocator);
+ could_have_non_ascii = could_have_non_ascii or sliced.allocated;
joiner.append(
sliced.slice(),
0,
@@ -3578,12 +3608,14 @@ pub const Blob = struct {
JSC.JSValue.JSType.BigUint64Array,
JSC.JSValue.JSType.DataView,
=> {
+ could_have_non_ascii = true;
var buf = item.asArrayBuffer(global).?;
joiner.append(buf.byteSlice(), 0, null);
continue;
},
.Array, .DerivedArray => {
any_arrays = true;
+ could_have_non_ascii = true;
break;
},
else => {
@@ -3592,6 +3624,7 @@ pub const Blob = struct {
switch (data.tag()) {
.Blob => {
var blob: *Blob = data.as(Blob);
+ could_have_non_ascii = could_have_non_ascii or !(blob.is_all_ascii orelse false);
joiner.append(blob.sharedView(), 0, null);
continue;
},
@@ -3622,6 +3655,7 @@ pub const Blob = struct {
=> {
var buf = current.asArrayBuffer(global).?;
joiner.append(buf.slice(), 0, null);
+ could_have_non_ascii = true;
},
else => {
@@ -3631,6 +3665,7 @@ pub const Blob = struct {
switch (data.tag()) {
.Blob => {
var blob: *Blob = data.as(Blob);
+ could_have_non_ascii = could_have_non_ascii or !(blob.is_all_ascii orelse false);
joiner.append(blob.sharedView(), 0, null);
break :outer;
},
@@ -3639,6 +3674,7 @@ pub const Blob = struct {
}
var sliced = current.toSlice(global, bun.default_allocator);
+ could_have_non_ascii = could_have_non_ascii or sliced.allocated;
joiner.append(
sliced.slice(),
0,
@@ -3651,6 +3687,10 @@ pub const Blob = struct {
}
var joined = try joiner.done(bun.default_allocator);
+
+ if (!could_have_non_ascii) {
+ return Blob.initWithAllASCII(joined, bun.default_allocator, global, true);
+ }
return Blob.init(joined, bun.default_allocator, global);
}
};
@@ -3771,13 +3811,15 @@ pub const Body = struct {
pub const PendingValue = struct {
promise: ?JSValue = null,
+ readable: JSValue = JSValue.zero,
+
global: *JSGlobalObject,
task: ?*anyopaque = null,
/// runs after the data is available.
callback: ?fn (ctx: *anyopaque, value: *Value) void = null,
/// conditionally runs when requesting data
/// used in HTTP server to ignore request bodies unless asked for it
- onRequestData: ?fn (ctx: *anyopaque) void = null,
+ onPull: ?fn (ctx: *anyopaque) void = null,
deinit: bool = false,
action: Action = Action.none,
@@ -3786,9 +3828,9 @@ pub const Body = struct {
var promise = JSC.JSPromise.create(globalThis);
const promise_value = promise.asValue(globalThis);
value.promise = promise_value;
- if (value.onRequestData) |onRequestData| {
- value.onRequestData = null;
- onRequestData(value.task.?);
+ if (value.onPull) |onPull| {
+ value.onPull = null;
+ onPull(value.task.?);
}
return promise_value;
}
@@ -3905,6 +3947,12 @@ pub const Body = struct {
this.* = .{ .Error = error_instance };
}
+ pub fn toErrorString(this: *Value, comptime err: string, global: *JSGlobalObject) void {
+ var error_str = ZigString.init(err);
+ var error_instance = error_str.toErrorInstance(global);
+ return this.toErrorInstance(error_instance, global);
+ }
+
pub fn toError(this: *Value, err: anyerror, global: *JSGlobalObject) void {
var error_str = ZigString.init(std.fmt.allocPrint(
bun.default_allocator,
@@ -4003,6 +4051,11 @@ pub const Body = struct {
} else |_| {}
}
+ // if (value.as(JSC.WebCore.ReadableStream)) |readable| {
+ // body.value = Body.Value.fromReadableStream(ctx, readable);
+ // return body;
+ // }
+
body.value = .{
.Blob = Blob.fromJS(ctx.ptr(), value, true, false) catch |err| {
if (err == error.InvalidArguments) {
diff --git a/src/javascript/jsc/webcore/streams.zig b/src/javascript/jsc/webcore/streams.zig
new file mode 100644
index 000000000..13829cd91
--- /dev/null
+++ b/src/javascript/jsc/webcore/streams.zig
@@ -0,0 +1,1321 @@
+const std = @import("std");
+const Api = @import("../../../api/schema.zig").Api;
+const bun = @import("../../../global.zig");
+const RequestContext = @import("../../../http.zig").RequestContext;
+const MimeType = @import("../../../http.zig").MimeType;
+const ZigURL = @import("../../../url.zig").URL;
+const HTTPClient = @import("http");
+const NetworkThread = HTTPClient.NetworkThread;
+const AsyncIO = NetworkThread.AsyncIO;
+const JSC = @import("javascript_core");
+const js = JSC.C;
+
+const Method = @import("../../../http/method.zig").Method;
+const FetchHeaders = JSC.FetchHeaders;
+const ObjectPool = @import("../../../pool.zig").ObjectPool;
+const SystemError = JSC.SystemError;
+const Output = @import("../../../global.zig").Output;
+const MutableString = @import("../../../global.zig").MutableString;
+const strings = @import("../../../global.zig").strings;
+const string = @import("../../../global.zig").string;
+const default_allocator = @import("../../../global.zig").default_allocator;
+const FeatureFlags = @import("../../../global.zig").FeatureFlags;
+const ArrayBuffer = @import("../base.zig").ArrayBuffer;
+const Properties = @import("../base.zig").Properties;
+const NewClass = @import("../base.zig").NewClass;
+const d = @import("../base.zig").d;
+const castObj = @import("../base.zig").castObj;
+const getAllocator = @import("../base.zig").getAllocator;
+const JSPrivateDataPtr = @import("../base.zig").JSPrivateDataPtr;
+const GetJSPrivateData = @import("../base.zig").GetJSPrivateData;
+const Environment = @import("../../../env.zig");
+const ZigString = JSC.ZigString;
+const IdentityContext = @import("../../../identity_context.zig").IdentityContext;
+const JSInternalPromise = JSC.JSInternalPromise;
+const JSPromise = JSC.JSPromise;
+const JSValue = JSC.JSValue;
+const JSError = JSC.JSError;
+const JSGlobalObject = JSC.JSGlobalObject;
+
+const VirtualMachine = @import("../javascript.zig").VirtualMachine;
+const Task = JSC.Task;
+const JSPrinter = @import("../../../js_printer.zig");
+const picohttp = @import("picohttp");
+const StringJoiner = @import("../../../string_joiner.zig");
+const uws = @import("uws");
+const Blob = JSC.WebCore.Blob;
+const Response = JSC.WebCore.Response;
+const Request = JSC.WebCore.Request;
+
+pub const ReadableStream = struct {
+ pub const Tag = enum(i32) {
+ Blob = 1,
+ File = 2,
+ HTTPRequest = 3,
+ HTTPSRequest = 4,
+ };
+
+ extern fn ZigGlobalObject__createNativeReadableStream(*JSGlobalObject, nativePtr: JSValue, nativeType: JSValue) JSValue;
+
+ pub fn fromNative(globalThis: *JSGlobalObject, id: Tag, ptr: *anyopaque) JSC.JSValue {
+ return ZigGlobalObject__createNativeReadableStream(globalThis, JSValue.fromPtr(ptr), JSValue.jsNumber(@enumToInt(id)));
+ }
+ pub fn fromBlob(globalThis: *JSGlobalObject, blob: *const Blob, recommended_chunk_size: Blob.SizeType) JSC.JSValue {
+ if (comptime JSC.is_bindgen)
+ unreachable;
+ var store = blob.store orelse {
+ return ReadableStream.empty(globalThis);
+ };
+ switch (store.data) {
+ .bytes => {
+ var reader = bun.default_allocator.create(ByteBlobLoader.Source) catch unreachable;
+ reader.* = .{
+ .context = undefined,
+ };
+ reader.context.setup(blob, recommended_chunk_size);
+ return reader.toJS(globalThis);
+ },
+ .file => {
+ var reader = bun.default_allocator.create(FileBlobLoader.Source) catch unreachable;
+ reader.* = .{
+ .context = undefined,
+ };
+ reader.context.setup(store, recommended_chunk_size);
+ return reader.toJS(globalThis);
+ },
+ }
+ }
+
+ pub fn empty(globalThis: *JSGlobalObject) JSC.JSValue {
+ if (comptime JSC.is_bindgen)
+ unreachable;
+
+ return ReadableStream__empty(globalThis);
+ }
+
+ extern fn ReadableStream__empty(*JSGlobalObject) JSC.JSValue;
+ extern fn ReadableStream__fromBlob(
+ *JSGlobalObject,
+ store: *anyopaque,
+ offset: usize,
+ length: usize,
+ ) JSC.JSValue;
+ const Base = @import("../../../ast/base.zig");
+ pub const StreamTag = enum(usize) {
+ invalid = 0,
+ _,
+
+ pub fn init(filedes: JSC.Node.FileDescriptor) StreamTag {
+ var bytes = [8]u8{ 1, 0, 0, 0, 0, 0, 0, 0 };
+ const filedes_ = @bitCast([8]u8, @as(usize, @truncate(u56, @intCast(usize, filedes))));
+ bytes[1..8].* = filedes_[0..7].*;
+
+ return @intToEnum(StreamTag, @bitCast(u64, bytes));
+ }
+
+ pub fn fd(this: StreamTag) JSC.Node.FileDescriptor {
+ var bytes = @bitCast([8]u8, @enumToInt(this));
+ if (bytes[0] != 1) {
+ return std.math.maxInt(JSC.Node.FileDescriptor);
+ }
+ var out: u64 = 0;
+ @bitCast([8]u8, out)[0..7].* = bytes[1..8].*;
+ return @intCast(JSC.Node.FileDescriptor, out);
+ }
+ };
+
+ pub fn NewNativeReader(
+ comptime Context: type,
+ comptime onEnqueue: anytype,
+ comptime onEnqueueMany: anytype,
+ comptime onClose: anytype,
+ comptime onError: anytype,
+ comptime name_: []const u8,
+ ) type {
+ return struct {
+ pub const JSReadableStreamReaderNative = struct {
+ pub const shim = JSC.Shimmer(std.mem.span(name_), "JSReadableStreamReaderNative", @This());
+ pub const tag = Context.tag;
+ pub const name = std.fmt.comptimePrint("{s}_JSReadableStreamReaderNative", .{std.mem.span(name_)});
+
+ pub fn enqueue(globalThis: *JSGlobalObject, callframe: *const JSC.CallFrame) callconv(.C) JSC.JSValue {
+ var this = callframe.argument(0).asPtr(*Context);
+ var buffer = callframe.argument(1).asArrayBuffer(globalThis) orelse {
+ globalThis.vm().throwError(globalThis, JSC.toInvalidArguments("Expected TypedArray or ArrayBuffer", .{}, globalThis));
+ return JSC.JSValue.jsUndefined();
+ };
+ return onEnqueue(this, globalThis, buffer.slice(), callframe.argument(1));
+ }
+
+ pub fn enqueueMany(globalThis: *JSGlobalObject, callframe: *const JSC.CallFrame) callconv(.C) JSC.JSValue {
+ var this = callframe.argument(0).asPtr(*Context);
+ return onEnqueueMany(this, globalThis, callframe.argument(1));
+ }
+
+ pub fn close(globalThis: *JSGlobalObject, callframe: *const JSC.CallFrame) callconv(.C) JSC.JSValue {
+ var this = callframe.argument(0).asPtr(*Context);
+ return onClose(this, globalThis, callframe.argument(1));
+ }
+
+ pub fn @"error"(globalThis: *JSGlobalObject, callframe: *const JSC.CallFrame) callconv(.C) JSC.JSValue {
+ var this = callframe.argument(0).asPtr(*Context);
+ return onError(this, globalThis, callframe.argument(1));
+ }
+
+ pub fn load(globalThis: *JSGlobalObject) callconv(.C) JSC.JSValue {
+ if (comptime JSC.is_bindgen) unreachable;
+ if (comptime Environment.allow_assert) {
+ // this should be cached per globals object
+ const OnlyOnce = struct {
+ pub threadlocal var last_globals: ?*JSGlobalObject = null;
+ };
+ if (OnlyOnce.last_globals) |last_globals| {
+ std.debug.assert(last_globals != globalThis);
+ }
+ OnlyOnce.last_globals = globalThis;
+ }
+ return JSC.JSArray.from(globalThis, &.{
+ JSC.NewFunction(globalThis, null, 2, JSReadableStreamReaderNative.enqueue),
+ JSC.NewFunction(globalThis, null, 2, JSReadableStreamReaderNative.enqueueMany),
+ JSC.NewFunction(globalThis, null, 2, JSReadableStreamReaderNative.close),
+ JSC.NewFunction(globalThis, null, 2, JSReadableStreamReaderNative.@"error"),
+ });
+ }
+
+ pub const Export = shim.exportFunctions(.{
+ .@"load" = load,
+ });
+
+ comptime {
+ if (!JSC.is_bindgen) {
+ @export(load, .{ .name = Export[0].symbol_name });
+ _ = JSReadableStreamReaderNative.enqueue;
+ _ = JSReadableStreamReaderNative.enqueueMany;
+ _ = JSReadableStreamReaderNative.close;
+ _ = JSReadableStreamReaderNative.@"error";
+ }
+ }
+ };
+ };
+ }
+};
+
+pub const StreamStart = union(enum) {
+ empty: void,
+ err: JSC.Node.Syscall.Error,
+ chunk_size: Blob.SizeType,
+ ready: void,
+};
+
+pub const StreamResult = union(enum) {
+ owned: bun.ByteList,
+ owned_and_done: bun.ByteList,
+ temporary_and_done: bun.ByteList,
+ temporary: bun.ByteList,
+ into_array: IntoArray,
+ into_array_and_done: IntoArray,
+ pending: *Pending,
+ err: JSC.Node.Syscall.Error,
+ done: void,
+
+ pub const IntoArray = struct {
+ value: JSValue = JSValue.zero,
+ len: Blob.SizeType = std.math.maxInt(Blob.SizeType),
+ };
+
+ pub const Pending = struct {
+ frame: anyframe,
+ result: StreamResult,
+ used: bool = false,
+ };
+
+ pub fn isDone(this: *const StreamResult) bool {
+ return switch (this.*) {
+ .owned_and_done, .temporary_and_done, .into_array_and_done, .done, .err => true,
+ else => false,
+ };
+ }
+
+ fn toPromisedWrap(globalThis: *JSGlobalObject, promise: *JSPromise, pending: *Pending) void {
+ suspend {}
+
+ pending.used = true;
+ const result: StreamResult = pending.result;
+
+ switch (result) {
+ .err => |err| {
+ promise.reject(globalThis, err.toJSC(globalThis));
+ },
+ .done => {
+ promise.resolve(globalThis, JSValue.jsBoolean(false));
+ },
+ else => {
+ promise.resolve(globalThis, result.toJS(globalThis));
+ },
+ }
+ }
+
+ pub fn toPromised(globalThis: *JSGlobalObject, promise: *JSPromise, pending: *Pending) void {
+ var frame = bun.default_allocator.create(@Frame(toPromisedWrap)) catch unreachable;
+ frame.* = async toPromisedWrap(globalThis, promise, pending);
+ pending.frame = frame;
+ }
+
+ pub fn toJS(this: *const StreamResult, globalThis: *JSGlobalObject) JSValue {
+ switch (this.*) {
+ .owned => |list| {
+ return JSC.ArrayBuffer.fromBytes(list.slice(), .Uint8Array).toJS(globalThis.ref(), null);
+ },
+ .owned_and_done => |list| {
+ return JSC.ArrayBuffer.fromBytes(list.slice(), .Uint8Array).toJS(globalThis.ref(), null);
+ },
+ .temporary => |temp| {
+ var array = JSC.JSValue.createUninitializedUint8Array(globalThis, temp.len);
+ var slice = array.asArrayBuffer(globalThis).?.slice();
+ @memcpy(slice.ptr, temp.ptr, temp.len);
+ return array;
+ },
+ .temporary_and_done => |temp| {
+ var array = JSC.JSValue.createUninitializedUint8Array(globalThis, temp.len);
+ var slice = array.asArrayBuffer(globalThis).?.slice();
+ @memcpy(slice.ptr, temp.ptr, temp.len);
+ return array;
+ },
+ .into_array => |array| {
+ return JSC.JSValue.jsNumberFromInt64(array.len);
+ },
+ .into_array_and_done => |array| {
+ return JSC.JSValue.jsNumberFromInt64(array.len);
+ },
+ .pending => |pending| {
+ var promise = JSC.JSPromise.create(globalThis);
+ toPromised(globalThis, promise, pending);
+ return promise.asValue(globalThis);
+ },
+
+ .err => |err| {
+ return JSC.JSPromise.rejectedPromise(globalThis, JSValue.c(err.toJS(globalThis.ref()))).asValue(globalThis);
+ },
+
+ // false == controller.close()
+ // undefined == noop, but we probably won't send it
+ .done => {
+ return JSC.JSValue.jsBoolean(false);
+ },
+ }
+ }
+};
+
+pub fn WritableStreamSink(
+ comptime Context: type,
+ comptime onStart: ?fn (this: Context) void,
+ comptime onWrite: fn (this: Context, bytes: []const u8) JSC.Maybe(Blob.SizeType),
+ comptime onAbort: ?fn (this: Context) void,
+ comptime onClose: ?fn (this: Context) void,
+ comptime deinit: ?fn (this: Context) void,
+) type {
+ return struct {
+ context: Context,
+ closed: bool = false,
+ deinited: bool = false,
+ pending_err: ?JSC.Node.Syscall.Error = null,
+ aborted: bool = false,
+
+ abort_signaler: ?*anyopaque = null,
+ onAbortCallback: ?fn (?*anyopaque) void = null,
+
+ close_signaler: ?*anyopaque = null,
+ onCloseCallback: ?fn (?*anyopaque) void = null,
+
+ pub const This = @This();
+
+ pub fn write(this: *This, bytes: []const u8) JSC.Maybe(Blob.SizeType) {
+ if (this.pending_err) |err| {
+ this.pending_err = null;
+ return .{ .err = err };
+ }
+
+ if (this.closed or this.aborted or this.deinited) {
+ return .{ .result = 0 };
+ }
+ return onWrite(&this.context, bytes);
+ }
+
+ pub fn start(this: *This) StreamStart {
+ return onStart(&this.context);
+ }
+
+ pub fn abort(this: *This) void {
+ if (this.closed or this.deinited or this.aborted) {
+ return;
+ }
+
+ this.aborted = true;
+ onAbort(&this.context);
+ }
+
+ pub fn didAbort(this: *This) void {
+ if (this.closed or this.deinited or this.aborted) {
+ return;
+ }
+ this.aborted = true;
+
+ if (this.onAbortCallback) |cb| {
+ this.onAbortCallback = null;
+ cb(this.abort_signaler);
+ }
+ }
+
+ pub fn didClose(this: *This) void {
+ if (this.closed or this.deinited or this.aborted) {
+ return;
+ }
+ this.closed = true;
+
+ if (this.onCloseCallback) |cb| {
+ this.onCloseCallback = null;
+ cb(this.close_signaler);
+ }
+ }
+
+ pub fn close(this: *This) void {
+ if (this.closed or this.deinited or this.aborted) {
+ return;
+ }
+
+ this.closed = true;
+ onClose(this.context);
+ }
+
+ pub fn deinit(this: *This) void {
+ if (this.deinited) {
+ return;
+ }
+ this.deinited = true;
+ deinit(this.context);
+ }
+
+ pub fn getError(this: *This) ?JSC.Node.Syscall.Error {
+ if (this.pending_err) |err| {
+ this.pending_err = null;
+ return err;
+ }
+
+ return null;
+ }
+ };
+}
+
+pub fn HTTPServerWritable(comptime ssl: bool) type {
+ return struct {
+ pub const UWSResponse = uws.NewApp(ssl).Response;
+ res: *UWSResponse,
+ pending_chunk: []const u8 = "",
+ is_listening_for_abort: bool = false,
+ wrote: Blob.SizeType = 0,
+ callback: anyframe->JSC.Maybe(Blob.SizeType) = undefined,
+ writable: Writable,
+
+ pub fn onWritable(this: *@This(), available: c_ulong, _: *UWSResponse) callconv(.C) bool {
+ const to_write = @minimum(@truncate(Blob.SizeType, available), @truncate(Blob.SizeType, this.pending_chunk.len));
+ if (!this.res.write(this.pending_chunk[0..to_write])) {
+ return true;
+ }
+
+ this.pending_chunk = this.pending_chunk[to_write..];
+ this.wrote += to_write;
+ if (this.pending_chunk.len > 0) {
+ this.res.onWritable(*@This(), onWritable, this);
+ return true;
+ }
+
+ var callback = this.callback;
+ this.callback = undefined;
+ // TODO: clarify what the boolean means
+ resume callback;
+ bun.default_allocator.destroy(callback.*);
+ return false;
+ }
+
+ pub fn onStart(this: *@This()) void {
+ if (this.res.hasResponded()) {
+ this.writable.didClose();
+ }
+ }
+ pub fn onWrite(this: *@This(), bytes: []const u8) JSC.Maybe(Blob.SizeType) {
+ if (this.writable.aborted) {
+ return .{ .result = 0 };
+ }
+
+ if (this.pending_chunk.len > 0) {
+ return JSC.Maybe(Blob.SizeType).retry;
+ }
+
+ if (this.res.write(bytes)) {
+ return .{ .result = @truncate(Blob.SizeType, bytes.len) };
+ }
+
+ this.pending_chunk = bytes;
+ this.writable.pending_err = null;
+ suspend {
+ if (!this.is_listening_for_abort) {
+ this.is_listening_for_abort = true;
+ this.res.onAborted(*@This(), onAborted);
+ }
+
+ this.res.onWritable(*@This(), onWritable, this);
+ var frame = bun.default_allocator.create(@TypeOf(@Frame(onWrite))) catch unreachable;
+ this.callback = frame;
+ frame.* = @frame().*;
+ }
+ const wrote = this.wrote;
+ this.wrote = 0;
+ if (this.writable.pending_err) |err| {
+ this.writable.pending_err = null;
+ return .{ .err = err };
+ }
+ return .{ .result = wrote };
+ }
+
+ // client-initiated
+ pub fn onAborted(this: *@This(), _: *UWSResponse) void {
+ this.writable.didAbort();
+ }
+ // writer-initiated
+ pub fn onAbort(this: *@This()) void {
+ this.res.end("", true);
+ }
+ pub fn onClose(this: *@This()) void {
+ this.res.end("", false);
+ }
+ pub fn deinit(_: *@This()) void {}
+
+ pub const Writable = WritableStreamSink(@This(), onStart, onWrite, onAbort, onClose, deinit);
+ };
+}
+pub const HTTPSWriter = HTTPServerWritable(true);
+pub const HTTPWriter = HTTPServerWritable(false);
+
+pub fn ReadableStreamSource(
+ comptime Context: type,
+ comptime name_: []const u8,
+ comptime onStart: anytype,
+ comptime onPull: anytype,
+ comptime onCancel: fn (this: *Context) void,
+ comptime deinit: fn (this: *Context) void,
+) type {
+ return struct {
+ context: Context,
+ cancelled: bool = false,
+ deinited: bool = false,
+ pending_err: ?JSC.Node.Syscall.Error = null,
+ close_handler: ?fn (*anyopaque) void = null,
+ close_ctx: ?*anyopaque = null,
+ close_jsvalue: JSValue = JSValue.zero,
+ globalThis: *JSGlobalObject = undefined,
+
+ const This = @This();
+ const ReadableStreamSourceType = @This();
+
+ pub fn pull(this: *This, buf: []u8) StreamResult {
+ return onPull(&this.context, buf, JSValue.zero);
+ }
+
+ pub fn start(
+ this: *This,
+ ) StreamStart {
+ return onStart(&this.context);
+ }
+
+ pub fn pullFromJS(this: *This, buf: []u8, view: JSValue) StreamResult {
+ return onPull(&this.context, buf, view);
+ }
+
+ pub fn startFromJS(this: *This) StreamStart {
+ return onStart(&this.context);
+ }
+
+ pub fn cancel(this: *This) void {
+ if (this.cancelled or this.deinited) {
+ return;
+ }
+
+ this.cancelled = true;
+ onCancel(&this.context);
+ }
+
+ pub fn onClose(this: *This) void {
+ if (this.cancelled or this.deinited) {
+ return;
+ }
+
+ if (this.close_handler) |close| {
+ this.close_handler = null;
+ close(this.close_ctx);
+ }
+ }
+
+ pub fn deinit(this: *This) void {
+ if (this.deinited) {
+ return;
+ }
+ this.deinited = true;
+ deinit(&this.context);
+ }
+
+ pub fn getError(this: *This) ?JSC.Node.Syscall.Error {
+ if (this.pending_err) |err| {
+ this.pending_err = null;
+ return err;
+ }
+
+ return null;
+ }
+
+ pub fn toJS(this: *ReadableStreamSourceType, globalThis: *JSGlobalObject) JSC.JSValue {
+ return ReadableStream.fromNative(globalThis, Context.tag, this);
+ }
+
+ pub const JSReadableStreamSource = struct {
+ pub const shim = JSC.Shimmer(std.mem.span(name_), "JSReadableStreamSource", @This());
+ pub const name = std.fmt.comptimePrint("{s}_JSReadableStreamSource", .{std.mem.span(name_)});
+
+ pub fn pull(globalThis: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ var this = callFrame.argument(0).asPtr(ReadableStreamSourceType);
+ const view = callFrame.argument(1);
+ view.ensureStillAlive();
+ var buffer = view.asArrayBuffer(globalThis) orelse return JSC.JSValue.jsUndefined();
+ return processResult(
+ globalThis,
+ callFrame,
+ this.pullFromJS(buffer.slice(), view),
+ );
+ }
+ pub fn start(globalThis: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ var this = callFrame.argument(0).asPtr(ReadableStreamSourceType);
+ switch (this.startFromJS()) {
+ .empty => return JSValue.jsNumber(0),
+ .ready => return JSValue.jsNumber(16384),
+ .chunk_size => |size| return JSValue.jsNumber(size),
+ .err => |err| {
+ globalThis.vm().throwError(globalThis, err.toJSC(globalThis));
+ return JSC.JSValue.jsUndefined();
+ },
+ }
+ }
+
+ pub fn processResult(globalThis: *JSGlobalObject, callFrame: *JSC.CallFrame, result: StreamResult) JSC.JSValue {
+ switch (result) {
+ .err => |err| {
+ globalThis.vm().throwError(globalThis, err.toJSC(globalThis));
+ return JSValue.jsUndefined();
+ },
+ .temporary_and_done, .owned_and_done, .into_array_and_done => {
+ JSC.C.JSObjectSetPropertyAtIndex(globalThis.ref(), callFrame.argument(2).asObjectRef(), 0, JSValue.jsBoolean(true).asObjectRef(), null);
+ return result.toJS(globalThis);
+ },
+ else => return result.toJS(globalThis),
+ }
+ }
+ pub fn cancel(_: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ var this = callFrame.argument(0).asPtr(ReadableStreamSourceType);
+ this.cancel();
+ return JSC.JSValue.jsUndefined();
+ }
+ pub fn setClose(globalThis: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ var this = callFrame.argument(0).asPtr(ReadableStreamSourceType);
+ this.close_ctx = this;
+ this.close_handler = JSReadableStreamSource.onClose;
+ this.globalThis = globalThis;
+ this.close_jsvalue = callFrame.argument(1);
+ return JSC.JSValue.jsUndefined();
+ }
+
+ fn onClose(ptr: *anyopaque) void {
+ var this = bun.cast(*ReadableStreamSourceType, ptr);
+ _ = this.close_jsvalue.call(this.globalThis, &.{});
+ // this.closer
+ }
+
+ pub fn deinit(_: *JSGlobalObject, callFrame: *JSC.CallFrame) callconv(.C) JSC.JSValue {
+ var this = callFrame.argument(0).asPtr(ReadableStreamSourceType);
+ this.deinit();
+ return JSValue.jsUndefined();
+ }
+
+ pub fn load(globalThis: *JSGlobalObject) callconv(.C) JSC.JSValue {
+ if (comptime JSC.is_bindgen) unreachable;
+ if (comptime Environment.allow_assert) {
+ // this should be cached per globals object
+ const OnlyOnce = struct {
+ pub threadlocal var last_globals: ?*JSGlobalObject = null;
+ };
+ if (OnlyOnce.last_globals) |last_globals| {
+ std.debug.assert(last_globals != globalThis);
+ }
+ OnlyOnce.last_globals = globalThis;
+ }
+ return JSC.JSArray.from(globalThis, &.{
+ JSC.NewFunction(globalThis, null, 1, JSReadableStreamSource.pull),
+ JSC.NewFunction(globalThis, null, 1, JSReadableStreamSource.start),
+ JSC.NewFunction(globalThis, null, 1, JSReadableStreamSource.cancel),
+ JSC.NewFunction(globalThis, null, 1, JSReadableStreamSource.setClose),
+ JSC.NewFunction(globalThis, null, 1, JSReadableStreamSource.deinit),
+ });
+ }
+
+ pub const Export = shim.exportFunctions(.{
+ .@"load" = load,
+ });
+
+ comptime {
+ if (!JSC.is_bindgen) {
+ @export(load, .{ .name = Export[0].symbol_name });
+ _ = JSReadableStreamSource.pull;
+ _ = JSReadableStreamSource.start;
+ _ = JSReadableStreamSource.cancel;
+ _ = JSReadableStreamSource.setClose;
+ _ = JSReadableStreamSource.load;
+ }
+ }
+ };
+ };
+}
+
+pub const ByteBlobLoader = struct {
+ offset: Blob.SizeType = 0,
+ store: *Blob.Store,
+ chunk_size: Blob.SizeType = 1024 * 1024 * 2,
+ remain: Blob.SizeType = 1024 * 1024 * 2,
+ done: bool = false,
+
+ pub const tag = ReadableStream.Tag.Blob;
+
+ pub fn setup(
+ this: *ByteBlobLoader,
+ blob: *const Blob,
+ user_chunk_size: Blob.SizeType,
+ ) void {
+ blob.store.?.ref();
+ var blobe = blob.*;
+ blobe.resolveSize();
+ this.* = ByteBlobLoader{
+ .offset = blobe.offset,
+ .store = blobe.store.?,
+ .chunk_size = if (user_chunk_size > 0) @minimum(user_chunk_size, blobe.size) else @minimum(1024 * 1024 * 2, blobe.size),
+ .remain = blobe.size,
+ .done = false,
+ };
+ }
+
+ pub fn onStart(this: *ByteBlobLoader) StreamStart {
+ return .{ .chunk_size = this.chunk_size };
+ }
+
+ pub fn onPull(this: *ByteBlobLoader, buffer: []u8, array: JSC.JSValue) StreamResult {
+ array.ensureStillAlive();
+ defer array.ensureStillAlive();
+ if (this.done) {
+ return .{ .done = {} };
+ }
+
+ var temporary = this.store.sharedView();
+ temporary = temporary[this.offset..];
+
+ temporary = temporary[0..@minimum(buffer.len, @minimum(temporary.len, this.remain))];
+ if (temporary.len == 0) {
+ this.store.deref();
+ this.done = true;
+ return .{ .done = {} };
+ }
+
+ const copied = @intCast(Blob.SizeType, temporary.len);
+
+ this.remain -|= copied;
+ this.offset +|= copied;
+ @memcpy(buffer.ptr, temporary.ptr, temporary.len);
+ if (this.remain == 0) {
+ return .{ .into_array_and_done = .{ .value = array, .len = copied } };
+ }
+
+ return .{ .into_array = .{ .value = array, .len = copied } };
+ }
+
+ pub fn onCancel(_: *ByteBlobLoader) void {}
+
+ pub fn deinit(this: *ByteBlobLoader) void {
+ if (!this.done) {
+ this.done = true;
+ this.store.deref();
+ }
+
+ bun.default_allocator.destroy(this);
+ }
+
+ pub const Source = ReadableStreamSource(@This(), "ByteBlob", onStart, onPull, onCancel, deinit);
+};
+
+pub fn RequestBodyStreamer(
+ comptime is_ssl: bool,
+) type {
+ return struct {
+ response: *uws.NewApp(is_ssl).Response,
+
+ pub const tag = if (is_ssl)
+ ReadableStream.Tag.HTTPRequest
+ else if (is_ssl)
+ ReadableStream.Tag.HTTPSRequest;
+
+ pub fn setup(
+ this: *ByteBlobLoader,
+ blob: *const Blob,
+ user_chunk_size: Blob.SizeType,
+ ) void {
+ blob.store.?.ref();
+ var blobe = blob.*;
+ blobe.resolveSize();
+ this.* = ByteBlobLoader{
+ .offset = blobe.offset,
+ .store = blobe.store.?,
+ .chunk_size = if (user_chunk_size > 0) @minimum(user_chunk_size, blobe.size) else @minimum(1024 * 1024 * 2, blobe.size),
+ .remain = blobe.size,
+ .done = false,
+ };
+ }
+
+ pub fn onStart(this: *ByteBlobLoader) StreamStart {
+ return .{ .chunk_size = this.chunk_size };
+ }
+
+ pub fn onPull(this: *ByteBlobLoader, buffer: []u8, array: JSC.JSValue) StreamResult {
+ array.ensureStillAlive();
+ defer array.ensureStillAlive();
+ if (this.done) {
+ return .{ .done = {} };
+ }
+
+ var temporary = this.store.sharedView();
+ temporary = temporary[this.offset..];
+
+ temporary = temporary[0..@minimum(buffer.len, @minimum(temporary.len, this.remain))];
+ if (temporary.len == 0) {
+ this.store.deref();
+ this.done = true;
+ return .{ .done = {} };
+ }
+
+ const copied = @intCast(Blob.SizeType, temporary.len);
+
+ this.remain -|= copied;
+ this.offset +|= copied;
+ @memcpy(buffer.ptr, temporary.ptr, temporary.len);
+ if (this.remain == 0) {
+ return .{ .into_array_and_done = .{ .value = array, .len = copied } };
+ }
+
+ return .{ .into_array = .{ .value = array, .len = copied } };
+ }
+
+ pub fn onCancel(_: *ByteBlobLoader) void {}
+
+ pub fn deinit(this: *ByteBlobLoader) void {
+ if (!this.done) {
+ this.done = true;
+ this.store.deref();
+ }
+
+ bun.default_allocator.destroy(this);
+ }
+
+ pub const label = if (is_ssl) "HTTPSRequestBodyStreamer" else "HTTPRequestBodyStreamer";
+ pub const Source = ReadableStreamSource(@This(), label, onStart, onPull, onCancel, deinit);
+ };
+}
+
+pub const FileBlobLoader = struct {
+ buf: []u8 = &[_]u8{},
+ protected_view: JSC.JSValue = JSC.JSValue.zero,
+ fd: JSC.Node.FileDescriptor = 0,
+ auto_close: bool = false,
+ loop: *JSC.EventLoop = undefined,
+ mode: JSC.Node.Mode = 0,
+ store: *Blob.Store,
+ total_read: Blob.SizeType = 0,
+ finalized: bool = false,
+ callback: anyframe = undefined,
+ pending: StreamResult.Pending = StreamResult.Pending{
+ .frame = undefined,
+ .used = false,
+ .result = .{ .done = {} },
+ },
+ cancelled: bool = false,
+ user_chunk_size: Blob.SizeType = 0,
+ scheduled_count: u32 = 0,
+ concurrent: Concurrent = Concurrent{},
+
+ const FileReader = @This();
+
+ const run_on_different_thread_size = bun.huge_allocator_threshold;
+
+ pub const tag = ReadableStream.Tag.File;
+
+ pub fn setup(this: *FileBlobLoader, store: *Blob.Store, chunk_size: Blob.SizeType) void {
+ store.ref();
+ this.* = .{
+ .loop = JSC.VirtualMachine.vm.eventLoop(),
+ .auto_close = store.data.file.pathlike == .path,
+ .store = store,
+ .user_chunk_size = chunk_size,
+ };
+ }
+
+ pub fn watch(this: *FileReader) void {
+ _ = JSC.VirtualMachine.vm.poller.watch(this.fd, .read, this, callback);
+ this.scheduled_count += 1;
+ }
+
+ const Concurrent = struct {
+ read: Blob.SizeType = 0,
+ task: NetworkThread.Task = .{ .callback = Concurrent.taskCallback },
+ completion: AsyncIO.Completion = undefined,
+ read_frame: anyframe = undefined,
+ chunk_size: Blob.SizeType = 0,
+ main_thread_task: JSC.AnyTask = .{ .callback = onJSThread, .ctx = null },
+
+ pub fn taskCallback(task: *NetworkThread.Task) void {
+ var this = @fieldParentPtr(FileBlobLoader, "concurrent", @fieldParentPtr(Concurrent, "task", task));
+ var frame = HTTPClient.getAllocator().create(@Frame(runAsync)) catch unreachable;
+ _ = @asyncCall(std.mem.asBytes(frame), undefined, runAsync, .{this});
+ }
+
+ pub fn onRead(this: *FileBlobLoader, completion: *HTTPClient.NetworkThread.Completion, result: AsyncIO.ReadError!usize) void {
+ this.concurrent.read = @truncate(Blob.SizeType, result catch |err| {
+ if (@hasField(HTTPClient.NetworkThread.Completion, "result")) {
+ this.pending.result = .{
+ .err = JSC.Node.Syscall.Error{
+ .errno = @intCast(JSC.Node.Syscall.Error.Int, -completion.result),
+ .syscall = .read,
+ },
+ };
+ } else {
+ this.pending.result = .{
+ .err = JSC.Node.Syscall.Error{
+ // this is too hacky
+ .errno = @truncate(JSC.Node.Syscall.Error.Int, @intCast(u16, @maximum(1, @errorToInt(err)))),
+ .syscall = .read,
+ },
+ };
+ }
+ this.concurrent.read = 0;
+ resume this.concurrent.read_frame;
+ return;
+ });
+
+ resume this.concurrent.read_frame;
+ }
+
+ pub fn scheduleRead(this: *FileBlobLoader) void {
+ if (comptime Environment.isMac) {
+ var remaining = this.buf[this.concurrent.read..];
+
+ while (remaining.len > 0) {
+ const to_read = @minimum(@as(usize, this.concurrent.chunk_size), remaining.len);
+ switch (JSC.Node.Syscall.read(this.fd, remaining[0..to_read])) {
+ .err => |err| {
+ const retry = comptime if (Environment.isLinux)
+ std.os.E.WOULDBLOCK
+ else
+ std.os.E.AGAIN;
+
+ switch (err.getErrno()) {
+ retry => break,
+ else => {},
+ }
+
+ this.pending.result = .{ .err = err };
+ scheduleMainThreadTask(this);
+ return;
+ },
+ .result => |result| {
+ this.concurrent.read += @intCast(Blob.SizeType, result);
+ remaining = remaining[result..];
+
+ if (result == 0) {
+ remaining.len = 0;
+ break;
+ }
+ },
+ }
+ }
+
+ if (remaining.len == 0) {
+ scheduleMainThreadTask(this);
+ return;
+ }
+ }
+
+ AsyncIO.global.read(
+ *FileBlobLoader,
+ this,
+ onRead,
+ &this.concurrent.completion,
+ this.fd,
+ this.buf[this.concurrent.read..],
+ null,
+ );
+
+ suspend {
+ var _frame = @frame();
+ var this_frame = HTTPClient.getAllocator().create(std.meta.Child(@TypeOf(_frame))) catch unreachable;
+ this_frame.* = _frame.*;
+ this.concurrent.read_frame = this_frame;
+ }
+
+ scheduleMainThreadTask(this);
+ }
+
+ pub fn onJSThread(task_ctx: *anyopaque) void {
+ var this: *FileBlobLoader = bun.cast(*FileBlobLoader, task_ctx);
+ const protected_view = this.protected_view;
+ defer protected_view.unprotect();
+ this.protected_view = JSC.JSValue.zero;
+
+ if (this.finalized and this.scheduled_count == 0) {
+ if (!this.pending.used) {
+ resume this.pending.frame;
+ }
+ this.scheduled_count -= 1;
+
+ this.deinit();
+
+ return;
+ }
+
+ if (!this.pending.used and this.pending.result == .err and this.concurrent.read == 0) {
+ resume this.pending.frame;
+ this.scheduled_count -= 1;
+ this.finalize();
+ return;
+ }
+
+ if (this.concurrent.read == 0) {
+ this.pending.result = .{ .done = {} };
+ resume this.pending.frame;
+ this.scheduled_count -= 1;
+ this.finalize();
+ return;
+ }
+
+ this.pending.result = this.handleReadChunk(@as(usize, this.concurrent.read));
+ resume this.pending.frame;
+ this.scheduled_count -= 1;
+ if (this.pending.result.isDone()) {
+ this.finalize();
+ }
+ }
+
+ pub fn scheduleMainThreadTask(this: *FileBlobLoader) void {
+ this.concurrent.main_thread_task.ctx = this;
+ this.loop.enqueueTaskConcurrent(JSC.Task.init(&this.concurrent.main_thread_task));
+ }
+
+ fn runAsync(this: *FileBlobLoader) void {
+ this.concurrent.read = 0;
+
+ Concurrent.scheduleRead(this);
+
+ suspend {
+ HTTPClient.getAllocator().destroy(@frame());
+ }
+ }
+ };
+
+ pub fn scheduleAsync(this: *FileReader, chunk_size: Blob.SizeType) void {
+ this.scheduled_count += 1;
+ this.loop.virtual_machine.active_tasks +|= 1;
+
+ NetworkThread.init() catch {};
+ this.concurrent.chunk_size = chunk_size;
+ NetworkThread.global.pool.schedule(.{ .head = &this.concurrent.task, .tail = &this.concurrent.task, .len = 1 });
+ }
+
+ const default_fifo_chunk_size = 1024;
+ const default_file_chunk_size = 1024 * 1024 * 2;
+ pub fn onStart(this: *FileBlobLoader) StreamStart {
+ var file = &this.store.data.file;
+ var file_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
+ var auto_close = this.auto_close;
+ defer this.auto_close = auto_close;
+ var fd = if (!auto_close)
+ file.pathlike.fd
+ else switch (JSC.Node.Syscall.open(file.pathlike.path.sliceZ(&file_buf), std.os.O.RDONLY | std.os.O.NONBLOCK | std.os.O.CLOEXEC, 0)) {
+ .result => |_fd| _fd,
+ .err => |err| {
+ this.deinit();
+ return .{ .err = err.withPath(file.pathlike.path.slice()) };
+ },
+ };
+
+ if (!auto_close) {
+ // ensure we have non-blocking IO set
+ const flags = std.os.fcntl(fd, std.os.F.GETFL, 0) catch return .{ .err = JSC.Node.Syscall.Error.fromCode(std.os.E.BADF, .fcntl) };
+
+ // if we do not, clone the descriptor and set non-blocking
+ // it is important for us to clone it so we don't cause Weird Things to happen
+ if ((flags & std.os.O.NONBLOCK) == 0) {
+ auto_close = true;
+ fd = @intCast(@TypeOf(fd), std.os.fcntl(fd, std.os.F.DUPFD, 0) catch return .{ .err = JSC.Node.Syscall.Error.fromCode(std.os.E.BADF, .fcntl) });
+ _ = std.os.fcntl(fd, std.os.F.SETFL, flags | std.os.O.NONBLOCK) catch return .{ .err = JSC.Node.Syscall.Error.fromCode(std.os.E.BADF, .fcntl) };
+ }
+ }
+
+ const stat: std.os.Stat = switch (JSC.Node.Syscall.fstat(fd)) {
+ .result => |result| result,
+ .err => |err| {
+ if (auto_close) {
+ _ = JSC.Node.Syscall.close(fd);
+ }
+ this.deinit();
+ return .{ .err = err.withPath(file.pathlike.path.slice()) };
+ },
+ };
+
+ if (std.os.S.ISDIR(stat.mode)) {
+ const err = JSC.Node.Syscall.Error.fromCode(.ISDIR, .fstat);
+ if (auto_close) {
+ _ = JSC.Node.Syscall.close(fd);
+ }
+ this.deinit();
+ return .{ .err = err };
+ }
+
+ if (std.os.S.ISSOCK(stat.mode)) {
+ const err = JSC.Node.Syscall.Error.fromCode(.INVAL, .fstat);
+
+ if (auto_close) {
+ _ = JSC.Node.Syscall.close(fd);
+ }
+ this.deinit();
+ return .{ .err = err };
+ }
+
+ file.seekable = std.os.S.ISREG(stat.mode);
+ file.mode = @intCast(JSC.Node.Mode, stat.mode);
+ this.mode = file.mode;
+
+ if (file.seekable orelse false)
+ file.max_size = @intCast(Blob.SizeType, stat.size);
+
+ if ((file.seekable orelse false) and file.max_size == 0) {
+ if (auto_close) {
+ _ = JSC.Node.Syscall.close(fd);
+ }
+ this.deinit();
+ return .{ .empty = {} };
+ }
+
+ this.fd = fd;
+ this.auto_close = auto_close;
+
+ const chunk_size = this.calculateChunkSize(std.math.maxInt(usize));
+ return .{ .chunk_size = @truncate(Blob.SizeType, chunk_size) };
+ }
+
+ fn calculateChunkSize(this: *FileBlobLoader, available_to_read: usize) usize {
+ const file = &this.store.data.file;
+
+ const chunk_size: usize = if (this.user_chunk_size > 0)
+ @as(usize, this.user_chunk_size)
+ else if (file.seekable orelse false)
+ @as(usize, default_file_chunk_size)
+ else
+ @as(usize, default_fifo_chunk_size);
+
+ return if (file.max_size > 0)
+ if (available_to_read != std.math.maxInt(usize)) @minimum(chunk_size, available_to_read) else @minimum(@maximum(this.total_read, file.max_size) - this.total_read, chunk_size)
+ else
+ @minimum(available_to_read, chunk_size);
+ }
+
+ pub fn onPull(this: *FileBlobLoader, buffer: []u8, view: JSC.JSValue) StreamResult {
+ const chunk_size = this.calculateChunkSize(std.math.maxInt(usize));
+
+ switch (chunk_size) {
+ 0 => {
+ std.debug.assert(this.store.data.file.seekable orelse false);
+ this.finalize();
+ return .{ .done = {} };
+ },
+ run_on_different_thread_size...std.math.maxInt(@TypeOf(chunk_size)) => {
+ this.protected_view = view;
+ this.protected_view.protect();
+ // should never be reached
+ this.pending.result = .{
+ .err = JSC.Node.Syscall.Error.todo,
+ };
+ this.buf = buffer;
+
+ this.scheduleAsync(@truncate(Blob.SizeType, chunk_size));
+
+ return .{ .pending = &this.pending };
+ },
+ else => {},
+ }
+
+ return this.read(buffer, view);
+ }
+
+ fn maybeAutoClose(this: *FileBlobLoader) void {
+ if (this.auto_close) {
+ _ = JSC.Node.Syscall.close(this.fd);
+ this.auto_close = false;
+ }
+ }
+
+ fn handleReadChunk(this: *FileBlobLoader, result: usize) StreamResult {
+ this.total_read += @intCast(Blob.SizeType, result);
+ const remaining: Blob.SizeType = if (this.store.data.file.seekable orelse false)
+ this.store.data.file.max_size -| this.total_read
+ else
+ @as(Blob.SizeType, std.math.maxInt(Blob.SizeType));
+
+ // this handles:
+ // - empty file
+ // - stream closed for some reason
+ if ((result == 0 and remaining == 0)) {
+ this.finalize();
+ return .{ .done = {} };
+ }
+
+ const has_more = remaining > 0;
+
+ if (!has_more) {
+ return .{ .into_array_and_done = .{ .len = @truncate(Blob.SizeType, result) } };
+ }
+
+ return .{ .into_array = .{ .len = @truncate(Blob.SizeType, result) } };
+ }
+
+ pub fn read(
+ this: *FileBlobLoader,
+ read_buf: []u8,
+ view: JSC.JSValue,
+ ) StreamResult {
+ const rc =
+ JSC.Node.Syscall.read(this.fd, read_buf);
+
+ switch (rc) {
+ .err => |err| {
+ const retry = comptime if (Environment.isLinux)
+ std.os.E.WOULDBLOCK
+ else
+ std.os.E.AGAIN;
+
+ switch (err.getErrno()) {
+ retry => {
+ this.protected_view = view;
+ this.protected_view.protect();
+ this.buf = read_buf;
+ this.watch();
+ return .{
+ .pending = &this.pending,
+ };
+ },
+ else => {},
+ }
+ const sys = if (this.store.data.file.pathlike == .path and this.store.data.file.pathlike.path.slice().len > 0)
+ err.withPath(this.store.data.file.pathlike.path.slice())
+ else
+ err;
+
+ this.finalize();
+ return .{ .err = sys };
+ },
+ .result => |result| {
+ return this.handleReadChunk(result);
+ },
+ }
+ }
+
+ pub fn callback(task: ?*anyopaque, sizeOrOffset: i64, _: u16) void {
+ var this: *FileReader = bun.cast(*FileReader, task.?);
+ this.scheduled_count -= 1;
+ const protected_view = this.protected_view;
+ defer protected_view.unprotect();
+ this.protected_view = JSValue.zero;
+
+ var available_to_read: usize = std.math.maxInt(usize);
+ if (comptime Environment.isMac) {
+ if (std.os.S.ISREG(this.mode)) {
+ // Returns when the file pointer is not at the end of
+ // file. data contains the offset from current position
+ // to end of file, and may be negative.
+ available_to_read = @intCast(usize, @maximum(sizeOrOffset, 0));
+ } else if (std.os.S.ISCHR(this.mode) or std.os.S.ISFIFO(this.mode)) {
+ available_to_read = @intCast(usize, @maximum(sizeOrOffset, 0));
+ }
+ }
+ if (this.finalized and this.scheduled_count == 0) {
+ if (!this.pending.used) {
+ // should never be reached
+ this.pending.result = .{
+ .err = JSC.Node.Syscall.Error.todo,
+ };
+ resume this.pending.frame;
+ }
+ this.deinit();
+ return;
+ }
+ if (this.cancelled)
+ return;
+
+ if (this.buf.len == 0) {
+ return;
+ } else {
+ this.buf.len = @minimum(this.buf.len, available_to_read);
+ }
+
+ this.pending.result = this.read(this.buf, this.protected_view);
+ resume this.pending.frame;
+ }
+
+ pub fn finalize(this: *FileBlobLoader) void {
+ if (this.finalized)
+ return;
+ this.finalized = true;
+
+ this.maybeAutoClose();
+
+ this.store.deref();
+ }
+
+ pub fn onCancel(this: *FileBlobLoader) void {
+ this.cancelled = true;
+
+ this.deinit();
+ }
+
+ pub fn deinit(this: *FileBlobLoader) void {
+ this.finalize();
+ if (this.scheduled_count == 0 and !this.pending.used) {
+ this.destroy();
+ }
+ }
+
+ pub fn destroy(this: *FileBlobLoader) void {
+ bun.default_allocator.destroy(this);
+ }
+
+ pub const Source = ReadableStreamSource(@This(), "FileBlobLoader", onStart, onPull, onCancel, deinit);
+};
+
+pub const StreamSource = struct {
+ ptr: ?*anyopaque = null,
+ vtable: VTable,
+
+ pub const VTable = struct {
+ onStart: fn (this: StreamSource) JSC.WebCore.StreamStart,
+ onPull: fn (this: StreamSource) JSC.WebCore.StreamResult,
+ onError: fn (this: StreamSource) void,
+ };
+};
diff --git a/src/js_ast.zig b/src/js_ast.zig
index f9a501537..650540aa8 100644
--- a/src/js_ast.zig
+++ b/src/js_ast.zig
@@ -211,108 +211,7 @@ pub fn NewBaseStore(comptime Union: anytype, comptime count: usize) type {
pub const BindingNodeIndex = Binding;
pub const StmtNodeIndex = Stmt;
pub const ExprNodeIndex = Expr;
-
-/// This is like ArrayList except it stores the length and capacity as u32
-/// In practice, it is very unusual to have lengths above 4 GB
-///
-/// This lets us have array lists which occupy the same amount of space as a slice
-pub fn BabyList(comptime Type: type) type {
- return struct {
- const ListType = @This();
- ptr: [*]Type = undefined,
- len: u32 = 0,
- cap: u32 = 0,
-
- pub inline fn init(items: []const Type) ListType {
- @setRuntimeSafety(false);
- return ListType{
- // Remove the const qualifier from the items
- .ptr = @intToPtr([*]Type, @ptrToInt(items.ptr)),
-
- .len = @truncate(u32, items.len),
- .cap = @truncate(u32, items.len),
- };
- }
-
- pub inline fn fromList(list_: anytype) ListType {
- @setRuntimeSafety(false);
-
- if (comptime Environment.allow_assert) {
- std.debug.assert(list_.items.len <= list_.capacity);
- }
-
- return ListType{
- .ptr = list_.items.ptr,
- .len = @truncate(u32, list_.items.len),
- .cap = @truncate(u32, list_.capacity),
- };
- }
-
- pub fn update(this: *ListType, list_: anytype) void {
- @setRuntimeSafety(false);
- this.ptr = list_.items.ptr;
- this.len = @truncate(u32, list_.items.len);
- this.cap = @truncate(u32, list_.capacity);
-
- if (comptime Environment.allow_assert) {
- std.debug.assert(this.len <= this.cap);
- }
- }
-
- pub fn list(this: ListType) std.ArrayListUnmanaged(Type) {
- return std.ArrayListUnmanaged(Type){
- .items = this.ptr[0..this.len],
- .capacity = this.cap,
- };
- }
-
- pub fn listManaged(this: ListType, allocator: std.mem.Allocator) std.ArrayList(Type) {
- return std.ArrayList(Type){
- .items = this.ptr[0..this.len],
- .capacity = this.cap,
- .allocator = allocator,
- };
- }
-
- pub inline fn first(this: ListType) ?*Type {
- return if (this.len > 0) this.ptr[0] else @as(?*Type, null);
- }
-
- pub inline fn last(this: ListType) ?*Type {
- return if (this.len > 0) &this.ptr[this.len - 1] else @as(?*Type, null);
- }
-
- pub inline fn first_(this: ListType) Type {
- return this.ptr[0];
- }
-
- pub fn one(allocator: std.mem.Allocator, value: Type) !ListType {
- var items = try allocator.alloc(Type, 1);
- items[0] = value;
- return ListType{
- .ptr = @ptrCast([*]Type, items.ptr),
- .len = 1,
- .cap = 1,
- };
- }
-
- pub inline fn @"[0]"(this: ListType) Type {
- return this.ptr[0];
- }
- const OOM = error{OutOfMemory};
-
- pub fn push(this: *ListType, allocator: std.mem.Allocator, value: Type) OOM!void {
- var list_ = this.list();
- try list_.append(allocator, value);
- this.update(list_);
- }
-
- pub inline fn slice(this: ListType) []Type {
- @setRuntimeSafety(false);
- return this.ptr[0..this.len];
- }
- };
-}
+pub const BabyList = @import("./baby_list.zig").BabyList;
/// Slice that stores capacity and length in the same space as a regular slice.
pub const ExprNodeList = BabyList(Expr);
@@ -348,6 +247,8 @@ pub const Flags = struct {
pub const JSXElement = enum {
is_key_before_rest,
has_any_dynamic,
+ can_be_inlined,
+ can_be_hoisted,
pub const Bitset = std.enums.EnumSet(JSXElement);
};
@@ -1311,12 +1212,14 @@ pub const E = struct {
__self, // old react transform used this as a prop
__source,
key,
+ ref,
any,
pub const Map = ComptimeStringMap(SpecialProp, .{
.{ "__self", .__self },
.{ "__source", .__source },
.{ "key", .key },
+ .{ "ref", .ref },
});
};
};
@@ -1380,8 +1283,10 @@ pub const E = struct {
is_single_line: bool = false,
is_parenthesized: bool = false,
was_originally_macro: bool = false,
+
close_brace_loc: logger.Loc = logger.Loc.Empty,
+ // used in TOML parser to merge properties
pub const Rope = struct {
head: Expr,
next: ?*Rope = null,
diff --git a/src/js_parser.zig b/src/js_parser.zig
index 89a3e82ca..4ef43865e 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -995,6 +995,8 @@ const StaticSymbolName = struct {
pub const ImportSource = NewStaticSymbol("JSX");
pub const ClassicImportSource = NewStaticSymbol("JSXClassic");
pub const jsxFilename = NewStaticSymbolWithBackup("fileName", "jsxFileName");
+ pub const REACT_ELEMENT_TYPE = NewStaticSymbolWithBackup("$$typeof", "$$reactEl");
+ pub const Symbol = NewStaticSymbolWithBackup("Symbol", "Symbol");
pub const Factory = NewStaticSymbol("jsxEl");
pub const Refresher = NewStaticSymbol("FastRefresh");
pub const Fragment = NewStaticSymbol("JSXFrag");
@@ -2548,7 +2550,10 @@ pub const Parser = struct {
// Auto-import & post-process JSX
switch (comptime ParserType.jsx_transform_type) {
.react => {
- const jsx_filename_symbol = p.symbols.items[p.jsx_filename.ref.innerIndex()];
+ const jsx_filename_symbol = if (p.options.jsx.development)
+ p.symbols.items[p.jsx_filename.ref.innerIndex()]
+ else
+ Symbol{ .original_name = "" };
{
const jsx_symbol = p.symbols.items[p.jsx_runtime.ref.innerIndex()];
@@ -2582,6 +2587,9 @@ pub const Parser = struct {
if (p.options.features.auto_import_jsx) {
const jsx_classic_symbol = p.symbols.items[p.jsx_classic.ref.innerIndex()];
const jsx_automatic_symbol = p.symbols.items[p.jsx_automatic.ref.innerIndex()];
+ const react_element_symbol = if (p.options.features.jsx_optimization_inline) p.symbols.items[p.react_element_type.ref.innerIndex()] else Symbol{
+ .original_name = "IF_YOU_SEE_THIS_ITS_A_BUG_IN_BUN_WHERE_REACT_ELEMENT_SYMBOL_IS_BEING_ADDED_WHEN_IT_SHOULDNT_BE_PLEASE_REPORT_IT",
+ };
// JSX auto-imports
// The classic runtime is a different import than the main import
@@ -2589,7 +2597,7 @@ pub const Parser = struct {
// 1. If you use a spread operator like this: <div foo bar key="foo" {...props} baz />
// 2. If you use a React.Fragment
// So we have to support both.
- if (jsx_classic_symbol.use_count_estimate > 0 or jsx_automatic_symbol.use_count_estimate > 0) {
+ if (jsx_classic_symbol.use_count_estimate > 0 or jsx_automatic_symbol.use_count_estimate > 0 or react_element_symbol.use_count_estimate > 0) {
// These must unfortunately be copied
// p.symbols may grow during this scope
// if it grows, the previous pointers are invalidated
@@ -2602,6 +2610,11 @@ pub const Parser = struct {
const automatic_namespace_ref = p.jsx_automatic.ref;
const decls_count: u32 =
+ // "REACT_ELEMENT_TYPE"
+ // "Symbol.for('react.element')"
+ @intCast(u32, @boolToInt(react_element_symbol.use_count_estimate > 0)) * 2 +
+
+ // "JSX"
@intCast(u32, @boolToInt(jsx_symbol.use_count_estimate > 0)) * 2 +
@intCast(u32, @boolToInt(jsx_static_symbol.use_count_estimate > 0)) * 2 +
@intCast(u32, @boolToInt(jsx_factory_symbol.use_count_estimate > 0)) +
@@ -2632,6 +2645,50 @@ pub const Parser = struct {
var require_call_args_i: usize = 0;
var stmt_i: usize = 0;
+ if (react_element_symbol.use_count_estimate > 0) {
+ declared_symbols[declared_symbols_i] = .{ .ref = p.react_element_type.ref, .is_top_level = true };
+ declared_symbols_i += 1;
+ p.recordUsage(p.es6_symbol_global.ref);
+ var call_args = p.allocator.alloc(Expr, 1) catch unreachable;
+ call_args[0] = Expr{ .data = Prefill.Data.REACT_ELEMENT_TYPE, .loc = logger.Loc.Empty };
+
+ decls[decl_i] = G.Decl{
+ .binding = p.b(
+ B.Identifier{
+ .ref = p.react_element_type.ref,
+ },
+ loc,
+ ),
+ .value = p.e(
+ E.Call{
+ // Symbol.for
+ .target = p.e(
+ E.Dot{
+ .name = "for",
+ .name_loc = logger.Loc.Empty,
+ .target = p.e(
+ E.Identifier{
+ .ref = p.es6_symbol_global.ref,
+ .can_be_removed_if_unused = true,
+ .call_can_be_unwrapped_if_unused = true,
+ },
+ logger.Loc.Empty,
+ ),
+ .can_be_removed_if_unused = true,
+ .call_can_be_unwrapped_if_unused = true,
+ },
+ logger.Loc.Empty,
+ ),
+ .args = ExprNodeList.init(call_args),
+ .close_paren_loc = logger.Loc.Empty,
+ .can_be_unwrapped_if_unused = true,
+ },
+ logger.Loc.Empty,
+ ),
+ };
+ decl_i += 1;
+ }
+
if (jsx_symbol.use_count_estimate > 0 or jsx_static_symbol.use_count_estimate > 0) {
declared_symbols[declared_symbols_i] = .{ .ref = automatic_namespace_ref, .is_top_level = true };
declared_symbols_i += 1;
@@ -2872,6 +2929,60 @@ pub const Parser = struct {
.tag = .jsx_import,
}) catch unreachable;
}
+ } else if (p.options.features.jsx_optimization_inline) {
+ const react_element_symbol = p.symbols.items[p.react_element_type.ref.innerIndex()];
+
+ if (react_element_symbol.use_count_estimate > 0) {
+ var declared_symbols = try p.allocator.alloc(js_ast.DeclaredSymbol, 1);
+ var decls = try p.allocator.alloc(G.Decl, 1);
+ var part_stmts = try p.allocator.alloc(Stmt, 1);
+
+ declared_symbols[0] = .{ .ref = p.react_element_type.ref, .is_top_level = true };
+ p.recordUsage(p.es6_symbol_global.ref);
+ var call_args = p.allocator.alloc(Expr, 1) catch unreachable;
+ call_args[0] = Expr{ .data = Prefill.Data.REACT_ELEMENT_TYPE, .loc = logger.Loc.Empty };
+
+ decls[0] = G.Decl{
+ .binding = p.b(
+ B.Identifier{
+ .ref = p.react_element_type.ref,
+ },
+ logger.Loc.Empty,
+ ),
+ .value = p.e(
+ E.Call{
+ // Symbol.for
+ .target = p.e(
+ E.Dot{
+ .name = "for",
+ .name_loc = logger.Loc.Empty,
+ .target = p.e(
+ E.Identifier{
+ .ref = p.es6_symbol_global.ref,
+ .can_be_removed_if_unused = true,
+ .call_can_be_unwrapped_if_unused = true,
+ },
+ logger.Loc.Empty,
+ ),
+ .can_be_removed_if_unused = true,
+ .call_can_be_unwrapped_if_unused = true,
+ },
+ logger.Loc.Empty,
+ ),
+ .args = ExprNodeList.init(call_args),
+ .close_paren_loc = logger.Loc.Empty,
+ .can_be_unwrapped_if_unused = true,
+ },
+ logger.Loc.Empty,
+ ),
+ };
+ part_stmts[0] = p.s(S.Local{ .kind = .k_var, .decls = decls }, logger.Loc.Empty);
+ before.append(js_ast.Part{
+ .stmts = part_stmts,
+ .declared_symbols = declared_symbols,
+ .tag = .jsx_import,
+ }) catch unreachable;
+ }
}
if (!did_import_fast_refresh and p.options.features.react_fast_refresh) {
@@ -3261,11 +3372,11 @@ pub const Prefill = struct {
};
};
pub const StringLiteral = struct {
- pub var Key = [3]u8{ 'k', 'e', 'y' };
- pub var Children = [_]u8{ 'c', 'h', 'i', 'l', 'd', 'r', 'e', 'n' };
- pub var Filename = [_]u8{ 'f', 'i', 'l', 'e', 'N', 'a', 'm', 'e' };
- pub var LineNumber = [_]u8{ 'l', 'i', 'n', 'e', 'N', 'u', 'm', 'b', 'e', 'r' };
- pub var ColumnNumber = [_]u8{ 'c', 'o', 'l', 'u', 'm', 'n', 'N', 'u', 'm', 'b', 'e', 'r' };
+ pub const Key = [3]u8{ 'k', 'e', 'y' };
+ pub const Children = [_]u8{ 'c', 'h', 'i', 'l', 'd', 'r', 'e', 'n' };
+ pub const Filename = [_]u8{ 'f', 'i', 'l', 'e', 'N', 'a', 'm', 'e' };
+ pub const LineNumber = [_]u8{ 'l', 'i', 'n', 'e', 'N', 'u', 'm', 'b', 'e', 'r' };
+ pub const ColumnNumber = [_]u8{ 'c', 'o', 'l', 'u', 'm', 'n', 'N', 'u', 'm', 'b', 'e', 'r' };
};
pub const Value = struct {
pub const EThis = E.This{};
@@ -3277,6 +3388,13 @@ pub const Prefill = struct {
pub var Filename = E.String{ .data = &Prefill.StringLiteral.Filename };
pub var LineNumber = E.String{ .data = &Prefill.StringLiteral.LineNumber };
pub var ColumnNumber = E.String{ .data = &Prefill.StringLiteral.ColumnNumber };
+
+ pub var @"$$typeof" = E.String{ .data = "$$typeof" };
+ pub var @"type" = E.String{ .data = "type" };
+ pub var @"ref" = E.String{ .data = "ref" };
+ pub var @"props" = E.String{ .data = "props" };
+ pub var @"_owner" = E.String{ .data = "_owner" };
+ pub var @"REACT_ELEMENT_TYPE" = E.String{ .data = "react.element" };
};
pub const Data = struct {
pub var BMissing = B{ .b_missing = BMissing_ };
@@ -3291,6 +3409,13 @@ pub const Prefill = struct {
pub var Filename = Expr.Data{ .e_string = &Prefill.String.Filename };
pub var LineNumber = Expr.Data{ .e_string = &Prefill.String.LineNumber };
pub var ColumnNumber = Expr.Data{ .e_string = &Prefill.String.ColumnNumber };
+ pub var @"$$typeof" = Expr.Data{ .e_string = &Prefill.String.@"$$typeof" };
+ pub var @"key" = Expr.Data{ .e_string = &Prefill.String.@"Key" };
+ pub var @"type" = Expr.Data{ .e_string = &Prefill.String.@"type" };
+ pub var @"ref" = Expr.Data{ .e_string = &Prefill.String.@"ref" };
+ pub var @"props" = Expr.Data{ .e_string = &Prefill.String.@"props" };
+ pub var @"_owner" = Expr.Data{ .e_string = &Prefill.String.@"_owner" };
+ pub var @"REACT_ELEMENT_TYPE" = Expr.Data{ .e_string = &Prefill.String.@"REACT_ELEMENT_TYPE" };
pub const This = Expr.Data{ .e_this = E.This{} };
pub const Zero = Expr.Data{ .e_number = Value.Zero };
};
@@ -3304,6 +3429,10 @@ pub const Prefill = struct {
};
};
+const ReactJSX = struct {
+ hoisted_elements: std.ArrayHashMapUnmanaged(Ref, G.Decl, bun.ArrayIdentityContext, false) = .{},
+};
+
var keyExprData = Expr.Data{ .e_string = &Prefill.String.Key };
var jsxChildrenKeyData = Expr.Data{ .e_string = &Prefill.String.Children };
var nullExprValueData = E.Null{};
@@ -3853,6 +3982,9 @@ fn NewParser_(
// "visit" pass.
enclosing_namespace_arg_ref: ?Ref = null,
+ react_element_type: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
+ /// Symbol object
+ es6_symbol_global: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
jsx_filename: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
jsx_runtime: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
jsx_factory: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None },
@@ -4876,6 +5008,11 @@ fn NewParser_(
if (p.options.jsx.development) {
p.jsx_filename = p.declareGeneratedSymbol(.other, "jsxFilename") catch unreachable;
}
+
+ if (p.options.features.jsx_optimization_inline) {
+ p.react_element_type = p.declareGeneratedSymbol(.other, "REACT_ELEMENT_TYPE") catch unreachable;
+ p.es6_symbol_global = p.declareGeneratedSymbol(.unbound, "Symbol") catch unreachable;
+ }
p.jsx_fragment = p.declareGeneratedSymbol(.other, "Fragment") catch unreachable;
p.jsx_runtime = p.declareGeneratedSymbol(.other, "jsx") catch unreachable;
p.jsxs_runtime = p.declareGeneratedSymbol(.other, "jsxs") catch unreachable;
@@ -4962,6 +5099,10 @@ fn NewParser_(
}
pub fn resolveStaticJSXSymbols(p: *P) void {
+ if (p.options.features.jsx_optimization_inline) {
+ p.resolveGeneratedSymbol(&p.react_element_type);
+ p.resolveGeneratedSymbol(&p.es6_symbol_global);
+ }
p.resolveGeneratedSymbol(&p.jsx_runtime);
p.resolveGeneratedSymbol(&p.jsxs_runtime);
p.resolveGeneratedSymbol(&p.jsx_factory);
@@ -11969,11 +12110,14 @@ fn NewParser_(
var key_prop: ?ExprNodeIndex = null;
var flags = Flags.JSXElement.Bitset{};
var start_tag: ?ExprNodeIndex = null;
+ var can_be_inlined = false;
// Fragments don't have props
// Fragments of the form "React.Fragment" are not parsed as fragments.
if (@as(JSXTag.TagType, tag.data) == .tag) {
start_tag = tag.data.tag;
+ can_be_inlined = p.options.features.jsx_optimization_inline;
+
var spread_loc: logger.Loc = logger.Loc.Empty;
var props = ListManaged(G.Property).init(p.allocator);
var key_prop_i: i32 = -1;
@@ -11990,7 +12134,6 @@ fn NewParser_(
try p.lexer.nextInsideJSXElement();
if (special_prop == .key) {
-
// <ListItem key>
if (p.lexer.token != .t_equals) {
// Unlike Babel, we're going to just warn here and move on.
@@ -12003,6 +12146,8 @@ fn NewParser_(
continue;
}
+ can_be_inlined = can_be_inlined and special_prop != .ref;
+
const prop_name = p.e(E.String{ .data = prop_name_literal }, key_range.loc);
// Parse the value
@@ -12034,6 +12179,7 @@ fn NewParser_(
switch (p.lexer.token) {
.t_dot_dot_dot => {
try p.lexer.next();
+ can_be_inlined = false;
spread_prop_i = i;
spread_loc = p.lexer.loc();
@@ -12146,6 +12292,10 @@ fn NewParser_(
try p.lexer.expected(.t_greater_than);
}
+ if (can_be_inlined) {
+ flags.insert(.can_be_inlined);
+ }
+
return p.e(E.JSXElement{
.tag = start_tag,
.properties = properties,
@@ -12263,6 +12413,10 @@ fn NewParser_(
try p.lexer.expected(.t_greater_than);
}
+ if (can_be_inlined) {
+ flags.insert(.can_be_inlined);
+ }
+
return p.e(E.JSXElement{
.tag = end_tag.data.asExpr(),
.children = ExprNodeList.fromList(children),
@@ -13377,14 +13531,21 @@ fn NewParser_(
const runtime = if (p.options.jsx.runtime == .automatic and !e_.flags.contains(.is_key_before_rest)) options.JSX.Runtime.automatic else options.JSX.Runtime.classic;
var children_count = e_.children.len;
- const is_childless_tag = FeatureFlags.react_specific_warnings and children_count > 0 and tag.data == .e_string and tag.data.e_string.isUTF8() and js_lexer.ChildlessJSXTags.has(tag.data.e_string.slice(p.allocator));
+ const is_childless_tag = FeatureFlags.react_specific_warnings and children_count > 0 and
+ tag.data == .e_string and tag.data.e_string.isUTF8() and js_lexer.ChildlessJSXTags.has(tag.data.e_string.slice(p.allocator));
children_count = if (is_childless_tag) 0 else children_count;
if (children_count != e_.children.len) {
// Error: meta is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.
// ^ from react-dom
- p.log.addWarningFmt(p.source, tag.loc, p.allocator, "<{s} /> is a void element and must not have \"children\"", .{tag.data.e_string.slice(p.allocator)}) catch {};
+ p.log.addWarningFmt(
+ p.source,
+ tag.loc,
+ p.allocator,
+ "<{s} /> is a void element and must not have \"children\"",
+ .{tag.data.e_string.slice(p.allocator)},
+ ) catch {};
}
// TODO: maybe we should split these into two different AST Nodes
@@ -13430,12 +13591,7 @@ fn NewParser_(
},
// function jsxDEV(type, config, maybeKey, source, self) {
.automatic => {
- // Either:
- // jsxDEV(type, arguments, key, isStaticChildren, source, self)
- // jsx(type, arguments, key)
- const include_filename = FeatureFlags.include_filename_in_jsx and p.options.jsx.development;
- const args = p.allocator.alloc(Expr, if (p.options.jsx.development) @as(usize, 6) else @as(usize, 4)) catch unreachable;
- args[0] = tag;
+ // --- These must be done in all cases --
const allocator = p.allocator;
var props = e_.properties.list();
// arguments needs to be like
@@ -13457,9 +13613,6 @@ fn NewParser_(
const children_key = Expr{ .data = jsxChildrenKeyData, .loc = expr.loc };
- // Babel defines static jsx as children.len > 1
- const is_static_jsx = e_.children.len > 1;
-
// Optimization: if the only non-child prop is a spread object
// we can just pass the object as the first argument
// this goes as deep as there are spreads
@@ -13471,6 +13624,9 @@ fn NewParser_(
props = props.items[0].value.?.data.e_object.properties.list();
}
+ // Babel defines static jsx as children.len > 1
+ const is_static_jsx = e_.children.len > 1;
+
// if (p.options.jsx.development) {
switch (e_.children.len) {
0 => {},
@@ -13490,84 +13646,239 @@ fn NewParser_(
}) catch unreachable;
},
}
+ // --- These must be done in all cases --
+
+ // Trivial elements can be inlined, removing the call to createElement or jsx()
+ if (p.options.features.jsx_optimization_inline and e_.flags.contains(.can_be_inlined)) {
+ // The output object should look like this:
+ // https://babeljs.io/repl/#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&build=&builtIns=false&corejs=false&spec=false&loose=false&code_lz=FAMwrgdgxgLglgewgAgLIE8DCCC2AHJAUwhgAoBvAIwEMAvAXwEplzhl3kAnQmMTlADwAxBAmQA-AIwAmAMxsOAFgCsANgEB6EQnEBuYPWBA&debug=false&forceAllTransforms=false&shippedProposals=true&circleciRepo=&evaluate=false&fileSize=true&timeTravel=false&sourceType=module&lineWrap=true&presets=react%2Ctypescript&prettier=true&targets=&version=7.18.4&externalPlugins=%40babel%2Fplugin-transform-flow-strip-types%407.16.7%2C%40babel%2Fplugin-transform-react-inline-elements%407.16.7&assumptions=%7B%22arrayLikeIsIterable%22%3Atrue%2C%22constantReexports%22%3Atrue%2C%22constantSuper%22%3Atrue%2C%22enumerableModuleMeta%22%3Atrue%2C%22ignoreFunctionLength%22%3Atrue%2C%22ignoreToPrimitiveHint%22%3Atrue%2C%22mutableTemplateObject%22%3Atrue%2C%22iterableIsArray%22%3Atrue%2C%22noClassCalls%22%3Atrue%2C%22noNewArrows%22%3Atrue%2C%22noDocumentAll%22%3Atrue%2C%22objectRestNoSymbols%22%3Atrue%2C%22privateFieldsAsProperties%22%3Atrue%2C%22pureGetters%22%3Atrue%2C%22setComputedProperties%22%3Atrue%2C%22setClassMethods%22%3Atrue%2C%22setSpreadProperties%22%3Atrue%2C%22setPublicClassFields%22%3Atrue%2C%22skipForOfIteratorClosing%22%3Atrue%2C%22superIsCallableConstructor%22%3Atrue%7D
+ // return {
+ // $$typeof: REACT_ELEMENT_TYPE,
+ // type: type,
+ // key: void 0 === key ? null : "" + key,
+ // ref: null,
+ // props: props,
+ // _owner: null
+ // };
+ //
+ p.recordUsage(p.react_element_type.ref);
+ const key = if (e_.key) |key_| brk: {
+ // key: void 0 === key ? null : "" + key,
+ break :brk switch (key_.data) {
+ .e_string => break :brk key_,
+ .e_undefined, .e_null => p.e(E.Null{}, key_.loc),
+ else => p.e(E.If{
+ .test_ = p.e(E.Binary{
+ .left = p.e(E.Undefined{}, key_.loc),
+ .op = Op.Code.bin_strict_eq,
+ .right = key_,
+ }, key_.loc),
+ .yes = p.e(E.Null{}, key_.loc),
+ .no = p.e(
+ E.Binary{
+ .op = Op.Code.bin_add,
+ .left = p.e(&E.String.empty, key_.loc),
+ .right = key_,
+ },
+ key_.loc,
+ ),
+ }, key_.loc),
+ };
+ } else p.e(E.Null{}, expr.loc);
+ var jsx_element = p.allocator.alloc(G.Property, 6) catch unreachable;
+ const props_object = p.e(
+ E.Object{
+ .properties = G.Property.List.fromList(props),
+ .close_brace_loc = e_.close_tag_loc,
+ },
+ expr.loc,
+ );
+ var props_expression = props_object;
+
+ // we must check for default props
+ if (tag.data != .e_string) {
+ // We assume defaultProps is supposed to _not_ have side effects
+ // We do not support "key" or "ref" in defaultProps.
+ const defaultProps = p.e(E.Dot{
+ .name = "defaultProps",
+ .name_loc = tag.loc,
+ .target = tag,
+ .can_be_removed_if_unused = true,
+ }, tag.loc);
+ // props: MyComponent.defaultProps || {}
+ if (props.items.len == 0) {
+ props_expression = p.e(E.Binary{ .op = Op.Code.bin_logical_or, .left = defaultProps, .right = props_object }, defaultProps.loc);
+ } else {
+ // we assume that most components don't use defaultProps
+ // props: !MyComponent.defaultProps ? {myProp: 123} : { ...MyComponent.defaultProps, myProp: 123}
+ var with_default_props = p.allocator.alloc(G.Property, props_object.data.e_object.properties.len + 1) catch unreachable;
+ with_default_props[0] = G.Property{
+ .key = null,
+ .value = defaultProps,
+ .kind = Property.Kind.spread,
+ .flags = Flags.Property.init(
+ .{
+ .is_spread = true,
+ },
+ ),
+ };
- args[1] = p.e(E.Object{
- .properties = G.Property.List.fromList(props),
- }, expr.loc);
+ std.mem.copy(G.Property, with_default_props[1..], props_object.data.e_object.properties.slice());
+ props_expression = p.e(
+ E.If{
+ .test_ = p.e(E.Unary{ .op = .un_not, .value = defaultProps }, defaultProps.loc),
+ .no = p.e(
+ E.Object{ .properties = G.Property.List.init(with_default_props), .close_brace_loc = e_.close_tag_loc },
+ tag.loc,
+ ),
+ .yes = props_object,
+ },
+ props_object.loc,
+ );
+ }
+ }
- if (e_.key) |key| {
- args[2] = key;
- } else {
- // if (maybeKey !== undefined)
- args[2] = Expr{
- .loc = expr.loc,
- .data = .{
- .e_undefined = E.Undefined{},
+ jsx_element[0..6].* =
+ [_]G.Property{
+ G.Property{
+ .key = Expr{ .data = Prefill.Data.@"$$typeof", .loc = tag.loc },
+ .value = p.e(
+ E.Identifier{
+ .ref = p.react_element_type.ref,
+ .can_be_removed_if_unused = true,
+ },
+ tag.loc,
+ ),
+ },
+ G.Property{
+ .key = Expr{ .data = Prefill.Data.@"type", .loc = tag.loc },
+ .value = tag,
+ },
+ G.Property{
+ .key = Expr{ .data = Prefill.Data.@"key", .loc = key.loc },
+ .value = key,
+ },
+ // this is a de-opt
+ // any usage of ref should make it impossible for this code to be reached
+ G.Property{
+ .key = Expr{ .data = Prefill.Data.@"ref", .loc = expr.loc },
+ .value = p.e(E.Null{}, expr.loc),
+ },
+ G.Property{
+ .key = Expr{ .data = Prefill.Data.@"props", .loc = expr.loc },
+ .value = props_expression,
+ },
+ G.Property{
+ .key = Expr{ .data = Prefill.Data.@"_owner", .loc = key.loc },
+ .value = p.e(
+ E.Null{},
+ expr.loc,
+ ),
},
};
- }
- if (p.options.jsx.development) {
- // is the return type of the first child an array?
- // It's dynamic
- // Else, it's static
- args[3] = Expr{
- .loc = expr.loc,
- .data = .{
- .e_boolean = .{
- .value = is_static_jsx,
- },
+ const output = p.e(
+ E.Object{
+ .properties = G.Property.List.init(jsx_element),
+ .close_brace_loc = e_.close_tag_loc,
},
- };
+ expr.loc,
+ );
- if (include_filename) {
- var source = p.allocator.alloc(G.Property, 2) catch unreachable;
- p.recordUsage(p.jsx_filename.ref);
- source[0] = G.Property{
- .key = Expr{ .loc = expr.loc, .data = Prefill.Data.Filename },
- .value = p.e(E.Identifier{
- .ref = p.jsx_filename.ref,
- .can_be_removed_if_unused = true,
- }, expr.loc),
+ if (p.options.features.jsx_optimization_hoist) {
+ // if the expression is free of side effects
+ if (p.exprCanBeRemovedIfUnused(&props_object)) {}
+ }
+
+ return output;
+ } else {
+ // -- The typical jsx automatic transform happens here --
+
+ // Either:
+ // jsxDEV(type, arguments, key, isStaticChildren, source, self)
+ // jsx(type, arguments, key)
+ const include_filename = FeatureFlags.include_filename_in_jsx and p.options.jsx.development;
+ const args = p.allocator.alloc(Expr, if (p.options.jsx.development) @as(usize, 6) else @as(usize, 2) + @as(usize, @boolToInt(e_.key != null))) catch unreachable;
+ args[0] = tag;
+
+ args[1] = p.e(E.Object{
+ .properties = G.Property.List.fromList(props),
+ }, expr.loc);
+
+ if (e_.key) |key| {
+ args[2] = key;
+ } else if (p.options.jsx.development) {
+ // if (maybeKey !== undefined)
+ args[2] = Expr{
+ .loc = expr.loc,
+ .data = .{
+ .e_undefined = E.Undefined{},
+ },
};
+ }
- source[1] = G.Property{
- .key = Expr{ .loc = expr.loc, .data = Prefill.Data.LineNumber },
- .value = p.e(E.Number{ .value = @intToFloat(f64, expr.loc.start) }, expr.loc),
+ if (p.options.jsx.development) {
+ // is the return type of the first child an array?
+ // It's dynamic
+ // Else, it's static
+ args[3] = Expr{
+ .loc = expr.loc,
+ .data = .{
+ .e_boolean = .{
+ .value = is_static_jsx,
+ },
+ },
};
- // Officially, they ask for columnNumber. But I don't see any usages of it in the code!
- // source[2] = G.Property{
- // .key = Expr{ .loc = expr.loc, .data = Prefill.Data.ColumnNumber },
- // .value = p.e(E.Number{ .value = @intToFloat(f64, expr.loc.start) }, expr.loc),
- // };
- args[4] = p.e(E.Object{
- .properties = G.Property.List.init(source),
- }, expr.loc);
+ if (include_filename) {
+ var source = p.allocator.alloc(G.Property, 2) catch unreachable;
+ p.recordUsage(p.jsx_filename.ref);
+ source[0] = G.Property{
+ .key = Expr{ .loc = expr.loc, .data = Prefill.Data.Filename },
+ .value = p.e(E.Identifier{
+ .ref = p.jsx_filename.ref,
+ .can_be_removed_if_unused = true,
+ }, expr.loc),
+ };
- // When disabled, this must specifically be undefined
- // Not an empty object
- // See this code from react:
- // > if (source !== undefined) {
- // > var fileName = source.fileName.replace(/^.*[\\\/]/, "");
- // > var lineNumber = source.lineNumber;
- // > return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
- // > }
- } else {
- args[4] = p.e(E.Undefined{}, expr.loc);
+ source[1] = G.Property{
+ .key = Expr{ .loc = expr.loc, .data = Prefill.Data.LineNumber },
+ .value = p.e(E.Number{ .value = @intToFloat(f64, expr.loc.start) }, expr.loc),
+ };
+
+ // Officially, they ask for columnNumber. But I don't see any usages of it in the code!
+ // source[2] = G.Property{
+ // .key = Expr{ .loc = expr.loc, .data = Prefill.Data.ColumnNumber },
+ // .value = p.e(E.Number{ .value = @intToFloat(f64, expr.loc.start) }, expr.loc),
+ // };
+ args[4] = p.e(E.Object{
+ .properties = G.Property.List.init(source),
+ }, expr.loc);
+
+ // When disabled, this must specifically be undefined
+ // Not an empty object
+ // See this code from react:
+ // > if (source !== undefined) {
+ // > var fileName = source.fileName.replace(/^.*[\\\/]/, "");
+ // > var lineNumber = source.lineNumber;
+ // > return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
+ // > }
+ } else {
+ args[4] = p.e(E.Undefined{}, expr.loc);
+ }
+
+ args[5] = Expr{ .data = Prefill.Data.This, .loc = expr.loc };
}
- args[5] = Expr{ .data = Prefill.Data.This, .loc = expr.loc };
+ return p.e(E.Call{
+ .target = p.jsxStringsToMemberExpressionAutomatic(expr.loc, is_static_jsx),
+ .args = ExprNodeList.init(args),
+ // Enable tree shaking
+ .can_be_unwrapped_if_unused = !p.options.ignore_dce_annotations,
+ .was_jsx_element = true,
+ .close_paren_loc = e_.close_tag_loc,
+ }, expr.loc);
}
-
- return p.e(E.Call{
- .target = p.jsxStringsToMemberExpressionAutomatic(expr.loc, is_static_jsx),
- .args = ExprNodeList.init(args),
- // Enable tree shaking
- .can_be_unwrapped_if_unused = !p.options.ignore_dce_annotations,
- .was_jsx_element = true,
- .close_paren_loc = e_.close_tag_loc,
- }, expr.loc);
},
else => unreachable,
}
diff --git a/src/jsc.zig b/src/jsc.zig
index fa71683dd..fa7f801f7 100644
--- a/src/jsc.zig
+++ b/src/jsc.zig
@@ -4,8 +4,10 @@ pub const is_bindgen = @import("std").meta.globalOption("bindgen", bool) orelse
pub const napi = @import("./napi/napi.zig");
pub usingnamespace @import("./javascript/jsc/bindings/exports.zig");
pub usingnamespace @import("./javascript/jsc/bindings/bindings.zig");
+pub usingnamespace @import("./javascript/jsc/event_loop.zig");
pub usingnamespace @import("./javascript/jsc/base.zig");
pub const RareData = @import("./javascript/jsc/rare_data.zig");
+pub const Shimmer = @import("./javascript/jsc/bindings/shimmer.zig").Shimmer;
pub usingnamespace @import("./javascript/jsc/javascript.zig");
pub const C = @import("./javascript/jsc/javascript_core_c_api.zig");
pub const WebCore = @import("./javascript/jsc/webcore.zig");
@@ -39,3 +41,4 @@ pub const Node = struct {
pub const Syscall = @import("./javascript/jsc/node/syscall.zig");
pub const fs = @import("./javascript/jsc/node/node_fs_constant.zig");
};
+pub const Maybe = Node.Maybe;
diff --git a/src/memory_allocator.zig b/src/memory_allocator.zig
index 19b738add..a8fbd116a 100644
--- a/src/memory_allocator.zig
+++ b/src/memory_allocator.zig
@@ -214,3 +214,129 @@ const z_allocator_vtable = Allocator.VTable{
.resize = ZAllocator.resize,
.free = ZAllocator.free,
};
+const HugeAllocator = struct {
+ fn alloc(
+ _: *anyopaque,
+ len: usize,
+ alignment: u29,
+ len_align: u29,
+ return_address: usize,
+ ) error{OutOfMemory}![]u8 {
+ _ = return_address;
+ assert(len > 0);
+ assert(std.math.isPowerOfTwo(alignment));
+
+ var slice = std.os.mmap(
+ null,
+ len,
+ std.os.PROT.READ | std.os.PROT.WRITE,
+ std.os.MAP.ANONYMOUS | std.os.MAP.PRIVATE,
+ -1,
+ 0,
+ ) catch
+ return error.OutOfMemory;
+
+ _ = len_align;
+ return slice;
+ }
+
+ fn resize(
+ _: *anyopaque,
+ _: []u8,
+ _: u29,
+ _: usize,
+ _: u29,
+ _: usize,
+ ) ?usize {
+ return null;
+ }
+
+ fn free(
+ _: *anyopaque,
+ buf: []u8,
+ _: u29,
+ _: usize,
+ ) void {
+ std.os.munmap(@alignCast(std.meta.alignment([]align(std.mem.page_size) u8), buf));
+ }
+};
+
+pub const huge_allocator = Allocator{
+ .ptr = undefined,
+ .vtable = &huge_allocator_vtable,
+};
+const huge_allocator_vtable = Allocator.VTable{
+ .alloc = HugeAllocator.alloc,
+ .resize = HugeAllocator.resize,
+ .free = HugeAllocator.free,
+};
+
+pub const huge_threshold = 1024 * 256;
+
+const AutoSizeAllocator = struct {
+ fn alloc(
+ _: *anyopaque,
+ len: usize,
+ alignment: u29,
+ len_align: u29,
+ return_address: usize,
+ ) error{OutOfMemory}![]u8 {
+ if (len >= huge_threshold) {
+ return huge_allocator.rawAlloc(
+ len,
+ alignment,
+ len_align,
+ return_address,
+ );
+ }
+
+ return c_allocator.rawAlloc(
+ len,
+ alignment,
+ len_align,
+ return_address,
+ );
+ }
+
+ fn resize(
+ _: *anyopaque,
+ _: []u8,
+ _: u29,
+ _: usize,
+ _: u29,
+ _: usize,
+ ) ?usize {
+ return null;
+ }
+
+ fn free(
+ _: *anyopaque,
+ buf: []u8,
+ a: u29,
+ b: usize,
+ ) void {
+ if (buf.len >= huge_threshold) {
+ return huge_allocator.rawFree(
+ buf,
+ a,
+ b,
+ );
+ }
+
+ return c_allocator.rawFree(
+ buf,
+ a,
+ b,
+ );
+ }
+};
+
+pub const auto_allocator = Allocator{
+ .ptr = undefined,
+ .vtable = &auto_allocator_vtable,
+};
+const auto_allocator_vtable = Allocator.VTable{
+ .alloc = AutoSizeAllocator.alloc,
+ .resize = AutoSizeAllocator.resize,
+ .free = AutoSizeAllocator.free,
+};
diff --git a/src/napi/napi.zig b/src/napi/napi.zig
index 7514f43b2..65ef0c45c 100644
--- a/src/napi/napi.zig
+++ b/src/napi/napi.zig
@@ -186,7 +186,7 @@ pub export fn napi_create_array_with_length(env: napi_env, length: usize, result
return .ok;
}
- const allocator = JSC.VirtualMachine.vm.allocator;
+ const allocator = env.bunVM().allocator;
var undefined_args = allocator.alloc(JSC.C.JSValueRef, length) catch return .generic_failure;
defer allocator.free(undefined_args);
for (undefined_args) |_, i| {
@@ -748,7 +748,7 @@ pub export fn napi_create_external_arraybuffer(env: napi_env, external_data: ?*a
@ptrCast([*]u8, external_data.?)[0..byte_length],
env,
finalize_cb,
- JSC.VirtualMachine.vm.allocator,
+ env.bunVM().allocator,
) catch {
return .generic_failure;
};
@@ -924,7 +924,7 @@ const WorkPoolTask = @import("../work_pool.zig").Task;
pub const napi_async_work = struct {
task: WorkPoolTask = .{ .callback = runFromThreadPool },
completion_task: ?*anyopaque = null,
- event_loop: *JSC.VirtualMachine.EventLoop,
+ event_loop: *JSC.EventLoop,
global: napi_env,
execute: napi_async_execute_callback = null,
complete: napi_async_complete_callback = null,
@@ -945,7 +945,7 @@ pub const napi_async_work = struct {
work.* = .{
.global = global,
.execute = execute,
- .event_loop = JSC.VirtualMachine.vm.eventLoop(),
+ .event_loop = global.bunVM().eventLoop(),
.complete = complete,
.ctx = ctx,
};
@@ -1054,8 +1054,8 @@ fn napiSpan(ptr: anytype, len: usize) []const u8 {
// C++
// pub export fn napi_module_register(mod: *napi_module) void {
// const register = mod.nm_register_func orelse return;
-// var ref = JSC.C.JSObjectMake(JSC.VirtualMachine.vm.global, null, null);
-// register(JSC.VirtualMachine.vm.global, JSC.JSValue.c(ref));
+// var ref = JSC.C.JSObjectMake(env.bunVM().global, null, null);
+// register(env.bunVM().global, JSC.JSValue.c(ref));
// }
pub export fn napi_fatal_error(location_ptr: ?[*:0]const u8, location_len: usize, message_ptr: ?[*:0]const u8, message_len_: usize) noreturn {
var message = napiSpan(message_ptr, message_len_);
@@ -1083,7 +1083,7 @@ pub export fn napi_fatal_error(location_ptr: ?[*:0]const u8, location_len: usize
// // JSC.C.JSObjectCallAsFunction(env.ref(), func.asObjectRef(), recv.asObjectRef(), argc, @ptrCast([*]const JSC.C.JSValueRef), exception: ExceptionRef)
// }
pub export fn napi_create_buffer(env: napi_env, length: usize, data: [*]*anyopaque, result: *napi_value) napi_status {
- var buf = JSC.ExternalBuffer.create(null, @ptrCast([*]u8, data)[0..length], env, null, JSC.VirtualMachine.vm.allocator) catch {
+ var buf = JSC.ExternalBuffer.create(null, @ptrCast([*]u8, data)[0..length], env, null, env.bunVM().allocator) catch {
return .generic_failure;
};
@@ -1091,7 +1091,7 @@ pub export fn napi_create_buffer(env: napi_env, length: usize, data: [*]*anyopaq
return .ok;
}
pub export fn napi_create_external_buffer(env: napi_env, length: usize, data: ?*anyopaque, finalize_cb: napi_finalize, finalize_hint: ?*anyopaque, result: *napi_value) napi_status {
- var buf = JSC.ExternalBuffer.create(finalize_hint, @ptrCast([*]u8, data.?)[0..length], env, finalize_cb, JSC.VirtualMachine.vm.allocator) catch {
+ var buf = JSC.ExternalBuffer.create(finalize_hint, @ptrCast([*]u8, data.?)[0..length], env, finalize_cb, env.bunVM().allocator) catch {
return .generic_failure;
};
@@ -1099,7 +1099,7 @@ pub export fn napi_create_external_buffer(env: napi_env, length: usize, data: ?*
return .ok;
}
pub export fn napi_create_buffer_copy(env: napi_env, length: usize, data: [*]u8, result_data: ?*?*anyopaque, result: *napi_value) napi_status {
- var duped = JSC.VirtualMachine.vm.allocator.alloc(u8, length) catch {
+ var duped = env.bunVM().allocator.alloc(u8, length) catch {
return .generic_failure;
};
@memcpy(duped.ptr, data, length);
@@ -1107,7 +1107,7 @@ pub export fn napi_create_buffer_copy(env: napi_env, length: usize, data: [*]u8,
res.* = duped.ptr;
}
- result.* = JSC.JSValue.createBuffer(env, duped, JSC.VirtualMachine.vm.allocator);
+ result.* = JSC.JSValue.createBuffer(env, duped, env.bunVM().allocator);
return .ok;
}
@@ -1161,9 +1161,9 @@ pub export fn napi_get_node_version(_: napi_env, version: **const napi_node_vers
version.* = &napi_node_version.global;
return .ok;
}
-pub export fn napi_get_uv_event_loop(_: napi_env, loop: **JSC.VirtualMachine.EventLoop) napi_status {
+pub export fn napi_get_uv_event_loop(env: napi_env, loop: **JSC.EventLoop) napi_status {
// lol
- loop.* = JSC.VirtualMachine.vm.eventLoop();
+ loop.* = env.bunVM().eventLoop();
return .ok;
}
pub extern fn napi_fatal_exception(env: napi_env, err: napi_value) napi_status;
@@ -1174,18 +1174,18 @@ pub export fn napi_add_env_cleanup_hook(env: napi_env, fun: ?fn (?*anyopaque) ca
if (fun == null)
return .ok;
- JSC.VirtualMachine.vm.rareData().pushCleanupHook(env, arg, fun.?);
+ env.bunVM().rareData().pushCleanupHook(env, arg, fun.?);
return .ok;
}
pub export fn napi_remove_env_cleanup_hook(env: napi_env, fun: ?fn (?*anyopaque) callconv(.C) void, arg: ?*anyopaque) napi_status {
- if (JSC.VirtualMachine.vm.rare_data == null or fun == null)
+ if (env.bunVM().rare_data == null or fun == null)
return .ok;
- var rare_data = JSC.VirtualMachine.vm.rare_data.?;
+ var rare_data = env.bunVM().rare_data.?;
var hook = rare_data.cleanup_hook orelse return .ok;
const cmp = JSC.RareData.CleanupHook.from(env, arg, fun.?);
if (hook.eql(cmp)) {
- JSC.VirtualMachine.vm.allocator.destroy(hook);
+ env.bunVM().allocator.destroy(hook);
rare_data.cleanup_hook = null;
rare_data.tail_cleanup_hook = null;
}
@@ -1196,7 +1196,7 @@ pub export fn napi_remove_env_cleanup_hook(env: napi_env, fun: ?fn (?*anyopaque)
} else {
hook.next = null;
}
- JSC.VirtualMachine.vm.allocator.destroy(current);
+ env.bunVM().allocator.destroy(current);
return .ok;
}
hook = current;
@@ -1226,7 +1226,7 @@ pub const ThreadSafeFunction = struct {
owning_threads: std.AutoArrayHashMapUnmanaged(u64, void) = .{},
owning_thread_lock: Lock = Lock.init(),
- event_loop: *JSC.VirtualMachine.EventLoop,
+ event_loop: *JSC.EventLoop,
javascript_function: JSValue,
finalizer_task: JSC.AnyTask = undefined,
@@ -1398,7 +1398,7 @@ pub export fn napi_create_threadsafe_function(
JSC.C.JSValueProtect(env.ref(), func.asObjectRef());
var function = bun.default_allocator.create(ThreadSafeFunction) catch return .generic_failure;
function.* = .{
- .event_loop = JSC.VirtualMachine.vm.eventLoop(),
+ .event_loop = env.bunVM().eventLoop(),
.javascript_function = func,
.call_js = call_js_cb,
.ctx = context,
diff --git a/src/options.zig b/src/options.zig
index 52352e323..202e99434 100644
--- a/src/options.zig
+++ b/src/options.zig
@@ -914,10 +914,14 @@ pub const JSX = struct {
pragma.package_name = parsePackageName(pragma.import_source);
} else if (jsx.development) {
pragma.import_source = Defaults.ImportSourceDev;
- pragma.jsx = Defaults.JSXFunctionDev;
pragma.package_name = "react";
} else {
pragma.import_source = Defaults.ImportSource;
+ }
+
+ if (jsx.development) {
+ pragma.jsx = Defaults.JSXFunctionDev;
+ } else {
pragma.jsx = Defaults.JSXFunction;
}
@@ -1183,6 +1187,9 @@ pub const BundleOptions = struct {
append_package_version_in_query_string: bool = false,
+ jsx_optimization_inline: ?bool = null,
+ jsx_optimization_hoist: ?bool = null,
+
resolve_mode: api.Api.ResolveMode,
tsconfig_override: ?string = null,
platform: Platform = Platform.browser,
diff --git a/src/runtime.js b/src/runtime.js
index 4ac76bff0..485cdc6f6 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -9,16 +9,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
// We're disabling Object.freeze because it breaks CJS => ESM and can cause
// issues with Suspense and other things that expect the CJS module namespace
// to be mutable when the ESM module namespace is NOT mutable
-var __objectFreezePolyfill = new WeakSet();
+// var __objectFreezePolyfill = new WeakSet();
-globalThis.Object.freeze = function freeze(obj) {
- __objectFreezePolyfill.add(obj);
- return obj;
-};
+// globalThis.Object.freeze = function freeze(obj) {
+// __objectFreezePolyfill.add(obj);
+// return obj;
+// };
-globalThis.Object.isFrozen = function isFrozen(obj) {
- return __objectFreezePolyfill.has(obj);
-};
+// globalThis.Object.isFrozen = function isFrozen(obj) {
+// return __objectFreezePolyfill.has(obj);
+// };
export var __markAsModule = (target) =>
__defProp(target, "__esModule", { value: true, configurable: true });
diff --git a/src/runtime.zig b/src/runtime.zig
index 9317324e9..b59d1a2af 100644
--- a/src/runtime.zig
+++ b/src/runtime.zig
@@ -273,6 +273,21 @@ pub const Runtime = struct {
top_level_await: bool = false,
auto_import_jsx: bool = false,
allow_runtime: bool = true,
+ /// Instead of jsx("div", {}, void 0)
+ /// ->
+ /// {
+ /// "type": "div",
+ /// "props": {},
+ /// "children": [],
+ /// key: void 0,
+ /// $$typeof: Symbol.for("react.element"),
+ /// }
+ /// See also https://github.com/babel/babel/commit/3cad2872335e2130f2ff6335027617ebbe9b5a46
+ /// See also https://github.com/babel/babel/pull/2972
+ /// See also https://github.com/facebook/react/issues/5138
+ jsx_optimization_inline: bool = false,
+
+ jsx_optimization_hoist: bool = false,
trim_unused_imports: bool = false,
should_fold_numeric_constants: bool = false,
diff --git a/src/sourcemap/sourcemap.zig b/src/sourcemap/sourcemap.zig
index 5bfc4ca51..22a916940 100644
--- a/src/sourcemap/sourcemap.zig
+++ b/src/sourcemap/sourcemap.zig
@@ -629,6 +629,7 @@ pub const LineOffsetTable = struct {
var stack_fallback = std.heap.stackFallback(@sizeOf(i32) * 256, allocator);
var columns_for_non_ascii = std.ArrayList(i32).initCapacity(stack_fallback.get(), 120) catch unreachable;
const reset_end_index = stack_fallback.fixed_buffer_allocator.end_index;
+ const initial_columns_for_non_ascii = columns_for_non_ascii;
var remaining = contents;
while (remaining.len > 0) {
@@ -712,8 +713,11 @@ pub const LineOffsetTable = struct {
byte_offset_to_first_non_ascii = 0;
column_byte_offset = 0;
line_byte_offset = 0;
+
+ // reset the list to use the stack-allocated memory
stack_fallback.fixed_buffer_allocator.reset();
stack_fallback.fixed_buffer_allocator.end_index = reset_end_index;
+ columns_for_non_ascii = initial_columns_for_non_ascii;
},
else => {
// Mozilla's "source-map" library counts columns using UTF-16 code units
diff --git a/src/string_immutable.zig b/src/string_immutable.zig
index b27a0f820..98ec70646 100644
--- a/src/string_immutable.zig
+++ b/src/string_immutable.zig
@@ -15,6 +15,10 @@ pub inline fn contains(self: string, str: string) bool {
return std.mem.indexOf(u8, self, str) != null;
}
+pub fn toUTF16Literal(comptime str: []const u8) []const u16 {
+ return comptime std.unicode.utf8ToUtf16LeStringLiteral(str);
+}
+
const OptionalUsize = std.meta.Int(.unsigned, @bitSizeOf(usize) - 1);
pub fn indexOfAny(self: string, comptime str: anytype) ?OptionalUsize {
for (self) |c, i| {
@@ -108,7 +112,7 @@ pub inline fn indexOf(self: string, str: string) ?usize {
}
// --
-// This is faster when the string is found, by about 2x for a 4 MB file.
+// This is faster when the string is found, by about 2x for a 8 MB file.
// It is slower when the string is NOT found
// fn indexOfPosN(comptime T: type, buf: []const u8, start_index: usize, delimiter: []const u8, comptime n: comptime_int) ?usize {
// const k = delimiter.len;
@@ -324,7 +328,7 @@ test "eqlComptimeCheckLen" {
}
test "eqlComptimeUTF16" {
- try std.testing.expectEqual(eqlComptimeUTF16(std.unicode.utf8ToUtf16LeStringLiteral("bun-darwin-aarch64.zip"), "bun-darwin-aarch64.zip"), true);
+ try std.testing.expectEqual(eqlComptimeUTF16(toUTF16Literal("bun-darwin-aarch64.zip"), "bun-darwin-aarch64.zip"), true);
const sizes = [_]u16{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 23, 22, 24 };
inline for (sizes) |size| {
var buf: [size]u16 = undefined;
@@ -542,7 +546,7 @@ pub fn eqlComptime(self: string, comptime alt: anytype) bool {
}
pub fn eqlComptimeUTF16(self: []const u16, comptime alt: []const u8) bool {
- return eqlComptimeCheckLenWithType(u16, self, comptime std.unicode.utf8ToUtf16LeStringLiteral(alt), true);
+ return eqlComptimeCheckLenWithType(u16, self, comptime toUTF16Literal(alt), true);
}
pub fn eqlComptimeIgnoreLen(self: string, comptime alt: anytype) bool {
@@ -703,7 +707,7 @@ pub fn index(self: string, str: string) i32 {
}
pub fn eqlUtf16(comptime self: string, other: []const u16) bool {
- return std.mem.eql(u16, std.unicode.utf8ToUtf16LeStringLiteral(self), other);
+ return std.mem.eql(u16, toUTF16Literal(self), other);
}
pub fn toUTF8Alloc(allocator: std.mem.Allocator, js: []const u16) !string {
@@ -974,7 +978,7 @@ pub fn toUTF8AllocWithType(allocator: std.mem.Allocator, comptime Type: type, ut
utf16_remaining = utf16_remaining[replacement.len..];
const count: usize = replacement.utf8Width();
- try list.ensureUnusedCapacity(i + count);
+ try list.ensureTotalCapacityPrecise(i + count + list.items.len + @floatToInt(usize, (@intToFloat(f64, @truncate(u52, utf16_remaining.len)) * 1.2)));
list.items.len += i;
copyU16IntoU8(
@@ -992,12 +996,13 @@ pub fn toUTF8AllocWithType(allocator: std.mem.Allocator, comptime Type: type, ut
);
}
- try list.ensureUnusedCapacity(utf16_remaining.len);
+ try list.ensureTotalCapacityPrecise(utf16_remaining.len + list.items.len);
const old_len = list.items.len;
list.items.len += utf16_remaining.len;
copyU16IntoU8(list.items[old_len..], Type, utf16_remaining);
- return list.toOwnedSlice();
+ // don't call toOwnedSlice() because our
+ return list.items;
}
pub const EncodeIntoResult = struct {
@@ -1005,6 +1010,12 @@ pub const EncodeIntoResult = struct {
written: u32 = 0,
};
pub fn allocateLatin1IntoUTF8(allocator: std.mem.Allocator, comptime Type: type, latin1_: Type) ![]u8 {
+ if (comptime bun.FeatureFlags.latin1_is_now_ascii) {
+ var out = try allocator.alloc(u8, latin1_.len);
+ @memcpy(out.ptr, latin1_.ptr, latin1_.len);
+ return out;
+ }
+
var list = try std.ArrayList(u8).initCapacity(allocator, latin1_.len);
var latin1 = latin1_;
while (latin1.len > 0) {
@@ -1029,6 +1040,56 @@ pub fn allocateLatin1IntoUTF8(allocator: std.mem.Allocator, comptime Type: type,
return list.toOwnedSlice();
}
+pub fn allocateLatin1IntoUTF8ForArrayBuffer(allocator: std.mem.Allocator, globalThis: *JSC.JSGlobalObject, comptime Type: type, latin1_: Type) !JSC.JSValue {
+ if (comptime bun.FeatureFlags.latin1_is_now_ascii) {
+ var out = try allocator.alloc(u8, latin1_.len);
+ @memcpy(out.ptr, latin1_.ptr, latin1_.len);
+ return out;
+ }
+
+ var latin1 = latin1_;
+
+ if (firstNonASCII(latin1)) |start_i| {
+ var list = try std.ArrayList(u8).initCapacity(allocator, latin1_.len + 2);
+ list.items.len = start_i;
+ @memcpy(list.items.ptr, latin1.ptr, start_i);
+ {
+ var buf = list.items.ptr[list.items.len .. list.items.len + 2][0..2];
+ list.items.len += 2;
+ buf[0..2].* = latin1ToCodepointBytesAssumeNotASCII(latin1[0]);
+ latin1 = latin1[1..];
+ }
+
+ while (latin1.len > 0) {
+ const read = @as(usize, firstNonASCII(latin1) orelse @intCast(u32, latin1.len));
+ try list.ensureTotalCapacityPrecise(
+ list.items.len + read + if (read != latin1.len) @as(usize, 2) else @as(usize, 0),
+ );
+ const before = list.items.len;
+ list.items.len += read;
+ @memcpy(list.items[before..].ptr, latin1.ptr, read);
+ latin1 = latin1[read..];
+
+ if (latin1.len > 0) {
+ try list.ensureUnusedCapacity(2);
+ var buf = list.items.ptr[list.items.len .. list.items.len + 2][0..2];
+ list.items.len += 2;
+ buf[0..2].* = latin1ToCodepointBytesAssumeNotASCII(latin1[0]);
+ latin1 = latin1[1..];
+ }
+ }
+
+ return JSC.ArrayBuffer.fromBytes(list.toOwnedSlice(), .Uint8Array).toJS(globalThis, null);
+ }
+
+ {
+ const array_buffer = JSC.JSValue.createUninitializedUint8Array(globalThis, latin1.len);
+ var bytes = array_buffer.asArrayBuffer(globalThis).?.slice();
+ @memcpy(bytes.ptr, latin1.ptr, latin1.len);
+ return array_buffer;
+ }
+}
+
pub const UTF16Replacement = struct {
code_point: u32 = unicode_replacement,
len: u3 = 0,
@@ -1132,6 +1193,12 @@ pub fn convertUTF8BytesIntoUTF16(sequence: *const [4]u8) UTF16Replacement {
}
pub fn copyLatin1IntoUTF8(buf_: []u8, comptime Type: type, latin1_: Type) EncodeIntoResult {
+ if (comptime bun.FeatureFlags.latin1_is_now_ascii) {
+ const to_copy = @truncate(u32, @minimum(buf_.len, latin1_.len));
+ @memcpy(buf_.ptr, latin1_.ptr, to_copy);
+ return .{ .written = to_copy, .read = to_copy };
+ }
+
var buf = buf_;
var latin1 = latin1_;
while (buf.len > 0 and latin1.len > 0) {
@@ -1144,19 +1211,18 @@ pub fn copyLatin1IntoUTF8(buf_: []u8, comptime Type: type, latin1_: Type) Encode
break;
}
- buf[0..8].* = @bitCast([ascii_vector_size]u8, vec)[0..8].*;
- buf[8..ascii_vector_size].* = @bitCast([ascii_vector_size]u8, vec)[8..ascii_vector_size].*;
+ buf[0..ascii_vector_size].* = @bitCast([ascii_vector_size]u8, vec)[0..ascii_vector_size].*;
latin1 = latin1[ascii_vector_size..];
buf = buf[ascii_vector_size..];
}
while (read < latin1.len and latin1[read] < 0x80) : (read += 1) {}
- const written = @minimum(read, buf.len);
- if (written == 0) break;
- @memcpy(buf.ptr, latin1.ptr, written);
- latin1 = latin1[written..];
- buf = buf[written..];
+ const to_copy = @minimum(read, buf.len);
+ @memcpy(buf.ptr, latin1.ptr, to_copy);
+ latin1 = latin1[to_copy..];
+ buf = buf[to_copy..];
+
if (latin1.len > 0 and buf.len >= 2) {
buf[0..2].* = latin1ToCodepointBytesAssumeNotASCII(latin1[0]);
latin1 = latin1[1..];
@@ -1165,11 +1231,19 @@ pub fn copyLatin1IntoUTF8(buf_: []u8, comptime Type: type, latin1_: Type) Encode
}
return .{
- .read = @truncate(u32, buf_.len - buf.len),
- .written = @truncate(u32, latin1_.len - latin1.len),
+ .written = @truncate(u32, buf_.len - buf.len),
+ .read = @truncate(u32, latin1_.len - latin1.len),
};
}
+pub fn replaceLatin1WithUTF8(buf_: []u8) void {
+ var latin1 = buf_;
+ while (strings.firstNonASCII(latin1)) |i| {
+ latin1[i..][0..2].* = latin1ToCodepointBytesAssumeNotASCII(latin1[i]);
+ latin1 = latin1[i + 2 ..];
+ }
+}
+
pub fn elementLengthLatin1IntoUTF8(comptime Type: type, latin1_: Type) usize {
var latin1 = latin1_;
var count: usize = 0;
@@ -1245,6 +1319,625 @@ pub fn elementLengthLatin1IntoUTF16(comptime Type: type, latin1_: Type) usize {
return count;
}
+pub fn escapeHTMLForLatin1Input(allocator: std.mem.Allocator, latin1: []const u8) ![]const u8 {
+ const Scalar = struct {
+ pub const lengths: [std.math.maxInt(u8)]u4 = brk: {
+ var values: [std.math.maxInt(u8)]u4 = undefined;
+ for (values) |_, i| {
+ switch (i) {
+ '"' => {
+ values[i] = "&quot;".len;
+ },
+ '&' => {
+ values[i] = "&amp;".len;
+ },
+ '\'' => {
+ values[i] = "&#x27;".len;
+ },
+ '<' => {
+ values[i] = "&lt;".len;
+ },
+ '>' => {
+ values[i] = "&gt;".len;
+ },
+ else => {
+ values[i] = 1;
+ },
+ }
+ }
+
+ break :brk values;
+ };
+
+ inline fn appendString(buf: [*]u8, comptime str: []const u8) usize {
+ buf[0..str.len].* = str[0..str.len].*;
+ return str.len;
+ }
+
+ pub inline fn append(buf: [*]u8, char: u8) usize {
+ if (lengths[char] == 1) {
+ buf[0] = char;
+ return 1;
+ }
+
+ return switch (char) {
+ '"' => appendString(buf, "&quot;"),
+ '&' => appendString(buf, "&amp;"),
+ '\'' => appendString(buf, "&#x27;"),
+ '<' => appendString(buf, "&lt;"),
+ '>' => appendString(buf, "&gt;"),
+ else => unreachable,
+ };
+ }
+
+ pub inline fn push(comptime len: anytype, chars_: *const [len]u8, allo: std.mem.Allocator) []const u8 {
+ const chars = chars_.*;
+ var total: usize = 0;
+
+ comptime var remain_to_comp = len;
+ comptime var comp_i = 0;
+
+ inline while (remain_to_comp > 0) : (remain_to_comp -= 1) {
+ total += lengths[chars[comp_i]];
+ comp_i += 1;
+ }
+
+ if (total == len) {
+ return chars_;
+ }
+
+ var output = allo.alloc(u8, total) catch unreachable;
+ var head = output.ptr;
+ inline for (comptime bun.range(0, len)) |i| {
+ head += @This().append(head, chars[i]);
+ }
+
+ return output;
+ }
+ };
+ switch (latin1.len) {
+ 0 => return "",
+ 1 => return switch (latin1[0]) {
+ '"' => "&quot;",
+ '&' => "&amp;",
+ '\'' => "&#x27;",
+ '<' => "&lt;",
+ '>' => "&gt;",
+ else => latin1,
+ },
+ 2 => {
+ const first: []const u8 = switch (latin1[0]) {
+ '"' => "&quot;",
+ '&' => "&amp;",
+ '\'' => "&#x27;",
+ '<' => "&lt;",
+ '>' => "&gt;",
+ else => latin1[0..1],
+ };
+ const second: []const u8 = switch (latin1[1]) {
+ '"' => "&quot;",
+ '&' => "&amp;",
+ '\'' => "&#x27;",
+ '<' => "&lt;",
+ '>' => "&gt;",
+ else => latin1[1..2],
+ };
+ if (first.len == 1 and second.len == 1) {
+ return latin1;
+ }
+
+ return strings.append(allocator, first, second);
+ },
+
+ // The simd implementation is slower for inputs less than 32 bytes.
+ 3 => return Scalar.push(3, latin1[0..3], allocator),
+ 4 => return Scalar.push(4, latin1[0..4], allocator),
+ 5 => return Scalar.push(5, latin1[0..5], allocator),
+ 6 => return Scalar.push(6, latin1[0..6], allocator),
+ 7 => return Scalar.push(7, latin1[0..7], allocator),
+ 8 => return Scalar.push(8, latin1[0..8], allocator),
+ 9 => return Scalar.push(9, latin1[0..9], allocator),
+ 10 => return Scalar.push(10, latin1[0..10], allocator),
+ 11 => return Scalar.push(11, latin1[0..11], allocator),
+ 12 => return Scalar.push(12, latin1[0..12], allocator),
+ 13 => return Scalar.push(13, latin1[0..13], allocator),
+ 14 => return Scalar.push(14, latin1[0..14], allocator),
+ 15 => return Scalar.push(15, latin1[0..15], allocator),
+ 16 => return Scalar.push(16, latin1[0..16], allocator),
+ 17 => return Scalar.push(17, latin1[0..17], allocator),
+ 18 => return Scalar.push(18, latin1[0..18], allocator),
+ 19 => return Scalar.push(19, latin1[0..19], allocator),
+ 20 => return Scalar.push(20, latin1[0..20], allocator),
+ 21 => return Scalar.push(21, latin1[0..21], allocator),
+ 22 => return Scalar.push(22, latin1[0..22], allocator),
+ 23 => return Scalar.push(23, latin1[0..23], allocator),
+ 24 => return Scalar.push(24, latin1[0..24], allocator),
+ 25 => return Scalar.push(25, latin1[0..25], allocator),
+ 26 => return Scalar.push(26, latin1[0..26], allocator),
+ 27 => return Scalar.push(27, latin1[0..27], allocator),
+ 28 => return Scalar.push(28, latin1[0..28], allocator),
+ 29 => return Scalar.push(29, latin1[0..29], allocator),
+ 30 => return Scalar.push(30, latin1[0..30], allocator),
+ 31 => return Scalar.push(31, latin1[0..31], allocator),
+ 32 => return Scalar.push(32, latin1[0..32], allocator),
+
+ else => {
+ var remaining = latin1;
+
+ const vec_chars = "\"&'<>";
+ const vecs: [vec_chars.len]AsciiVector = comptime brk: {
+ var _vecs: [vec_chars.len]AsciiVector = undefined;
+ for (vec_chars) |c, i| {
+ _vecs[i] = @splat(ascii_vector_size, c);
+ }
+ break :brk _vecs;
+ };
+
+ var any_needs_escape = false;
+ var buf: std.ArrayList(u8) = undefined;
+
+ if (comptime Environment.isAarch64 or Environment.isX64) {
+ // pass #1: scan for any characters that need escaping
+ // assume most strings won't need any escaping, so don't actually allocate the buffer
+ scan_and_allocate_lazily: while (remaining.len >= ascii_vector_size) {
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(!any_needs_escape);
+ }
+ const vec: AsciiVector = remaining[0..ascii_vector_size].*;
+ if (@reduce(.Max, @bitCast(AsciiVectorU1, (vec == vecs[0])) |
+ @bitCast(AsciiVectorU1, (vec == vecs[1])) |
+ @bitCast(AsciiVectorU1, (vec == vecs[2])) |
+ @bitCast(AsciiVectorU1, (vec == vecs[3])) |
+ @bitCast(AsciiVectorU1, (vec == vecs[4]))) == 1)
+ {
+ buf = try std.ArrayList(u8).initCapacity(allocator, latin1.len + 6);
+ const copy_len = @ptrToInt(remaining.ptr) - @ptrToInt(latin1.ptr);
+ @memcpy(buf.items.ptr, latin1.ptr, copy_len);
+ buf.items.len = copy_len;
+ any_needs_escape = true;
+ comptime var i: usize = 0;
+ inline while (i < ascii_vector_size) : (i += 1) {
+ switch (vec[i]) {
+ '"' => {
+ buf.ensureUnusedCapacity((ascii_vector_size - i) + "&quot;".len) catch unreachable;
+ buf.items.ptr[buf.items.len .. buf.items.len + "&quot;".len][0.."&quot;".len].* = "&quot;".*;
+ buf.items.len += "&quot;".len;
+ },
+ '&' => {
+ buf.ensureUnusedCapacity((ascii_vector_size - i) + "&amp;".len) catch unreachable;
+ buf.items.ptr[buf.items.len .. buf.items.len + "&amp;".len][0.."&amp;".len].* = "&amp;".*;
+ buf.items.len += "&amp;".len;
+ },
+ '\'' => {
+ buf.ensureUnusedCapacity((ascii_vector_size - i) + "&#x27;".len) catch unreachable;
+ buf.items.ptr[buf.items.len .. buf.items.len + "&#x27;".len][0.."&#x27;".len].* = "&#x27;".*;
+ buf.items.len += "&#x27;".len;
+ },
+ '<' => {
+ buf.ensureUnusedCapacity((ascii_vector_size - i) + "&lt;".len) catch unreachable;
+ buf.items.ptr[buf.items.len .. buf.items.len + "&lt;".len][0.."&lt;".len].* = "&lt;".*;
+ buf.items.len += "&lt;".len;
+ },
+ '>' => {
+ buf.ensureUnusedCapacity((ascii_vector_size - i) + "&gt;".len) catch unreachable;
+ buf.items.ptr[buf.items.len .. buf.items.len + "&gt;".len][0.."&gt;".len].* = "&gt;".*;
+ buf.items.len += "&gt;".len;
+ },
+ else => |c| {
+ buf.appendAssumeCapacity(c);
+ },
+ }
+ }
+
+ remaining = remaining[ascii_vector_size..];
+ break :scan_and_allocate_lazily;
+ }
+
+ remaining = remaining[ascii_vector_size..];
+ }
+ }
+
+ if (any_needs_escape) {
+ // pass #2: we found something that needed an escape
+ // so we'll go ahead and copy the buffer into a new buffer
+ while (remaining.len >= ascii_vector_size) {
+ const vec: AsciiVector = remaining[0..ascii_vector_size].*;
+ if (@reduce(.Max, @bitCast(AsciiVectorU1, (vec == vecs[0])) |
+ @bitCast(AsciiVectorU1, (vec == vecs[1])) |
+ @bitCast(AsciiVectorU1, (vec == vecs[2])) |
+ @bitCast(AsciiVectorU1, (vec == vecs[3])) |
+ @bitCast(AsciiVectorU1, (vec == vecs[4]))) == 1)
+ {
+ buf.ensureUnusedCapacity(ascii_vector_size + 6) catch unreachable;
+ comptime var i: usize = 0;
+ inline while (i < ascii_vector_size) : (i += 1) {
+ switch (vec[i]) {
+ '"' => {
+ buf.ensureUnusedCapacity((ascii_vector_size - i) + "&quot;".len) catch unreachable;
+ buf.items.ptr[buf.items.len .. buf.items.len + "&quot;".len][0.."&quot;".len].* = "&quot;".*;
+ buf.items.len += "&quot;".len;
+ },
+ '&' => {
+ buf.ensureUnusedCapacity((ascii_vector_size - i) + "&amp;".len) catch unreachable;
+ buf.items.ptr[buf.items.len .. buf.items.len + "&amp;".len][0.."&amp;".len].* = "&amp;".*;
+ buf.items.len += "&amp;".len;
+ },
+ '\'' => {
+ buf.ensureUnusedCapacity((ascii_vector_size - i) + "&#x27;".len) catch unreachable;
+ buf.items.ptr[buf.items.len .. buf.items.len + "&#x27;".len][0.."&#x27;".len].* = "&#x27;".*;
+ buf.items.len += "&#x27;".len;
+ },
+ '<' => {
+ buf.ensureUnusedCapacity((ascii_vector_size - i) + "&lt;".len) catch unreachable;
+ buf.items.ptr[buf.items.len .. buf.items.len + "&lt;".len][0.."&lt;".len].* = "&lt;".*;
+ buf.items.len += "&lt;".len;
+ },
+ '>' => {
+ buf.ensureUnusedCapacity((ascii_vector_size - i) + "&gt;".len) catch unreachable;
+ buf.items.ptr[buf.items.len .. buf.items.len + "&gt;".len][0.."&gt;".len].* = "&gt;".*;
+ buf.items.len += "&gt;".len;
+ },
+ else => |c| {
+ buf.appendAssumeCapacity(c);
+ },
+ }
+ }
+
+ remaining = remaining[ascii_vector_size..];
+ continue;
+ }
+
+ try buf.ensureUnusedCapacity(ascii_vector_size);
+ buf.items.ptr[buf.items.len .. buf.items.len + ascii_vector_size][0..ascii_vector_size].* = remaining[0..ascii_vector_size].*;
+ buf.items.len += ascii_vector_size;
+ remaining = remaining[ascii_vector_size..];
+ }
+ }
+
+ var ptr = remaining.ptr;
+ const end = remaining.ptr + remaining.len;
+
+ if (!any_needs_escape) {
+ scan_and_allocate_lazily: while (ptr != end) : (ptr += 1) {
+ switch (ptr[0]) {
+ '"', '&', '\'', '<', '>' => |c| {
+ buf = try std.ArrayList(u8).initCapacity(allocator, latin1.len + @as(usize, Scalar.lengths[c]));
+ const copy_len = @ptrToInt(ptr) - @ptrToInt(latin1.ptr);
+ @memcpy(buf.items.ptr, latin1.ptr, copy_len - 1);
+ buf.items.len = copy_len;
+ any_needs_escape = true;
+ break :scan_and_allocate_lazily;
+ },
+ else => {},
+ }
+ }
+ }
+
+ while (ptr != end) : (ptr += 1) {
+ switch (ptr[0]) {
+ '"' => {
+ buf.appendSlice("&quot;") catch unreachable;
+ },
+ '&' => {
+ buf.appendSlice("&amp;") catch unreachable;
+ },
+ '\'' => {
+ buf.appendSlice("&#x27;") catch unreachable; // modified from escape-html; used to be '&#39'
+ },
+ '<' => {
+ buf.appendSlice("&lt;") catch unreachable;
+ },
+ '>' => {
+ buf.appendSlice("&gt;") catch unreachable;
+ },
+ else => |c| {
+ buf.append(c) catch unreachable;
+ },
+ }
+ }
+
+ if (!any_needs_escape) {
+ return latin1;
+ }
+
+ return buf.toOwnedSlice();
+ },
+ }
+}
+
+pub fn escapeHTMLForUTF16Input(allocator: std.mem.Allocator, utf16: []const u16) ![]const u16 {
+ const Scalar = struct {
+ pub const lengths: [std.math.maxInt(u8)]u4 = brk: {
+ var values: [std.math.maxInt(u8)]u4 = undefined;
+ for (values) |_, i| {
+ values[i] = switch (i) {
+ '"' => "&quot;".len,
+ '&' => "&amp;".len,
+ '\'' => "&#x27;".len,
+ '<' => "&lt;".len,
+ '>' => "&gt;".len,
+ else => 1,
+ };
+ }
+
+ break :brk values;
+ };
+ };
+ switch (utf16.len) {
+ 0 => return &[_]u16{},
+ 1 => return switch (utf16[0]) {
+ '"' => toUTF16Literal("&quot;"),
+ '&' => toUTF16Literal("&amp;"),
+ '\'' => toUTF16Literal("&#x27;"),
+ '<' => toUTF16Literal("&lt;"),
+ '>' => toUTF16Literal("&gt;"),
+ else => utf16,
+ },
+ 2 => {
+ const first_16 = switch (utf16[0]) {
+ '"' => toUTF16Literal("&quot;"),
+ '&' => toUTF16Literal("&amp;"),
+ '\'' => toUTF16Literal("&#x27;"),
+ '<' => toUTF16Literal("&lt;"),
+ '>' => toUTF16Literal("&gt;"),
+ else => @as([]const u16, utf16[0..1]),
+ };
+
+ const second_16 = switch (utf16[1]) {
+ '"' => toUTF16Literal("&quot;"),
+ '&' => toUTF16Literal("&amp;"),
+ '\'' => toUTF16Literal("&#x27;"),
+ '<' => toUTF16Literal("&lt;"),
+ '>' => toUTF16Literal("&gt;"),
+ else => @as([]const u16, utf16[1..2]),
+ };
+
+ if (first_16.ptr == utf16.ptr and second_16.ptr == utf16.ptr + 1) {
+ return utf16;
+ }
+
+ var buf = allocator.alloc(u16, first_16.len + second_16.len) catch unreachable;
+ std.mem.copy(u16, buf, first_16);
+ std.mem.copy(u16, buf[first_16.len..], second_16);
+ return buf;
+ },
+
+ else => {
+ var remaining = utf16;
+
+ var any_needs_escape = false;
+ var buf: std.ArrayList(u16) = undefined;
+
+ if (comptime Environment.isAarch64 or Environment.isX64) {
+ const vec_chars = "\"&'<>";
+ const vecs: [vec_chars.len]AsciiU16Vector = brk: {
+ var _vecs: [vec_chars.len]AsciiU16Vector = undefined;
+ for (vec_chars) |c, i| {
+ _vecs[i] = @splat(ascii_u16_vector_size, @as(u16, c));
+ }
+ break :brk _vecs;
+ };
+ // pass #1: scan for any characters that need escaping
+ // assume most strings won't need any escaping, so don't actually allocate the buffer
+ scan_and_allocate_lazily: while (remaining.len >= ascii_u16_vector_size) {
+ if (comptime Environment.allow_assert) {
+ std.debug.assert(!any_needs_escape);
+ }
+ const vec: AsciiU16Vector = remaining[0..ascii_u16_vector_size].*;
+ if (@reduce(.Max, @bitCast(AsciiVectorU16U1, vec > @splat(ascii_u16_vector_size, @as(u16, 127))) |
+ @bitCast(AsciiVectorU16U1, (vec == vecs[0])) |
+ @bitCast(AsciiVectorU16U1, (vec == vecs[1])) |
+ @bitCast(AsciiVectorU16U1, (vec == vecs[2])) |
+ @bitCast(AsciiVectorU16U1, (vec == vecs[3])) |
+ @bitCast(AsciiVectorU16U1, (vec == vecs[4]))) == 1)
+ {
+ var i: u16 = 0;
+ lazy: {
+ while (i < ascii_u16_vector_size) {
+ switch (remaining[i]) {
+ '"', '&', '\'', '<', '>' => {
+ any_needs_escape = true;
+ break :lazy;
+ },
+ 128...std.math.maxInt(u16) => {
+ const cp = utf16Codepoint([]const u16, remaining[i..]);
+ i += @as(u16, cp.len);
+ },
+ else => {
+ i += 1;
+ },
+ }
+ }
+ }
+
+ if (!any_needs_escape) {
+ remaining = remaining[i..];
+ continue :scan_and_allocate_lazily;
+ }
+
+ buf = try std.ArrayList(u16).initCapacity(allocator, utf16.len + 6);
+ std.debug.assert(@ptrToInt(remaining.ptr + i) >= @ptrToInt(utf16.ptr));
+ const to_copy = std.mem.sliceAsBytes(utf16)[0 .. @ptrToInt(remaining.ptr + i) - @ptrToInt(utf16.ptr)];
+ @memcpy(@ptrCast([*]align(2) u8, buf.items.ptr), to_copy.ptr, to_copy.len);
+ buf.items.len = std.mem.bytesAsSlice(u16, to_copy).len;
+
+ while (i < ascii_u16_vector_size) {
+ switch (remaining[i]) {
+ '"', '&', '\'', '<', '>' => |c| {
+ const result = switch (c) {
+ '"' => toUTF16Literal("&quot;"),
+ '&' => toUTF16Literal("&amp;"),
+ '\'' => toUTF16Literal("&#x27;"),
+ '<' => toUTF16Literal("&lt;"),
+ '>' => toUTF16Literal("&gt;"),
+ else => unreachable,
+ };
+
+ buf.appendSlice(result) catch unreachable;
+ i += 1;
+ },
+ 128...std.math.maxInt(u16) => {
+ const cp = utf16Codepoint([]const u16, remaining[i..]);
+
+ buf.appendSlice(remaining[i..][0..@as(usize, cp.len)]) catch unreachable;
+ i += @as(u16, cp.len);
+ },
+ else => |c| {
+ i += 1;
+ buf.append(c) catch unreachable;
+ },
+ }
+ }
+
+ // edgecase: code point width could exceed asdcii_u16_vector_size
+ remaining = remaining[i..];
+ break :scan_and_allocate_lazily;
+ }
+
+ remaining = remaining[ascii_u16_vector_size..];
+ }
+
+ if (any_needs_escape) {
+ // pass #2: we found something that needed an escape
+ // but there's still some more text to
+ // so we'll go ahead and copy the buffer into a new buffer
+ while (remaining.len >= ascii_u16_vector_size) {
+ const vec: AsciiU16Vector = remaining[0..ascii_u16_vector_size].*;
+ if (@reduce(.Max, @bitCast(AsciiVectorU16U1, vec > @splat(ascii_u16_vector_size, @as(u16, 127))) |
+ @bitCast(AsciiVectorU16U1, (vec == vecs[0])) |
+ @bitCast(AsciiVectorU16U1, (vec == vecs[1])) |
+ @bitCast(AsciiVectorU16U1, (vec == vecs[2])) |
+ @bitCast(AsciiVectorU16U1, (vec == vecs[3])) |
+ @bitCast(AsciiVectorU16U1, (vec == vecs[4]))) == 1)
+ {
+ buf.ensureUnusedCapacity(ascii_u16_vector_size) catch unreachable;
+ var i: u16 = 0;
+ while (i < ascii_u16_vector_size) {
+ switch (remaining[i]) {
+ '"' => {
+ buf.appendSlice(toUTF16Literal("&quot;")) catch unreachable;
+ i += 1;
+ },
+ '&' => {
+ buf.appendSlice(toUTF16Literal("&amp;")) catch unreachable;
+ i += 1;
+ },
+ '\'' => {
+ buf.appendSlice(toUTF16Literal("&#x27;")) catch unreachable; // modified from escape-html; used to be '&#39'
+ i += 1;
+ },
+ '<' => {
+ buf.appendSlice(toUTF16Literal("&lt;")) catch unreachable;
+ i += 1;
+ },
+ '>' => {
+ buf.appendSlice(toUTF16Literal("&gt;")) catch unreachable;
+ i += 1;
+ },
+ 128...std.math.maxInt(u16) => {
+ const cp = utf16Codepoint([]const u16, remaining[i..]);
+
+ buf.appendSlice(remaining[i..][0..@as(usize, cp.len)]) catch unreachable;
+ i += @as(u16, cp.len);
+ },
+ else => |c| {
+ buf.append(c) catch unreachable;
+ i += 1;
+ },
+ }
+ }
+
+ remaining = remaining[i..];
+ continue;
+ }
+
+ try buf.ensureUnusedCapacity(ascii_u16_vector_size);
+ buf.items.ptr[buf.items.len .. buf.items.len + ascii_u16_vector_size][0..ascii_u16_vector_size].* = remaining[0..ascii_u16_vector_size].*;
+ buf.items.len += ascii_u16_vector_size;
+ remaining = remaining[ascii_u16_vector_size..];
+ }
+ }
+ }
+
+ var ptr = remaining.ptr;
+ const end = remaining.ptr + remaining.len;
+
+ if (!any_needs_escape) {
+ scan_and_allocate_lazily: while (ptr != end) {
+ switch (ptr[0]) {
+ '"', '&', '\'', '<', '>' => |c| {
+ buf = try std.ArrayList(u16).initCapacity(allocator, utf16.len + @as(usize, Scalar.lengths[c]));
+ std.debug.assert(@ptrToInt(ptr) >= @ptrToInt(utf16.ptr));
+
+ const to_copy = std.mem.sliceAsBytes(utf16)[0 .. @ptrToInt(ptr) - @ptrToInt(utf16.ptr)];
+
+ @memcpy(
+ @ptrCast([*]align(2) u8, buf.items.ptr),
+ to_copy.ptr,
+ to_copy.len,
+ );
+
+ buf.items.len = std.mem.bytesAsSlice(u16, to_copy).len;
+ any_needs_escape = true;
+ break :scan_and_allocate_lazily;
+ },
+ 128...std.math.maxInt(u16) => {
+ const cp = utf16Codepoint([]const u16, ptr[0..2]);
+
+ ptr += @as(u16, cp.len);
+ },
+ else => {
+ ptr += 1;
+ },
+ }
+ }
+ }
+
+ while (ptr != end) {
+ switch (ptr[0]) {
+ '"' => {
+ buf.appendSlice(toUTF16Literal("&quot;")) catch unreachable;
+ ptr += 1;
+ },
+ '&' => {
+ buf.appendSlice(toUTF16Literal("&amp;")) catch unreachable;
+ ptr += 1;
+ },
+ '\'' => {
+ buf.appendSlice(toUTF16Literal("&#x27;")) catch unreachable; // modified from escape-html; used to be '&#39'
+ ptr += 1;
+ },
+ '<' => {
+ buf.appendSlice(toUTF16Literal("&lt;")) catch unreachable;
+ ptr += 1;
+ },
+ '>' => {
+ buf.appendSlice(toUTF16Literal("&gt;")) catch unreachable;
+ ptr += 1;
+ },
+ 128...std.math.maxInt(u16) => {
+ const cp = utf16Codepoint([]const u16, ptr[0..2]);
+
+ buf.appendSlice(ptr[0..@as(usize, cp.len)]) catch unreachable;
+ ptr += @as(u16, cp.len);
+ },
+
+ else => |c| {
+ buf.append(c) catch unreachable;
+ ptr += 1;
+ },
+ }
+ }
+
+ if (!any_needs_escape) {
+ return utf16;
+ }
+
+ return buf.toOwnedSlice();
+ },
+ }
+}
+
test "copyLatin1IntoUTF8" {
var input: string = "hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!hello world!";
var output = std.mem.zeroes([500]u8);
@@ -1516,7 +2209,9 @@ pub const min_16_ascii = @splat(ascii_vector_size, @as(u8, 0x20));
pub const max_u16_ascii = @splat(ascii_u16_vector_size, @as(u16, 127));
pub const min_u16_ascii = @splat(ascii_u16_vector_size, @as(u16, 0x20));
pub const AsciiVector = std.meta.Vector(ascii_vector_size, u8);
+pub const AsciiVectorSmall = std.meta.Vector(8, u8);
pub const AsciiVectorU1 = std.meta.Vector(ascii_vector_size, u1);
+pub const AsciiVectorU1Small = std.meta.Vector(8, u1);
pub const AsciiVectorU16U1 = std.meta.Vector(ascii_u16_vector_size, u1);
pub const AsciiU16Vector = std.meta.Vector(ascii_u16_vector_size, u16);
pub const max_4_ascii = @splat(4, @as(u8, 127));
@@ -1703,9 +2398,10 @@ pub fn indexOfChar(slice: []const u8, char: u8) ?u32 {
while (remaining.len >= ascii_vector_size) {
const vec: AsciiVector = remaining[0..ascii_vector_size].*;
const cmp = vec == @splat(ascii_vector_size, char);
- const bitmask = @ptrCast(*const AsciiVectorInt, &cmp).*;
- const first = @ctz(AsciiVectorInt, bitmask);
- if (first < 16) {
+
+ if (@reduce(.Max, @bitCast(AsciiVectorU1, cmp)) > 0) {
+ const bitmask = @ptrCast(*const AsciiVectorInt, &cmp).*;
+ const first = @ctz(AsciiVectorInt, bitmask);
return @intCast(u32, @as(u32, first) + @intCast(u32, slice.len - remaining.len));
}
remaining = remaining[ascii_vector_size..];
@@ -2089,27 +2785,27 @@ test "firstNonASCII" {
test "firstNonASCII16" {
@setEvalBranchQuota(99999);
- const yes = std.mem.span(std.unicode.utf8ToUtf16LeStringLiteral("aspdokasdpokasdpokasd aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasd aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasd aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasd aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123"));
+ const yes = std.mem.span(toUTF16Literal("aspdokasdpokasdpokasd aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasd aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasd aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasd aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123"));
try std.testing.expectEqual(true, firstNonASCII16(@TypeOf(yes), yes) == null);
{
@setEvalBranchQuota(99999);
- const no = std.mem.span(std.unicode.utf8ToUtf16LeStringLiteral("aspdokasdpokasdpokasd aspdokasdpokasdpokasdaspdoka🙂sdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123"));
+ const no = std.mem.span(toUTF16Literal("aspdokasdpokasdpokasd aspdokasdpokasdpokasdaspdoka🙂sdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123"));
try std.testing.expectEqual(@as(u32, 50), firstNonASCII16(@TypeOf(no), no).?);
}
{
@setEvalBranchQuota(99999);
- const no = std.mem.span(std.unicode.utf8ToUtf16LeStringLiteral("🙂sdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123"));
+ const no = std.mem.span(toUTF16Literal("🙂sdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123"));
try std.testing.expectEqual(@as(u32, 0), firstNonASCII16(@TypeOf(no), no).?);
}
{
@setEvalBranchQuota(99999);
- const no = std.mem.span(std.unicode.utf8ToUtf16LeStringLiteral("a🙂sdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123"));
+ const no = std.mem.span(toUTF16Literal("a🙂sdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123"));
try std.testing.expectEqual(@as(u32, 1), firstNonASCII16(@TypeOf(no), no).?);
}
{
@setEvalBranchQuota(99999);
- const no = std.mem.span(std.unicode.utf8ToUtf16LeStringLiteral("aspdokasdpokasdpokasd aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd12312🙂3"));
+ const no = std.mem.span(toUTF16Literal("aspdokasdpokasdpokasd aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd123123aspdokasdpokasdpokasdaspdokasdpokasdpokasdaspdokasdpokasdpokasd12312🙂3"));
try std.testing.expectEqual(@as(u32, 366), firstNonASCII16(@TypeOf(no), no).?);
}
}
@@ -2147,7 +2843,7 @@ pub fn formatUTF16(slice_: []align(1) const u16, writer: anytype) !void {
test "print UTF16" {
var err = std.io.getStdErr();
- const utf16 = comptime std.unicode.utf8ToUtf16LeStringLiteral("❌ ✅ opkay ");
+ const utf16 = comptime toUTF16Literal("❌ ✅ opkay ");
try formatUTF16(utf16, err.writer());
// std.unicode.fmtUtf16le(utf16le: []const u16)
}