diff options
author | 2023-05-22 18:51:05 -0700 | |
---|---|---|
committer | 2023-05-22 18:51:05 -0700 | |
commit | fc40c690ea30a632a8d0d9490321c50ec898d8a5 (patch) | |
tree | 6e3ca0bb2c02347006a6b2a09c4aa156b86bd770 | |
parent | 23d42dc2377440dedc9d8e423f1ea077507d62c8 (diff) | |
download | bun-fc40c690ea30a632a8d0d9490321c50ec898d8a5.tar.gz bun-fc40c690ea30a632a8d0d9490321c50ec898d8a5.tar.zst bun-fc40c690ea30a632a8d0d9490321c50ec898d8a5.zip |
Write out builtins with TypeScript + Minify them (#2999)
* start work drafting how builtins will work
* work on ts builtin
* builtins stuff so far
* builtins
* done for today
* continue work
* working on it
* bindings so far
* well, it builds. doesnt run
* IT RUNS
* still lots of ts errors but it is functional
* sloppy mode
127 files changed, 16346 insertions, 25009 deletions
diff --git a/.prettierignore b/.prettierignore index 2b1e85e80..6fb929e8e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,6 +1,6 @@ src/fallback.html src/bun.js/WebKit -src/bun.js/builtins/js +src/bun.js/builtins/js/*.js src/*.out.js src/*out.*.js src/deps diff --git a/.vscode/settings.json b/.vscode/settings.json index 6c8a24381..7ecda7727 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -108,6 +108,11 @@ "editor.defaultFormatter": "xaver.clang-format" }, "files.associations": { + "*.{setting,comp,fuse,fu}": "lua", + "*.ctk": "json", + "*.json5": "json5", + "*.json": "jsonc", + "*.scriptlib": "lua", "*.lock": "yarnlock", "*.idl": "cpp", "memory": "cpp", @@ -216,7 +221,14 @@ "regex": "cpp", "span": "cpp", "valarray": "cpp", - "codecvt": "cpp" + "codecvt": "cpp", + "hash_map": "cpp", + "source_location": "cpp", + "numbers": "cpp", + "semaphore": "cpp", + "stdfloat": "cpp", + "stop_token": "cpp", + "cfenv": "cpp" }, "cmake.configureOnOpen": false, "C_Cpp.errorSquiggles": "enabled", @@ -530,9 +530,6 @@ get-% : ; @echo $($*) print-version: @echo $(PACKAGE_JSON_VERSION) - - - # Prevent dependency on libtcc1 so it doesn't do filesystem lookups TINYCC_CFLAGS= -DTCC_LIBTCC1=\"\0\" @@ -550,24 +547,8 @@ tinycc: PYTHON=$(shell which python 2>/dev/null || which python3 2>/dev/null || which python2 2>/dev/null) .PHONY: builtins -builtins: ## to generate builtins - @if [ -z "$(WEBKIT_DIR)" ] || [ ! -d "$(WEBKIT_DIR)/Source" ]; then echo "WebKit is not cloned. Please run make init-submodules"; exit 1; fi - rm -f src/bun.js/bindings/*Builtin*.cpp src/bun.js/bindings/*Builtin*.h src/bun.js/bindings/*Builtin*.cpp - rm -rf src/bun.js/builtins/cpp - mkdir -p src/bun.js/builtins/cpp - $(PYTHON) $(realpath $(WEBKIT_DIR)/Source/JavaScriptCore/Scripts/generate-js-builtins.py) -i $(realpath src)/bun.js/builtins/js -o $(realpath src)/bun.js/builtins/cpp --framework WebCore --force - $(PYTHON) $(realpath $(WEBKIT_DIR)/Source/JavaScriptCore/Scripts/generate-js-builtins.py) -i $(realpath src)/bun.js/builtins/js -o $(realpath src)/bun.js/builtins/cpp --framework WebCore --wrappers-only - rm -rf /tmp/1.h src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h.1 - echo -e '// $(CLANG_FORMAT) off\nnamespace Zig { class GlobalObject; }\n#include "root.h"\n' >> /tmp/1.h - cat /tmp/1.h src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h > src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h.1 - mv src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h.1 src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h - rm -rf /tmp/1.h src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h.1 - echo -e '// $(CLANG_FORMAT) off\nnamespace Zig { class GlobalObject; }\n#include "root.h"\n' >> /tmp/1.h - cat /tmp/1.h src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.cpp > src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.cpp.1 - mv src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.cpp.1 src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.cpp - $(SED) -i -e 's/class JSDOMGlobalObject/using JSDOMGlobalObject = Zig::GlobalObject/' src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h - # this is the one we actually build - mv src/bun.js/builtins/cpp/*JSBuiltin*.cpp src/bun.js/builtins +builtins: + bun src/bun.js/builtins/codegen/index.ts --minify .PHONY: generate-builtins generate-builtins: builtins diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index d5085e739..381e888a3 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -962,7 +962,7 @@ declare module "bun" { entry?: string; asset?: string; }; // | string; - // root?: string; // project root + root?: string; // project root splitting?: boolean; // default true, enable code splitting plugins?: BunPlugin[]; // manifest?: boolean; // whether to return manifest @@ -2746,6 +2746,7 @@ declare module "bun" { * ``` */ namespace?: string; + external: boolean; } type OnResolveCallback = ( diff --git a/packages/bun-types/globals.d.ts b/packages/bun-types/globals.d.ts index b8388b49c..a0efdc983 100644 --- a/packages/bun-types/globals.d.ts +++ b/packages/bun-types/globals.d.ts @@ -2087,7 +2087,6 @@ type EventListenerOrEventListenerObject = EventListener | EventListenerObject; * "/node_modules.server.bun". * * Bun may inject additional imports into your code. This usually has a `bun:` prefix. - * */ declare var Loader: { /** @@ -2110,25 +2109,34 @@ declare var Loader: { * * Virtual modules and JS polyfills are embedded in bun's binary. They don't * point to anywhere in your local filesystem. - * - * */ registry: Map< string, { + key: string; /** * This refers to the state the ESM module is in * * TODO: make an enum for this number - * - * */ state: number; - dependencies: string[]; + fetch: Promise<any>; + instantiate: Promise<any>; + satisfy: Promise<any>; + dependencies: Array< + (typeof Loader)["registry"] extends Map<any, infer V> ? V : any + >; /** * Your application will probably crash if you mess with this. */ - module: any; + module: { + dependenciesMap: (typeof Loader)["registry"]; + }; + linkError?: any; + linkSucceeded: boolean; + evaluated: boolean; + then?: any; + isAsync: boolean; } >; /** @@ -2252,6 +2260,7 @@ declare var ReadableStreamDefaultController: { interface ReadableStreamDefaultReader<R = any> extends ReadableStreamGenericReader { read(): Promise<ReadableStreamDefaultReadResult<R>>; + readMany(): Promise<ReadableStreamDefaultReadValueResult<R>>; releaseLock(): void; } diff --git a/src/bun.js/bindings/ImportMetaObject.cpp b/src/bun.js/bindings/ImportMetaObject.cpp index 7831cf881..9c421d839 100644 --- a/src/bun.js/bindings/ImportMetaObject.cpp +++ b/src/bun.js/bindings/ImportMetaObject.cpp @@ -33,8 +33,6 @@ #include "JavaScriptCore/BuiltinNames.h" #include "JSBufferEncodingType.h" -#include "JSBufferPrototypeBuiltins.h" -#include "JSBufferConstructorBuiltins.h" #include "JavaScriptCore/JSBase.h" #include "JSDOMURL.h" diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp index 5c41ba0b1..00965da89 100644 --- a/src/bun.js/bindings/JSBuffer.cpp +++ b/src/bun.js/bindings/JSBuffer.cpp @@ -38,8 +38,6 @@ #include "JavaScriptCore/BuiltinNames.h" #include "JSBufferEncodingType.h" -#include "JSBufferPrototypeBuiltins.h" -#include "JSBufferConstructorBuiltins.h" #include "JavaScriptCore/JSBase.h" #if ENABLE(MEDIA_SOURCE) #include "BufferMediaSource.h" @@ -2177,4 +2175,4 @@ bool JSBuffer__isBuffer(JSC::JSGlobalObject* lexicalGlobalObject, JSC::EncodedJS JSValue prototype = cell->getPrototype(vm, lexicalGlobalObject); return prototype.inherits<WebCore::JSBufferPrototype>(); -}
\ No newline at end of file +} diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp index 84f69aa31..36be334dd 100644 --- a/src/bun.js/bindings/JSSink.cpp +++ b/src/bun.js/bindings/JSSink.cpp @@ -41,8 +41,6 @@ #include "JavaScriptCore/BuiltinNames.h" #include "JSBufferEncodingType.h" -#include "JSBufferPrototypeBuiltins.h" -#include "JSBufferConstructorBuiltins.h" #include "JavaScriptCore/JSBase.h" #if ENABLE(MEDIA_SOURCE) #include "BufferMediaSource.h" diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 766f0f427..663c2a491 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -93,7 +93,7 @@ #include "JSReadableHelper.h" #include "Process.h" -#include "WebCoreJSBuiltinInternals.h" +#include "WebCoreJSBuiltins.h" #include "JSBuffer.h" #include "JSBufferList.h" #include "JSFFIFunction.h" @@ -103,7 +103,6 @@ #include "JavaScriptCore/FunctionPrototype.h" #include "napi.h" #include "JSSQLStatement.h" -#include "ReadableStreamBuiltins.h" #include "BunJSCModule.h" #include "ModuleLoader.h" #include "NodeVMScript.h" diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h index 662de56e6..f489b3942 100644 --- a/src/bun.js/bindings/ZigGlobalObject.h +++ b/src/bun.js/bindings/ZigGlobalObject.h @@ -37,7 +37,7 @@ class DOMWrapperWorld; #include "JavaScriptCore/JSGlobalObject.h" #include "JavaScriptCore/JSTypeInfo.h" #include "JavaScriptCore/Structure.h" -#include "WebCoreJSBuiltinInternals.h" +#include "WebCoreJSBuiltins.h" #include "DOMConstructors.h" #include "BunPlugin.h" diff --git a/src/bun.js/bindings/webcore/JSByteLengthQueuingStrategy.cpp b/src/bun.js/bindings/webcore/JSByteLengthQueuingStrategy.cpp index bbb4bf168..2b8ff4c7b 100644 --- a/src/bun.js/bindings/webcore/JSByteLengthQueuingStrategy.cpp +++ b/src/bun.js/bindings/webcore/JSByteLengthQueuingStrategy.cpp @@ -21,7 +21,6 @@ #include "config.h" #include "JSByteLengthQueuingStrategy.h" -#include "ByteLengthQueuingStrategyBuiltins.h" #include "ExtendedDOMClientIsoSubspaces.h" #include "ExtendedDOMIsoSubspaces.h" #include "JSDOMAttribute.h" diff --git a/src/bun.js/bindings/webcore/JSCountQueuingStrategy.cpp b/src/bun.js/bindings/webcore/JSCountQueuingStrategy.cpp index 723d10c9b..a193f805c 100644 --- a/src/bun.js/bindings/webcore/JSCountQueuingStrategy.cpp +++ b/src/bun.js/bindings/webcore/JSCountQueuingStrategy.cpp @@ -21,7 +21,6 @@ #include "config.h" #include "JSCountQueuingStrategy.h" -#include "CountQueuingStrategyBuiltins.h" #include "ExtendedDOMClientIsoSubspaces.h" #include "ExtendedDOMIsoSubspaces.h" #include "JSDOMAttribute.h" diff --git a/src/bun.js/bindings/webcore/JSDOMBindingInternalsBuiltins.cpp b/src/bun.js/bindings/webcore/JSDOMBindingInternalsBuiltins.cpp index 2ae04a290..84f96c5b9 100644 --- a/src/bun.js/bindings/webcore/JSDOMBindingInternalsBuiltins.cpp +++ b/src/bun.js/bindings/webcore/JSDOMBindingInternalsBuiltins.cpp @@ -29,7 +29,6 @@ // // builtins by the script: Source/JavaScriptCore/Scripts/generate-js-builtins.py // #include "config.h" -// #include "JSDOMBindingInternalsBuiltins.h" // #include "WebCoreJSClientData.h" // #include "JavaScriptCore/HeapInlines.h" diff --git a/src/bun.js/bindings/webcore/JSReadableByteStreamController.cpp b/src/bun.js/bindings/webcore/JSReadableByteStreamController.cpp index 75ff72b00..54b1a9034 100644 --- a/src/bun.js/bindings/webcore/JSReadableByteStreamController.cpp +++ b/src/bun.js/bindings/webcore/JSReadableByteStreamController.cpp @@ -30,7 +30,6 @@ #include "JSDOMGlobalObjectInlines.h" #include "JSDOMOperation.h" #include "JSDOMWrapperCache.h" -#include "ReadableByteStreamControllerBuiltins.h" #include "WebCoreJSClientData.h" #include <JavaScriptCore/FunctionPrototype.h> #include <JavaScriptCore/JSCInlines.h> diff --git a/src/bun.js/bindings/webcore/JSReadableStream.cpp b/src/bun.js/bindings/webcore/JSReadableStream.cpp index 4da9e0b1b..3fea3d44f 100644 --- a/src/bun.js/bindings/webcore/JSReadableStream.cpp +++ b/src/bun.js/bindings/webcore/JSReadableStream.cpp @@ -30,7 +30,6 @@ #include "JSDOMGlobalObjectInlines.h" #include "JSDOMOperation.h" #include "JSDOMWrapperCache.h" -#include "ReadableStreamBuiltins.h" #include "WebCoreJSClientData.h" #include <JavaScriptCore/FunctionPrototype.h> #include <JavaScriptCore/JSCInlines.h> diff --git a/src/bun.js/bindings/webcore/JSReadableStreamBYOBReader.cpp b/src/bun.js/bindings/webcore/JSReadableStreamBYOBReader.cpp index dc8a40be2..4d64bf23a 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamBYOBReader.cpp +++ b/src/bun.js/bindings/webcore/JSReadableStreamBYOBReader.cpp @@ -30,7 +30,6 @@ #include "JSDOMGlobalObjectInlines.h" #include "JSDOMOperation.h" #include "JSDOMWrapperCache.h" -#include "ReadableStreamBYOBReaderBuiltins.h" #include "WebCoreJSClientData.h" #include <JavaScriptCore/FunctionPrototype.h> #include <JavaScriptCore/JSCInlines.h> diff --git a/src/bun.js/bindings/webcore/JSReadableStreamBYOBRequest.cpp b/src/bun.js/bindings/webcore/JSReadableStreamBYOBRequest.cpp index ff61e5c98..b3520e8f8 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamBYOBRequest.cpp +++ b/src/bun.js/bindings/webcore/JSReadableStreamBYOBRequest.cpp @@ -30,7 +30,6 @@ #include "JSDOMGlobalObjectInlines.h" #include "JSDOMOperation.h" #include "JSDOMWrapperCache.h" -#include "ReadableStreamBYOBRequestBuiltins.h" #include "WebCoreJSClientData.h" #include <JavaScriptCore/FunctionPrototype.h> #include <JavaScriptCore/JSCInlines.h> diff --git a/src/bun.js/bindings/webcore/JSReadableStreamDefaultController.cpp b/src/bun.js/bindings/webcore/JSReadableStreamDefaultController.cpp index 8a8075a1f..fea3ffc8c 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamDefaultController.cpp +++ b/src/bun.js/bindings/webcore/JSReadableStreamDefaultController.cpp @@ -30,7 +30,6 @@ #include "JSDOMGlobalObjectInlines.h" #include "JSDOMOperation.h" #include "JSDOMWrapperCache.h" -#include "ReadableStreamDefaultControllerBuiltins.h" #include "WebCoreJSClientData.h" #include <JavaScriptCore/FunctionPrototype.h> #include <JavaScriptCore/JSCInlines.h> diff --git a/src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.cpp b/src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.cpp index 876001aa2..55b89ad46 100644 --- a/src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.cpp +++ b/src/bun.js/bindings/webcore/JSReadableStreamDefaultReader.cpp @@ -30,7 +30,6 @@ #include "JSDOMGlobalObjectInlines.h" #include "JSDOMOperation.h" #include "JSDOMWrapperCache.h" -#include "ReadableStreamDefaultReaderBuiltins.h" #include "WebCoreJSClientData.h" #include <JavaScriptCore/FunctionPrototype.h> #include <JavaScriptCore/JSCInlines.h> diff --git a/src/bun.js/bindings/webcore/JSTransformStream.cpp b/src/bun.js/bindings/webcore/JSTransformStream.cpp index f6cdfc6f9..029886bba 100644 --- a/src/bun.js/bindings/webcore/JSTransformStream.cpp +++ b/src/bun.js/bindings/webcore/JSTransformStream.cpp @@ -29,7 +29,6 @@ #include "JSDOMExceptionHandling.h" #include "JSDOMGlobalObjectInlines.h" #include "JSDOMWrapperCache.h" -#include "TransformStreamBuiltins.h" #include "WebCoreJSClientData.h" #include <JavaScriptCore/FunctionPrototype.h> #include <JavaScriptCore/JSCInlines.h> diff --git a/src/bun.js/bindings/webcore/JSTransformStreamDefaultController.cpp b/src/bun.js/bindings/webcore/JSTransformStreamDefaultController.cpp index c7733b624..c4367f635 100644 --- a/src/bun.js/bindings/webcore/JSTransformStreamDefaultController.cpp +++ b/src/bun.js/bindings/webcore/JSTransformStreamDefaultController.cpp @@ -30,7 +30,6 @@ #include "JSDOMGlobalObjectInlines.h" #include "JSDOMOperation.h" #include "JSDOMWrapperCache.h" -#include "TransformStreamDefaultControllerBuiltins.h" #include "WebCoreJSClientData.h" #include <JavaScriptCore/FunctionPrototype.h> #include <JavaScriptCore/JSCInlines.h> diff --git a/src/bun.js/bindings/webcore/JSWritableStreamDefaultController.cpp b/src/bun.js/bindings/webcore/JSWritableStreamDefaultController.cpp index 295aa596c..a1463908a 100644 --- a/src/bun.js/bindings/webcore/JSWritableStreamDefaultController.cpp +++ b/src/bun.js/bindings/webcore/JSWritableStreamDefaultController.cpp @@ -30,7 +30,6 @@ #include "JSDOMOperation.h" #include "JSDOMWrapperCache.h" #include "WebCoreJSClientData.h" -#include "WritableStreamDefaultControllerBuiltins.h" #include <JavaScriptCore/FunctionPrototype.h> #include <JavaScriptCore/JSCInlines.h> #include <JavaScriptCore/JSDestructibleObjectHeapCellType.h> diff --git a/src/bun.js/bindings/webcore/JSWritableStreamDefaultWriter.cpp b/src/bun.js/bindings/webcore/JSWritableStreamDefaultWriter.cpp index 005d30d53..fd72ddfb4 100644 --- a/src/bun.js/bindings/webcore/JSWritableStreamDefaultWriter.cpp +++ b/src/bun.js/bindings/webcore/JSWritableStreamDefaultWriter.cpp @@ -31,7 +31,6 @@ #include "JSDOMOperation.h" #include "JSDOMWrapperCache.h" #include "WebCoreJSClientData.h" -#include "WritableStreamDefaultWriterBuiltins.h" #include <JavaScriptCore/FunctionPrototype.h> #include <JavaScriptCore/JSCInlines.h> #include <JavaScriptCore/JSDestructibleObjectHeapCellType.h> diff --git a/src/bun.js/builtins/BunBuiltinNames.h b/src/bun.js/builtins/BunBuiltinNames.h index ebc2c2c05..735141faa 100644 --- a/src/bun.js/builtins/BunBuiltinNames.h +++ b/src/bun.js/builtins/BunBuiltinNames.h @@ -1,25 +1,16 @@ -// clang-format off - #pragma once -#include "root.h" - - #include "JavaScriptCore/BuiltinUtils.h" - +#include "root.h" namespace WebCore { using namespace JSC; - #if !defined(BUN_ADDITIONAL_PRIVATE_IDENTIFIERS) #define BUN_ADDITIONAL_PRIVATE_IDENTIFIERS(macro) #endif - - - #define BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \ macro(AbortSignal) \ macro(Buffer) \ @@ -265,7 +256,6 @@ public: #undef EXPORT_NAME } - BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) private: @@ -273,7 +263,4 @@ private: BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(DECLARE_BUILTIN_NAMES) }; - - } // namespace WebCore - diff --git a/src/bun.js/builtins/README.md b/src/bun.js/builtins/README.md index c9288f47d..67b8882ee 100644 --- a/src/bun.js/builtins/README.md +++ b/src/bun.js/builtins/README.md @@ -1,22 +1,20 @@ # JavaScript Builtins -TLDR: +**TLDR** — When files in this directory change, run: ```bash # Delete the built files -make clean-bindings generate-bindings && \ - # Compile all the C++ files which live in ../bindings - make bindings -j10 && \ - # Re-link the binary without compiling zig (so it's faster) - make bun-link-lld-debug +$ make regenerate-bindings +# Re-link the binary without compiling zig (so it's faster) +$ make bun-link-lld-debug ``` -JavaScript files in [./js](./js) use JavaScriptCore's builtins syntax +TypeScript files in [./ts](./ts) are bundled into C++ Headers that can access JavaScriptCore intrinsics. These files use special globals that are prefixed with `$`. ```js -@getter -function foo() { - return @getByIdDirectPrivate(this, "superSecret"); +$getter +export function foo() { + return $getByIdDirectPrivate(this, "superSecret"); } ``` @@ -26,16 +24,30 @@ V8 has a [similar feature](https://v8.dev/blog/embedded-builtins) (they use `%` They usually are accompanied by a C++ file. -The `js` directory is necessary for the bindings generator to work. +We use a custom code generator located in `./codegen` which contains a regex-based parser that separates each function into it's own bundling context, so syntax like top level variables / functions will not work. + +You can also use `process.platform` and `process.arch` in these files. The values are inlined and DCE'd. + +## Generating builtins To regenerate the builtins, run this from Bun's project root (where the `Makefile` is) ```bash -make builtins +$ make builtins ``` You'll want to also rebuild all the C++ bindings or you will get strange crashes on start ```bash -make clean-bindings +$ make clean-bindings +``` + +The `make regenerate-bindings` command will clean and rebuild the bindings. + +Also, you can run the code generator manually. + +```bash +$ bun ./codegen/index.ts +# pass --minify to minify (make passes this by default) +# pass --keep-tmp to keep the temporary ./tmp folder, which contains processed pre-bundled .ts files ``` diff --git a/src/bun.js/builtins/WebCoreJSBuiltinInternals.cpp b/src/bun.js/builtins/WebCoreJSBuiltinInternals.cpp deleted file mode 100644 index 6d7b0cb04..000000000 --- a/src/bun.js/builtins/WebCoreJSBuiltinInternals.cpp +++ /dev/null @@ -1,115 +0,0 @@ -// clang-format off -namespace Zig { class GlobalObject; } -#include "root.h" - -/* - * 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) 2023 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 "WebCoreJSBuiltinInternals.h" - -#include "JSDOMGlobalObject.h" -#include "WebCoreJSClientData.h" -#include <JavaScriptCore/JSObjectInlines.h> - -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); -} - -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); -} - -template void JSBuiltinInternalFunctions::visit(AbstractSlotVisitor&); -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, std::size(staticGlobals)); - UNUSED_PARAM(clientData); -} - -} // namespace WebCore diff --git a/src/bun.js/builtins/WebCoreJSBuiltins.cpp b/src/bun.js/builtins/WebCoreJSBuiltins.cpp index 492a7b8d1..898765f86 100644 --- a/src/bun.js/builtins/WebCoreJSBuiltins.cpp +++ b/src/bun.js/builtins/WebCoreJSBuiltins.cpp @@ -1,58 +1,2977 @@ -/* - * 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) 2023 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 "BundlerPluginBuiltins.cpp" -#include "ByteLengthQueuingStrategyBuiltins.cpp" -#include "ConsoleObjectBuiltins.cpp" -#include "CountQueuingStrategyBuiltins.cpp" -#include "ImportMetaObjectBuiltins.cpp" -#include "JSBufferConstructorBuiltins.cpp" -#include "JSBufferPrototypeBuiltins.cpp" -#include "ProcessObjectInternalsBuiltins.cpp" -#include "ReadableByteStreamControllerBuiltins.cpp" -#include "ReadableByteStreamInternalsBuiltins.cpp" -#include "ReadableStreamBYOBReaderBuiltins.cpp" -#include "ReadableStreamBYOBRequestBuiltins.cpp" -#include "ReadableStreamBuiltins.cpp" -#include "ReadableStreamDefaultControllerBuiltins.cpp" -#include "ReadableStreamDefaultReaderBuiltins.cpp" -#include "ReadableStreamInternalsBuiltins.cpp" -#include "StreamInternalsBuiltins.cpp" -#include "TransformStreamBuiltins.cpp" -#include "TransformStreamDefaultControllerBuiltins.cpp" -#include "TransformStreamInternalsBuiltins.cpp" -#include "WritableStreamDefaultControllerBuiltins.cpp" -#include "WritableStreamDefaultWriterBuiltins.cpp" -#include "WritableStreamInternalsBuiltins.cpp" +// Generated by `bun src/bun.js/builtins/codegen/index.js` +// Do not edit by hand. +namespace Zig { class GlobalObject; } +#include "root.h" +#include "config.h" +#include "JSDOMGlobalObject.h" +#include "WebCoreJSClientData.h" +#include <JavaScriptCore/JSObjectInlines.h> + +namespace WebCore { + +/* BundlerPlugin.ts */ +// runSetupFunction +const JSC::ConstructAbility s_bundlerPluginRunSetupFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_bundlerPluginRunSetupFunctionCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_bundlerPluginRunSetupFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_bundlerPluginRunSetupFunctionCodeLength = 2165; +static const JSC::Intrinsic s_bundlerPluginRunSetupFunctionCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_bundlerPluginRunSetupFunctionCode = "(function (_,h){\"use strict\";var w=new Map,I=new Map;function M(C,D,E){if(!C||!@isObject(C))@throwTypeError('Expected an object with \"filter\" RegExp');if(!D||!@isCallable(D))@throwTypeError(\"callback must be a function\");var{filter:F,namespace:G=\"file\"}=C;if(!F)@throwTypeError('Expected an object with \"filter\" RegExp');if(!@isRegExpObject(F))@throwTypeError(\"filter must be a RegExp\");if(G&&typeof G!==\"string\")@throwTypeError(\"namespace must be a string\");if((G\?.length\?\?0)===0)G=\"file\";if(!/^([/@a-zA-Z0-9_\\\\-]+)$/.test(G))@throwTypeError(\"namespace can only contain $a-zA-Z0-9_\\\\-\");var H=E.@get(G);if(!H)E.@set(G,[[F,D]]);else @arrayPush(H,[F,D])}function q(C,D){M(C,D,w)}function z(C,D){M(C,D,I)}const A=()=>{var C=!1,D=!1;for(var[E,F]of w.entries())for(var[G]of F)this.addFilter(G,E,1),C=!0;for(var[E,F]of I.entries())for(var[G]of F)this.addFilter(G,E,0),D=!0;if(D){var H=this.onResolve;if(!H)this.onResolve=I;else for(var[E,F]of I.entries()){var J=H.@get(E);if(!J)H.@set(E,F);else H.@set(E,J.concat(F))}}if(C){var K=this.onLoad;if(!K)this.onLoad=w;else for(var[E,F]of w.entries()){var J=K.@get(E);if(!J)K.@set(E,F);else K.@set(E,J.concat(F))}}return C||D};var B=_({config:h,onDispose:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onEnd:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),onLoad:q,onResolve:z,onStart:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),resolve:()=>@throwTypeError(`@{@2} is not implemented yet. See https://github.com/oven-sh/bun/issues/@1`),initialOptions:{...h,bundle:!0,entryPoints:h.entrypoints\?\?h.entryPoints\?\?[],minify:typeof h.minify===\"boolean\"\?h.minify:!1,minifyIdentifiers:h.minify===!0||h.minify\?.identifiers,minifyWhitespace:h.minify===!0||h.minify\?.whitespace,minifySyntax:h.minify===!0||h.minify\?.syntax,outbase:h.root,platform:h.target===\"bun\"\?\"node\":h.target},esbuild:{}});if(B&&@isPromise(B))if(@getPromiseInternalField(B,@promiseFieldFlags)&@promiseStateFulfilled)B=@getPromiseInternalField(B,@promiseFieldReactionsOrResult);else return B.@then(A);return A()})\n"; + +// runOnResolvePlugins +const JSC::ConstructAbility s_bundlerPluginRunOnResolvePluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_bundlerPluginRunOnResolvePluginsCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_bundlerPluginRunOnResolvePluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_bundlerPluginRunOnResolvePluginsCodeLength = 1711; +static const JSC::Intrinsic s_bundlerPluginRunOnResolvePluginsCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_bundlerPluginRunOnResolvePluginsCode = "(function (_,E,W,g,j){\"use strict\";const q=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][j];var w=(async(y,z,A,B)=>{var{onResolve:C,onLoad:F}=this,G=C.@get(z);if(!G)return this.onResolveAsync(g,null,null,null),null;for(let[O,Q]of G)if(O.test(y)){var H=Q({path:y,importer:A,namespace:z,kind:B});while(H&&@isPromise(H)&&(@getPromiseInternalField(H,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)H=@getPromiseInternalField(H,@promiseFieldReactionsOrResult);if(H&&@isPromise(H))H=await H;if(!H||!@isObject(H))continue;var{path:J,namespace:K=z,external:M}=H;if(typeof J!==\"string\"||typeof K!==\"string\")@throwTypeError(\"onResolve plugins must return an object with a string 'path' and string 'loader' field\");if(!J)continue;if(!K)K=z;if(typeof M!==\"boolean\"&&!@isUndefinedOrNull(M))@throwTypeError('onResolve plugins \"external\" field must be boolean or unspecified');if(!M){if(K===\"file\"){if(darwin!==\"win32\"){if(J[0]!==\"/\"||J.includes(\"..\"))@throwTypeError('onResolve plugin \"path\" must be absolute when the namespace is \"file\"')}}if(K===\"dataurl\"){if(!J.startsWith(\"data:\"))@throwTypeError('onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"')}if(K&&K!==\"file\"&&(!F||!F.@has(K)))@throwTypeError(`Expected onLoad plugin for namespace ${K} to exist`)}return this.onResolveAsync(g,J,K,M),null}return this.onResolveAsync(g,null,null,null),null})(_,E,W,q);while(w&&@isPromise(w)&&(@getPromiseInternalField(w,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)w=@getPromiseInternalField(w,@promiseFieldReactionsOrResult);if(w&&@isPromise(w))w.then(()=>{},(y)=>{this.addError(g,y,0)})})\n"; + +// runOnLoadPlugins +const JSC::ConstructAbility s_bundlerPluginRunOnLoadPluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_bundlerPluginRunOnLoadPluginsCodeLength = 1325; +static const JSC::Intrinsic s_bundlerPluginRunOnLoadPluginsCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (_,b,g,j){\"use strict\";const q={jsx:0,js:1,ts:2,tsx:3,css:4,file:5,json:6,toml:7,wasm:8,napi:9,base64:10,dataurl:11,text:12},v=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][j];var w=(async(x,y,z,B)=>{var C=this.onLoad.@get(z);if(!C)return this.onLoadAsync(x,null,null),null;for(let[H,J]of C)if(H.test(y)){var E=J({path:y,namespace:z,loader:B});while(E&&@isPromise(E)&&(@getPromiseInternalField(E,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)E=@getPromiseInternalField(E,@promiseFieldReactionsOrResult);if(E&&@isPromise(E))E=await E;if(!E||!@isObject(E))continue;var{contents:F,loader:G=B}=E;if(typeof F!==\"string\"&&!@isTypedArrayView(F))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof G!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const K=q[G];if(K===@undefined)@throwTypeError(`Loader ${G} is not supported.`);return this.onLoadAsync(x,F,K),null}return this.onLoadAsync(x,null,null),null})(_,b,g,v);while(w&&@isPromise(w)&&(@getPromiseInternalField(w,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)w=@getPromiseInternalField(w,@promiseFieldReactionsOrResult);if(w&&@isPromise(w))w.then(()=>{},(x)=>{this.addError(_,x,1)})})\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().bundlerPluginBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().bundlerPluginBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ +} +WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) +#undef DEFINE_BUILTIN_GENERATOR + +/* ByteLengthQueuingStrategy.ts */ +// highWaterMark +const JSC::ConstructAbility s_byteLengthQueuingStrategyHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_byteLengthQueuingStrategyHighWaterMarkCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_byteLengthQueuingStrategyHighWaterMarkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_byteLengthQueuingStrategyHighWaterMarkCodeLength = 210; +static const JSC::Intrinsic s_byteLengthQueuingStrategyHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_byteLengthQueuingStrategyHighWaterMarkCode = "(function (){\"use strict\";const e=@getByIdDirectPrivate(this,\"highWaterMark\");if(e===@undefined)@throwTypeError(\"ByteLengthQueuingStrategy.highWaterMark getter called on incompatible |this| value.\");return e})\n"; + +// size +const JSC::ConstructAbility s_byteLengthQueuingStrategySizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_byteLengthQueuingStrategySizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_byteLengthQueuingStrategySizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_byteLengthQueuingStrategySizeCodeLength = 49; +static const JSC::Intrinsic s_byteLengthQueuingStrategySizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_byteLengthQueuingStrategySizeCode = "(function (e){\"use strict\";return e.byteLength})\n"; + +// initializeByteLengthQueuingStrategy +const JSC::ConstructAbility s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeLength = 121; +static const JSC::Intrinsic s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCode = "(function (d){\"use strict\";@putByIdDirectPrivate(this,\"highWaterMark\",@extractHighWaterMarkFromQueuingStrategyInit(d))})\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 + +/* WritableStreamInternals.ts */ +// isWritableStream +const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsIsWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsIsWritableStreamCodeLength = 94; +static const JSC::Intrinsic s_writableStreamInternalsIsWritableStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsIsWritableStreamCode = "(function (b){\"use strict\";return @isObject(b)&&!!@getByIdDirectPrivate(b,\"underlyingSink\")})\n"; + +// isWritableStreamDefaultWriter +const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamDefaultWriterCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamDefaultWriterCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsIsWritableStreamDefaultWriterCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsIsWritableStreamDefaultWriterCodeLength = 93; +static const JSC::Intrinsic s_writableStreamInternalsIsWritableStreamDefaultWriterCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsIsWritableStreamDefaultWriterCode = "(function (s){\"use strict\";return @isObject(s)&&!!@getByIdDirectPrivate(s,\"closedPromise\")})\n"; + +// acquireWritableStreamDefaultWriter +const JSC::ConstructAbility s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeLength = 72; +static const JSC::Intrinsic s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsAcquireWritableStreamDefaultWriterCode = "(function (d){\"use strict\";return new @WritableStreamDefaultWriter(d)})\n"; + +// createWritableStream +const JSC::ConstructAbility s_writableStreamInternalsCreateWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsCreateWritableStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsCreateWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsCreateWritableStreamCodeLength = 278; +static const JSC::Intrinsic s_writableStreamInternalsCreateWritableStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (_,d,p,u,I,f){\"use strict\";@assert(typeof I===\"number\"&&!@isNaN(I)&&I>=0);const j={};@initializeWritableStreamSlots(j,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(j,q,_,d,p,u,I,f),@createWritableStreamFromInternal(j)})\n"; + +// createInternalWritableStreamFromUnderlyingSink +const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength = 956; +static const JSC::Intrinsic s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (_,f){\"use strict\";const p={};if(_===@undefined)_={};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"WritableStream constructor takes an object as first argument\");if(\"type\"in _)@throwRangeError(\"Invalid type is specified\");const v=@extractSizeAlgorithm(f),U=@extractHighWaterMark(f,1),b={};if(\"start\"in _){if(b[\"start\"]=_[\"start\"],typeof b[\"start\"]!==\"function\")@throwTypeError(\"underlyingSink.start should be a function\")}if(\"write\"in _){if(b[\"write\"]=_[\"write\"],typeof b[\"write\"]!==\"function\")@throwTypeError(\"underlyingSink.write should be a function\")}if(\"close\"in _){if(b[\"close\"]=_[\"close\"],typeof b[\"close\"]!==\"function\")@throwTypeError(\"underlyingSink.close should be a function\")}if(\"abort\"in _){if(b[\"abort\"]=_[\"abort\"],typeof b[\"abort\"]!==\"function\")@throwTypeError(\"underlyingSink.abort should be a function\")}return @initializeWritableStreamSlots(p,_),@setUpWritableStreamDefaultControllerFromUnderlyingSink(p,_,b,U,v),p})\n"; + +// initializeWritableStreamSlots +const JSC::ConstructAbility s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsInitializeWritableStreamSlotsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsInitializeWritableStreamSlotsCodeLength = 588; +static const JSC::Intrinsic s_writableStreamInternalsInitializeWritableStreamSlotsCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsInitializeWritableStreamSlotsCode = "(function (_,c){\"use strict\";@putByIdDirectPrivate(_,\"state\",\"writable\"),@putByIdDirectPrivate(_,\"storedError\",@undefined),@putByIdDirectPrivate(_,\"writer\",@undefined),@putByIdDirectPrivate(_,\"controller\",@undefined),@putByIdDirectPrivate(_,\"inFlightWriteRequest\",@undefined),@putByIdDirectPrivate(_,\"closeRequest\",@undefined),@putByIdDirectPrivate(_,\"inFlightCloseRequest\",@undefined),@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined),@putByIdDirectPrivate(_,\"writeRequests\",@createFIFO()),@putByIdDirectPrivate(_,\"backpressure\",!1),@putByIdDirectPrivate(_,\"underlyingSink\",c)})\n"; + +// writableStreamCloseForBindings +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseForBindingsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseForBindingsCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseForBindingsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamCloseForBindingsCodeLength = 370; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamCloseForBindingsCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamCloseForBindingsCode = "(function (_){\"use strict\";if(@isWritableStreamLocked(_))return @Promise.@reject(@makeTypeError(\"WritableStream.close method can only be used on non locked WritableStream\"));if(@writableStreamCloseQueuedOrInFlight(_))return @Promise.@reject(@makeTypeError(\"WritableStream.close method can only be used on a being close WritableStream\"));return @writableStreamClose(_)})\n"; + +// writableStreamAbortForBindings +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAbortForBindingsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAbortForBindingsCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAbortForBindingsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamAbortForBindingsCodeLength = 211; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAbortForBindingsCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamAbortForBindingsCode = "(function (i,b){\"use strict\";if(@isWritableStreamLocked(i))return @Promise.@reject(@makeTypeError(\"WritableStream.abort method can only be used on non locked WritableStream\"));return @writableStreamAbort(i,b)})\n"; + +// isWritableStreamLocked +const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamLockedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamLockedCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsIsWritableStreamLockedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsIsWritableStreamLockedCodeLength = 83; +static const JSC::Intrinsic s_writableStreamInternalsIsWritableStreamLockedCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsIsWritableStreamLockedCode = "(function (d){\"use strict\";return @getByIdDirectPrivate(d,\"writer\")!==@undefined})\n"; + +// setUpWritableStreamDefaultWriter +const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeLength = 887; +static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultWriterCode = "(function (_,n){\"use strict\";if(@isWritableStreamLocked(n))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(_,\"stream\",n),@putByIdDirectPrivate(n,\"writer\",_);const u=@newPromiseCapability(@Promise),B=@newPromiseCapability(@Promise);@putByIdDirectPrivate(_,\"readyPromise\",u),@putByIdDirectPrivate(_,\"closedPromise\",B);const f=@getByIdDirectPrivate(n,\"state\");if(f===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(n)||!@getByIdDirectPrivate(n,\"backpressure\"))u.@resolve.@call()}else if(f===\"erroring\")u.@reject.@call(@undefined,@getByIdDirectPrivate(n,\"storedError\")),@markPromiseAsHandled(u.@promise);else if(f===\"closed\")u.@resolve.@call(),B.@resolve.@call();else{@assert(f===\"errored\");const g=@getByIdDirectPrivate(n,\"storedError\");u.@reject.@call(@undefined,g),@markPromiseAsHandled(u.@promise),B.@reject.@call(@undefined,g),@markPromiseAsHandled(B.@promise)}})\n"; + +// writableStreamAbort +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAbortCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAbortCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAbortCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamAbortCodeLength = 501; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAbortCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamAbortCode = "(function (_,c){\"use strict\";const f=@getByIdDirectPrivate(_,\"state\");if(f===\"closed\"||f===\"errored\")return @Promise.@resolve();const h=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(h!==@undefined)return h.promise.@promise;@assert(f===\"writable\"||f===\"erroring\");let j=!1;if(f===\"erroring\")j=!0,c=@undefined;const k=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(_,\"pendingAbortRequest\",{promise:k,reason:c,wasAlreadyErroring:j}),!j)@writableStreamStartErroring(_,c);return k.@promise})\n"; + +// writableStreamClose +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamCloseCodeLength = 642; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamCloseCode = "(function (n){\"use strict\";const _=@getByIdDirectPrivate(n,\"state\");if(_===\"closed\"||_===\"errored\")return @Promise.@reject(@makeTypeError(\"Cannot close a writable stream that is closed or errored\"));@assert(_===\"writable\"||_===\"erroring\"),@assert(!@writableStreamCloseQueuedOrInFlight(n));const d=@newPromiseCapability(@Promise);@putByIdDirectPrivate(n,\"closeRequest\",d);const u=@getByIdDirectPrivate(n,\"writer\");if(u!==@undefined&&@getByIdDirectPrivate(n,\"backpressure\")&&_===\"writable\")@getByIdDirectPrivate(u,\"readyPromise\").@resolve.@call();return @writableStreamDefaultControllerClose(@getByIdDirectPrivate(n,\"controller\")),d.@promise})\n"; + +// writableStreamAddWriteRequest +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAddWriteRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAddWriteRequestCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAddWriteRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamAddWriteRequestCodeLength = 227; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAddWriteRequestCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamAddWriteRequestCode = "(function (_){\"use strict\";@assert(@isWritableStreamLocked(_)),@assert(@getByIdDirectPrivate(_,\"state\")===\"writable\");const c=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"writeRequests\").push(c),c.@promise})\n"; + +// writableStreamCloseQueuedOrInFlight +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeLength = 151; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCode = "(function (_){\"use strict\";return @getByIdDirectPrivate(_,\"closeRequest\")!==@undefined||@getByIdDirectPrivate(_,\"inFlightCloseRequest\")!==@undefined})\n"; + +// writableStreamDealWithRejection +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDealWithRejectionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDealWithRejectionCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDealWithRejectionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDealWithRejectionCodeLength = 189; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDealWithRejectionCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode = "(function (n,c){\"use strict\";const d=@getByIdDirectPrivate(n,\"state\");if(d===\"writable\"){@writableStreamStartErroring(n,c);return}@assert(d===\"erroring\"),@writableStreamFinishErroring(n)})\n"; + +// writableStreamFinishErroring +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishErroringCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishErroringCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishErroringCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamFinishErroringCodeLength = 1058; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishErroringCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamFinishErroringCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"erroring\"),@assert(!@writableStreamHasOperationMarkedInFlight(i)),@putByIdDirectPrivate(i,\"state\",\"errored\");const c=@getByIdDirectPrivate(i,\"controller\");@getByIdDirectPrivate(c,\"errorSteps\").@call();const p=@getByIdDirectPrivate(i,\"storedError\"),_=@getByIdDirectPrivate(i,\"writeRequests\");for(var d=_.shift();d;d=_.shift())d.@reject.@call(@undefined,p);@putByIdDirectPrivate(i,\"writeRequests\",@createFIFO());const f=@getByIdDirectPrivate(i,\"pendingAbortRequest\");if(f===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}if(@putByIdDirectPrivate(i,\"pendingAbortRequest\",@undefined),f.wasAlreadyErroring){f.promise.@reject.@call(@undefined,p),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}@getByIdDirectPrivate(c,\"abortSteps\").@call(@undefined,f.reason).@then(()=>{f.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)},(j)=>{f.promise.@reject.@call(@undefined,j),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)})})\n"; + +// writableStreamFinishInFlightClose +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength = 751; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (i){\"use strict\";@getByIdDirectPrivate(i,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(i,\"inFlightCloseRequest\",@undefined);const _=@getByIdDirectPrivate(i,\"state\");if(@assert(_===\"writable\"||_===\"erroring\"),_===\"erroring\"){@putByIdDirectPrivate(i,\"storedError\",@undefined);const d=@getByIdDirectPrivate(i,\"pendingAbortRequest\");if(d!==@undefined)d.promise.@resolve.@call(),@putByIdDirectPrivate(i,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(i,\"state\",\"closed\");const c=@getByIdDirectPrivate(i,\"writer\");if(c!==@undefined)@getByIdDirectPrivate(c,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(i,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(i,\"storedError\")===@undefined)})\n"; + +// writableStreamFinishInFlightCloseWithError +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeLength = 488; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode = "(function (_,c){\"use strict\";const d=@getByIdDirectPrivate(_,\"inFlightCloseRequest\");@assert(d!==@undefined),d.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"inFlightCloseRequest\",@undefined);const f=@getByIdDirectPrivate(_,\"state\");@assert(f===\"writable\"||f===\"erroring\");const j=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(j!==@undefined)j.promise.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(_,c)})\n"; + +// writableStreamFinishInFlightWrite +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeLength = 187; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteCode = "(function (d){\"use strict\";const P=@getByIdDirectPrivate(d,\"inFlightWriteRequest\");@assert(P!==@undefined),P.@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightWriteRequest\",@undefined)})\n"; + +// writableStreamFinishInFlightWriteWithError +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeLength = 319; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCode = "(function (c,d){\"use strict\";const f=@getByIdDirectPrivate(c,\"inFlightWriteRequest\");@assert(f!==@undefined),f.@reject.@call(@undefined,d),@putByIdDirectPrivate(c,\"inFlightWriteRequest\",@undefined);const _=@getByIdDirectPrivate(c,\"state\");@assert(_===\"writable\"||_===\"erroring\"),@writableStreamDealWithRejection(c,d)})\n"; + +// writableStreamHasOperationMarkedInFlight +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeLength = 159; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCode = "(function (n){\"use strict\";return @getByIdDirectPrivate(n,\"inFlightWriteRequest\")!==@undefined||@getByIdDirectPrivate(n,\"inFlightCloseRequest\")!==@undefined})\n"; + +// writableStreamMarkCloseRequestInFlight +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeLength = 272; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCode = "(function (d){\"use strict\";const i=@getByIdDirectPrivate(d,\"closeRequest\");@assert(@getByIdDirectPrivate(d,\"inFlightCloseRequest\")===@undefined),@assert(i!==@undefined),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",i),@putByIdDirectPrivate(d,\"closeRequest\",@undefined)})\n"; + +// writableStreamMarkFirstWriteRequestInFlight +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeLength = 240; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode = "(function (n){\"use strict\";const d=@getByIdDirectPrivate(n,\"writeRequests\");@assert(@getByIdDirectPrivate(n,\"inFlightWriteRequest\")===@undefined),@assert(d.isNotEmpty());const h=d.shift();@putByIdDirectPrivate(n,\"inFlightWriteRequest\",h)})\n"; + +// writableStreamRejectCloseAndClosedPromiseIfNeeded +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength = 516; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = "(function (_){\"use strict\";@assert(@getByIdDirectPrivate(_,\"state\")===\"errored\");const n=@getByIdDirectPrivate(_,\"storedError\"),p=@getByIdDirectPrivate(_,\"closeRequest\");if(p!==@undefined)@assert(@getByIdDirectPrivate(_,\"inFlightCloseRequest\")===@undefined),p.@reject.@call(@undefined,n),@putByIdDirectPrivate(_,\"closeRequest\",@undefined);const b=@getByIdDirectPrivate(_,\"writer\");if(b!==@undefined){const f=@getByIdDirectPrivate(b,\"closedPromise\");f.@reject.@call(@undefined,n),@markPromiseAsHandled(f.@promise)}})\n"; + +// writableStreamStartErroring +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamStartErroringCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamStartErroringCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamStartErroringCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamStartErroringCodeLength = 544; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamStartErroringCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamStartErroringCode = "(function (d,c){\"use strict\";@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined),@assert(@getByIdDirectPrivate(d,\"state\")===\"writable\");const p=@getByIdDirectPrivate(d,\"controller\");@assert(p!==@undefined),@putByIdDirectPrivate(d,\"state\",\"erroring\"),@putByIdDirectPrivate(d,\"storedError\",c);const u=@getByIdDirectPrivate(d,\"writer\");if(u!==@undefined)@writableStreamDefaultWriterEnsureReadyPromiseRejected(u,c);if(!@writableStreamHasOperationMarkedInFlight(d)&&@getByIdDirectPrivate(p,\"started\")===1)@writableStreamFinishErroring(d)})\n"; + +// writableStreamUpdateBackpressure +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamUpdateBackpressureCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamUpdateBackpressureCodeLength = 422; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamUpdateBackpressureCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamUpdateBackpressureCode = "(function (_,d){\"use strict\";@assert(@getByIdDirectPrivate(_,\"state\")===\"writable\"),@assert(!@writableStreamCloseQueuedOrInFlight(_));const n=@getByIdDirectPrivate(_,\"writer\");if(n!==@undefined&&d!==@getByIdDirectPrivate(_,\"backpressure\"))if(d)@putByIdDirectPrivate(n,\"readyPromise\",@newPromiseCapability(@Promise));else @getByIdDirectPrivate(n,\"readyPromise\").@resolve.@call();@putByIdDirectPrivate(_,\"backpressure\",d)})\n"; + +// writableStreamDefaultWriterAbort +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeLength = 130; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode = "(function (_,d){\"use strict\";const p=@getByIdDirectPrivate(_,\"stream\");return @assert(p!==@undefined),@writableStreamAbort(p,d)})\n"; + +// writableStreamDefaultWriterClose +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeLength = 126; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode = "(function (c){\"use strict\";const d=@getByIdDirectPrivate(c,\"stream\");return @assert(d!==@undefined),@writableStreamClose(d)})\n"; + +// writableStreamDefaultWriterCloseWithErrorPropagation +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeLength = 385; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode = "(function (c){\"use strict\";const u=@getByIdDirectPrivate(c,\"stream\");@assert(u!==@undefined);const d=@getByIdDirectPrivate(u,\"state\");if(@writableStreamCloseQueuedOrInFlight(u)||d===\"closed\")return @Promise.@resolve();if(d===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(u,\"storedError\"));return @assert(d===\"writable\"||d===\"erroring\"),@writableStreamDefaultWriterClose(c)})\n"; + +// writableStreamDefaultWriterEnsureClosedPromiseRejected +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeLength = 329; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode = "(function (_,n){\"use strict\";let g=@getByIdDirectPrivate(_,\"closedPromise\"),u=g.@promise;if((@getPromiseInternalField(u,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)g=@newPromiseCapability(@Promise),u=g.@promise,@putByIdDirectPrivate(_,\"closedPromise\",g);g.@reject.@call(@undefined,n),@markPromiseAsHandled(u)})\n"; + +// writableStreamDefaultWriterEnsureReadyPromiseRejected +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength = 327; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (n,k){\"use strict\";let _=@getByIdDirectPrivate(n,\"readyPromise\"),c=_.@promise;if((@getPromiseInternalField(c,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)_=@newPromiseCapability(@Promise),c=_.@promise,@putByIdDirectPrivate(n,\"readyPromise\",_);_.@reject.@call(@undefined,k),@markPromiseAsHandled(c)})\n"; + +// writableStreamDefaultWriterGetDesiredSize +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeLength = 299; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = "(function (c){\"use strict\";const d=@getByIdDirectPrivate(c,\"stream\");@assert(d!==@undefined);const l=@getByIdDirectPrivate(d,\"state\");if(l===\"errored\"||l===\"erroring\")return null;if(l===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(d,\"controller\"))})\n"; + +// writableStreamDefaultWriterRelease +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeLength = 414; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterReleaseCode = "(function (n){\"use strict\";const c=@getByIdDirectPrivate(n,\"stream\");@assert(c!==@undefined),@assert(@getByIdDirectPrivate(c,\"writer\")===n);const d=@makeTypeError(\"writableStreamDefaultWriterRelease\");@writableStreamDefaultWriterEnsureReadyPromiseRejected(n,d),@writableStreamDefaultWriterEnsureClosedPromiseRejected(n,d),@putByIdDirectPrivate(c,\"writer\",@undefined),@putByIdDirectPrivate(n,\"stream\",@undefined)})\n"; + +// writableStreamDefaultWriterWrite +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeLength = 919; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = "(function (d,I){\"use strict\";const _=@getByIdDirectPrivate(d,\"stream\");@assert(_!==@undefined);const b=@getByIdDirectPrivate(_,\"controller\");@assert(b!==@undefined);const f=@writableStreamDefaultControllerGetChunkSize(b,I);if(_!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const g=@getByIdDirectPrivate(_,\"state\");if(g===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(_,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(_)||g===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(_)||g===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(g===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(_,\"storedError\"));@assert(g===\"writable\");const j=@writableStreamAddWriteRequest(_);return @writableStreamDefaultControllerWrite(b,I,f),j})\n"; + +// setUpWritableStreamDefaultController +const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeLength = 700; +static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode = "(function (_,d,p,B,f,j,q,u){\"use strict\";@assert(@isWritableStream(_)),@assert(@getByIdDirectPrivate(_,\"controller\")===@undefined),@putByIdDirectPrivate(d,\"stream\",_),@putByIdDirectPrivate(_,\"controller\",d),@resetQueue(@getByIdDirectPrivate(d,\"queue\")),@putByIdDirectPrivate(d,\"started\",-1),@putByIdDirectPrivate(d,\"startAlgorithm\",p),@putByIdDirectPrivate(d,\"strategySizeAlgorithm\",u),@putByIdDirectPrivate(d,\"strategyHWM\",q),@putByIdDirectPrivate(d,\"writeAlgorithm\",B),@putByIdDirectPrivate(d,\"closeAlgorithm\",f),@putByIdDirectPrivate(d,\"abortAlgorithm\",j);const v=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(_,v),@writableStreamDefaultControllerStart(d)})\n"; + +// writableStreamDefaultControllerStart +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength = 647; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerStartCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (_){\"use strict\";if(@getByIdDirectPrivate(_,\"started\")!==-1)return;@putByIdDirectPrivate(_,\"started\",0);const d=@getByIdDirectPrivate(_,\"startAlgorithm\");@putByIdDirectPrivate(_,\"startAlgorithm\",@undefined);const b=@getByIdDirectPrivate(_,\"stream\");return @Promise.@resolve(d.@call()).@then(()=>{const y=@getByIdDirectPrivate(b,\"state\");@assert(y===\"writable\"||y===\"erroring\"),@putByIdDirectPrivate(_,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(_)},(y)=>{const P=@getByIdDirectPrivate(b,\"state\");@assert(P===\"writable\"||P===\"erroring\"),@putByIdDirectPrivate(_,\"started\",1),@writableStreamDealWithRejection(b,y)})})\n"; + +// setUpWritableStreamDefaultControllerFromUnderlyingSink +const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 573; +static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (_,p,f,I,j){\"use strict\";const q=new @WritableStreamDefaultController;let v=()=>{},x=()=>{return @Promise.@resolve()},B=()=>{return @Promise.@resolve()},C=()=>{return @Promise.@resolve()};if(\"start\"in f){const E=f[\"start\"];v=()=>@promiseInvokeOrNoopMethodNoCatch(p,E,[q])}if(\"write\"in f){const E=f[\"write\"];x=(F)=>@promiseInvokeOrNoopMethod(p,E,[F,q])}if(\"close\"in f){const E=f[\"close\"];B=()=>@promiseInvokeOrNoopMethod(p,E,[])}if(\"abort\"in f){const E=f[\"abort\"];C=(F)=>@promiseInvokeOrNoopMethod(p,E,[F])}@setUpWritableStreamDefaultController(_,q,v,x,B,C,I,j)})\n"; + +// writableStreamDefaultControllerAdvanceQueueIfNeeded +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeLength = 582; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode = "(function (i){\"use strict\";const d=@getByIdDirectPrivate(i,\"stream\");if(@getByIdDirectPrivate(i,\"started\")!==1)return;if(@assert(d!==@undefined),@getByIdDirectPrivate(d,\"inFlightWriteRequest\")!==@undefined)return;const f=@getByIdDirectPrivate(d,\"state\");if(@assert(f!==\"closed\"||f!==\"errored\"),f===\"erroring\"){@writableStreamFinishErroring(d);return}const g=@getByIdDirectPrivate(i,\"queue\");if(g.content\?.isEmpty()\?\?!1)return;const y=@peekQueueValue(g);if(y===@isCloseSentinel)@writableStreamDefaultControllerProcessClose(i);else @writableStreamDefaultControllerProcessWrite(i,y)})\n"; + +// isCloseSentinel +const JSC::ConstructAbility s_writableStreamInternalsIsCloseSentinelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsIsCloseSentinelCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsIsCloseSentinelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsIsCloseSentinelCodeLength = 29; +static const JSC::Intrinsic s_writableStreamInternalsIsCloseSentinelCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsIsCloseSentinelCode = "(function (){\"use strict\";})\n"; + +// writableStreamDefaultControllerClearAlgorithms +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeLength = 248; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCode = "(function (i){\"use strict\";@putByIdDirectPrivate(i,\"writeAlgorithm\",@undefined),@putByIdDirectPrivate(i,\"closeAlgorithm\",@undefined),@putByIdDirectPrivate(i,\"abortAlgorithm\",@undefined),@putByIdDirectPrivate(i,\"strategySizeAlgorithm\",@undefined)})\n"; + +// writableStreamDefaultControllerClose +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeLength = 160; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerCloseCode = "(function (d){\"use strict\";@enqueueValueWithSize(@getByIdDirectPrivate(d,\"queue\"),@isCloseSentinel,0),@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)})\n"; + +// writableStreamDefaultControllerError +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeLength = 237; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = "(function (_,b){\"use strict\";const d=@getByIdDirectPrivate(_,\"stream\");@assert(d!==@undefined),@assert(@getByIdDirectPrivate(d,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(_),@writableStreamStartErroring(d,b)})\n"; + +// writableStreamDefaultControllerErrorIfNeeded +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeLength = 165; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCode = "(function (_,a){\"use strict\";const d=@getByIdDirectPrivate(_,\"stream\");if(@getByIdDirectPrivate(d,\"state\")===\"writable\")@writableStreamDefaultControllerError(_,a)})\n"; + +// writableStreamDefaultControllerGetBackpressure +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeLength = 89; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCode = "(function (_){\"use strict\";return @writableStreamDefaultControllerGetDesiredSize(_)<=0})\n"; + +// writableStreamDefaultControllerGetChunkSize +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeLength = 181; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCode = "(function (a,d){\"use strict\";try{return @getByIdDirectPrivate(a,\"strategySizeAlgorithm\").@call(@undefined,d)}catch(i){return @writableStreamDefaultControllerErrorIfNeeded(a,i),1}})\n"; + +// writableStreamDefaultControllerGetDesiredSize +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeLength = 113; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCode = "(function (q){\"use strict\";return @getByIdDirectPrivate(q,\"strategyHWM\")-@getByIdDirectPrivate(q,\"queue\").size})\n"; + +// writableStreamDefaultControllerProcessClose +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeLength = 441; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"stream\");@writableStreamMarkCloseRequestInFlight(d),@dequeueValue(@getByIdDirectPrivate(_,\"queue\")),@assert(@getByIdDirectPrivate(_,\"queue\").content\?.isEmpty());const h=@getByIdDirectPrivate(_,\"closeAlgorithm\").@call();@writableStreamDefaultControllerClearAlgorithms(_),h.@then(()=>{@writableStreamFinishInFlightClose(d)},(i)=>{@writableStreamFinishInFlightCloseWithError(d,i)})})\n"; + +// writableStreamDefaultControllerProcessWrite +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeLength = 734; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode = "(function (i,_){\"use strict\";const W=@getByIdDirectPrivate(i,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(W),@getByIdDirectPrivate(i,\"writeAlgorithm\").@call(@undefined,_).@then(()=>{@writableStreamFinishInFlightWrite(W);const f=@getByIdDirectPrivate(W,\"state\");if(@assert(f===\"writable\"||f===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(i,\"queue\")),!@writableStreamCloseQueuedOrInFlight(W)&&f===\"writable\"){const g=@writableStreamDefaultControllerGetBackpressure(i);@writableStreamUpdateBackpressure(W,g)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(f)=>{if(@getByIdDirectPrivate(W,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(i);@writableStreamFinishInFlightWriteWithError(W,f)})})\n"; + +// writableStreamDefaultControllerWrite +const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeLength = 450; +static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode = "(function (C,P,d){\"use strict\";try{@enqueueValueWithSize(@getByIdDirectPrivate(C,\"queue\"),P,d);const f=@getByIdDirectPrivate(C,\"stream\"),g=@getByIdDirectPrivate(f,\"state\");if(!@writableStreamCloseQueuedOrInFlight(f)&&g===\"writable\"){const i=@writableStreamDefaultControllerGetBackpressure(C);@writableStreamUpdateBackpressure(f,i)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(C)}catch(f){@writableStreamDefaultControllerErrorIfNeeded(C,f)}})\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 + +/* TransformStreamInternals.ts */ +// isTransformStream +const JSC::ConstructAbility s_transformStreamInternalsIsTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsIsTransformStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsIsTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsIsTransformStreamCodeLength = 88; +static const JSC::Intrinsic s_transformStreamInternalsIsTransformStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsIsTransformStreamCode = "(function (d){\"use strict\";return @isObject(d)&&!!@getByIdDirectPrivate(d,\"readable\")})\n"; + +// isTransformStreamDefaultController +const JSC::ConstructAbility s_transformStreamInternalsIsTransformStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsIsTransformStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsIsTransformStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsIsTransformStreamDefaultControllerCodeLength = 98; +static const JSC::Intrinsic s_transformStreamInternalsIsTransformStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsIsTransformStreamDefaultControllerCode = "(function (i){\"use strict\";return @isObject(i)&&!!@getByIdDirectPrivate(i,\"transformAlgorithm\")})\n"; + +// createTransformStream +const JSC::ConstructAbility s_transformStreamInternalsCreateTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsCreateTransformStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsCreateTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsCreateTransformStreamCodeLength = 513; +static const JSC::Intrinsic s_transformStreamInternalsCreateTransformStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (c,I,_,j,q,u,v){\"use strict\";if(j===@undefined)j=1;if(q===@undefined)q=()=>1;if(u===@undefined)u=0;if(v===@undefined)v=()=>1;@assert(j>=0),@assert(u>=0);const x={};@putByIdDirectPrivate(x,\"TransformStream\",!0);const B=new @TransformStream(x),D=@newPromiseCapability(@Promise);@initializeTransformStream(B,D.@promise,j,q,u,v);const E=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(B,E,I,_),c().@then(()=>{D.@resolve.@call()},(F)=>{D.@reject.@call(@undefined,F)}),B})\n"; + +// initializeTransformStream +const JSC::ConstructAbility s_transformStreamInternalsInitializeTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsInitializeTransformStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsInitializeTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsInitializeTransformStreamCodeLength = 1015; +static const JSC::Intrinsic s_transformStreamInternalsInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (_,B,I,f,j,q){\"use strict\";const v=()=>{return B},x=(N)=>{return @transformStreamDefaultSinkWriteAlgorithm(_,N)},C=(N)=>{return @transformStreamDefaultSinkAbortAlgorithm(_,N)},D=()=>{return @transformStreamDefaultSinkCloseAlgorithm(_)},E=@createWritableStream(v,x,D,C,I,f),F=()=>{return @transformStreamDefaultSourcePullAlgorithm(_)},G=(N)=>{return @transformStreamErrorWritableAndUnblockWrite(_,N),@Promise.@resolve()},J={};@putByIdDirectPrivate(J,\"start\",v),@putByIdDirectPrivate(J,\"pull\",F),@putByIdDirectPrivate(J,\"cancel\",G);const K={};@putByIdDirectPrivate(K,\"size\",q),@putByIdDirectPrivate(K,\"highWaterMark\",j);const L=new @ReadableStream(J,K);@putByIdDirectPrivate(_,\"writable\",E),@putByIdDirectPrivate(_,\"internalWritable\",@getInternalWritableStream(E)),@putByIdDirectPrivate(_,\"readable\",L),@putByIdDirectPrivate(_,\"backpressure\",@undefined),@putByIdDirectPrivate(_,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(_,!0),@putByIdDirectPrivate(_,\"controller\",@undefined)})\n"; + +// transformStreamError +const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsTransformStreamErrorCodeLength = 222; +static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsTransformStreamErrorCode = "(function (i,y){\"use strict\";const c=@getByIdDirectPrivate(i,\"readable\"),f=@getByIdDirectPrivate(c,\"readableStreamController\");@readableStreamDefaultControllerError(f,y),@transformStreamErrorWritableAndUnblockWrite(i,y)})\n"; + +// transformStreamErrorWritableAndUnblockWrite +const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeLength = 339; +static const JSC::Intrinsic s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCode = "(function (c,B){\"use strict\";@transformStreamDefaultControllerClearAlgorithms(@getByIdDirectPrivate(c,\"controller\"));const S=@getByIdDirectPrivate(c,\"internalWritable\");if(@writableStreamDefaultControllerErrorIfNeeded(@getByIdDirectPrivate(S,\"controller\"),B),@getByIdDirectPrivate(c,\"backpressure\"))@transformStreamSetBackpressure(c,!1)})\n"; + +// transformStreamSetBackpressure +const JSC::ConstructAbility s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsTransformStreamSetBackpressureCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamSetBackpressureCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsTransformStreamSetBackpressureCodeLength = 309; +static const JSC::Intrinsic s_transformStreamInternalsTransformStreamSetBackpressureCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsTransformStreamSetBackpressureCode = "(function (_,y){\"use strict\";@assert(@getByIdDirectPrivate(_,\"backpressure\")!==y);const d=@getByIdDirectPrivate(_,\"backpressureChangePromise\");if(d!==@undefined)d.@resolve.@call();@putByIdDirectPrivate(_,\"backpressureChangePromise\",@newPromiseCapability(@Promise)),@putByIdDirectPrivate(_,\"backpressure\",y)})\n"; + +// setUpTransformStreamDefaultController +const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeLength = 294; +static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerCode = "(function (_,p,d,b){\"use strict\";@assert(@isTransformStream(_)),@assert(@getByIdDirectPrivate(_,\"controller\")===@undefined),@putByIdDirectPrivate(p,\"stream\",_),@putByIdDirectPrivate(_,\"controller\",p),@putByIdDirectPrivate(p,\"transformAlgorithm\",d),@putByIdDirectPrivate(p,\"flushAlgorithm\",b)})\n"; + +// setUpTransformStreamDefaultControllerFromTransformer +const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 449; +static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,b,d){\"use strict\";const j=new @TransformStreamDefaultController;let p=(v)=>{try{@transformStreamDefaultControllerEnqueue(j,v)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},q=()=>{return @Promise.@resolve()};if(\"transform\"in d)p=(v)=>{return @promiseInvokeOrNoopMethod(b,d[\"transform\"],[v,j])};if(\"flush\"in d)q=()=>{return @promiseInvokeOrNoopMethod(b,d[\"flush\"],[j])};@setUpTransformStreamDefaultController(_,j,p,q)})\n"; + +// transformStreamDefaultControllerClearAlgorithms +const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeLength = 131; +static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCode = "(function (v){\"use strict\";@putByIdDirectPrivate(v,\"transformAlgorithm\",!0),@putByIdDirectPrivate(v,\"flushAlgorithm\",@undefined)})\n"; + +// transformStreamDefaultControllerEnqueue +const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeLength = 622; +static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode = "(function (_,g){\"use strict\";const E=@getByIdDirectPrivate(_,\"stream\"),S=@getByIdDirectPrivate(E,\"readable\"),f=@getByIdDirectPrivate(S,\"readableStreamController\");if(@assert(f!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(f))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(f,g)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(E,j),@getByIdDirectPrivate(S,\"storedError\")}const i=!@readableStreamDefaultControllerShouldCallPull(f);if(i!==@getByIdDirectPrivate(E,\"backpressure\"))@assert(i),@transformStreamSetBackpressure(E,!0)})\n"; + +// transformStreamDefaultControllerError +const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeLength = 90; +static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerErrorCode = "(function (f,B){\"use strict\";@transformStreamError(@getByIdDirectPrivate(f,\"stream\"),B)})\n"; + +// transformStreamDefaultControllerPerformTransform +const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeLength = 277; +static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (_,d){\"use strict\";const f=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,d).@then(()=>{f.@resolve()},(j)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),j),f.@reject.@call(@undefined,j)}),f.@promise})\n"; + +// transformStreamDefaultControllerTerminate +const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeLength = 367; +static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (i){\"use strict\";const S=@getByIdDirectPrivate(i,\"stream\"),f=@getByIdDirectPrivate(S,\"readable\"),g=@getByIdDirectPrivate(f,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(g))@readableStreamDefaultControllerClose(g);const h=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(S,h)})\n"; + +// transformStreamDefaultSinkWriteAlgorithm +const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeLength = 764; +static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode = "(function (_,d){\"use strict\";const f=@getByIdDirectPrivate(_,\"internalWritable\");@assert(@getByIdDirectPrivate(f,\"state\")===\"writable\");const j=@getByIdDirectPrivate(_,\"controller\");if(@getByIdDirectPrivate(_,\"backpressure\")){const q=@newPromiseCapability(@Promise),v=@getByIdDirectPrivate(_,\"backpressureChangePromise\");return @assert(v!==@undefined),v.@promise.@then(()=>{const x=@getByIdDirectPrivate(f,\"state\");if(x===\"erroring\"){q.@reject.@call(@undefined,@getByIdDirectPrivate(f,\"storedError\"));return}@assert(x===\"writable\"),@transformStreamDefaultControllerPerformTransform(j,d).@then(()=>{q.@resolve()},(z)=>{q.@reject.@call(@undefined,z)})},(x)=>{q.@reject.@call(@undefined,x)}),q.@promise}return @transformStreamDefaultControllerPerformTransform(j,d)})\n"; + +// transformStreamDefaultSinkAbortAlgorithm +const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeLength = 85; +static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCode = "(function (l,c){\"use strict\";return @transformStreamError(l,c),@Promise.@resolve()})\n"; + +// transformStreamDefaultSinkCloseAlgorithm +const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeLength = 789; +static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode = "(function (_){\"use strict\";const j=@getByIdDirectPrivate(_,\"readable\"),k=@getByIdDirectPrivate(_,\"controller\"),q=@getByIdDirectPrivate(j,\"readableStreamController\"),v=@getByIdDirectPrivate(k,\"flushAlgorithm\");@assert(v!==@undefined);const w=@getByIdDirectPrivate(k,\"flushAlgorithm\").@call();@transformStreamDefaultControllerClearAlgorithms(k);const x=@newPromiseCapability(@Promise);return w.@then(()=>{if(@getByIdDirectPrivate(j,\"state\")===@streamErrored){x.@reject.@call(@undefined,@getByIdDirectPrivate(j,\"storedError\"));return}if(@readableStreamDefaultControllerCanCloseOrEnqueue(q))@readableStreamDefaultControllerClose(q);x.@resolve()},(z)=>{@transformStreamError(@getByIdDirectPrivate(k,\"stream\"),z),x.@reject.@call(@undefined,@getByIdDirectPrivate(j,\"storedError\"))}),x.@promise})\n"; + +// transformStreamDefaultSourcePullAlgorithm +const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeLength = 260; +static const JSC::Intrinsic s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCode = "(function (_){\"use strict\";return @assert(@getByIdDirectPrivate(_,\"backpressure\")),@assert(@getByIdDirectPrivate(_,\"backpressureChangePromise\")!==@undefined),@transformStreamSetBackpressure(_,!1),@getByIdDirectPrivate(_,\"backpressureChangePromise\").@promise})\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 + +/* ProcessObjectInternals.ts */ +// binding +const JSC::ConstructAbility s_processObjectInternalsBindingCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_processObjectInternalsBindingCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_processObjectInternalsBindingCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_processObjectInternalsBindingCodeLength = 473; +static const JSC::Intrinsic s_processObjectInternalsBindingCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_processObjectInternalsBindingCode = "(function (f){\"use strict\";if(f!==\"constants\")@throwTypeError(\"process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.\");var r=globalThis.Symbol.for(\"process.bindings.constants\"),p=globalThis[r];if(!p){const{constants:u}=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\"createImportMeta\",\"node:process\").require(\"node:fs\");p={fs:u,zlib:{},crypto:{},os:@Bun._Os().constants},globalThis[r]=p}return p})\n"; + +// getStdioWriteStream +const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 4250; +static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_processObjectInternalsGetStdioWriteStreamCode = "(function (j,z){\"use strict\";var B={path:\"node:process\",require:z},G=(N)=>B.require(N);function H(N){var{Duplex:O,eos:Q,destroy:U}=G(\"node:stream\"),V=class X extends O{#$;#j;#z=!0;#B=!0;#G;#H;#J;#K;#L;#M;get isTTY(){return this.#M\?\?=G(\"node:tty\").isatty(N)}get fd(){return N}constructor(Z){super({readable:!0,writable:!0});this.#G=`/dev/fd/${Z}`}#N(Z){const Y=this.#H;if(this.#H=null,Y)Y(Z);else if(Z)this.destroy(Z);else if(!this.#z&&!this.#B)this.destroy()}_destroy(Z,Y){if(!Z&&this.#H!==null){var P=class A extends Error{code;name;constructor(T=\"The operation was aborted\",x=void 0){if(x!==void 0&&typeof x!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(x,null,2)}`);super(T,x);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};Z=new P}if(this.#J=null,this.#K=null,this.#H===null)Y(Z);else{if(this.#H=Y,this.#$)U(this.#$,Z);if(this.#j)U(this.#j,Z)}}_write(Z,Y,P){if(!this.#$){var{createWriteStream:A}=G(\"node:fs\"),T=this.#$=A(this.#G);T.on(\"finish\",()=>{if(this.#K){const x=this.#K;this.#K=null,x()}}),T.on(\"drain\",()=>{if(this.#J){const x=this.#J;this.#J=null,x()}}),Q(T,(x)=>{if(this.#B=!1,x)U(T,x);this.#N(x)})}if(T.write(Z,Y))P();else this.#J=P}_final(Z){this.#$&&this.#$.end(),this.#K=Z}#O(){var{createReadStream:Z}=G(\"node:fs\"),Y=this.#j=Z(this.#G);return Y.on(\"readable\",()=>{if(this.#L){const P=this.#L;this.#L=null,P()}else this.read()}),Y.on(\"end\",()=>{this.push(null)}),Q(Y,(P)=>{if(this.#z=!1,P)U(Y,P);this.#N(P)}),Y}_read(){var Z=this.#j;if(!Z)Z=this.#O();while(!0){const Y=Z.read();if(Y===null||!this.push(Y))return}}};return new V(N)}var{EventEmitter:J}=G(\"node:events\");function K(N){if(!N)return!0;var O=N.toLowerCase();return O===\"utf8\"||O===\"utf-8\"||O===\"buffer\"||O===\"binary\"}var L,M=class N extends J{#$;#j;#z;#B;bytesWritten=0;setDefaultEncoding(O){if(this.#j||!K(O))return this.#J(),this.#j.setDefaultEncoding(O)}#G(){switch(this.#$){case 1:{var O=@Bun.stdout.writer({highWaterMark:0});return O.unref(),O}case 2:{var O=@Bun.stderr.writer({highWaterMark:0});return O.unref(),O}default:throw new Error(\"Unsupported writer\")}}#H(){return this.#z\?\?=this.#G()}constructor(O){super();this.#$=O}get fd(){return this.#$}get isTTY(){return this.#B\?\?=G(\"node:tty\").isatty(this.#$)}cursorTo(O,Q,U){return(L\?\?=G(\"readline\")).cursorTo(this,O,Q,U)}moveCursor(O,Q,U){return(L\?\?=G(\"readline\")).moveCursor(this,O,Q,U)}clearLine(O,Q){return(L\?\?=G(\"readline\")).clearLine(this,O,Q)}clearScreenDown(O){return(L\?\?=G(\"readline\")).clearScreenDown(this,O)}ref(){this.#H().ref()}unref(){this.#H().unref()}on(O,Q){if(O===\"close\"||O===\"finish\")return this.#J(),this.#j.on(O,Q);if(O===\"drain\")return super.on(\"drain\",Q);if(O===\"error\")return super.on(\"error\",Q);return super.on(O,Q)}get _writableState(){return this.#J(),this.#j._writableState}get _readableState(){return this.#J(),this.#j._readableState}pipe(O){return this.#J(),this.#j.pipe(O)}unpipe(O){return this.#J(),this.#j.unpipe(O)}#J(){if(this.#j)return;this.#j=H(this.#$);const O=this.eventNames();for(let Q of O)this.#j.on(Q,(...U)=>{this.emit(Q,...U)})}#K(O){var Q=this.#H();const U=Q.write(O);this.bytesWritten+=U;const V=Q.flush(!1);return!!(U||V)}#L(O,Q){if(!K(Q))return this.#J(),this.#j.write(O,Q);return this.#K(O)}#M(O,Q){if(Q)this.emit(\"error\",Q);try{O(Q\?Q:null)}catch(U){this.emit(\"error\",U)}}#N(O,Q,U){if(!K(Q))return this.#J(),this.#j.write(O,Q,U);var V=this.#H();const X=V.write(O),Z=V.flush(!0);if(Z\?.then)return Z.then(()=>{this.#M(U),this.emit(\"drain\")},(Y)=>this.#M(U,Y)),!1;return queueMicrotask(()=>{this.#M(U)}),!!(X||Z)}write(O,Q,U){const V=this._write(O,Q,U);if(V)this.emit(\"drain\");return V}get hasColors(){return @Bun.tty[this.#$].hasColors}_write(O,Q,U){var V=this.#j;if(V)return V.write(O,Q,U);switch(arguments.length){case 0:{var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}case 1:return this.#K(O);case 2:if(typeof Q===\"function\")return this.#N(O,\"\",Q);else if(typeof Q===\"string\")return this.#L(O,Q);default:{if(typeof Q!==\"undefined\"&&typeof Q!==\"string\"||typeof U!==\"undefined\"&&typeof U!==\"function\"){var X=new Error(\"Invalid arguments\");throw X.code=\"ERR_INVALID_ARG_TYPE\",X}if(typeof U===\"undefined\")return this.#L(O,Q);return this.#N(O,Q,U)}}}destroy(){return this}end(){return this}};return new M(j)})\n"; + +// getStdinStream +const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_processObjectInternalsGetStdinStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_processObjectInternalsGetStdinStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_processObjectInternalsGetStdinStreamCodeLength = 1799; +static const JSC::Intrinsic s_processObjectInternalsGetStdinStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_processObjectInternalsGetStdinStreamCode = "(function (j,T,Y){\"use strict\";var z={path:\"node:process\",require:T},G=(M)=>z.require(M),{Duplex:H,eos:J,destroy:K}=G(\"node:stream\"),L=class M extends H{#$;#j;#T;#Y=!0;#z=!1;#G=!0;#H;#J;#K;get isTTY(){return G(\"tty\").isatty(j)}get fd(){return j}constructor(){super({readable:!0,writable:!0})}#L(N){const P=this.#J;if(this.#J=null,P)P(N);else if(N)this.destroy(N);else if(!this.#Y&&!this.#G)this.destroy()}_destroy(N,P){if(!N&&this.#J!==null){var Q=class U extends Error{constructor(V=\"The operation was aborted\",X=void 0){if(X!==void 0&&typeof X!==\"object\")throw new Error(`Invalid AbortError options:\\n\\n${JSON.stringify(X,null,2)}`);super(V,X);this.code=\"ABORT_ERR\",this.name=\"AbortError\"}};N=new Q}if(this.#J===null)P(N);else if(this.#J=P,this.#T)K(this.#T,N)}setRawMode(N){}on(N,P){if(N===\"readable\")this.ref(),this.#z=!0;return super.on(N,P)}pause(){return this.unref(),super.pause()}resume(){return this.ref(),super.resume()}ref(){this.#$\?\?=Y.stdin.stream().getReader(),this.#j\?\?=setInterval(()=>{},1<<30)}unref(){if(this.#j)clearInterval(this.#j),this.#j=null}async#M(){try{var N,P;const Q=this.#$.readMany();if(!Q\?.then)({done:N,value:P}=Q);else({done:N,value:P}=await Q);if(!N){this.push(P[0]);const U=P.length;for(let V=1;V<U;V++)this.push(P[V])}else this.push(null),this.pause(),this.#Y=!1,this.#L()}catch(Q){this.#Y=!1,this.#L(Q)}}_read(N){if(this.#z)this.unref(),this.#z=!1;this.#M()}#N(){var{createWriteStream:N}=G(\"node:fs\"),P=this.#T=N(\"/dev/fd/0\");return P.on(\"finish\",()=>{if(this.#H){const Q=this.#H;this.#H=null,Q()}}),P.on(\"drain\",()=>{if(this.#K){const Q=this.#K;this.#K=null,Q()}}),J(P,(Q)=>{if(this.#G=!1,Q)K(P,Q);this.#L(Q)}),P}_write(N,P,Q){var U=this.#T;if(!U)U=this.#N();if(U.write(N,P))Q();else this.#K=Q}_final(N){this.#T.end(),this.#H=(...P)=>N(...P)}};return new L})\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().processObjectInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().processObjectInternalsBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ +} +WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) +#undef DEFINE_BUILTIN_GENERATOR + +/* TransformStream.ts */ +// initializeTransformStream +const JSC::ConstructAbility s_transformStreamInitializeTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamInitializeTransformStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamInitializeTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamInitializeTransformStreamCodeLength = 1334; +static const JSC::Intrinsic s_transformStreamInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let O=arguments[0];if(@isObject(O)&&@getByIdDirectPrivate(O,\"TransformStream\"))return this;let T=arguments[1],_=arguments[2];if(O===@undefined)O=null;if(_===@undefined)_={};if(T===@undefined)T={};let j={};if(O!==null){if(\"start\"in O){if(j[\"start\"]=O[\"start\"],typeof j[\"start\"]!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in O){if(j[\"transform\"]=O[\"transform\"],typeof j[\"transform\"]!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in O){if(j[\"flush\"]=O[\"flush\"],typeof j[\"flush\"]!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in O)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in O)@throwRangeError(\"TransformStream transformer has a writableType\")}const q=@extractHighWaterMark(_,0),u=@extractSizeAlgorithm(_),v=@extractHighWaterMark(T,1),x=@extractSizeAlgorithm(T),B=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,B.@promise,v,x,q,u),@setUpTransformStreamDefaultControllerFromTransformer(this,O,j),(\"start\"in j)){const E=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(O,j[\"start\"],[E]))().@then(()=>{B.@resolve.@call()},(G)=>{B.@reject.@call(@undefined,G)})}else B.@resolve.@call();return this})\n"; + +// readable +const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamReadableCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamReadableCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamReadableCodeLength = 158; +static const JSC::Intrinsic s_transformStreamReadableCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamReadableCode = "(function (){\"use strict\";if(!@isTransformStream(this))throw @makeThisTypeError(\"TransformStream\",\"readable\");return @getByIdDirectPrivate(this,\"readable\")})\n"; + +// writable +const JSC::ConstructAbility s_transformStreamWritableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamWritableCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamWritableCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamWritableCodeLength = 158; +static const JSC::Intrinsic s_transformStreamWritableCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamWritableCode = "(function (){\"use strict\";if(!@isTransformStream(this))throw @makeThisTypeError(\"TransformStream\",\"writable\");return @getByIdDirectPrivate(this,\"writable\")})\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 + +/* JSBufferPrototype.ts */ +// setBigUint64 +const JSC::ConstructAbility s_jsBufferPrototypeSetBigUint64CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeSetBigUint64CodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeSetBigUint64CodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeSetBigUint64CodeLength = 136; +static const JSC::Intrinsic s_jsBufferPrototypeSetBigUint64CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeSetBigUint64Code = "(function (i,r,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(i,r,c)})\n"; + +// readInt8 +const JSC::ConstructAbility s_jsBufferPrototypeReadInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt8CodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadInt8CodeLength = 123; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt8CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt8Code = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getInt8(r)})\n"; + +// readUInt8 +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt8CodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadUInt8CodeLength = 124; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt8CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt8Code = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getUint8(r)})\n"; + +// readInt16LE +const JSC::ConstructAbility s_jsBufferPrototypeReadInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt16LECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadInt16LECodeLength = 127; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt16LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt16LECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getInt16(r,!0)})\n"; + +// readInt16BE +const JSC::ConstructAbility s_jsBufferPrototypeReadInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt16BECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadInt16BECodeLength = 127; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt16BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt16BECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getInt16(r,!1)})\n"; + +// readUInt16LE +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16LECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadUInt16LECodeLength = 128; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt16LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt16LECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getUint16(r,!0)})\n"; + +// readUInt16BE +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16BECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadUInt16BECodeLength = 128; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt16BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt16BECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getUint16(r,!1)})\n"; + +// readInt32LE +const JSC::ConstructAbility s_jsBufferPrototypeReadInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt32LECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadInt32LECodeLength = 127; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt32LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt32LECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getInt32(r,!0)})\n"; + +// readInt32BE +const JSC::ConstructAbility s_jsBufferPrototypeReadInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadInt32BECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadInt32BECodeLength = 127; +static const JSC::Intrinsic s_jsBufferPrototypeReadInt32BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadInt32BECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getInt32(r,!1)})\n"; + +// readUInt32LE +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32LECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadUInt32LECodeLength = 128; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt32LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt32LECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getUint32(r,!0)})\n"; + +// readUInt32BE +const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32BECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadUInt32BECodeLength = 128; +static const JSC::Intrinsic s_jsBufferPrototypeReadUInt32BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUInt32BECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getUint32(r,!1)})\n"; + +// readIntLE +const JSC::ConstructAbility s_jsBufferPrototypeReadIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadIntLECodeLength = 528; +static const JSC::Intrinsic s_jsBufferPrototypeReadIntLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadIntLECode = "(function (c,r){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return u.getInt8(c);case 2:return u.getInt16(c,!0);case 3:{const _=u.getUint16(c,!0)+u.getUint8(c+2)*65536;return _|(_&8388608)*510}case 4:return u.getInt32(c,!0);case 5:{const _=u.getUint8(c+4);return(_|(_&128)*33554430)*4294967296+u.getUint32(c,!0)}case 6:{const _=u.getUint16(c+4,!0);return(_|(_&32768)*131070)*4294967296+u.getUint32(c,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; + +// readIntBE +const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadIntBECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadIntBECodeLength = 528; +static const JSC::Intrinsic s_jsBufferPrototypeReadIntBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadIntBECode = "(function (u,_){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:return d.getInt8(u);case 2:return d.getInt16(u,!1);case 3:{const r=d.getUint16(u+1,!1)+d.getUint8(u)*65536;return r|(r&8388608)*510}case 4:return d.getInt32(u,!1);case 5:{const r=d.getUint8(u);return(r|(r&128)*33554430)*4294967296+d.getUint32(u+1,!1)}case 6:{const r=d.getUint16(u,!1);return(r|(r&32768)*131070)*4294967296+d.getUint32(u+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; + +// readUIntLE +const JSC::ConstructAbility s_jsBufferPrototypeReadUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUIntLECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadUIntLECodeLength = 445; +static const JSC::Intrinsic s_jsBufferPrototypeReadUIntLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUIntLECode = "(function (a,r){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return u.getUint8(a);case 2:return u.getUint16(a,!0);case 3:return u.getUint16(a,!0)+u.getUint8(a+2)*65536;case 4:return u.getUint32(a,!0);case 5:return u.getUint8(a+4)*4294967296+u.getUint32(a,!0);case 6:return u.getUint16(a+4,!0)*4294967296+u.getUint32(a,!0)}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; + +// readUIntBE +const JSC::ConstructAbility s_jsBufferPrototypeReadUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadUIntBECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadUIntBECodeLength = 504; +static const JSC::Intrinsic s_jsBufferPrototypeReadUIntBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadUIntBECode = "(function (_,r){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return u.getUint8(_);case 2:return u.getUint16(_,!1);case 3:return u.getUint16(_+1,!1)+u.getUint8(_)*65536;case 4:return u.getUint32(_,!1);case 5:{const c=u.getUint8(_);return(c|(c&128)*33554430)*4294967296+u.getUint32(_+1,!1)}case 6:{const c=u.getUint16(_,!1);return(c|(c&32768)*131070)*4294967296+u.getUint32(_+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; + +// readFloatLE +const JSC::ConstructAbility s_jsBufferPrototypeReadFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadFloatLECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadFloatLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadFloatLECodeLength = 129; +static const JSC::Intrinsic s_jsBufferPrototypeReadFloatLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadFloatLECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getFloat32(r,!0)})\n"; + +// readFloatBE +const JSC::ConstructAbility s_jsBufferPrototypeReadFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadFloatBECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadFloatBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadFloatBECodeLength = 129; +static const JSC::Intrinsic s_jsBufferPrototypeReadFloatBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadFloatBECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getFloat32(r,!1)})\n"; + +// readDoubleLE +const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleLECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadDoubleLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadDoubleLECodeLength = 129; +static const JSC::Intrinsic s_jsBufferPrototypeReadDoubleLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadDoubleLECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getFloat64(r,!0)})\n"; + +// readDoubleBE +const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleBECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadDoubleBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadDoubleBECodeLength = 129; +static const JSC::Intrinsic s_jsBufferPrototypeReadDoubleBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadDoubleBECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getFloat64(r,!1)})\n"; + +// readBigInt64LE +const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64LECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadBigInt64LECodeLength = 130; +static const JSC::Intrinsic s_jsBufferPrototypeReadBigInt64LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadBigInt64LECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getBigInt64(r,!0)})\n"; + +// readBigInt64BE +const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64BECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadBigInt64BECodeLength = 130; +static const JSC::Intrinsic s_jsBufferPrototypeReadBigInt64BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadBigInt64BECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getBigInt64(r,!1)})\n"; + +// readBigUInt64LE +const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64LECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigUInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadBigUInt64LECodeLength = 131; +static const JSC::Intrinsic s_jsBufferPrototypeReadBigUInt64LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadBigUInt64LECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getBigUint64(r,!0)})\n"; + +// readBigUInt64BE +const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64BECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigUInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeReadBigUInt64BECodeLength = 131; +static const JSC::Intrinsic s_jsBufferPrototypeReadBigUInt64BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeReadBigUInt64BECode = "(function (r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).getBigUint64(r,!1)})\n"; + +// writeInt8 +const JSC::ConstructAbility s_jsBufferPrototypeWriteInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteInt8CodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteInt8CodeLength = 131; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt8CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt8Code = "(function (d,h){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt8(h,d),h+1})\n"; + +// writeUInt8 +const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt8CodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteUInt8CodeLength = 132; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt8CodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt8Code = "(function (d,h){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint8(h,d),h+1})\n"; + +// writeInt16LE +const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16LECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteInt16LECodeLength = 135; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt16LECode = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(d,r,!0),d+2})\n"; + +// writeInt16BE +const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16BECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteInt16BECodeLength = 135; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt16BECode = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(d,r,!1),d+2})\n"; + +// writeUInt16LE +const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16LECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteUInt16LECodeLength = 136; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt16LECode = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(d,r,!0),d+2})\n"; + +// writeUInt16BE +const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16BECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteUInt16BECodeLength = 136; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt16BECode = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(d,r,!1),d+2})\n"; + +// writeInt32LE +const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32LECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteInt32LECodeLength = 135; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt32LECode = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(d,r,!0),d+4})\n"; + +// writeInt32BE +const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32BECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteInt32BECodeLength = 135; +static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteInt32BECode = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(d,r,!1),d+4})\n"; + +// writeUInt32LE +const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32LECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteUInt32LECodeLength = 136; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt32LECode = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,r,!0),d+4})\n"; + +// writeUInt32BE +const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32BECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteUInt32BECodeLength = 136; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUInt32BECode = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,r,!1),d+4})\n"; + +// writeIntLE +const JSC::ConstructAbility s_jsBufferPrototypeWriteIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteIntLECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteIntLECodeLength = 573; +static const JSC::Intrinsic s_jsBufferPrototypeWriteIntLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteIntLECode = "(function (r,c,d){\"use strict\";const p=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(d){case 1:{p.setInt8(c,r);break}case 2:{p.setInt16(c,r,!0);break}case 3:{p.setUint16(c,r&65535,!0),p.setInt8(c+2,Math.floor(r*0.0000152587890625));break}case 4:{p.setInt32(c,r,!0);break}case 5:{p.setUint32(c,r|0,!0),p.setInt8(c+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{p.setUint32(c,r|0,!0),p.setInt16(c+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return c+d})\n"; + +// writeIntBE +const JSC::ConstructAbility s_jsBufferPrototypeWriteIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteIntBECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteIntBECodeLength = 573; +static const JSC::Intrinsic s_jsBufferPrototypeWriteIntBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteIntBECode = "(function (r,_,c){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{d.setInt8(_,r);break}case 2:{d.setInt16(_,r,!1);break}case 3:{d.setUint16(_+1,r&65535,!1),d.setInt8(_,Math.floor(r*0.0000152587890625));break}case 4:{d.setInt32(_,r,!1);break}case 5:{d.setUint32(_+1,r|0,!1),d.setInt8(_,Math.floor(r*0.00000000023283064365386964));break}case 6:{d.setUint32(_+2,r|0,!1),d.setInt16(_,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return _+c})\n"; + +// writeUIntLE +const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntLECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteUIntLECodeLength = 579; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUIntLECode = "(function (r,_,c){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{d.setUint8(_,r);break}case 2:{d.setUint16(_,r,!0);break}case 3:{d.setUint16(_,r&65535,!0),d.setUint8(_+2,Math.floor(r*0.0000152587890625));break}case 4:{d.setUint32(_,r,!0);break}case 5:{d.setUint32(_,r|0,!0),d.setUint8(_+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{d.setUint32(_,r|0,!0),d.setUint16(_+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return _+c})\n"; + +// writeUIntBE +const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntBECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteUIntBECodeLength = 579; +static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (c,k,r){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:{d.setUint8(k,c);break}case 2:{d.setUint16(k,c,!1);break}case 3:{d.setUint16(k+1,c&65535,!1),d.setUint8(k,Math.floor(c*0.0000152587890625));break}case 4:{d.setUint32(k,c,!1);break}case 5:{d.setUint32(k+1,c|0,!1),d.setUint8(k,Math.floor(c*0.00000000023283064365386964));break}case 6:{d.setUint32(k+2,c|0,!1),d.setUint16(k,Math.floor(c*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return k+r})\n"; + +// writeFloatLE +const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteFloatLECodeLength = 137; +static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,r,!0),d+4})\n"; + +// writeFloatBE +const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteFloatBECodeLength = 137; +static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (r,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,r,!1),c+4})\n"; + +// writeDoubleLE +const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleLECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteDoubleLECodeLength = 137; +static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleLECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteDoubleLECode = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(d,r,!0),d+8})\n"; + +// writeDoubleBE +const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleBECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteDoubleBECodeLength = 137; +static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleBECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteDoubleBECode = "(function (r,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(c,r,!1),c+8})\n"; + +// writeBigInt64LE +const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64LECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteBigInt64LECodeLength = 138; +static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteBigInt64LECode = "(function (r,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(c,r,!0),c+8})\n"; + +// writeBigInt64BE +const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64BECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteBigInt64BECodeLength = 138; +static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteBigInt64BECode = "(function (r,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(c,r,!1),c+8})\n"; + +// writeBigUInt64LE +const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64LECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteBigUInt64LECodeLength = 139; +static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64LECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteBigUInt64LECode = "(function (r,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(c,r,!0),c+8})\n"; + +// writeBigUInt64BE +const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64BECodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeWriteBigUInt64BECodeLength = 139; +static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64BECodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeWriteBigUInt64BECode = "(function (r,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(c,r,!1),c+8})\n"; + +// utf8Write +const JSC::ConstructAbility s_jsBufferPrototypeUtf8WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeUtf8WriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeUtf8WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeUtf8WriteCodeLength = 65; +static const JSC::Intrinsic s_jsBufferPrototypeUtf8WriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeUtf8WriteCode = "(function (r,u,a){\"use strict\";return this.write(r,u,a,\"utf8\")})\n"; + +// ucs2Write +const JSC::ConstructAbility s_jsBufferPrototypeUcs2WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeUcs2WriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeUcs2WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeUcs2WriteCodeLength = 65; +static const JSC::Intrinsic s_jsBufferPrototypeUcs2WriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeUcs2WriteCode = "(function (r,u,a){\"use strict\";return this.write(r,u,a,\"ucs2\")})\n"; + +// utf16leWrite +const JSC::ConstructAbility s_jsBufferPrototypeUtf16leWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeUtf16leWriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeUtf16leWriteCodeLength = 68; +static const JSC::Intrinsic s_jsBufferPrototypeUtf16leWriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeUtf16leWriteCode = "(function (r,u,a){\"use strict\";return this.write(r,u,a,\"utf16le\")})\n"; + +// latin1Write +const JSC::ConstructAbility s_jsBufferPrototypeLatin1WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeLatin1WriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeLatin1WriteCodeLength = 67; +static const JSC::Intrinsic s_jsBufferPrototypeLatin1WriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeLatin1WriteCode = "(function (r,u,a){\"use strict\";return this.write(r,u,a,\"latin1\")})\n"; + +// asciiWrite +const JSC::ConstructAbility s_jsBufferPrototypeAsciiWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeAsciiWriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeAsciiWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeAsciiWriteCodeLength = 66; +static const JSC::Intrinsic s_jsBufferPrototypeAsciiWriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeAsciiWriteCode = "(function (r,u,a){\"use strict\";return this.write(r,u,a,\"ascii\")})\n"; + +// base64Write +const JSC::ConstructAbility s_jsBufferPrototypeBase64WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeBase64WriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeBase64WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeBase64WriteCodeLength = 67; +static const JSC::Intrinsic s_jsBufferPrototypeBase64WriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeBase64WriteCode = "(function (r,u,a){\"use strict\";return this.write(r,u,a,\"base64\")})\n"; + +// base64urlWrite +const JSC::ConstructAbility s_jsBufferPrototypeBase64urlWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeBase64urlWriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeBase64urlWriteCodeLength = 70; +static const JSC::Intrinsic s_jsBufferPrototypeBase64urlWriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeBase64urlWriteCode = "(function (r,u,a){\"use strict\";return this.write(r,u,a,\"base64url\")})\n"; + +// hexWrite +const JSC::ConstructAbility s_jsBufferPrototypeHexWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeHexWriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeHexWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeHexWriteCodeLength = 64; +static const JSC::Intrinsic s_jsBufferPrototypeHexWriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeHexWriteCode = "(function (r,u,a){\"use strict\";return this.write(r,u,a,\"hex\")})\n"; + +// utf8Slice +const JSC::ConstructAbility s_jsBufferPrototypeUtf8SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeUtf8SliceCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeUtf8SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeUtf8SliceCodeLength = 64; +static const JSC::Intrinsic s_jsBufferPrototypeUtf8SliceCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeUtf8SliceCode = "(function (r,d){\"use strict\";return this.toString(r,d,\"utf8\")})\n"; + +// ucs2Slice +const JSC::ConstructAbility s_jsBufferPrototypeUcs2SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeUcs2SliceCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeUcs2SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeUcs2SliceCodeLength = 64; +static const JSC::Intrinsic s_jsBufferPrototypeUcs2SliceCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeUcs2SliceCode = "(function (r,d){\"use strict\";return this.toString(r,d,\"ucs2\")})\n"; + +// utf16leSlice +const JSC::ConstructAbility s_jsBufferPrototypeUtf16leSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeUtf16leSliceCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeUtf16leSliceCodeLength = 67; +static const JSC::Intrinsic s_jsBufferPrototypeUtf16leSliceCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeUtf16leSliceCode = "(function (r,u){\"use strict\";return this.toString(r,u,\"utf16le\")})\n"; + +// latin1Slice +const JSC::ConstructAbility s_jsBufferPrototypeLatin1SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeLatin1SliceCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeLatin1SliceCodeLength = 66; +static const JSC::Intrinsic s_jsBufferPrototypeLatin1SliceCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeLatin1SliceCode = "(function (r,u){\"use strict\";return this.toString(r,u,\"latin1\")})\n"; + +// asciiSlice +const JSC::ConstructAbility s_jsBufferPrototypeAsciiSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeAsciiSliceCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeAsciiSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeAsciiSliceCodeLength = 65; +static const JSC::Intrinsic s_jsBufferPrototypeAsciiSliceCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeAsciiSliceCode = "(function (r,u){\"use strict\";return this.toString(r,u,\"ascii\")})\n"; + +// base64Slice +const JSC::ConstructAbility s_jsBufferPrototypeBase64SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeBase64SliceCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeBase64SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeBase64SliceCodeLength = 66; +static const JSC::Intrinsic s_jsBufferPrototypeBase64SliceCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeBase64SliceCode = "(function (r,u){\"use strict\";return this.toString(r,u,\"base64\")})\n"; + +// base64urlSlice +const JSC::ConstructAbility s_jsBufferPrototypeBase64urlSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeBase64urlSliceCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeBase64urlSliceCodeLength = 69; +static const JSC::Intrinsic s_jsBufferPrototypeBase64urlSliceCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeBase64urlSliceCode = "(function (r,u){\"use strict\";return this.toString(r,u,\"base64url\")})\n"; + +// hexSlice +const JSC::ConstructAbility s_jsBufferPrototypeHexSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeHexSliceCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeHexSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeHexSliceCodeLength = 63; +static const JSC::Intrinsic s_jsBufferPrototypeHexSliceCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeHexSliceCode = "(function (d,r){\"use strict\";return this.toString(d,r,\"hex\")})\n"; + +// toJSON +const JSC::ConstructAbility s_jsBufferPrototypeToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeToJSONCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeToJSONCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeToJSONCodeLength = 73; +static const JSC::Intrinsic s_jsBufferPrototypeToJSONCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeToJSONCode = "(function (){\"use strict\";return{type:\"Buffer\",data:@Array.from(this)}})\n"; + +// slice +const JSC::ConstructAbility s_jsBufferPrototypeSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeSliceCodeLength = 260; +static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeSliceCode = "(function (c,p){\"use strict\";var{buffer:i,byteOffset:k,byteLength:m}=this;function q(x,z){if(x=@trunc(x),x===0||@isNaN(x))return 0;else if(x<0)return x+=z,x>0\?x:0;else return x<z\?x:z}var v=q(c,m),w=p!==@undefined\?q(p,m):m;return new @Buffer(i,k+v,w>v\?w-v:0)})\n"; + +// parent +const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeParentCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeParentCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeParentCodeLength = 99; +static const JSC::Intrinsic s_jsBufferPrototypeParentCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeParentCode = "(function (){\"use strict\";return @isObject(this)&&this instanceof @Buffer\?this.buffer:@undefined})\n"; + +// offset +const JSC::ConstructAbility s_jsBufferPrototypeOffsetCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeOffsetCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeOffsetCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeOffsetCodeLength = 103; +static const JSC::Intrinsic s_jsBufferPrototypeOffsetCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeOffsetCode = "(function (){\"use strict\";return @isObject(this)&&this instanceof @Buffer\?this.byteOffset:@undefined})\n"; + +// inspect +const JSC::ConstructAbility s_jsBufferPrototypeInspectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferPrototypeInspectCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferPrototypeInspectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferPrototypeInspectCodeLength = 57; +static const JSC::Intrinsic s_jsBufferPrototypeInspectCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferPrototypeInspectCode = "(function (e,r){\"use strict\";return @Bun.inspect(this)})\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().jsBufferPrototypeBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().jsBufferPrototypeBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ +} +WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) +#undef DEFINE_BUILTIN_GENERATOR + +/* ReadableByteStreamController.ts */ +// initializeReadableByteStreamController +const JSC::ConstructAbility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeLength = 253; +static const JSC::Intrinsic s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamControllerInitializeReadableByteStreamControllerCode = "(function (b,f,j){\"use strict\";if(arguments.length!==4&&arguments[3]!==@isReadableStream)@throwTypeError(\"ReadableByteStreamController constructor should not be called directly\");return @privateInitializeReadableByteStreamController.@call(this,b,f,j)})\n"; + +// enqueue +const JSC::ConstructAbility s_readableByteStreamControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamControllerEnqueueCodeLength = 562; +static const JSC::Intrinsic s_readableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamControllerEnqueueCode = "(function (e){\"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(e)||!@ArrayBuffer.@isView(e))@throwTypeError(\"Provided chunk is not a TypedArray\");return @readableByteStreamControllerEnqueue(this,e)})\n"; + +// error +const JSC::ConstructAbility s_readableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamControllerErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamControllerErrorCodeLength = 336; +static const JSC::Intrinsic s_readableByteStreamControllerErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamControllerErrorCode = "(function (d){\"use strict\";if(!@isReadableByteStreamController(this))throw @makeThisTypeError(\"ReadableByteStreamController\",\"error\");if(@getByIdDirectPrivate(@getByIdDirectPrivate(this,\"controlledReadableStream\"),\"state\")!==@streamReadable)@throwTypeError(\"ReadableStream is not readable\");@readableByteStreamControllerError(this,d)})\n"; + +// close +const JSC::ConstructAbility s_readableByteStreamControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamControllerCloseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamControllerCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamControllerCloseCodeLength = 433; +static const JSC::Intrinsic s_readableByteStreamControllerCloseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamControllerCloseCode = "(function (){\"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)})\n"; + +// byobRequest +const JSC::ConstructAbility s_readableByteStreamControllerByobRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamControllerByobRequestCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamControllerByobRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamControllerByobRequestCodeLength = 523; +static const JSC::Intrinsic s_readableByteStreamControllerByobRequestCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamControllerByobRequestCode = "(function (){\"use strict\";if(!@isReadableByteStreamController(this))throw @makeGetterTypeError(\"ReadableByteStreamController\",\"byobRequest\");var u=@getByIdDirectPrivate(this,\"byobRequest\");if(u===@undefined){var _=@getByIdDirectPrivate(this,\"pendingPullIntos\");const l=_.peek();if(l){const y=new @Uint8Array(l.buffer,l.byteOffset+l.bytesFilled,l.byteLength-l.bytesFilled);@putByIdDirectPrivate(this,\"byobRequest\",new @ReadableStreamBYOBRequest(this,y,@isReadableStream))}}return @getByIdDirectPrivate(this,\"byobRequest\")})\n"; + +// desiredSize +const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamControllerDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamControllerDesiredSizeCodeLength = 200; +static const JSC::Intrinsic s_readableByteStreamControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isReadableByteStreamController(this))throw @makeGetterTypeError(\"ReadableByteStreamController\",\"desiredSize\");return @readableByteStreamControllerGetDesiredSize(this)})\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 + +/* ConsoleObject.ts */ +// asyncIterator +const JSC::ConstructAbility s_consoleObjectAsyncIteratorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_consoleObjectAsyncIteratorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_consoleObjectAsyncIteratorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_consoleObjectAsyncIteratorCodeLength = 577; +static const JSC::Intrinsic s_consoleObjectAsyncIteratorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const _=async function*j(){var q=@Bun.stdin.stream().getReader(),w=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),z,A=@Bun.indexOfLine;try{while(!0){var B,F,G;const L=q.readMany();if(@isPromise(L))({done:B,value:F}=await L);else({done:B,value:F}=L);if(B){if(G)yield w.decode(G);return}var H;for(let M of F){if(H=M,G)H=@Buffer.concat([G,M]),G=null;var J=0,K=A(H,J);while(K!==-1)yield w.decode(H.subarray(J,K)),J=K+1,K=A(H,J);G=H.subarray(J)}}}catch(L){z=L}finally{if(q.releaseLock(),z)throw z}},D=globalThis.Symbol.asyncIterator;return this[D]=_,_()})\n"; + +// write +const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_consoleObjectWriteCodeLength = 310; +static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_consoleObjectWriteCode = "(function (_){\"use strict\";var d=@getByIdDirectPrivate(this,\"writer\");if(!d){var s=@toLength(_\?.length\?\?0);d=@Bun.stdout.writer({highWaterMark:s>65536\?s:65536}),@putByIdDirectPrivate(this,\"writer\",d)}var a=d.write(_);const b=@argumentCount();for(var f=1;f<b;f++)a+=d.write(@argument(f));return d.flush(!0),a})\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().consoleObjectBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().consoleObjectBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ +} +WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) +#undef DEFINE_BUILTIN_GENERATOR + +/* ReadableStreamInternals.ts */ +// readableStreamReaderGenericInitialize +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeLength = 585; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamReaderGenericInitializeCode = "(function (_,c){\"use strict\";if(@putByIdDirectPrivate(_,\"ownerReadableStream\",c),@putByIdDirectPrivate(c,\"reader\",_),@getByIdDirectPrivate(c,\"state\")===@streamReadable)@putByIdDirectPrivate(_,\"closedPromiseCapability\",@newPromiseCapability(@Promise));else if(@getByIdDirectPrivate(c,\"state\")===@streamClosed)@putByIdDirectPrivate(_,\"closedPromiseCapability\",{@promise:@Promise.@resolve()});else @assert(@getByIdDirectPrivate(c,\"state\")===@streamErrored),@putByIdDirectPrivate(_,\"closedPromiseCapability\",{@promise:@newHandledRejectedPromise(@getByIdDirectPrivate(c,\"storedError\"))})})\n"; + +// privateInitializeReadableStreamDefaultController +const JSC::ConstructAbility s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeLength = 675; +static const JSC::Intrinsic s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCode = "(function (_,p,b,f){\"use strict\";if(!@isReadableStream(_))@throwTypeError(\"ReadableStreamDefaultController needs a ReadableStream\");if(@getByIdDirectPrivate(_,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");return @putByIdDirectPrivate(this,\"controlledReadableStream\",_),@putByIdDirectPrivate(this,\"underlyingSource\",p),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",-1),@putByIdDirectPrivate(this,\"closeRequested\",!1),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@putByIdDirectPrivate(this,\"strategy\",@validateAndNormalizeQueuingStrategy(b,f)),this})\n"; + +// readableStreamDefaultControllerError +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeLength = 223; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerErrorCode = "(function (_,b){\"use strict\";const d=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@getByIdDirectPrivate(d,\"state\")!==@streamReadable)return;@putByIdDirectPrivate(_,\"queue\",@newQueue()),@readableStreamError(d,b)})\n"; + +// readableStreamPipeTo +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamPipeToCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamPipeToCodeLength = 427; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamPipeToCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamPipeToCode = "(function (_,b){\"use strict\";@assert(@isReadableStream(_));const c=new @ReadableStreamDefaultReader(_);@getByIdDirectPrivate(c,\"closedPromiseCapability\").@promise.@then(()=>{},(g)=>{b.error(g)});function f(){@readableStreamDefaultReaderRead(c).@then(function(g){if(g.done){b.close();return}try{b.enqueue(g.value)}catch(h){b.error(\"ReadableStream chunk enqueueing in the sink failed\");return}f()},function(g){b.error(g)})}f()})\n"; + +// acquireReadableStreamDefaultReader +const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeLength = 127; +static const JSC::Intrinsic s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsAcquireReadableStreamDefaultReaderCode = "(function (d){\"use strict\";var g=@getByIdDirectPrivate(d,\"start\");if(g)g.@call(d);return new @ReadableStreamDefaultReader(d)})\n"; + +// setupReadableStreamDefaultController +const JSC::ConstructAbility s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeLength = 523; +static const JSC::Intrinsic s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (D,O,b,f,j,q,v){\"use strict\";const w=new @ReadableStreamDefaultController(D,O,b,f,@isReadableStream),x=()=>@promiseInvokeOrNoopMethod(O,q,[w]),B=(C)=>@promiseInvokeOrNoopMethod(O,v,[C]);@putByIdDirectPrivate(w,\"pullAlgorithm\",x),@putByIdDirectPrivate(w,\"cancelAlgorithm\",B),@putByIdDirectPrivate(w,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(w,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(D,\"readableStreamController\",w),@readableStreamDefaultControllerStart(w)})\n"; + +// createReadableStreamController +const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 671; +static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (_,f,b){\"use strict\";const j=f.type,q=@toString(j);if(q===\"bytes\"){if(b.highWaterMark===@undefined)b.highWaterMark=0;if(b.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(_,\"readableStreamController\",new @ReadableByteStreamController(_,f,b.highWaterMark,@isReadableStream))}else if(q===\"direct\"){var v=b\?.highWaterMark;@initializeArrayBufferStream.@call(_,f,v)}else if(j===@undefined){if(b.highWaterMark===@undefined)b.highWaterMark=1;@setupReadableStreamDefaultController(_,f,b.size,b.highWaterMark,f.start,f.pull,f.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; + +// readableStreamDefaultControllerStart +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamDefaultControllerStartCodeLength = 465; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerStartCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerStartCode = "(function (_){\"use strict\";if(@getByIdDirectPrivate(_,\"started\")!==-1)return;const a=@getByIdDirectPrivate(_,\"underlyingSource\"),s=a.start;@putByIdDirectPrivate(_,\"started\",0),@promiseInvokeOrNoopMethodNoCatch(a,s,[_]).@then(()=>{@putByIdDirectPrivate(_,\"started\",1),@assert(!@getByIdDirectPrivate(_,\"pulling\")),@assert(!@getByIdDirectPrivate(_,\"pullAgain\")),@readableStreamDefaultControllerCallPullIfNeeded(_)},(C)=>{@readableStreamDefaultControllerError(_,C)})})\n"; + +// readableStreamPipeToWritableStream +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeLength = 1631; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (_,f,k,D,q,w){\"use strict\";if(@assert(@isReadableStream(_)),@assert(@isWritableStream(f)),@assert(!@isReadableStreamLocked(_)),@assert(!@isWritableStreamLocked(f)),@assert(w===@undefined||@isAbortSignal(w)),@getByIdDirectPrivate(_,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let x={source:_,destination:f,preventAbort:D,preventCancel:q,preventClose:k,signal:w};if(x.reader=@acquireReadableStreamDefaultReader(_),x.writer=@acquireWritableStreamDefaultWriter(f),@putByIdDirectPrivate(_,\"disturbed\",!0),x.finalized=!1,x.shuttingDown=!1,x.promiseCapability=@newPromiseCapability(@Promise),x.pendingReadPromiseCapability=@newPromiseCapability(@Promise),x.pendingReadPromiseCapability.@resolve.@call(),x.pendingWritePromise=@Promise.@resolve(),w!==@undefined){const z=(B)=>{if(x.finalized)return;@pipeToShutdownWithAction(x,()=>{const F=!x.preventAbort&&@getByIdDirectPrivate(x.destination,\"state\")===\"writable\"\?@writableStreamAbort(x.destination,B):@Promise.@resolve(),H=!x.preventCancel&&@getByIdDirectPrivate(x.source,\"state\")===@streamReadable\?@readableStreamCancel(x.source,B):@Promise.@resolve();let I=@newPromiseCapability(@Promise),J=!0,K=()=>{if(J){J=!1;return}I.@resolve.@call()},L=(M)=>{I.@reject.@call(@undefined,M)};return F.@then(K,L),H.@then(K,L),I.@promise},B)};if(@whenSignalAborted(w,z))return x.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(x),@pipeToErrorsMustBePropagatedBackward(x),@pipeToClosingMustBePropagatedForward(x),@pipeToClosingMustBePropagatedBackward(x),@pipeToLoop(x),x.promiseCapability.@promise})\n"; + +// pipeToLoop +const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsPipeToLoopCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsPipeToLoopCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsPipeToLoopCodeLength = 110; +static const JSC::Intrinsic s_readableStreamInternalsPipeToLoopCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsPipeToLoopCode = "(function (d){\"use strict\";if(d.shuttingDown)return;@pipeToDoReadWrite(d).@then((n)=>{if(n)@pipeToLoop(d)})})\n"; + +// pipeToDoReadWrite +const JSC::ConstructAbility s_readableStreamInternalsPipeToDoReadWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsPipeToDoReadWriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsPipeToDoReadWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsPipeToDoReadWriteCodeLength = 731; +static const JSC::Intrinsic s_readableStreamInternalsPipeToDoReadWriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsPipeToDoReadWriteCode = "(function (_){\"use strict\";return @assert(!_.shuttingDown),_.pendingReadPromiseCapability=@newPromiseCapability(@Promise),@getByIdDirectPrivate(_.writer,\"readyPromise\").@promise.@then(()=>{if(_.shuttingDown){_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);return}@readableStreamDefaultReaderRead(_.reader).@then((n)=>{const b=!n.done&&@getByIdDirectPrivate(_.writer,\"stream\")!==@undefined;if(_.pendingReadPromiseCapability.@resolve.@call(@undefined,b),!b)return;_.pendingWritePromise=@writableStreamDefaultWriterWrite(_.writer,n.value)},(n)=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1)})},(n)=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1)}),_.pendingReadPromiseCapability.@promise})\n"; + +// pipeToErrorsMustBePropagatedForward +const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeLength = 438; +static const JSC::Intrinsic s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode = "(function (s){\"use strict\";const d=()=>{s.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);const l=@getByIdDirectPrivate(s.source,\"storedError\");if(!s.preventAbort){@pipeToShutdownWithAction(s,()=>@writableStreamAbort(s.destination,l),l);return}@pipeToShutdown(s,l)};if(@getByIdDirectPrivate(s.source,\"state\")===@streamErrored){d();return}@getByIdDirectPrivate(s.reader,\"closedPromiseCapability\").@promise.@then(@undefined,d)})\n"; + +// pipeToErrorsMustBePropagatedBackward +const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeLength = 369; +static const JSC::Intrinsic s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode = "(function (d){\"use strict\";const n=()=>{const g=@getByIdDirectPrivate(d.destination,\"storedError\");if(!d.preventCancel){@pipeToShutdownWithAction(d,()=>@readableStreamCancel(d.source,g),g);return}@pipeToShutdown(d,g)};if(@getByIdDirectPrivate(d.destination,\"state\")===\"errored\"){n();return}@getByIdDirectPrivate(d.writer,\"closedPromise\").@promise.@then(@undefined,n)})\n"; + +// pipeToClosingMustBePropagatedForward +const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeLength = 405; +static const JSC::Intrinsic s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCode = "(function (r){\"use strict\";const l=()=>{if(r.pendingReadPromiseCapability.@resolve.@call(@undefined,!1),!r.preventClose){@pipeToShutdownWithAction(r,()=>@writableStreamDefaultWriterCloseWithErrorPropagation(r.writer));return}@pipeToShutdown(r)};if(@getByIdDirectPrivate(r.source,\"state\")===@streamClosed){l();return}@getByIdDirectPrivate(r.reader,\"closedPromiseCapability\").@promise.@then(l,@undefined)})\n"; + +// pipeToClosingMustBePropagatedBackward +const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeLength = 324; +static const JSC::Intrinsic s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCode = "(function (n){\"use strict\";if(!@writableStreamCloseQueuedOrInFlight(n.destination)&&@getByIdDirectPrivate(n.destination,\"state\")!==\"closed\")return;const _=@makeTypeError(\"closing is propagated backward\");if(!n.preventCancel){@pipeToShutdownWithAction(n,()=>@readableStreamCancel(n.source,_),_);return}@pipeToShutdown(n,_)})\n"; + +// pipeToShutdownWithAction +const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownWithActionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownWithActionCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownWithActionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsPipeToShutdownWithActionCodeLength = 458; +static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownWithActionCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (d,h){\"use strict\";if(d.shuttingDown)return;d.shuttingDown=!0;const s=arguments.length>2,u=arguments[2],_=()=>{h().@then(()=>{if(s)@pipeToFinalize(d,u);else @pipeToFinalize(d)},(g)=>{@pipeToFinalize(d,g)})};if(@getByIdDirectPrivate(d.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(d.destination)){d.pendingReadPromiseCapability.@promise.@then(()=>{d.pendingWritePromise.@then(_,_)},(b)=>@pipeToFinalize(d,b));return}_()})\n"; + +// pipeToShutdown +const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsPipeToShutdownCodeLength = 411; +static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (c){\"use strict\";if(c.shuttingDown)return;c.shuttingDown=!0;const D=arguments.length>1,_=arguments[1],b=()=>{if(D)@pipeToFinalize(c,_);else @pipeToFinalize(c)};if(@getByIdDirectPrivate(c.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(c.destination)){c.pendingReadPromiseCapability.@promise.@then(()=>{c.pendingWritePromise.@then(b,b)},(d)=>@pipeToFinalize(c,d));return}b()})\n"; + +// pipeToFinalize +const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsPipeToFinalizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsPipeToFinalizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsPipeToFinalizeCodeLength = 259; +static const JSC::Intrinsic s_readableStreamInternalsPipeToFinalizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsPipeToFinalizeCode = "(function (r){\"use strict\";if(@writableStreamDefaultWriterRelease(r.writer),@readableStreamReaderGenericRelease(r.reader),r.finalized=!0,arguments.length>1)r.promiseCapability.@reject.@call(@undefined,arguments[1]);else r.promiseCapability.@resolve.@call()})\n"; + +// readableStreamTee +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamTeeCodeLength = 1104; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (_,f){\"use strict\";@assert(@isReadableStream(_)),@assert(typeof f===\"boolean\");var D=@getByIdDirectPrivate(_,\"start\");if(D)@putByIdDirectPrivate(_,\"start\",@undefined),D();const E=new @ReadableStreamDefaultReader(_),T={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};T.cancelPromiseCapability=@newPromiseCapability(@Promise);const g=@readableStreamTeePullFunction(T,E,f),i={};@putByIdDirectPrivate(i,\"pull\",g),@putByIdDirectPrivate(i,\"cancel\",@readableStreamTeeBranch1CancelFunction(T,_));const j={};@putByIdDirectPrivate(j,\"pull\",g),@putByIdDirectPrivate(j,\"cancel\",@readableStreamTeeBranch2CancelFunction(T,_));const k=new @ReadableStream(i),q=new @ReadableStream(j);return @getByIdDirectPrivate(E,\"closedPromiseCapability\").@promise.@then(@undefined,function(v){if(T.closedOrErrored)return;if(@readableStreamDefaultControllerError(k.@readableStreamController,v),@readableStreamDefaultControllerError(q.@readableStreamController,v),T.closedOrErrored=!0,!T.canceled1||!T.canceled2)T.cancelPromiseCapability.@resolve.@call()}),T.branch1=k,T.branch2=q,[k,q]})\n"; + +// readableStreamTeePullFunction +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeePullFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamTeePullFunctionCodeLength = 764; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeePullFunctionCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamTeePullFunctionCode = "(function (f,m,i){\"use strict\";return function(){@Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(m),function(j){if(@assert(@isObject(j)),@assert(typeof j.done===\"boolean\"),j.done&&!f.closedOrErrored){if(!f.canceled1)@readableStreamDefaultControllerClose(f.branch1.@readableStreamController);if(!f.canceled2)@readableStreamDefaultControllerClose(f.branch2.@readableStreamController);if(f.closedOrErrored=!0,!f.canceled1||!f.canceled2)f.cancelPromiseCapability.@resolve.@call()}if(f.closedOrErrored)return;if(!f.canceled1)@readableStreamDefaultControllerEnqueue(f.branch1.@readableStreamController,j.value);if(!f.canceled2)@readableStreamDefaultControllerEnqueue(f.branch2.@readableStreamController,i\?@structuredCloneForStream(j.value):j.value)})}})\n"; + +// readableStreamTeeBranch1CancelFunction +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeLength = 258; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode = "(function (i,n){\"use strict\";return function(d){if(i.canceled1=!0,i.reason1=d,i.canceled2)@readableStreamCancel(n,[i.reason1,i.reason2]).@then(i.cancelPromiseCapability.@resolve,i.cancelPromiseCapability.@reject);return i.cancelPromiseCapability.@promise}})\n"; + +// readableStreamTeeBranch2CancelFunction +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeLength = 258; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCode = "(function (i,n){\"use strict\";return function(d){if(i.canceled2=!0,i.reason2=d,i.canceled1)@readableStreamCancel(n,[i.reason1,i.reason2]).@then(i.cancelPromiseCapability.@resolve,i.cancelPromiseCapability.@reject);return i.cancelPromiseCapability.@promise}})\n"; + +// isReadableStream +const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsIsReadableStreamCodeLength = 115; +static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsIsReadableStreamCode = "(function (r){\"use strict\";return @isObject(r)&&@getByIdDirectPrivate(r,\"readableStreamController\")!==@undefined})\n"; + +// isReadableStreamDefaultReader +const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamDefaultReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsIsReadableStreamDefaultReaderCodeLength = 92; +static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamDefaultReaderCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsIsReadableStreamDefaultReaderCode = "(function (s){\"use strict\";return @isObject(s)&&!!@getByIdDirectPrivate(s,\"readRequests\")})\n"; + +// isReadableStreamDefaultController +const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsIsReadableStreamDefaultControllerCodeLength = 96; +static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsIsReadableStreamDefaultControllerCode = "(function (a){\"use strict\";return @isObject(a)&&!!@getByIdDirectPrivate(a,\"underlyingSource\")})\n"; + +// readDirectStream +const JSC::ConstructAbility s_readableStreamInternalsReadDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadDirectStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadDirectStreamCodeLength = 900; +static const JSC::Intrinsic s_readableStreamInternalsReadDirectStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (_,f,B){\"use strict\";@putByIdDirectPrivate(_,\"underlyingSource\",@undefined),@putByIdDirectPrivate(_,\"start\",@undefined);function j(w,x){if(x&&B\?.cancel){try{var z=B.cancel(x);@markPromiseAsHandled(z)}catch(A){}B=@undefined}if(w){if(@putByIdDirectPrivate(w,\"readableStreamController\",@undefined),@putByIdDirectPrivate(w,\"reader\",@undefined),x)@putByIdDirectPrivate(w,\"state\",@streamErrored),@putByIdDirectPrivate(w,\"storedError\",x);else @putByIdDirectPrivate(w,\"state\",@streamClosed);w=@undefined}}if(!B.pull){j();return}if(!@isCallable(B.pull)){j(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(_,\"readableStreamController\",f);const q=@getByIdDirectPrivate(_,\"highWaterMark\");f.start({highWaterMark:!q||q<64\?64:q}),@startDirectStream.@call(f,_,B.pull,j),@putByIdDirectPrivate(_,\"reader\",{});var v=B.pull(f);if(f=@undefined,v&&@isPromise(v))return v.@then(()=>{})})\n"; + +// assignToStream +const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsAssignToStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsAssignToStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_readableStreamInternalsAssignToStreamCodeLength = 221; +static const JSC::Intrinsic s_readableStreamInternalsAssignToStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsAssignToStreamCode = "(function (h,p){\"use strict\";var P=@getByIdDirectPrivate(h,\"underlyingSource\");if(P)try{return @readDirectStream(h,p,P)}catch(_){throw _}finally{P=@undefined,h=@undefined,p=@undefined}return @readStreamIntoSink(h,p,!0)})\n"; + +// readStreamIntoSink +const JSC::ConstructAbility s_readableStreamInternalsReadStreamIntoSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadStreamIntoSinkCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadStreamIntoSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadStreamIntoSinkCodeLength = 1395; +static const JSC::Intrinsic s_readableStreamInternalsReadStreamIntoSinkCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadStreamIntoSinkCode = "(async function (B,_,f){\"use strict\";var D=!1,c=!1;try{var q=B.getReader(),w=q.readMany();if(w&&@isPromise(w))w=await w;if(w.done)return D=!0,_.end();var x=w.value.length;const J=@getByIdDirectPrivate(B,\"highWaterMark\");if(f)@startDirectStream.@call(_,B,@undefined,()=>!c&&@markPromiseAsHandled(B.cancel()));_.start({highWaterMark:J||0});for(var z=0,A=w.value,E=w.value.length;z<E;z++)_.write(A[z]);var F=@getByIdDirectPrivate(B,\"state\");if(F===@streamClosed)return D=!0,_.end();while(!0){var{value:G,done:H}=await q.read();if(H)return D=!0,_.end();_.write(G)}}catch(J){c=!0;try{q=@undefined;const K=B.cancel(J);@markPromiseAsHandled(K)}catch(K){}if(_&&!D){D=!0;try{_.close(J)}catch(K){throw new globalThis.AggregateError([J,K])}}throw J}finally{if(q){try{q.releaseLock()}catch(K){}q=@undefined}_=@undefined;var F=@getByIdDirectPrivate(B,\"state\");if(B){var I=@getByIdDirectPrivate(B,\"readableStreamController\");if(I){if(@getByIdDirectPrivate(I,\"underlyingSource\"))@putByIdDirectPrivate(I,\"underlyingSource\",@undefined);if(@getByIdDirectPrivate(I,\"controlledReadableStream\"))@putByIdDirectPrivate(I,\"controlledReadableStream\",@undefined);if(@putByIdDirectPrivate(B,\"readableStreamController\",null),@getByIdDirectPrivate(B,\"underlyingSource\"))@putByIdDirectPrivate(B,\"underlyingSource\",@undefined);I=@undefined}if(!c&&F!==@streamClosed&&F!==@streamErrored)@readableStreamClose(B);B=@undefined}}})\n"; + +// handleDirectStreamError +const JSC::ConstructAbility s_readableStreamInternalsHandleDirectStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsHandleDirectStreamErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsHandleDirectStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsHandleDirectStreamErrorCodeLength = 496; +static const JSC::Intrinsic s_readableStreamInternalsHandleDirectStreamErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsHandleDirectStreamErrorCode = "(function (i){\"use strict\";var _=this,f=_.@sink;if(f){@putByIdDirectPrivate(_,\"sink\",@undefined);try{f.close(i)}catch(g){}}if(this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed,typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,i)}catch(g){}try{var u=_._pendingRead;if(u)_._pendingRead=@undefined,@rejectPromise(u,i)}catch(g){}var b=_.@controlledReadableStream;if(b)@readableStreamError(b,i)})\n"; + +// handleDirectStreamErrorReject +const JSC::ConstructAbility s_readableStreamInternalsHandleDirectStreamErrorRejectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsHandleDirectStreamErrorRejectCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsHandleDirectStreamErrorRejectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsHandleDirectStreamErrorRejectCodeLength = 95; +static const JSC::Intrinsic s_readableStreamInternalsHandleDirectStreamErrorRejectCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsHandleDirectStreamErrorRejectCode = "(function (r){\"use strict\";return @handleDirectStreamError.@call(this,r),@Promise.@reject(r)})\n"; + +// onPullDirectStream +const JSC::ConstructAbility s_readableStreamInternalsOnPullDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsOnPullDirectStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsOnPullDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsOnPullDirectStreamCodeLength = 785; +static const JSC::Intrinsic s_readableStreamInternalsOnPullDirectStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsOnPullDirectStreamCode = "(function (i){\"use strict\";var _=i.@controlledReadableStream;if(!_||@getByIdDirectPrivate(_,\"state\")!==@streamReadable)return;if(i._deferClose===-1)return;i._deferClose=-1,i._deferFlush=-1;var h,w;try{var b=i.@underlyingSource.pull(i);if(b&&@isPromise(b)){if(i._handleError===@undefined)i._handleError=@handleDirectStreamErrorReject.bind(i);@Promise.prototype.catch.@call(b,i._handleError)}}catch(k){return @handleDirectStreamErrorReject.@call(i,k)}finally{h=i._deferClose,w=i._deferFlush,i._deferFlush=i._deferClose=0}var g;if(i._pendingRead===@undefined)i._pendingRead=g=@newPromise();else g=@readableStreamAddReadRequest(_);if(h===1){var j=i._deferCloseReason;return i._deferCloseReason=@undefined,@onCloseDirectStream.@call(i,j),g}if(w===1)@onFlushDirectStream.@call(i);return g})\n"; + +// noopDoneFunction +const JSC::ConstructAbility s_readableStreamInternalsNoopDoneFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsNoopDoneFunctionCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsNoopDoneFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsNoopDoneFunctionCodeLength = 81; +static const JSC::Intrinsic s_readableStreamInternalsNoopDoneFunctionCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsNoopDoneFunctionCode = "(function (){\"use strict\";return @Promise.@resolve({value:@undefined,done:!0})})\n"; + +// onReadableStreamDirectControllerClosed +const JSC::ConstructAbility s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeLength = 93; +static const JSC::Intrinsic s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsOnReadableStreamDirectControllerClosedCode = "(function (e){\"use strict\";@throwTypeError(\"ReadableStreamDirectController is now closed\")})\n"; + +// onCloseDirectStream +const JSC::ConstructAbility s_readableStreamInternalsOnCloseDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsOnCloseDirectStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsOnCloseDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsOnCloseDirectStreamCodeLength = 1460; +static const JSC::Intrinsic s_readableStreamInternalsOnCloseDirectStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsOnCloseDirectStreamCode = "(function (c){\"use strict\";var y=this.@controlledReadableStream;if(!y||@getByIdDirectPrivate(y,\"state\")!==@streamReadable)return;if(this._deferClose!==0){this._deferClose=1,this._deferCloseReason=c;return}if(@putByIdDirectPrivate(y,\"state\",@streamClosing),typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,c)}catch(v){}var _;try{_=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(v){if(this._pendingRead){var b=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(b,v)}@readableStreamError(y,v);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var C=@getByIdDirectPrivate(y,\"reader\");if(C&&@isReadableStreamDefaultReader(C)){var j=this._pendingRead;if(j&&@isPromise(j)&&_\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(j,{value:_,done:!1}),@readableStreamClose(y);return}}if(_\?.byteLength){var k=@getByIdDirectPrivate(C,\"readRequests\");if(k\?.isNotEmpty()){@readableStreamFulfillReadRequest(y,_,!1),@readableStreamClose(y);return}@putByIdDirectPrivate(y,\"state\",@streamReadable),this.@pull=()=>{var v=@createFulfilledPromise({value:_,done:!1});return _=@undefined,@readableStreamClose(y),y=@undefined,v}}else if(this._pendingRead){var b=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(b,{value:@undefined,done:!0})}@readableStreamClose(y)})\n"; + +// onFlushDirectStream +const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsOnFlushDirectStreamCodeLength = 591; +static const JSC::Intrinsic s_readableStreamInternalsOnFlushDirectStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var c=this.@controlledReadableStream,b=@getByIdDirectPrivate(c,\"reader\");if(!b||!@isReadableStreamDefaultReader(b))return;var j=this._pendingRead;if(this._pendingRead=@undefined,j&&@isPromise(j)){var k=this.@sink.flush();if(k\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(j,{value:k,done:!1});else this._pendingRead=j}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var k=this.@sink.flush();if(k\?.byteLength)@readableStreamFulfillReadRequest(c,k,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; + +// createTextStream +const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsCreateTextStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsCreateTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsCreateTextStreamCodeLength = 984; +static const JSC::Intrinsic s_readableStreamInternalsCreateTextStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (v){\"use strict\";var E,U=[],_=!1,j=!1,q=\"\",w=@toLength(0),x=@newPromiseCapability(@Promise),z=!1;return E={start(){},write(A){if(typeof A===\"string\"){var C=@toLength(A.length);if(C>0)q+=A,_=!0,w+=C;return C}if(!A||!(@ArrayBuffer.@isView(A)||A instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const F=@toLength(A.byteLength);if(F>0)if(j=!0,q.length>0)@arrayPush(U,q,A),q=\"\";else @arrayPush(U,A);return w+=F,F},flush(){return 0},end(){if(z)return\"\";return E.fulfill()},fulfill(){z=!0;const A=E.finishInternal();return @fulfillPromise(x.@promise,A),A},finishInternal(){if(!_&&!j)return\"\";if(_&&!j)return q;if(j&&!_)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(U));var A=new @Bun.ArrayBufferSink;A.start({highWaterMark:w,asUint8Array:!0});for(let C of U)A.write(C);if(U.length=0,q.length>0)A.write(q),q=\"\";return new globalThis.TextDecoder().decode(A.end())},close(){try{if(!z)z=!0,E.fulfill()}catch(A){}}},[E,x]})\n"; + +// initializeTextStream +const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsInitializeTextStreamCodeLength = 578; +static const JSC::Intrinsic s_readableStreamInternalsInitializeTextStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (_,t){\"use strict\";var[f,p]=@createTextStream(t),I={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:f,close:@onCloseDirectStream,write:f.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",I),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),p})\n"; + +// initializeArrayStream +const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsInitializeArrayStreamCodeLength = 797; +static const JSC::Intrinsic s_readableStreamInternalsInitializeArrayStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsInitializeArrayStreamCode = "(function (_,t){\"use strict\";var p=[],v=@newPromiseCapability(@Promise),b=!1;function j(){return b=!0,v.@resolve.@call(@undefined,p),p}var q={start(){},write(x){return @arrayPush(p,x),x.byteLength||x.length},flush(){return 0},end(){if(b)return[];return j()},close(){if(!b)j()}},w={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:q,close:@onCloseDirectStream,write:q.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",w),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),v})\n"; + +// initializeArrayBufferStream +const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayBufferStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsInitializeArrayBufferStreamCodeLength = 690; +static const JSC::Intrinsic s_readableStreamInternalsInitializeArrayBufferStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode = "(function (d,_){\"use strict\";var R=_&&typeof _===\"number\"\?{highWaterMark:_,stream:!0,asUint8Array:!0}:{stream:!0,asUint8Array:!0},b=new @Bun.ArrayBufferSink;b.start(R);var f={@underlyingSource:d,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:b,close:@onCloseDirectStream,write:b.write.bind(b),error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};@putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined)})\n"; + +// readableStreamError +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamErrorCodeLength = 840; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (c,i){\"use strict\";@assert(@isReadableStream(c)),@assert(@getByIdDirectPrivate(c,\"state\")===@streamReadable),@putByIdDirectPrivate(c,\"state\",@streamErrored),@putByIdDirectPrivate(c,\"storedError\",i);const n=@getByIdDirectPrivate(c,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const f=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var _=f.shift();_;_=f.shift())@rejectPromise(_,i)}else{@assert(@isReadableStreamBYOBReader(n));const f=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var _=f.shift();_;_=f.shift())@rejectPromise(_,i)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,i);const b=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(b)})\n"; + +// readableStreamDefaultControllerShouldCallPull +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeLength = 477; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCode = "(function (_){\"use strict\";const a=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(!@readableStreamDefaultControllerCanCloseOrEnqueue(_))return!1;if(@getByIdDirectPrivate(_,\"started\")!==1)return!1;if((!@isReadableStreamLocked(a)||!@getByIdDirectPrivate(@getByIdDirectPrivate(a,\"reader\"),\"readRequests\")\?.isNotEmpty())&&@readableStreamDefaultControllerGetDesiredSize(_)<=0)return!1;const f=@readableStreamDefaultControllerGetDesiredSize(_);return @assert(f!==null),f>0})\n"; + +// readableStreamDefaultControllerCallPullIfNeeded +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeLength = 859; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(!@readableStreamDefaultControllerCanCloseOrEnqueue(_))return;if(@getByIdDirectPrivate(_,\"started\")!==1)return;if((!@isReadableStreamLocked(d)||!@getByIdDirectPrivate(@getByIdDirectPrivate(d,\"reader\"),\"readRequests\")\?.isNotEmpty())&&@readableStreamDefaultControllerGetDesiredSize(_)<=0)return;if(@getByIdDirectPrivate(_,\"pulling\")){@putByIdDirectPrivate(_,\"pullAgain\",!0);return}@assert(!@getByIdDirectPrivate(_,\"pullAgain\")),@putByIdDirectPrivate(_,\"pulling\",!0),@getByIdDirectPrivate(_,\"pullAlgorithm\").@call(@undefined).@then(function(){if(@putByIdDirectPrivate(_,\"pulling\",!1),@getByIdDirectPrivate(_,\"pullAgain\"))@putByIdDirectPrivate(_,\"pullAgain\",!1),@readableStreamDefaultControllerCallPullIfNeeded(_)},function(g){@readableStreamDefaultControllerError(_,g)})})\n"; + +// isReadableStreamLocked +const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamLockedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamLockedCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamLockedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsIsReadableStreamLockedCodeLength = 102; +static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamLockedCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsIsReadableStreamLockedCode = "(function (c){\"use strict\";return @assert(@isReadableStream(c)),!!@getByIdDirectPrivate(c,\"reader\")})\n"; + +// readableStreamDefaultControllerGetDesiredSize +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength = 283; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const _=@getByIdDirectPrivate(i,\"controlledReadableStream\"),d=@getByIdDirectPrivate(_,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategy\").highWaterMark-@getByIdDirectPrivate(i,\"queue\").size})\n"; + +// readableStreamReaderGenericCancel +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength = 133; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericCancelCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (c,p){\"use strict\";const u=@getByIdDirectPrivate(c,\"ownerReadableStream\");return @assert(!!u),@readableStreamCancel(u,p)})\n"; + +// readableStreamCancel +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamCancelCodeLength = 509; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (b,D){\"use strict\";@putByIdDirectPrivate(b,\"disturbed\",!0);const I=@getByIdDirectPrivate(b,\"state\");if(I===@streamClosed)return @Promise.@resolve();if(I===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(b,\"storedError\"));@readableStreamClose(b);var _=@getByIdDirectPrivate(b,\"readableStreamController\"),d=_.@cancel;if(d)return d(_,D).@then(function(){});var f=_.close;if(f)return @Promise.@resolve(_.close(D));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; + +// readableStreamDefaultControllerCancel +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeLength = 146; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerCancelCode = "(function (d,u){\"use strict\";return @putByIdDirectPrivate(d,\"queue\",@newQueue()),@getByIdDirectPrivate(d,\"cancelAlgorithm\").@call(@undefined,u)})\n"; + +// readableStreamDefaultControllerPull +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength = 519; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerPullCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = "(function (a){\"use strict\";var d=@getByIdDirectPrivate(a,\"queue\");if(d.content.isNotEmpty()){const y=@dequeueValue(d);if(@getByIdDirectPrivate(a,\"closeRequested\")&&d.content.isEmpty())@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableStreamDefaultControllerCallPullIfNeeded(a);return @createFulfilledPromise({value:y,done:!1})}const i=@readableStreamAddReadRequest(@getByIdDirectPrivate(a,\"controlledReadableStream\"));return @readableStreamDefaultControllerCallPullIfNeeded(a),i})\n"; + +// readableStreamDefaultControllerClose +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeLength = 266; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerCloseCode = "(function (d){\"use strict\";if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(d)),@putByIdDirectPrivate(d,\"closeRequested\",!0),@getByIdDirectPrivate(d,\"queue\")\?.content\?.isEmpty())@readableStreamClose(@getByIdDirectPrivate(d,\"controlledReadableStream\"))})\n"; + +// readableStreamClose +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamCloseCodeLength = 617; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamCloseCode = "(function (i){\"use strict\";if(@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamClosed),!@getByIdDirectPrivate(i,\"reader\"))return;if(@isReadableStreamDefaultReader(@getByIdDirectPrivate(i,\"reader\"))){const p=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\");if(p.isNotEmpty()){@putByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\",@createFIFO());for(var c=p.shift();c;c=p.shift())@fulfillPromise(c,{value:@undefined,done:!0})}}@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"closedPromiseCapability\").@resolve.@call()})\n"; + +// readableStreamFulfillReadRequest +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength = 157; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamFulfillReadRequestCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (p,P,_){\"use strict\";const b=@getByIdDirectPrivate(@getByIdDirectPrivate(p,\"reader\"),\"readRequests\").shift();@fulfillPromise(b,{value:P,done:_})})\n"; + +// readableStreamDefaultControllerEnqueue +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength = 659; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,b){\"use strict\";const f=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(f)&&@getByIdDirectPrivate(@getByIdDirectPrivate(f,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(f,b,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let v=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)v=@getByIdDirectPrivate(_,\"strategy\").size(b);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),b,v)}catch(v){throw @readableStreamDefaultControllerError(_,v),v}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; + +// readableStreamDefaultReaderRead +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength = 491; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (i){\"use strict\";const P=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!P);const c=@getByIdDirectPrivate(P,\"state\");if(@putByIdDirectPrivate(P,\"disturbed\",!0),c===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(c===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));return @assert(c===@streamReadable),@getByIdDirectPrivate(P,\"readableStreamController\").@pull(@getByIdDirectPrivate(P,\"readableStreamController\"))})\n"; + +// readableStreamAddReadRequest +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamAddReadRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamAddReadRequestCodeLength = 274; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamAddReadRequestCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamAddReadRequestCode = "(function (i){\"use strict\";@assert(@isReadableStreamDefaultReader(@getByIdDirectPrivate(i,\"reader\"))),@assert(@getByIdDirectPrivate(i,\"state\")==@streamReadable);const g=@newPromise();return @getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\").push(g),g})\n"; + +// isReadableStreamDisturbed +const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDisturbedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDisturbedCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamDisturbedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsIsReadableStreamDisturbedCodeLength = 103; +static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamDisturbedCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsIsReadableStreamDisturbedCode = "(function (c){\"use strict\";return @assert(@isReadableStream(c)),@getByIdDirectPrivate(c,\"disturbed\")})\n"; + +// readableStreamReaderGenericRelease +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeLength = 813; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamReaderGenericReleaseCode = "(function (c){\"use strict\";if(@assert(!!@getByIdDirectPrivate(c,\"ownerReadableStream\")),@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(c,\"ownerReadableStream\"),\"reader\")===c),@getByIdDirectPrivate(@getByIdDirectPrivate(c,\"ownerReadableStream\"),\"state\")===@streamReadable)@getByIdDirectPrivate(c,\"closedPromiseCapability\").@reject.@call(@undefined,@makeTypeError(\"releasing lock of reader whose stream is still in readable state\"));else @putByIdDirectPrivate(c,\"closedPromiseCapability\",{@promise:@newHandledRejectedPromise(@makeTypeError(\"reader released lock\"))});const s=@getByIdDirectPrivate(c,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(s),@putByIdDirectPrivate(@getByIdDirectPrivate(c,\"ownerReadableStream\"),\"reader\",@undefined),@putByIdDirectPrivate(c,\"ownerReadableStream\",@undefined)})\n"; + +// readableStreamDefaultControllerCanCloseOrEnqueue +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeLength = 180; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCode = "(function (a){\"use strict\";return!@getByIdDirectPrivate(a,\"closeRequested\")&&@getByIdDirectPrivate(@getByIdDirectPrivate(a,\"controlledReadableStream\"),\"state\")===@streamReadable})\n"; + +// lazyLoadStream +const JSC::ConstructAbility s_readableStreamInternalsLazyLoadStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsLazyLoadStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsLazyLoadStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsLazyLoadStreamCodeLength = 1589; +static const JSC::Intrinsic s_readableStreamInternalsLazyLoadStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (b,f){\"use strict\";var j=@getByIdDirectPrivate(b,\"bunNativeType\"),m=@getByIdDirectPrivate(b,\"bunNativePtr\"),q=@lazyStreamPrototypeMap.@get(j);if(q===@undefined){let U=function(Z){var{c:_,v:p}=this;this.c=@undefined,this.v=@undefined,J(Z,_,p)},W=function(Z){try{Z.close()}catch(_){globalThis.reportError(_)}},X=function(Z,_,p,z){z[0]=!1;var A;try{A=x(Z,p,z)}catch(C){return _.error(C)}return J(A,_,p)};var Q=U,P=W,O=X,[x,B,D,E,F,G,H]=@lazyLoad(j),I=[!1],J;J=function Z(_,p,z){if(_&&@isPromise(_))return _.then(U.bind({c:p,v:z}),(A)=>p.error(A));else if(typeof _===\"number\")if(z&&z.byteLength===_&&z.buffer===p.byobRequest\?.view\?.buffer)p.byobRequest.respondWithNewView(z);else p.byobRequest.respond(_);else if(_.constructor===@Uint8Array)p.enqueue(_);if(I[0]||_===!1)@enqueueJob(W,p),I[0]=!1};const Y=F\?new FinalizationRegistry(F):null;q=class Z{constructor(_,p,z){if(this.#f=_,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=p,z!==@undefined)this.start=(A)=>{A.enqueue(z)};if(Y)Y.register(this,_,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=B;#j(_){var p=this.#f;if(!p){_.close();return}X(p,_,_.byobRequest.view,I)}#m(_){var p=this.#f;Y&&Y.unregister(this.#b),G&&G(p,!1),D(p,_)}static deinit=F;static drain=H},@lazyStreamPrototypeMap.@set(j,q)}const K=q.startSync(m,f);var L;const{drain:M,deinit:N}=q;if(M)L=M(m);if(K===0){if(F&&m&&@enqueueJob(F,m),(L\?.byteLength\?\?0)>0)return{start(U){U.enqueue(L),U.close()},type:\"bytes\"};return{start(U){U.close()},type:\"bytes\"}}return new q(m,K,L)})\n"; + +// readableStreamIntoArray +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 247; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (_){\"use strict\";var b=_.getReader(),f=b.readMany();async function g(j){if(j.done)return[];var q=j.value||[];while(!0){var v=await b.read();if(v.done)break;q=q.concat(v.value)}return q}if(f&&@isPromise(f))return f.@then(g);return g(f)})\n"; + +// readableStreamIntoText +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoTextCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoTextCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamIntoTextCodeLength = 214; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoTextCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (_){\"use strict\";const[d,n]=@createTextStream(@getByIdDirectPrivate(_,\"highWaterMark\")),u=@readStreamIntoSink(_,d,!1);if(u&&@isPromise(u))return @Promise.@resolve(u).@then(n.@promise);return n.@promise})\n"; + +// readableStreamToArrayBufferDirect +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeLength = 727; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (v,_){\"use strict\";var j=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(v,\"underlyingSource\",@undefined);var q=@getByIdDirectPrivate(v,\"highWaterMark\");j.start(q\?{highWaterMark:q}:{});var w=@newPromiseCapability(@Promise),x=!1,z=_.pull,A=_.close,B={start(){},close(D){if(!x){if(x=!0,A)A();@fulfillPromise(w.@promise,j.end())}},end(){if(!x){if(x=!0,A)A();@fulfillPromise(w.@promise,j.end())}},flush(){return 0},write:j.write.bind(j)},C=!1;try{const D=z(B);if(D&&@isObject(D)&&@isPromise(D))return async function(F,G,H){while(!x)await H(F);return await G}(B,promise,z);return w.@promise}catch(D){return C=!0,@readableStreamError(v,D),@Promise.@reject(D)}finally{if(!C&&v)@readableStreamClose(v);B=A=j=z=v=@undefined}})\n"; + +// readableStreamToTextDirect +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength = 278; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToTextDirectCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,f){\"use strict\";const j=@initializeTextStream.@call(_,f,@undefined);var k=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var n=await k.read();if(n.done)break}try{k.releaseLock()}catch(q){}return k=@undefined,_=@undefined,j.@promise})\n"; + +// readableStreamToArrayDirect +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 371; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (_,k){\"use strict\";const f=@initializeArrayStream.@call(_,k,@undefined);k=@undefined;var j=_.getReader();try{while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var q=await j.read();if(q.done)break}try{j.releaseLock()}catch(v){}return j=@undefined,@Promise.@resolve(f.@promise)}catch(v){throw v}finally{_=@undefined,j=@undefined}return f.@promise})\n"; + +// readableStreamDefineLazyIterators +const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength = 516; +static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (_){\"use strict\";var g=globalThis.Symbol.asyncIterator,h=async function*q(w,x){var z=w.getReader(),B;try{while(!0){var D,F;const G=z.readMany();if(@isPromise(G))({done:D,value:F}=await G);else({done:D,value:F}=G);if(D)return;yield*F}}catch(G){B=G}finally{if(z.releaseLock(),!x)w.cancel(B);if(B)throw B}},j=function q(){return h(this,!1)},k=function q({preventCancel:w=!1}={preventCancel:!1}){return h(this,w)};return @Object.@defineProperty(_,g,{value:j}),@Object.@defineProperty(_,\"values\",{value:k}),_})\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 + +/* TransformStreamDefaultController.ts */ +// initializeTransformStreamDefaultController +const JSC::ConstructAbility s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeLength = 40; +static const JSC::Intrinsic s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCode = "(function (){\"use strict\";return this})\n"; + +// desiredSize +const JSC::ConstructAbility s_transformStreamDefaultControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamDefaultControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamDefaultControllerDesiredSizeCodeLength = 339; +static const JSC::Intrinsic s_transformStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const i=@getByIdDirectPrivate(this,\"stream\"),h=@getByIdDirectPrivate(i,\"readable\"),C=@getByIdDirectPrivate(h,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(C)})\n"; + +// enqueue +const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamDefaultControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamDefaultControllerEnqueueCodeLength = 195; +static const JSC::Intrinsic s_transformStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamDefaultControllerEnqueueCode = "(function (e){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");@transformStreamDefaultControllerEnqueue(this,e)})\n"; + +// error +const JSC::ConstructAbility s_transformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamDefaultControllerErrorCodeLength = 191; +static const JSC::Intrinsic s_transformStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamDefaultControllerErrorCode = "(function (r){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"error\");@transformStreamDefaultControllerError(this,r)})\n"; + +// terminate +const JSC::ConstructAbility s_transformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_transformStreamDefaultControllerTerminateCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_transformStreamDefaultControllerTerminateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_transformStreamDefaultControllerTerminateCodeLength = 196; +static const JSC::Intrinsic s_transformStreamDefaultControllerTerminateCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_transformStreamDefaultControllerTerminateCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"terminate\");@transformStreamDefaultControllerTerminate(this)})\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 + +/* ReadableStreamBYOBReader.ts */ +// initializeReadableStreamBYOBReader +const JSC::ConstructAbility s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeLength = 485; +static const JSC::Intrinsic s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCode = "(function (_){\"use strict\";if(!@isReadableStream(_))@throwTypeError(\"ReadableStreamBYOBReader needs a ReadableStream\");if(!@isReadableByteStreamController(@getByIdDirectPrivate(_,\"readableStreamController\")))@throwTypeError(\"ReadableStreamBYOBReader needs a ReadableByteStreamController\");if(@isReadableStreamLocked(_))@throwTypeError(\"ReadableStream is locked\");return @readableStreamReaderGenericInitialize(this,_),@putByIdDirectPrivate(this,\"readIntoRequests\",@createFIFO()),this})\n"; + +// cancel +const JSC::ConstructAbility s_readableStreamBYOBReaderCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamBYOBReaderCancelCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamBYOBReaderCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamBYOBReaderCancelCodeLength = 351; +static const JSC::Intrinsic s_readableStreamBYOBReaderCancelCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamBYOBReaderCancelCode = "(function (r){\"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,r)})\n"; + +// read +const JSC::ConstructAbility s_readableStreamBYOBReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamBYOBReaderReadCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamBYOBReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamBYOBReaderReadCodeLength = 648; +static const JSC::Intrinsic s_readableStreamBYOBReaderReadCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamBYOBReaderReadCode = "(function (n){\"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(n))return @Promise.@reject(@makeTypeError(\"Provided view is not an object\"));if(!@ArrayBuffer.@isView(n))return @Promise.@reject(@makeTypeError(\"Provided view is not an ArrayBufferView\"));if(n.byteLength===0)return @Promise.@reject(@makeTypeError(\"Provided view cannot have a 0 byteLength\"));return @readableStreamBYOBReaderRead(this,n)})\n"; + +// releaseLock +const JSC::ConstructAbility s_readableStreamBYOBReaderReleaseLockCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamBYOBReaderReleaseLockCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamBYOBReaderReleaseLockCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamBYOBReaderReleaseLockCodeLength = 382; +static const JSC::Intrinsic s_readableStreamBYOBReaderReleaseLockCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamBYOBReaderReleaseLockCode = "(function (){\"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)})\n"; + +// closed +const JSC::ConstructAbility s_readableStreamBYOBReaderClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamBYOBReaderClosedCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamBYOBReaderClosedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamBYOBReaderClosedCodeLength = 219; +static const JSC::Intrinsic s_readableStreamBYOBReaderClosedCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamBYOBReaderClosedCode = "(function (){\"use strict\";if(!@isReadableStreamBYOBReader(this))return @Promise.@reject(@makeGetterTypeError(\"ReadableStreamBYOBReader\",\"closed\"));return @getByIdDirectPrivate(this,\"closedPromiseCapability\").@promise})\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 + +/* JSBufferConstructor.ts */ +// from +const JSC::ConstructAbility s_jsBufferConstructorFromCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_jsBufferConstructorFromCodeLength = 1107; +static const JSC::Intrinsic s_jsBufferConstructorFromCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_jsBufferConstructorFromCode = "(function (n){\"use strict\";if(@isUndefinedOrNull(n))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof n===\"string\"||typeof n===\"object\"&&(@isTypedArrayView(n)||n instanceof @ArrayBuffer||n instanceof SharedArrayBuffer||n instanceof String))switch(@argumentCount()){case 1:return new @Buffer(n);case 2:return new @Buffer(n,@argument(1));default:return new @Buffer(n,@argument(1),@argument(2))}var _=@toObject(n,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(_)){const f=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(f){const u=f.@call(n,\"string\");if(typeof u===\"string\")switch(@argumentCount()){case 1:return new @Buffer(u);case 2:return new @Buffer(u,@argument(1));default:return new @Buffer(u,@argument(1),@argument(2))}}if(!(\"length\"in _)||@isCallable(_))@throwTypeError(\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\")}return new @Buffer(@Uint8Array.from(_).buffer)})\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().jsBufferConstructorBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().jsBufferConstructorBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ +} +WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) +#undef DEFINE_BUILTIN_GENERATOR + +/* ReadableStreamDefaultReader.ts */ +// initializeReadableStreamDefaultReader +const JSC::ConstructAbility s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeLength = 314; +static const JSC::Intrinsic s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCode = "(function (n){\"use strict\";if(!@isReadableStream(n))@throwTypeError(\"ReadableStreamDefaultReader needs a ReadableStream\");if(@isReadableStreamLocked(n))@throwTypeError(\"ReadableStream is locked\");return @readableStreamReaderGenericInitialize(this,n),@putByIdDirectPrivate(this,\"readRequests\",@createFIFO()),this})\n"; + +// cancel +const JSC::ConstructAbility s_readableStreamDefaultReaderCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamDefaultReaderCancelCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamDefaultReaderCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamDefaultReaderCancelCodeLength = 357; +static const JSC::Intrinsic s_readableStreamDefaultReaderCancelCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamDefaultReaderCancelCode = "(function (e){\"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,e)})\n"; + +// readMany +const JSC::ConstructAbility s_readableStreamDefaultReaderReadManyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamDefaultReaderReadManyCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamDefaultReaderReadManyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamDefaultReaderReadManyCodeLength = 2598; +static const JSC::Intrinsic s_readableStreamDefaultReaderReadManyCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamDefaultReaderReadManyCode = "(function (){\"use strict\";if(!@isReadableStreamDefaultReader(this))@throwTypeError(\"ReadableStreamDefaultReader.readMany() should not be called directly\");const _=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!_)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const d=@getByIdDirectPrivate(_,\"state\");if(@putByIdDirectPrivate(_,\"disturbed\",!0),d===@streamClosed)return{value:[],size:0,done:!0};else if(d===@streamErrored)throw @getByIdDirectPrivate(_,\"storedError\");var S=@getByIdDirectPrivate(_,\"readableStreamController\"),D=@getByIdDirectPrivate(S,\"queue\");if(!D)return S.@pull(S).@then(function({done:B,value:C}){return B\?{done:!0,value:[],size:0}:{value:[C],size:1,done:!1}});const Q=D.content;var W=D.size,j=Q.toArray(!1),k=j.length;if(k>0){var w=@newArrayWithSize(k);if(@isReadableByteStreamController(S)){{const B=j[0];if(!(@ArrayBuffer.@isView(B)||B instanceof @ArrayBuffer))@putByValDirect(w,0,new @Uint8Array(B.buffer,B.byteOffset,B.byteLength));else @putByValDirect(w,0,B)}for(var x=1;x<k;x++){const B=j[x];if(!(@ArrayBuffer.@isView(B)||B instanceof @ArrayBuffer))@putByValDirect(w,x,new @Uint8Array(B.buffer,B.byteOffset,B.byteLength));else @putByValDirect(w,x,B)}}else{@putByValDirect(w,0,j[0].value);for(var x=1;x<k;x++)@putByValDirect(w,x,j[x].value)}if(@resetQueue(@getByIdDirectPrivate(S,\"queue\")),@getByIdDirectPrivate(S,\"closeRequested\"))@readableStreamClose(@getByIdDirectPrivate(S,\"controlledReadableStream\"));else if(@isReadableStreamDefaultController(S))@readableStreamDefaultControllerCallPullIfNeeded(S);else if(@isReadableByteStreamController(S))@readableByteStreamControllerCallPullIfNeeded(S);return{value:w,size:W,done:!1}}var y=(B)=>{if(B.done)return{value:[],size:0,done:!0};var C=@getByIdDirectPrivate(_,\"readableStreamController\"),E=@getByIdDirectPrivate(C,\"queue\"),F=[B.value].concat(E.content.toArray(!1)),G=F.length;if(@isReadableByteStreamController(C))for(var H=0;H<G;H++){const J=F[H];if(!(@ArrayBuffer.@isView(J)||J instanceof @ArrayBuffer)){const{buffer:K,byteOffset:N,byteLength:T}=J;@putByValDirect(F,H,new @Uint8Array(K,N,T))}}else for(var H=1;H<G;H++)@putByValDirect(F,H,F[H].value);var I=E.size;if(@resetQueue(E),@getByIdDirectPrivate(C,\"closeRequested\"))@readableStreamClose(@getByIdDirectPrivate(C,\"controlledReadableStream\"));else if(@isReadableStreamDefaultController(C))@readableStreamDefaultControllerCallPullIfNeeded(C);else if(@isReadableByteStreamController(C))@readableByteStreamControllerCallPullIfNeeded(C);return{value:F,size:I,done:!1}},A=S.@pull(S);if(A&&@isPromise(A))return A.@then(y);return y(A)})\n"; + +// read +const JSC::ConstructAbility s_readableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamDefaultReaderReadCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamDefaultReaderReadCodeLength = 348; +static const JSC::Intrinsic s_readableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamDefaultReaderReadCode = "(function (){\"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)})\n"; + +// releaseLock +const JSC::ConstructAbility s_readableStreamDefaultReaderReleaseLockCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamDefaultReaderReleaseLockCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamDefaultReaderReleaseLockCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamDefaultReaderReleaseLockCodeLength = 384; +static const JSC::Intrinsic s_readableStreamDefaultReaderReleaseLockCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamDefaultReaderReleaseLockCode = "(function (){\"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)})\n"; + +// closed +const JSC::ConstructAbility s_readableStreamDefaultReaderClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamDefaultReaderClosedCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamDefaultReaderClosedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamDefaultReaderClosedCodeLength = 225; +static const JSC::Intrinsic s_readableStreamDefaultReaderClosedCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamDefaultReaderClosedCode = "(function (){\"use strict\";if(!@isReadableStreamDefaultReader(this))return @Promise.@reject(@makeGetterTypeError(\"ReadableStreamDefaultReader\",\"closed\"));return @getByIdDirectPrivate(this,\"closedPromiseCapability\").@promise})\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 + +/* StreamInternals.ts */ +// markPromiseAsHandled +const JSC::ConstructAbility s_streamInternalsMarkPromiseAsHandledCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsMarkPromiseAsHandledCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsMarkPromiseAsHandledCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsMarkPromiseAsHandledCodeLength = 169; +static const JSC::Intrinsic s_streamInternalsMarkPromiseAsHandledCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsMarkPromiseAsHandledCode = "(function (_){\"use strict\";@assert(@isPromise(_)),@putPromiseInternalField(_,@promiseFieldFlags,@getPromiseInternalField(_,@promiseFieldFlags)|@promiseFlagsIsHandled)})\n"; + +// shieldingPromiseResolve +const JSC::ConstructAbility s_streamInternalsShieldingPromiseResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsShieldingPromiseResolveCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsShieldingPromiseResolveCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsShieldingPromiseResolveCodeLength = 124; +static const JSC::Intrinsic s_streamInternalsShieldingPromiseResolveCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsShieldingPromiseResolveCode = "(function (a){\"use strict\";const d=@Promise.@resolve(a);if(d.@then===@undefined)d.@then=@Promise.prototype.@then;return d})\n"; + +// promiseInvokeOrNoopMethodNoCatch +const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeLength = 125; +static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCode = "(function (_,n,p){\"use strict\";if(n===@undefined)return @Promise.@resolve();return @shieldingPromiseResolve(n.@apply(_,p))})\n"; + +// promiseInvokeOrNoopNoCatch +const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopNoCatchCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsPromiseInvokeOrNoopNoCatchCodeLength = 84; +static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopNoCatchCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsPromiseInvokeOrNoopNoCatchCode = "(function (d,i,n){\"use strict\";return @promiseInvokeOrNoopMethodNoCatch(d,d[i],n)})\n"; + +// promiseInvokeOrNoopMethod +const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopMethodCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopMethodCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopMethodCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsPromiseInvokeOrNoopMethodCodeLength = 122; +static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopMethodCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsPromiseInvokeOrNoopMethodCode = "(function (n,p,u){\"use strict\";try{return @promiseInvokeOrNoopMethodNoCatch(n,p,u)}catch(P){return @Promise.@reject(P)}})\n"; + +// promiseInvokeOrNoop +const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsPromiseInvokeOrNoopCodeLength = 116; +static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrNoopCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsPromiseInvokeOrNoopCode = "(function (n,d,p){\"use strict\";try{return @promiseInvokeOrNoopNoCatch(n,d,p)}catch(u){return @Promise.@reject(u)}})\n"; + +// promiseInvokeOrFallbackOrNoop +const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeLength = 198; +static const JSC::Intrinsic s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsPromiseInvokeOrFallbackOrNoopCode = "(function (p,i,n,u,P){\"use strict\";try{const _=p[i];if(_===@undefined)return @promiseInvokeOrNoopNoCatch(p,u,P);return @shieldingPromiseResolve(_.@apply(p,n))}catch(_){return @Promise.@reject(_)}})\n"; + +// validateAndNormalizeQueuingStrategy +const JSC::ConstructAbility s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsValidateAndNormalizeQueuingStrategyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsValidateAndNormalizeQueuingStrategyCodeLength = 263; +static const JSC::Intrinsic s_streamInternalsValidateAndNormalizeQueuingStrategyCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsValidateAndNormalizeQueuingStrategyCode = "(function (d,_){\"use strict\";if(d!==@undefined&&typeof d!==\"function\")@throwTypeError(\"size parameter must be a function\");const b=@toNumber(_);if(@isNaN(b)||b<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return{size:d,highWaterMark:b}})\n"; + +// createFIFO +const JSC::ConstructAbility s_streamInternalsCreateFIFOCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsCreateFIFOCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsCreateFIFOCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_streamInternalsCreateFIFOCodeLength = 1472; +static const JSC::Intrinsic s_streamInternalsCreateFIFOCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var g=@Array.prototype.slice;class b{constructor(){this._head=0,this._tail=0,this._capacityMask=3,this._list=@newArrayWithSize(4)}_head;_tail;_capacityMask;_list;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:k,_tail:v,_list:w,_capacityMask:x}=this;if(k===v)return @undefined;var z=w[k];if(@putByValDirect(w,k,@undefined),k=this._head=k+1&x,k<2&&v>1e4&&v<=w.length>>>2)this._shrinkArray();return z}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(k){var v=this._tail;if(@putByValDirect(this._list,v,k),this._tail=v+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(k){var v=this._list,w=@toLength(v.length);if(k||this._head>this._tail){var x=@toLength(this._head),z=@toLength(this._tail),A=@toLength(w-x+z),B=@newArrayWithSize(A),E=0;for(var F=x;F<w;F++)@putByValDirect(B,E++,v[F]);for(var F=0;F<z;F++)@putByValDirect(B,E++,v[F]);return B}else return g.@call(v,this._head,this._tail)}clear(){this._head=0,this._tail=0,this._list.fill(@undefined)}_growArray(){if(this._head)this._list=this.toArray(!0),this._head=0;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 b})\n"; + +// newQueue +const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsNewQueueCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsNewQueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsNewQueueCodeLength = 65; +static const JSC::Intrinsic s_streamInternalsNewQueueCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsNewQueueCode = "(function (){\"use strict\";return{content:@createFIFO(),size:0}})\n"; + +// dequeueValue +const JSC::ConstructAbility s_streamInternalsDequeueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsDequeueValueCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsDequeueValueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsDequeueValueCodeLength = 106; +static const JSC::Intrinsic s_streamInternalsDequeueValueCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsDequeueValueCode = "(function (a){\"use strict\";const n=a.content.shift();if(a.size-=n.size,a.size<0)a.size=0;return n.value})\n"; + +// enqueueValueWithSize +const JSC::ConstructAbility s_streamInternalsEnqueueValueWithSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsEnqueueValueWithSizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsEnqueueValueWithSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsEnqueueValueWithSizeCodeLength = 161; +static const JSC::Intrinsic s_streamInternalsEnqueueValueWithSizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsEnqueueValueWithSizeCode = "(function (r,c,d){\"use strict\";if(d=@toNumber(d),!@isFinite(d)||d<0)@throwRangeError(\"size has an incorrect value\");r.content.push({value:c,size:d}),r.size+=d})\n"; + +// peekQueueValue +const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsPeekQueueValueCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsPeekQueueValueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsPeekQueueValueCodeLength = 60; +static const JSC::Intrinsic s_streamInternalsPeekQueueValueCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsPeekQueueValueCode = "(function (a){\"use strict\";return a.content.peek()\?.value})\n"; + +// resetQueue +const JSC::ConstructAbility s_streamInternalsResetQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsResetQueueCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsResetQueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsResetQueueCodeLength = 99; +static const JSC::Intrinsic s_streamInternalsResetQueueCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsResetQueueCode = "(function (a){\"use strict\";@assert(\"content\"in a),@assert(\"size\"in a),a.content.clear(),a.size=0})\n"; + +// extractSizeAlgorithm +const JSC::ConstructAbility s_streamInternalsExtractSizeAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsExtractSizeAlgorithmCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsExtractSizeAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsExtractSizeAlgorithmCodeLength = 176; +static const JSC::Intrinsic s_streamInternalsExtractSizeAlgorithmCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsExtractSizeAlgorithmCode = "(function (d){\"use strict\";const p=d.size;if(p===@undefined)return()=>1;if(typeof p!==\"function\")@throwTypeError(\"strategy.size must be a function\");return(_)=>{return p(_)}})\n"; + +// extractHighWaterMark +const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsExtractHighWaterMarkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsExtractHighWaterMarkCodeLength = 188; +static const JSC::Intrinsic s_streamInternalsExtractHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsExtractHighWaterMarkCode = "(function (n,c){\"use strict\";const p=n.highWaterMark;if(p===@undefined)return c;if(@isNaN(p)||p<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return @toNumber(p)})\n"; + +// extractHighWaterMarkFromQueuingStrategyInit +const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeLength = 249; +static const JSC::Intrinsic s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCode = "(function (_){\"use strict\";if(!@isObject(_))@throwTypeError(\"QueuingStrategyInit argument must be an object.\");const{highWaterMark:e}=_;if(e===@undefined)@throwTypeError(\"QueuingStrategyInit.highWaterMark member is required.\");return @toNumber(e)})\n"; + +// createFulfilledPromise +const JSC::ConstructAbility s_streamInternalsCreateFulfilledPromiseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsCreateFulfilledPromiseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsCreateFulfilledPromiseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsCreateFulfilledPromiseCodeLength = 81; +static const JSC::Intrinsic s_streamInternalsCreateFulfilledPromiseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsCreateFulfilledPromiseCode = "(function (n){\"use strict\";const r=@newPromise();return @fulfillPromise(r,n),r})\n"; + +// toDictionary +const JSC::ConstructAbility s_streamInternalsToDictionaryCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_streamInternalsToDictionaryCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_streamInternalsToDictionaryCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_streamInternalsToDictionaryCodeLength = 115; +static const JSC::Intrinsic s_streamInternalsToDictionaryCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_streamInternalsToDictionaryCode = "(function (n,_,b){\"use strict\";if(n===@undefined||n===null)return _;if(!@isObject(n))@throwTypeError(b);return 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 + +/* ImportMetaObject.ts */ +// loadCJS2ESM +const JSC::ConstructAbility s_importMetaObjectLoadCJS2ESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_importMetaObjectLoadCJS2ESMCodeLength = 1309; +static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (_){\"use strict\";var F=@Loader,W=@createFIFO(),b=_;while(b){var w=F.registry.@get(b);if(!w||!w.state||w.state<=@ModuleFetch)@fulfillModuleSync(b),w=F.registry.@get(b);var x=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),z=F.parseModule(b,x),B=w.module;if(!B&&z&&@isPromise(z)){var D=@getPromiseInternalField(z,@promiseFieldReactionsOrResult),G=@getPromiseInternalField(z,@promiseFieldFlags),H=G&@promiseStateMask;if(H===@promiseStatePending||D&&@isPromise(D))@throwTypeError(`require() async module \"${b}\" is unsupported`);else if(H===@promiseStateRejected)@throwTypeError(`${D\?.message\?\?\"An error occurred\"} while parsing module \\\"${b}\\\"`);w.module=B=D}else if(z&&!B)w.module=B=z;@setStateToMax(w,@ModuleLink);var I=B.dependenciesMap,J=F.requestedModules(B),L=@newArrayWithSize(J.length);for(var Q=0,T=J.length;Q<T;++Q){var U=J[Q],V=U[0]===\"/\"\?U:F.resolve(U,b),X=F.ensureRegistered(V);if(X.state<@ModuleLink)W.push(V);@putByValDirect(L,Q,X),I.@set(U,X)}w.dependencies=L,w.instantiate=@Promise.resolve(w),w.satisfy=@Promise.resolve(w),b=W.shift();while(b&&(F.registry.@get(b)\?.state\?\?@ModuleFetch)>=@ModuleLink)b=W.shift()}var Y=F.linkAndEvaluateModule(_,@undefined);if(Y&&@isPromise(Y))@throwTypeError(`require() async module \\\"${_}\\\" is unsupported`);return F.registry.@get(_)})\n"; + +// requireESM +const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_importMetaObjectRequireESMCodeLength = 382; +static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_importMetaObjectRequireESMCode = "(function (a){\"use strict\";var i=@Loader.registry.@get(a);if(!i||!i.evaluated)i=@loadCJS2ESM(a);if(!i||!i.evaluated||!i.module)@throwTypeError(`require() failed to evaluate module \"${a}\". This is an internal consistentency error.`);var E=@Loader.getModuleNamespaceObject(i.module),_=E.default,b=_\?.[@commonJSSymbol];if(b===0)return _;else if(b&&@isCallable(_))return _();return E})\n"; + +// internalRequire +const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_importMetaObjectInternalRequireCodeLength = 569; +static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_importMetaObjectInternalRequireCode = "(function (n){\"use strict\";var _=@requireMap.@get(n);const i=n.substring(n.length-5);if(_){if(i===\".node\")return _.exports;return _}if(i===\".json\"){var S=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),F=JSON.parse(S.readFileSync(n,\"utf8\"));return @requireMap.@set(n,F),F}else if(i===\".node\"){var b={exports:{}};return process.dlopen(b,n),@requireMap.@set(n,b),b.exports}else if(i===\".toml\"){var S=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),F=@Bun.TOML.parse(S.readFileSync(n,\"utf8\"));return @requireMap.@set(n,F),F}else{var F=@requireESM(n);return @requireMap.@set(n,F),F}})\n"; + +// require +const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_importMetaObjectRequireCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_importMetaObjectRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_importMetaObjectRequireCodeLength = 172; +static const JSC::Intrinsic s_importMetaObjectRequireCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_importMetaObjectRequireCode = "(function (r){var _=this\?.path\?\?arguments.callee.path;if(typeof r!==\"string\")@throwTypeError(\"require(name) must be a string\");return @internalRequire(@resolveSync(r,_))})\n"; + +// main +const JSC::ConstructAbility s_importMetaObjectMainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_importMetaObjectMainCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_importMetaObjectMainCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_importMetaObjectMainCodeLength = 57; +static const JSC::Intrinsic s_importMetaObjectMainCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_importMetaObjectMainCode = "(function (){\"use strict\";return this.path===@Bun.main})\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().importMetaObjectBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().importMetaObjectBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ +} +WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) +#undef DEFINE_BUILTIN_GENERATOR + +/* CountQueuingStrategy.ts */ +// highWaterMark +const JSC::ConstructAbility s_countQueuingStrategyHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_countQueuingStrategyHighWaterMarkCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_countQueuingStrategyHighWaterMarkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_countQueuingStrategyHighWaterMarkCodeLength = 205; +static const JSC::Intrinsic s_countQueuingStrategyHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_countQueuingStrategyHighWaterMarkCode = "(function (){\"use strict\";const c=@getByIdDirectPrivate(this,\"highWaterMark\");if(c===@undefined)@throwTypeError(\"CountQueuingStrategy.highWaterMark getter called on incompatible |this| value.\");return c})\n"; + +// size +const JSC::ConstructAbility s_countQueuingStrategySizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_countQueuingStrategySizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_countQueuingStrategySizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_countQueuingStrategySizeCodeLength = 37; +static const JSC::Intrinsic s_countQueuingStrategySizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_countQueuingStrategySizeCode = "(function (){\"use strict\";return 1})\n"; + +// initializeCountQueuingStrategy +const JSC::ConstructAbility s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_countQueuingStrategyInitializeCountQueuingStrategyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_countQueuingStrategyInitializeCountQueuingStrategyCodeLength = 121; +static const JSC::Intrinsic s_countQueuingStrategyInitializeCountQueuingStrategyCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_countQueuingStrategyInitializeCountQueuingStrategyCode = "(function (c){\"use strict\";@putByIdDirectPrivate(this,\"highWaterMark\",@extractHighWaterMarkFromQueuingStrategyInit(c))})\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 + +/* ReadableStreamBYOBRequest.ts */ +// initializeReadableStreamBYOBRequest +const JSC::ConstructAbility s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeLength = 243; +static const JSC::Intrinsic s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCode = "(function (d,O){\"use strict\";if(arguments.length!==3&&arguments[2]!==@isReadableStream)@throwTypeError(\"ReadableStreamBYOBRequest constructor should not be called directly\");return @privateInitializeReadableStreamBYOBRequest.@call(this,d,O)})\n"; + +// respond +const JSC::ConstructAbility s_readableStreamBYOBRequestRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamBYOBRequestRespondCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamBYOBRequestRespondCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamBYOBRequestRespondCodeLength = 430; +static const JSC::Intrinsic s_readableStreamBYOBRequestRespondCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamBYOBRequestRespondCode = "(function (e){\"use strict\";if(!@isReadableStreamBYOBRequest(this))throw @makeThisTypeError(\"ReadableStreamBYOBRequest\",\"respond\");if(@getByIdDirectPrivate(this,\"associatedReadableByteStreamController\")===@undefined)@throwTypeError(\"ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined\");return @readableByteStreamControllerRespond(@getByIdDirectPrivate(this,\"associatedReadableByteStreamController\"),e)})\n"; + +// respondWithNewView +const JSC::ConstructAbility s_readableStreamBYOBRequestRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamBYOBRequestRespondWithNewViewCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamBYOBRequestRespondWithNewViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamBYOBRequestRespondWithNewViewCodeLength = 595; +static const JSC::Intrinsic s_readableStreamBYOBRequestRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamBYOBRequestRespondWithNewViewCode = "(function (t){\"use strict\";if(!@isReadableStreamBYOBRequest(this))throw @makeThisTypeError(\"ReadableStreamBYOBRequest\",\"respond\");if(@getByIdDirectPrivate(this,\"associatedReadableByteStreamController\")===@undefined)@throwTypeError(\"ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined\");if(!@isObject(t))@throwTypeError(\"Provided view is not an object\");if(!@ArrayBuffer.@isView(t))@throwTypeError(\"Provided view is not an ArrayBufferView\");return @readableByteStreamControllerRespondWithNewView(@getByIdDirectPrivate(this,\"associatedReadableByteStreamController\"),t)})\n"; + +// view +const JSC::ConstructAbility s_readableStreamBYOBRequestViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamBYOBRequestViewCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamBYOBRequestViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamBYOBRequestViewCodeLength = 172; +static const JSC::Intrinsic s_readableStreamBYOBRequestViewCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamBYOBRequestViewCode = "(function (){\"use strict\";if(!@isReadableStreamBYOBRequest(this))throw @makeGetterTypeError(\"ReadableStreamBYOBRequest\",\"view\");return @getByIdDirectPrivate(this,\"view\")})\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 + +/* WritableStreamDefaultWriter.ts */ +// initializeWritableStreamDefaultWriter +const JSC::ConstructAbility s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeLength = 237; +static const JSC::Intrinsic s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCode = "(function (d){\"use strict\";const u=@getInternalWritableStream(d);if(u)d=u;if(!@isWritableStream(d))@throwTypeError(\"WritableStreamDefaultWriter constructor takes a WritableStream\");return @setUpWritableStreamDefaultWriter(this,d),this})\n"; + +// closed +const JSC::ConstructAbility s_writableStreamDefaultWriterClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamDefaultWriterClosedCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamDefaultWriterClosedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamDefaultWriterClosedCodeLength = 215; +static const JSC::Intrinsic s_writableStreamDefaultWriterClosedCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamDefaultWriterClosedCode = "(function (){\"use strict\";if(!@isWritableStreamDefaultWriter(this))return @Promise.@reject(@makeGetterTypeError(\"WritableStreamDefaultWriter\",\"closed\"));return @getByIdDirectPrivate(this,\"closedPromise\").@promise})\n"; + +// desiredSize +const JSC::ConstructAbility s_writableStreamDefaultWriterDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamDefaultWriterDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamDefaultWriterDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamDefaultWriterDesiredSizeCodeLength = 309; +static const JSC::Intrinsic s_writableStreamDefaultWriterDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamDefaultWriterDesiredSizeCode = "(function (){\"use strict\";if(!@isWritableStreamDefaultWriter(this))throw @makeThisTypeError(\"WritableStreamDefaultWriter\",\"desiredSize\");if(@getByIdDirectPrivate(this,\"stream\")===@undefined)@throwTypeError(\"WritableStreamDefaultWriter has no stream\");return @writableStreamDefaultWriterGetDesiredSize(this)})\n"; + +// ready +const JSC::ConstructAbility s_writableStreamDefaultWriterReadyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamDefaultWriterReadyCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamDefaultWriterReadyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamDefaultWriterReadyCodeLength = 211; +static const JSC::Intrinsic s_writableStreamDefaultWriterReadyCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamDefaultWriterReadyCode = "(function (){\"use strict\";if(!@isWritableStreamDefaultWriter(this))return @Promise.@reject(@makeThisTypeError(\"WritableStreamDefaultWriter\",\"ready\"));return @getByIdDirectPrivate(this,\"readyPromise\").@promise})\n"; + +// abort +const JSC::ConstructAbility s_writableStreamDefaultWriterAbortCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamDefaultWriterAbortCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamDefaultWriterAbortCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamDefaultWriterAbortCodeLength = 340; +static const JSC::Intrinsic s_writableStreamDefaultWriterAbortCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamDefaultWriterAbortCode = "(function (r){\"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,r)})\n"; + +// close +const JSC::ConstructAbility s_writableStreamDefaultWriterCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamDefaultWriterCloseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamDefaultWriterCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamDefaultWriterCloseCodeLength = 477; +static const JSC::Intrinsic s_writableStreamDefaultWriterCloseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamDefaultWriterCloseCode = "(function (){\"use strict\";if(!@isWritableStreamDefaultWriter(this))return @Promise.@reject(@makeThisTypeError(\"WritableStreamDefaultWriter\",\"close\"));const e=@getByIdDirectPrivate(this,\"stream\");if(e===@undefined)return @Promise.@reject(@makeTypeError(\"WritableStreamDefaultWriter has no stream\"));if(@writableStreamCloseQueuedOrInFlight(e))return @Promise.@reject(@makeTypeError(\"WritableStreamDefaultWriter is being closed\"));return @writableStreamDefaultWriterClose(this)})\n"; + +// releaseLock +const JSC::ConstructAbility s_writableStreamDefaultWriterReleaseLockCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamDefaultWriterReleaseLockCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamDefaultWriterReleaseLockCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamDefaultWriterReleaseLockCodeLength = 307; +static const JSC::Intrinsic s_writableStreamDefaultWriterReleaseLockCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamDefaultWriterReleaseLockCode = "(function (){\"use strict\";if(!@isWritableStreamDefaultWriter(this))throw @makeThisTypeError(\"WritableStreamDefaultWriter\",\"releaseLock\");const c=@getByIdDirectPrivate(this,\"stream\");if(c===@undefined)return;@assert(@getByIdDirectPrivate(c,\"writer\")!==@undefined),@writableStreamDefaultWriterRelease(this)})\n"; + +// write +const JSC::ConstructAbility s_writableStreamDefaultWriterWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamDefaultWriterWriteCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamDefaultWriterWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamDefaultWriterWriteCodeLength = 340; +static const JSC::Intrinsic s_writableStreamDefaultWriterWriteCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamDefaultWriterWriteCode = "(function (_){\"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,_)})\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 + +/* ReadableStream.ts */ +// initializeReadableStream +const JSC::ConstructAbility s_readableStreamInitializeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamInitializeReadableStreamCodeLength = 2065; +static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,f){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(f===@undefined)f={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(f!==@undefined&&!@isObject(f))@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\",!1),@putByIdDirectPrivate(this,\"readableStreamController\",null),@putByIdDirectPrivate(this,\"bunNativeType\",@getByIdDirectPrivate(_,\"bunNativeType\")\?\?0),@putByIdDirectPrivate(this,\"bunNativePtr\",@getByIdDirectPrivate(_,\"bunNativePtr\")\?\?0);const I=_.type===\"direct\",P=!!_.@lazy,b=I||P;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!b){const j=@getByIdDirectPrivate(f,\"size\"),m=@getByIdDirectPrivate(f,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",m),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,j,m!==@undefined\?m:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(I)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,f));else if(b){const j=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",j||@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const m=@lazyLoadStream(this,j);if(m)@createReadableStreamController(this,m,f)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(f,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,f);return this})\n"; + +// readableStreamToArray +const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamReadableStreamToArrayCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_readableStreamReadableStreamToArrayCodeLength = 173; +static const JSC::Intrinsic s_readableStreamReadableStreamToArrayCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamReadableStreamToArrayCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToArrayDirect(_,p);return @readableStreamIntoArray(_)})\n"; + +// readableStreamToText +const JSC::ConstructAbility s_readableStreamReadableStreamToTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamReadableStreamToTextCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamReadableStreamToTextCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_readableStreamReadableStreamToTextCodeLength = 171; +static const JSC::Intrinsic s_readableStreamReadableStreamToTextCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamReadableStreamToTextCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToTextDirect(_,p);return @readableStreamIntoText(_)})\n"; + +// readableStreamToArrayBuffer +const JSC::ConstructAbility s_readableStreamReadableStreamToArrayBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_readableStreamReadableStreamToArrayBufferCodeLength = 212; +static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToArrayBufferDirect(_,p);return @Bun.readableStreamToArray(_).@then(@Bun.concatArrayBuffers)})\n"; + +// readableStreamToJSON +const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamReadableStreamToJSONCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamReadableStreamToJSONCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_readableStreamReadableStreamToJSONCodeLength = 94; +static const JSC::Intrinsic s_readableStreamReadableStreamToJSONCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamReadableStreamToJSONCode = "(function (d){\"use strict\";return @Bun.readableStreamToText(d).@then(globalThis.JSON.parse)})\n"; + +// readableStreamToBlob +const JSC::ConstructAbility s_readableStreamReadableStreamToBlobCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamReadableStreamToBlobCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamReadableStreamToBlobCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_readableStreamReadableStreamToBlobCodeLength = 108; +static const JSC::Intrinsic s_readableStreamReadableStreamToBlobCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamReadableStreamToBlobCode = "(function (d){\"use strict\";return @Promise.resolve(@Bun.readableStreamToArray(d)).@then((_)=>new Blob(_))})\n"; + +// consumeReadableStream +const JSC::ConstructAbility s_readableStreamConsumeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamConsumeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamConsumeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_readableStreamConsumeReadableStreamCodeLength = 1603; +static const JSC::Intrinsic s_readableStreamConsumeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamConsumeReadableStreamCode = "(function (_,I,j){\"use strict\";const k=globalThis.Symbol.for(\"Bun.consumeReadableStreamPrototype\");var q=globalThis[k];if(!q)q=globalThis[k]=[];var w=q[I];if(w===@undefined){var[x,A,B,D,F,G]=globalThis[globalThis.Symbol.for(\"Bun.lazy\")](I);w=class J{handleError;handleClosed;processResult;constructor(K,L){this.#_=L,this.#I=K,this.#$=!1,this.handleError=this._handleError.bind(this),this.handleClosed=this._handleClosed.bind(this),this.processResult=this._processResult.bind(this),K.closed.then(this.handleClosed,this.handleError)}_handleClosed(){if(this.#$)return;this.#$=!0;var K=this.#_;this.#_=0,D(K),G(K)}_handleError(K){if(this.#$)return;this.#$=!0;var L=this.#_;this.#_=0,A(L,K),G(L)}#_;#$=!1;#I;_handleReadMany({value:K,done:L,size:N}){if(L){this.handleClosed();return}if(this.#$)return;B(this.#_,K,L,N)}read(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#I.read())}_processResult(K){if(K&&@isPromise(K)){if(@getPromiseInternalField(K,@promiseFieldFlags)&@promiseStateFulfilled){const N=@getPromiseInternalField(K,@promiseFieldReactionsOrResult);if(N)K=N}}if(K&&@isPromise(K))return K.then(this.processResult,this.handleError),null;if(K.done)return this.handleClosed(),0;else if(K.value)return K.value;else return-1}readMany(){if(!this.#_)return @throwTypeError(\"ReadableStreamSink is already closed\");return this.processResult(this.#I.readMany())}};const H=I+1;if(q.length<H)q.length=H;@putByValDirect(q,I,w)}if(@isReadableStreamLocked(j))@throwTypeError(\"Cannot start reading from a locked stream\");return new w(j.getReader(),_)})\n"; + +// createEmptyReadableStream +const JSC::ConstructAbility s_readableStreamCreateEmptyReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamCreateEmptyReadableStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamCreateEmptyReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_readableStreamCreateEmptyReadableStreamCodeLength = 99; +static const JSC::Intrinsic s_readableStreamCreateEmptyReadableStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamCreateEmptyReadableStreamCode = "(function (){\"use strict\";var d=new @ReadableStream({pull(){}});return @readableStreamClose(d),d})\n"; + +// createNativeReadableStream +const JSC::ConstructAbility s_readableStreamCreateNativeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamCreateNativeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamCreateNativeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_readableStreamCreateNativeReadableStreamCodeLength = 129; +static const JSC::Intrinsic s_readableStreamCreateNativeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamCreateNativeReadableStreamCode = "(function (_,d,m){\"use strict\";return new @ReadableStream({@lazy:!0,@bunNativeType:d,@bunNativePtr:_,autoAllocateChunkSize:m})})\n"; + +// cancel +const JSC::ConstructAbility s_readableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamCancelCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamCancelCodeLength = 266; +static const JSC::Intrinsic s_readableStreamCancelCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamCancelCode = "(function (d){\"use strict\";if(!@isReadableStream(this))return @Promise.@reject(@makeThisTypeError(\"ReadableStream\",\"cancel\"));if(@isReadableStreamLocked(this))return @Promise.@reject(@makeTypeError(\"ReadableStream is locked\"));return @readableStreamCancel(this,d)})\n"; + +// getReader +const JSC::ConstructAbility s_readableStreamGetReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamGetReaderCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamGetReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamGetReaderCodeLength = 470; +static const JSC::Intrinsic s_readableStreamGetReaderCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamGetReaderCode = "(function (d){\"use strict\";if(!@isReadableStream(this))throw @makeThisTypeError(\"ReadableStream\",\"getReader\");const c=@toDictionary(d,{},\"ReadableStream.getReader takes an object as first argument\").mode;if(c===@undefined){var e=@getByIdDirectPrivate(this,\"start\");if(e)@putByIdDirectPrivate(this,\"start\",@undefined),e();return new @ReadableStreamDefaultReader(this)}if(c==\"byob\")return new @ReadableStreamBYOBReader(this);@throwTypeError(\"Invalid mode is specified\")})\n"; + +// pipeThrough +const JSC::ConstructAbility s_readableStreamPipeThroughCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamPipeThroughCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamPipeThroughCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamPipeThroughCodeLength = 877; +static const JSC::Intrinsic s_readableStreamPipeThroughCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamPipeThroughCode = "(function (h,_){\"use strict\";const u=h,c=u[\"readable\"];if(!@isReadableStream(c))throw @makeTypeError(\"readable should be ReadableStream\");const d=u[\"writable\"],j=@getInternalWritableStream(d);if(!@isWritableStream(j))throw @makeTypeError(\"writable should be WritableStream\");let k=!1,q=!1,x=!1,y;if(!@isUndefinedOrNull(_)){if(!@isObject(_))throw @makeTypeError(\"options must be an object\");if(q=!!_[\"preventAbort\"],x=!!_[\"preventCancel\"],k=!!_[\"preventClose\"],y=_[\"signal\"],y!==@undefined&&!@isAbortSignal(y))throw @makeTypeError(\"options.signal must be AbortSignal\")}if(!@isReadableStream(this))throw @makeThisTypeError(\"ReadableStream\",\"pipeThrough\");if(@isReadableStreamLocked(this))throw @makeTypeError(\"ReadableStream is locked\");if(@isWritableStreamLocked(j))throw @makeTypeError(\"WritableStream is locked\");return @readableStreamPipeToWritableStream(this,j,k,q,x,y),c})\n"; + +// pipeTo +const JSC::ConstructAbility s_readableStreamPipeToCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamPipeToCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamPipeToCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamPipeToCodeLength = 926; +static const JSC::Intrinsic s_readableStreamPipeToCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamPipeToCode = "(function (_){\"use strict\";if(!@isReadableStream(this))return @Promise.@reject(@makeThisTypeError(\"ReadableStream\",\"pipeTo\"));if(@isReadableStreamLocked(this))return @Promise.@reject(@makeTypeError(\"ReadableStream is locked\"));let m=@argument(1),k=!1,P=!1,S=!1,f;if(!@isUndefinedOrNull(m)){if(!@isObject(m))return @Promise.@reject(@makeTypeError(\"options must be an object\"));try{P=!!m[\"preventAbort\"],S=!!m[\"preventCancel\"],k=!!m[\"preventClose\"],f=m[\"signal\"]}catch(j){return @Promise.@reject(j)}if(f!==@undefined&&!@isAbortSignal(f))return @Promise.@reject(@makeTypeError(\"options.signal must be AbortSignal\"))}const h=@getInternalWritableStream(_);if(!@isWritableStream(h))return @Promise.@reject(@makeTypeError(\"ReadableStream pipeTo requires a WritableStream\"));if(@isWritableStreamLocked(h))return @Promise.@reject(@makeTypeError(\"WritableStream is locked\"));return @readableStreamPipeToWritableStream(this,h,k,P,S,f)})\n"; + +// tee +const JSC::ConstructAbility s_readableStreamTeeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamTeeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamTeeCodeLength = 140; +static const JSC::Intrinsic s_readableStreamTeeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamTeeCode = "(function (){\"use strict\";if(!@isReadableStream(this))throw @makeThisTypeError(\"ReadableStream\",\"tee\");return @readableStreamTee(this,!1)})\n"; + +// locked +const JSC::ConstructAbility s_readableStreamLockedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamLockedCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamLockedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamLockedCodeLength = 147; +static const JSC::Intrinsic s_readableStreamLockedCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamLockedCode = "(function (){\"use strict\";if(!@isReadableStream(this))throw @makeGetterTypeError(\"ReadableStream\",\"locked\");return @isReadableStreamLocked(this)})\n"; + +// values +const JSC::ConstructAbility s_readableStreamValuesCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamValuesCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamValuesCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamValuesCodeLength = 129; +static const JSC::Intrinsic s_readableStreamValuesCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamValuesCode = "(function (_){\"use strict\";var a=@ReadableStream.prototype;return @readableStreamDefineLazyIterators(a),a.values.@call(this,_)})\n"; + +// lazyAsyncIterator +const JSC::ConstructAbility s_readableStreamLazyAsyncIteratorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamLazyAsyncIteratorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamLazyAsyncIteratorCodeImplementationVisibility = JSC::ImplementationVisibility::Private; +const int s_readableStreamLazyAsyncIteratorCodeLength = 152; +static const JSC::Intrinsic s_readableStreamLazyAsyncIteratorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamLazyAsyncIteratorCode = "(function (){\"use strict\";var b=@ReadableStream.prototype;return @readableStreamDefineLazyIterators(b),b[globalThis.Symbol.asyncIterator].@call(this)})\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 + +/* ReadableStreamDefaultController.ts */ +// initializeReadableStreamDefaultController +const JSC::ConstructAbility s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeLength = 263; +static const JSC::Intrinsic s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCode = "(function (p,_,b,f){\"use strict\";if(arguments.length!==5&&arguments[4]!==@isReadableStream)@throwTypeError(\"ReadableStreamDefaultController constructor should not be called directly\");return @privateInitializeReadableStreamDefaultController.@call(this,p,_,b,f)})\n"; + +// enqueue +const JSC::ConstructAbility s_readableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamDefaultControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamDefaultControllerEnqueueCodeLength = 356; +static const JSC::Intrinsic s_readableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamDefaultControllerEnqueueCode = "(function (e){\"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,e)})\n"; + +// error +const JSC::ConstructAbility s_readableStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamDefaultControllerErrorCodeLength = 188; +static const JSC::Intrinsic s_readableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamDefaultControllerErrorCode = "(function (t){\"use strict\";if(!@isReadableStreamDefaultController(this))throw @makeThisTypeError(\"ReadableStreamDefaultController\",\"error\");@readableStreamDefaultControllerError(this,t)})\n"; + +// close +const JSC::ConstructAbility s_readableStreamDefaultControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamDefaultControllerCloseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamDefaultControllerCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamDefaultControllerCloseCodeLength = 337; +static const JSC::Intrinsic s_readableStreamDefaultControllerCloseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamDefaultControllerCloseCode = "(function (){\"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)})\n"; + +// desiredSize +const JSC::ConstructAbility s_readableStreamDefaultControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableStreamDefaultControllerDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableStreamDefaultControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableStreamDefaultControllerDesiredSizeCodeLength = 209; +static const JSC::Intrinsic s_readableStreamDefaultControllerDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isReadableStreamDefaultController(this))throw @makeGetterTypeError(\"ReadableStreamDefaultController\",\"desiredSize\");return @readableStreamDefaultControllerGetDesiredSize(this)})\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 + +/* ReadableByteStreamInternals.ts */ +// privateInitializeReadableByteStreamController +const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeLength = 1654; +static const JSC::Intrinsic s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (_,D,b){\"use strict\";if(!@isReadableStream(_))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(_,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",_),@putByIdDirectPrivate(this,\"underlyingByteSource\",D),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let p=@toNumber(b);if(@isNaN(p)||p<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",p);let f=D.autoAllocateChunkSize;if(f!==@undefined){if(f=@toNumber(f),f<=0||f===@Infinity||f===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",f),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const j=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(j,\"underlyingByteSource\"),\"start\",[j]).@then(()=>{@putByIdDirectPrivate(j,\"started\",1),@assert(!@getByIdDirectPrivate(j,\"pulling\")),@assert(!@getByIdDirectPrivate(j,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(j)},(q)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(j,q)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; + +// readableStreamByteStreamControllerStart +const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeLength = 73; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCode = "(function (a){\"use strict\";@putByIdDirectPrivate(a,\"start\",@undefined)})\n"; + +// privateInitializeReadableStreamBYOBRequest +const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeLength = 139; +static const JSC::Intrinsic s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCode = "(function (_,a){\"use strict\";@putByIdDirectPrivate(this,\"associatedReadableByteStreamController\",_),@putByIdDirectPrivate(this,\"view\",a)})\n"; + +// isReadableByteStreamController +const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableByteStreamControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsIsReadableByteStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsIsReadableByteStreamControllerCodeLength = 100; +static const JSC::Intrinsic s_readableByteStreamInternalsIsReadableByteStreamControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsIsReadableByteStreamControllerCode = "(function (a){\"use strict\";return @isObject(a)&&!!@getByIdDirectPrivate(a,\"underlyingByteSource\")})\n"; + +// isReadableStreamBYOBRequest +const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeLength = 118; +static const JSC::Intrinsic s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsIsReadableStreamBYOBRequestCode = "(function (r){\"use strict\";return @isObject(r)&&!!@getByIdDirectPrivate(r,\"associatedReadableByteStreamController\")})\n"; + +// isReadableStreamBYOBReader +const JSC::ConstructAbility s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeLength = 96; +static const JSC::Intrinsic s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsIsReadableStreamBYOBReaderCode = "(function (i){\"use strict\";return @isObject(i)&&!!@getByIdDirectPrivate(i,\"readIntoRequests\")})\n"; + +// readableByteStreamControllerCancel +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeLength = 248; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (_,d){\"use strict\";var b=@getByIdDirectPrivate(_,\"pendingPullIntos\"),g=b.peek();if(g)g.bytesFilled=0;return @putByIdDirectPrivate(_,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(_,\"underlyingByteSource\"),\"cancel\",[d])})\n"; + +// readableByteStreamControllerError +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeLength = 316; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerErrorCode = "(function (u,d){\"use strict\";@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(u,\"controlledReadableStream\"),\"state\")===@streamReadable),@readableByteStreamControllerClearPendingPullIntos(u),@putByIdDirectPrivate(u,\"queue\",@newQueue()),@readableStreamError(@getByIdDirectPrivate(u,\"controlledReadableStream\"),d)})\n"; + +// readableByteStreamControllerClose +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeLength = 569; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCloseCode = "(function (a){\"use strict\";if(@assert(!@getByIdDirectPrivate(a,\"closeRequested\")),@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(a,\"controlledReadableStream\"),\"state\")===@streamReadable),@getByIdDirectPrivate(a,\"queue\").size>0){@putByIdDirectPrivate(a,\"closeRequested\",!0);return}var d=@getByIdDirectPrivate(a,\"pendingPullIntos\")\?.peek();if(d){if(d.bytesFilled>0){const i=@makeTypeError(\"Close requested while there remain pending bytes\");throw @readableByteStreamControllerError(a,i),i}}@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"))})\n"; + +// readableByteStreamControllerClearPendingPullIntos +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeLength = 224; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCode = "(function (_){\"use strict\";@readableByteStreamControllerInvalidateBYOBRequest(_);var a=@getByIdDirectPrivate(_,\"pendingPullIntos\");if(a!==@undefined)a.clear();else @putByIdDirectPrivate(_,\"pendingPullIntos\",@createFIFO())})\n"; + +// readableByteStreamControllerGetDesiredSize +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeLength = 272; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (i){\"use strict\";const d=@getByIdDirectPrivate(i,\"controlledReadableStream\"),p=@getByIdDirectPrivate(d,\"state\");if(p===@streamErrored)return null;if(p===@streamClosed)return 0;return @getByIdDirectPrivate(i,\"strategyHWM\")-@getByIdDirectPrivate(i,\"queue\").size})\n"; + +// readableStreamHasBYOBReader +const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeLength = 125; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableStreamHasBYOBReaderCode = "(function (n){\"use strict\";const c=@getByIdDirectPrivate(n,\"reader\");return c!==@undefined&&@isReadableStreamBYOBReader(c)})\n"; + +// readableStreamHasDefaultReader +const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeLength = 128; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode = "(function (n){\"use strict\";const c=@getByIdDirectPrivate(n,\"reader\");return c!==@undefined&&@isReadableStreamDefaultReader(c)})\n"; + +// readableByteStreamControllerHandleQueueDrain +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeLength = 352; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCode = "(function (a){\"use strict\";if(@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(a,\"controlledReadableStream\"),\"state\")===@streamReadable),!@getByIdDirectPrivate(a,\"queue\").size&&@getByIdDirectPrivate(a,\"closeRequested\"))@readableStreamClose(@getByIdDirectPrivate(a,\"controlledReadableStream\"));else @readableByteStreamControllerCallPullIfNeeded(a)})\n"; + +// readableByteStreamControllerPull +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerPullCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1005; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const d=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(d)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const i=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=i.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let u;try{u=new @Uint8Array(i.buffer,i.byteOffset,i.byteLength)}catch(E){return @Promise.@reject(E)}return @createFulfilledPromise({value:u,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let i;try{i=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(E){return @Promise.@reject(E)}const u={buffer:i,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(u)}const a=@readableStreamAddReadRequest(d);return @readableByteStreamControllerCallPullIfNeeded(_),a})\n"; + +// readableByteStreamControllerShouldCallPull +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength = 619; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (i){\"use strict\";const u=@getByIdDirectPrivate(i,\"controlledReadableStream\");if(@getByIdDirectPrivate(u,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(i,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(i,\"started\")>0))return!1;const _=@getByIdDirectPrivate(u,\"reader\");if(_&&(@getByIdDirectPrivate(_,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(_,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(u)&&@getByIdDirectPrivate(@getByIdDirectPrivate(u,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(i)>0)return!0;return!1})\n"; + +// readableByteStreamControllerCallPullIfNeeded +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeLength = 670; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCode = "(function (p){\"use strict\";if(!@readableByteStreamControllerShouldCallPull(p))return;if(@getByIdDirectPrivate(p,\"pulling\")){@putByIdDirectPrivate(p,\"pullAgain\",!0);return}@assert(!@getByIdDirectPrivate(p,\"pullAgain\")),@putByIdDirectPrivate(p,\"pulling\",!0),@promiseInvokeOrNoop(@getByIdDirectPrivate(p,\"underlyingByteSource\"),\"pull\",[p]).@then(()=>{if(@putByIdDirectPrivate(p,\"pulling\",!1),@getByIdDirectPrivate(p,\"pullAgain\"))@putByIdDirectPrivate(p,\"pullAgain\",!1),@readableByteStreamControllerCallPullIfNeeded(p)},(u)=>{if(@getByIdDirectPrivate(@getByIdDirectPrivate(p,\"controlledReadableStream\"),\"state\")===@streamReadable)@readableByteStreamControllerError(p,u)})})\n"; + +// transferBufferToCurrentRealm +const JSC::ConstructAbility s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeLength = 38; +static const JSC::Intrinsic s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsTransferBufferToCurrentRealmCode = "(function (r){\"use strict\";return r})\n"; + +// readableStreamReaderKind +const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamReaderKindCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamReaderKindCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamReaderKindCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableStreamReaderKindCodeLength = 188; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamReaderKindCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableStreamReaderKindCode = "(function (n){\"use strict\";if(@getByIdDirectPrivate(n,\"readRequests\"))return @getByIdDirectPrivate(n,\"bunNativePtr\")\?3:1;if(@getByIdDirectPrivate(n,\"readIntoRequests\"))return 2;return 0})\n"; + +// readableByteStreamControllerEnqueue +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeLength = 1076; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (_,d){\"use strict\";const i=@getByIdDirectPrivate(_,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(_,\"closeRequested\")),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@getByIdDirectPrivate(i,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(i,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(_,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength);else{@assert(!@getByIdDirectPrivate(_,\"queue\").content.size());const b=d.constructor===@Uint8Array\?d:new @Uint8Array(d.buffer,d.byteOffset,d.byteLength);@readableStreamFulfillReadRequest(i,b,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(_,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength),@readableByteStreamControllerProcessPullDescriptors(_);break}case 3:break;default:{@assert(!@isReadableStreamLocked(i)),@readableByteStreamControllerEnqueueChunk(_,@transferBufferToCurrentRealm(d.buffer),d.byteOffset,d.byteLength);break}}})\n"; + +// readableByteStreamControllerEnqueueChunk +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeLength = 160; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (d,D,P,a){\"use strict\";@getByIdDirectPrivate(d,\"queue\").content.push({buffer:D,byteOffset:P,byteLength:a}),@getByIdDirectPrivate(d,\"queue\").size+=a})\n"; + +// readableByteStreamControllerRespondWithNewView +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeLength = 417; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (_,d){\"use strict\";@assert(@getByIdDirectPrivate(_,\"pendingPullIntos\").isNotEmpty());let a=@getByIdDirectPrivate(_,\"pendingPullIntos\").peek();if(a.byteOffset+a.bytesFilled!==d.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(a.byteLength!==d.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");a.buffer=d.buffer,@readableByteStreamControllerRespondInternal(_,d.byteLength)})\n"; + +// readableByteStreamControllerRespond +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeLength = 251; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode = "(function (a,d){\"use strict\";if(d=@toNumber(d),@isNaN(d)||d===@Infinity||d<0)@throwRangeError(\"bytesWritten has an incorrect value\");@assert(@getByIdDirectPrivate(a,\"pendingPullIntos\").isNotEmpty()),@readableByteStreamControllerRespondInternal(a,d)})\n"; + +// readableByteStreamControllerRespondInternal +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeLength = 464; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode = "(function (_,d){\"use strict\";let u=@getByIdDirectPrivate(_,\"pendingPullIntos\").peek(),I=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@getByIdDirectPrivate(I,\"state\")===@streamClosed){if(d!==0)@throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");@readableByteStreamControllerRespondInClosedState(_,u)}else @assert(@getByIdDirectPrivate(I,\"state\")===@streamReadable),@readableByteStreamControllerRespondInReadableState(_,d,u)})\n"; + +// readableByteStreamControllerRespondInReadableState +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeLength = 799; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (_,v,T){\"use strict\";if(T.bytesFilled+v>T.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(_,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(_,\"pendingPullIntos\").peek()===T),@readableByteStreamControllerInvalidateBYOBRequest(_),T.bytesFilled+=v,T.bytesFilled<T.elementSize)return;@readableByteStreamControllerShiftPendingDescriptor(_);const f=T.bytesFilled%T.elementSize;if(f>0){const g=T.byteOffset+T.bytesFilled,h=@cloneArrayBuffer(T.buffer,g-f,f);@readableByteStreamControllerEnqueueChunk(_,h,0,h.byteLength)}T.buffer=@transferBufferToCurrentRealm(T.buffer),T.bytesFilled-=f,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(_,\"controlledReadableStream\"),T),@readableByteStreamControllerProcessPullDescriptors(_)})\n"; + +// readableByteStreamControllerRespondInClosedState +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeLength = 502; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCode = "(function (a,m){\"use strict\";if(m.buffer=@transferBufferToCurrentRealm(m.buffer),@assert(m.bytesFilled===0),@readableStreamHasBYOBReader(@getByIdDirectPrivate(a,\"controlledReadableStream\")))while(@getByIdDirectPrivate(@getByIdDirectPrivate(@getByIdDirectPrivate(a,\"controlledReadableStream\"),\"reader\"),\"readIntoRequests\")\?.isNotEmpty()){let d=@readableByteStreamControllerShiftPendingDescriptor(a);@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(a,\"controlledReadableStream\"),d)}})\n"; + +// readableByteStreamControllerProcessPullDescriptors +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeLength = 472; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCode = "(function (a){\"use strict\";@assert(!@getByIdDirectPrivate(a,\"closeRequested\"));while(@getByIdDirectPrivate(a,\"pendingPullIntos\").isNotEmpty()){if(@getByIdDirectPrivate(a,\"queue\").size===0)return;let d=@getByIdDirectPrivate(a,\"pendingPullIntos\").peek();if(@readableByteStreamControllerFillDescriptorFromQueue(a,d))@readableByteStreamControllerShiftPendingDescriptor(a),@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(a,\"controlledReadableStream\"),d)}})\n"; + +// readableByteStreamControllerFillDescriptorFromQueue +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeLength = 970; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode = "(function (_,v){\"use strict\";const j=v.bytesFilled-v.bytesFilled%v.elementSize,k=@getByIdDirectPrivate(_,\"queue\").size<v.byteLength-v.bytesFilled\?@getByIdDirectPrivate(_,\"queue\").size:v.byteLength-v.bytesFilled,q=v.bytesFilled+k,w=q-q%v.elementSize;let z=k,E=!1;if(w>j)z=w-v.bytesFilled,E=!0;while(z>0){let G=@getByIdDirectPrivate(_,\"queue\").content.peek();const H=z<G.byteLength\?z:G.byteLength,J=v.byteOffset+v.bytesFilled;if(new @Uint8Array(v.buffer).set(new @Uint8Array(G.buffer,G.byteOffset,H),J),G.byteLength===H)@getByIdDirectPrivate(_,\"queue\").content.shift();else G.byteOffset+=H,G.byteLength-=H;@getByIdDirectPrivate(_,\"queue\").size-=H,@assert(@getByIdDirectPrivate(_,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(_,\"pendingPullIntos\").peek()===v),@readableByteStreamControllerInvalidateBYOBRequest(_),v.bytesFilled+=H,z-=H}if(!E)@assert(@getByIdDirectPrivate(_,\"queue\").size===0),@assert(v.bytesFilled>0),@assert(v.bytesFilled<v.elementSize);return E})\n"; + +// readableByteStreamControllerShiftPendingDescriptor +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeLength = 150; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCode = "(function (B){\"use strict\";let _=@getByIdDirectPrivate(B,\"pendingPullIntos\").shift();return @readableByteStreamControllerInvalidateBYOBRequest(B),_})\n"; + +// readableByteStreamControllerInvalidateBYOBRequest +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeLength = 308; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"byobRequest\")===@undefined)return;const d=@getByIdDirectPrivate(i,\"byobRequest\");@putByIdDirectPrivate(d,\"associatedReadableByteStreamController\",@undefined),@putByIdDirectPrivate(d,\"view\",@undefined),@putByIdDirectPrivate(i,\"byobRequest\",@undefined)})\n"; + +// readableByteStreamControllerCommitDescriptor +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeLength = 386; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCode = "(function (_,b){\"use strict\";@assert(@getByIdDirectPrivate(_,\"state\")!==@streamErrored);let g=!1;if(@getByIdDirectPrivate(_,\"state\")===@streamClosed)@assert(!b.bytesFilled),g=!0;let h=@readableByteStreamControllerConvertDescriptor(b);if(b.readerType===\"default\")@readableStreamFulfillReadRequest(_,h,g);else @assert(b.readerType===\"byob\"),@readableStreamFulfillReadIntoRequest(_,h,g)})\n"; + +// readableByteStreamControllerConvertDescriptor +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeLength = 176; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCode = "(function (d){\"use strict\";return @assert(d.bytesFilled<=d.byteLength),@assert(d.bytesFilled%d.elementSize===0),new d.ctor(d.buffer,d.byteOffset,d.bytesFilled/d.elementSize)})\n"; + +// readableStreamFulfillReadIntoRequest +const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeLength = 161; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode = "(function (r,B,I){\"use strict\";const b=@getByIdDirectPrivate(@getByIdDirectPrivate(r,\"reader\"),\"readIntoRequests\").shift();@fulfillPromise(b,{value:B,done:I})})\n"; + +// readableStreamBYOBReaderRead +const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeLength = 356; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode = "(function (_,c){\"use strict\";const n=@getByIdDirectPrivate(_,\"ownerReadableStream\");if(@assert(!!n),@putByIdDirectPrivate(n,\"disturbed\",!0),@getByIdDirectPrivate(n,\"state\")===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(n,\"storedError\"));return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(n,\"readableStreamController\"),c)})\n"; + +// readableByteStreamControllerPullInto +const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeLength = 1255; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (y,_){\"use strict\";const b=@getByIdDirectPrivate(y,\"controlledReadableStream\");let h=1;if(_.BYTES_PER_ELEMENT!==@undefined)h=_.BYTES_PER_ELEMENT;const E=_.constructor,F={buffer:_.buffer,byteOffset:_.byteOffset,byteLength:_.byteLength,bytesFilled:0,elementSize:h,ctor:E,readerType:\"byob\"};var P=@getByIdDirectPrivate(y,\"pendingPullIntos\");if(P\?.isNotEmpty())return F.buffer=@transferBufferToCurrentRealm(F.buffer),P.push(F),@readableStreamAddReadIntoRequest(b);if(@getByIdDirectPrivate(b,\"state\")===@streamClosed){const T=new E(F.buffer,F.byteOffset,0);return @createFulfilledPromise({value:T,done:!0})}if(@getByIdDirectPrivate(y,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(y,F)){const T=@readableByteStreamControllerConvertDescriptor(F);return @readableByteStreamControllerHandleQueueDrain(y),@createFulfilledPromise({value:T,done:!1})}if(@getByIdDirectPrivate(y,\"closeRequested\")){const T=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(y,T),@Promise.@reject(T)}}F.buffer=@transferBufferToCurrentRealm(F.buffer),@getByIdDirectPrivate(y,\"pendingPullIntos\").push(F);const R=@readableStreamAddReadIntoRequest(b);return @readableByteStreamControllerCallPullIfNeeded(y),R})\n"; + +// readableStreamAddReadIntoRequest +const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeLength = 326; +static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCode = "(function (_){\"use strict\";@assert(@isReadableStreamBYOBReader(@getByIdDirectPrivate(_,\"reader\"))),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable||@getByIdDirectPrivate(_,\"state\")===@streamClosed);const n=@newPromise();return @getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readIntoRequests\").push(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().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 + +/* WritableStreamDefaultController.ts */ +// initializeWritableStreamDefaultController +const JSC::ConstructAbility s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeLength = 368; +static const JSC::Intrinsic s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCode = "(function (){\"use strict\";return @putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"abortSteps\",(c)=>{const i=@getByIdDirectPrivate(this,\"abortAlgorithm\").@call(@undefined,c);return @writableStreamDefaultControllerClearAlgorithms(this),i}),@putByIdDirectPrivate(this,\"errorSteps\",()=>{@resetQueue(@getByIdDirectPrivate(this,\"queue\"))}),this})\n"; + +// error +const JSC::ConstructAbility s_writableStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_writableStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_writableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_writableStreamDefaultControllerErrorCodeLength = 301; +static const JSC::Intrinsic s_writableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_writableStreamDefaultControllerErrorCode = "(function (n){\"use strict\";if(@getByIdDirectPrivate(this,\"abortSteps\")===@undefined)throw @makeThisTypeError(\"WritableStreamDefaultController\",\"error\");const o=@getByIdDirectPrivate(this,\"stream\");if(@getByIdDirectPrivate(o,\"state\")!==\"writable\")return;@writableStreamDefaultControllerError(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().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 + + + +JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm) + : m_vm(vm) + , m_writableStreamInternals(vm) + , m_transformStreamInternals(vm) + , m_readableStreamInternals(vm) + , m_streamInternals(vm) + , m_readableByteStreamInternals(vm) + +{ + UNUSED_PARAM(vm); +} + +template<typename Visitor> +void JSBuiltinInternalFunctions::visit(Visitor& visitor) +{ + m_writableStreamInternals.visit(visitor); + m_transformStreamInternals.visit(visitor); + m_readableStreamInternals.visit(visitor); + m_streamInternals.visit(visitor); + m_readableByteStreamInternals.visit(visitor); + + UNUSED_PARAM(visitor); +} + +template void JSBuiltinInternalFunctions::visit(AbstractSlotVisitor&); +template void JSBuiltinInternalFunctions::visit(SlotVisitor&); + +SUPPRESS_ASAN void JSBuiltinInternalFunctions::initialize(Zig::GlobalObject& globalObject) +{ + UNUSED_PARAM(globalObject); + m_writableStreamInternals.init(globalObject); + m_transformStreamInternals.init(globalObject); + m_readableStreamInternals.init(globalObject); + m_streamInternals.init(globalObject); + m_readableByteStreamInternals.init(globalObject); + + JSVMClientData& clientData = *static_cast<JSVMClientData*>(m_vm.clientData); + Zig::GlobalObject::GlobalPropertyInfo staticGlobals[] = { +#define DECLARE_GLOBAL_STATIC(name) \ + Zig::GlobalObject::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 + #define DECLARE_GLOBAL_STATIC(name) \ + Zig::GlobalObject::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) \ + Zig::GlobalObject::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) \ + Zig::GlobalObject::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) \ + Zig::GlobalObject::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 + + }; + globalObject.addStaticGlobals(staticGlobals, std::size(staticGlobals)); + UNUSED_PARAM(clientData); +} + +} // namespace WebCore diff --git a/src/bun.js/builtins/WebCoreJSBuiltins.d.ts b/src/bun.js/builtins/WebCoreJSBuiltins.d.ts new file mode 100644 index 000000000..a39c38348 --- /dev/null +++ b/src/bun.js/builtins/WebCoreJSBuiltins.d.ts @@ -0,0 +1,199 @@ +// Generated by `bun src/bun.js/builtins/codegen/index.js` +// Do not edit by hand. +type RemoveThis<F> = F extends (this: infer T, ...args: infer A) => infer R ? (...args: A) => R : F; + +// WritableStreamInternals.ts +declare const $isWritableStream: RemoveThis<typeof import("./ts/WritableStreamInternals")["isWritableStream"]>; +declare const $isWritableStreamDefaultWriter: RemoveThis<typeof import("./ts/WritableStreamInternals")["isWritableStreamDefaultWriter"]>; +declare const $acquireWritableStreamDefaultWriter: RemoveThis<typeof import("./ts/WritableStreamInternals")["acquireWritableStreamDefaultWriter"]>; +declare const $createWritableStream: RemoveThis<typeof import("./ts/WritableStreamInternals")["createWritableStream"]>; +declare const $createInternalWritableStreamFromUnderlyingSink: RemoveThis<typeof import("./ts/WritableStreamInternals")["createInternalWritableStreamFromUnderlyingSink"]>; +declare const $initializeWritableStreamSlots: RemoveThis<typeof import("./ts/WritableStreamInternals")["initializeWritableStreamSlots"]>; +declare const $writableStreamCloseForBindings: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamCloseForBindings"]>; +declare const $writableStreamAbortForBindings: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamAbortForBindings"]>; +declare const $isWritableStreamLocked: RemoveThis<typeof import("./ts/WritableStreamInternals")["isWritableStreamLocked"]>; +declare const $setUpWritableStreamDefaultWriter: RemoveThis<typeof import("./ts/WritableStreamInternals")["setUpWritableStreamDefaultWriter"]>; +declare const $writableStreamAbort: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamAbort"]>; +declare const $writableStreamClose: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamClose"]>; +declare const $writableStreamAddWriteRequest: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamAddWriteRequest"]>; +declare const $writableStreamCloseQueuedOrInFlight: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamCloseQueuedOrInFlight"]>; +declare const $writableStreamDealWithRejection: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDealWithRejection"]>; +declare const $writableStreamFinishErroring: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamFinishErroring"]>; +declare const $writableStreamFinishInFlightClose: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamFinishInFlightClose"]>; +declare const $writableStreamFinishInFlightCloseWithError: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamFinishInFlightCloseWithError"]>; +declare const $writableStreamFinishInFlightWrite: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamFinishInFlightWrite"]>; +declare const $writableStreamFinishInFlightWriteWithError: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamFinishInFlightWriteWithError"]>; +declare const $writableStreamHasOperationMarkedInFlight: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamHasOperationMarkedInFlight"]>; +declare const $writableStreamMarkCloseRequestInFlight: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamMarkCloseRequestInFlight"]>; +declare const $writableStreamMarkFirstWriteRequestInFlight: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamMarkFirstWriteRequestInFlight"]>; +declare const $writableStreamRejectCloseAndClosedPromiseIfNeeded: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamRejectCloseAndClosedPromiseIfNeeded"]>; +declare const $writableStreamStartErroring: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamStartErroring"]>; +declare const $writableStreamUpdateBackpressure: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamUpdateBackpressure"]>; +declare const $writableStreamDefaultWriterAbort: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultWriterAbort"]>; +declare const $writableStreamDefaultWriterClose: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultWriterClose"]>; +declare const $writableStreamDefaultWriterCloseWithErrorPropagation: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultWriterCloseWithErrorPropagation"]>; +declare const $writableStreamDefaultWriterEnsureClosedPromiseRejected: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultWriterEnsureClosedPromiseRejected"]>; +declare const $writableStreamDefaultWriterEnsureReadyPromiseRejected: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultWriterEnsureReadyPromiseRejected"]>; +declare const $writableStreamDefaultWriterGetDesiredSize: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultWriterGetDesiredSize"]>; +declare const $writableStreamDefaultWriterRelease: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultWriterRelease"]>; +declare const $writableStreamDefaultWriterWrite: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultWriterWrite"]>; +declare const $setUpWritableStreamDefaultController: RemoveThis<typeof import("./ts/WritableStreamInternals")["setUpWritableStreamDefaultController"]>; +declare const $writableStreamDefaultControllerStart: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultControllerStart"]>; +declare const $setUpWritableStreamDefaultControllerFromUnderlyingSink: RemoveThis<typeof import("./ts/WritableStreamInternals")["setUpWritableStreamDefaultControllerFromUnderlyingSink"]>; +declare const $writableStreamDefaultControllerAdvanceQueueIfNeeded: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultControllerAdvanceQueueIfNeeded"]>; +declare const $isCloseSentinel: RemoveThis<typeof import("./ts/WritableStreamInternals")["isCloseSentinel"]>; +declare const $writableStreamDefaultControllerClearAlgorithms: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultControllerClearAlgorithms"]>; +declare const $writableStreamDefaultControllerClose: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultControllerClose"]>; +declare const $writableStreamDefaultControllerError: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultControllerError"]>; +declare const $writableStreamDefaultControllerErrorIfNeeded: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultControllerErrorIfNeeded"]>; +declare const $writableStreamDefaultControllerGetBackpressure: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultControllerGetBackpressure"]>; +declare const $writableStreamDefaultControllerGetChunkSize: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultControllerGetChunkSize"]>; +declare const $writableStreamDefaultControllerGetDesiredSize: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultControllerGetDesiredSize"]>; +declare const $writableStreamDefaultControllerProcessClose: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultControllerProcessClose"]>; +declare const $writableStreamDefaultControllerProcessWrite: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultControllerProcessWrite"]>; +declare const $writableStreamDefaultControllerWrite: RemoveThis<typeof import("./ts/WritableStreamInternals")["writableStreamDefaultControllerWrite"]>; + +// TransformStreamInternals.ts +declare const $isTransformStream: RemoveThis<typeof import("./ts/TransformStreamInternals")["isTransformStream"]>; +declare const $isTransformStreamDefaultController: RemoveThis<typeof import("./ts/TransformStreamInternals")["isTransformStreamDefaultController"]>; +declare const $createTransformStream: RemoveThis<typeof import("./ts/TransformStreamInternals")["createTransformStream"]>; +declare const $initializeTransformStream: RemoveThis<typeof import("./ts/TransformStreamInternals")["initializeTransformStream"]>; +declare const $transformStreamError: RemoveThis<typeof import("./ts/TransformStreamInternals")["transformStreamError"]>; +declare const $transformStreamErrorWritableAndUnblockWrite: RemoveThis<typeof import("./ts/TransformStreamInternals")["transformStreamErrorWritableAndUnblockWrite"]>; +declare const $transformStreamSetBackpressure: RemoveThis<typeof import("./ts/TransformStreamInternals")["transformStreamSetBackpressure"]>; +declare const $setUpTransformStreamDefaultController: RemoveThis<typeof import("./ts/TransformStreamInternals")["setUpTransformStreamDefaultController"]>; +declare const $setUpTransformStreamDefaultControllerFromTransformer: RemoveThis<typeof import("./ts/TransformStreamInternals")["setUpTransformStreamDefaultControllerFromTransformer"]>; +declare const $transformStreamDefaultControllerClearAlgorithms: RemoveThis<typeof import("./ts/TransformStreamInternals")["transformStreamDefaultControllerClearAlgorithms"]>; +declare const $transformStreamDefaultControllerEnqueue: RemoveThis<typeof import("./ts/TransformStreamInternals")["transformStreamDefaultControllerEnqueue"]>; +declare const $transformStreamDefaultControllerError: RemoveThis<typeof import("./ts/TransformStreamInternals")["transformStreamDefaultControllerError"]>; +declare const $transformStreamDefaultControllerPerformTransform: RemoveThis<typeof import("./ts/TransformStreamInternals")["transformStreamDefaultControllerPerformTransform"]>; +declare const $transformStreamDefaultControllerTerminate: RemoveThis<typeof import("./ts/TransformStreamInternals")["transformStreamDefaultControllerTerminate"]>; +declare const $transformStreamDefaultSinkWriteAlgorithm: RemoveThis<typeof import("./ts/TransformStreamInternals")["transformStreamDefaultSinkWriteAlgorithm"]>; +declare const $transformStreamDefaultSinkAbortAlgorithm: RemoveThis<typeof import("./ts/TransformStreamInternals")["transformStreamDefaultSinkAbortAlgorithm"]>; +declare const $transformStreamDefaultSinkCloseAlgorithm: RemoveThis<typeof import("./ts/TransformStreamInternals")["transformStreamDefaultSinkCloseAlgorithm"]>; +declare const $transformStreamDefaultSourcePullAlgorithm: RemoveThis<typeof import("./ts/TransformStreamInternals")["transformStreamDefaultSourcePullAlgorithm"]>; + +// ReadableStreamInternals.ts +declare const $readableStreamReaderGenericInitialize: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamReaderGenericInitialize"]>; +declare const $privateInitializeReadableStreamDefaultController: RemoveThis<typeof import("./ts/ReadableStreamInternals")["privateInitializeReadableStreamDefaultController"]>; +declare const $readableStreamDefaultControllerError: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamDefaultControllerError"]>; +declare const $readableStreamPipeTo: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamPipeTo"]>; +declare const $acquireReadableStreamDefaultReader: RemoveThis<typeof import("./ts/ReadableStreamInternals")["acquireReadableStreamDefaultReader"]>; +declare const $setupReadableStreamDefaultController: RemoveThis<typeof import("./ts/ReadableStreamInternals")["setupReadableStreamDefaultController"]>; +declare const $createReadableStreamController: RemoveThis<typeof import("./ts/ReadableStreamInternals")["createReadableStreamController"]>; +declare const $readableStreamDefaultControllerStart: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamDefaultControllerStart"]>; +declare const $readableStreamPipeToWritableStream: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamPipeToWritableStream"]>; +declare const $pipeToLoop: RemoveThis<typeof import("./ts/ReadableStreamInternals")["pipeToLoop"]>; +declare const $pipeToDoReadWrite: RemoveThis<typeof import("./ts/ReadableStreamInternals")["pipeToDoReadWrite"]>; +declare const $pipeToErrorsMustBePropagatedForward: RemoveThis<typeof import("./ts/ReadableStreamInternals")["pipeToErrorsMustBePropagatedForward"]>; +declare const $pipeToErrorsMustBePropagatedBackward: RemoveThis<typeof import("./ts/ReadableStreamInternals")["pipeToErrorsMustBePropagatedBackward"]>; +declare const $pipeToClosingMustBePropagatedForward: RemoveThis<typeof import("./ts/ReadableStreamInternals")["pipeToClosingMustBePropagatedForward"]>; +declare const $pipeToClosingMustBePropagatedBackward: RemoveThis<typeof import("./ts/ReadableStreamInternals")["pipeToClosingMustBePropagatedBackward"]>; +declare const $pipeToShutdownWithAction: RemoveThis<typeof import("./ts/ReadableStreamInternals")["pipeToShutdownWithAction"]>; +declare const $pipeToShutdown: RemoveThis<typeof import("./ts/ReadableStreamInternals")["pipeToShutdown"]>; +declare const $pipeToFinalize: RemoveThis<typeof import("./ts/ReadableStreamInternals")["pipeToFinalize"]>; +declare const $readableStreamTee: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamTee"]>; +declare const $readableStreamTeePullFunction: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamTeePullFunction"]>; +declare const $readableStreamTeeBranch1CancelFunction: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamTeeBranch1CancelFunction"]>; +declare const $readableStreamTeeBranch2CancelFunction: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamTeeBranch2CancelFunction"]>; +declare const $isReadableStream: RemoveThis<typeof import("./ts/ReadableStreamInternals")["isReadableStream"]>; +declare const $isReadableStreamDefaultReader: RemoveThis<typeof import("./ts/ReadableStreamInternals")["isReadableStreamDefaultReader"]>; +declare const $isReadableStreamDefaultController: RemoveThis<typeof import("./ts/ReadableStreamInternals")["isReadableStreamDefaultController"]>; +declare const $readDirectStream: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readDirectStream"]>; +declare const $assignToStream: RemoveThis<typeof import("./ts/ReadableStreamInternals")["assignToStream"]>; +declare const $readStreamIntoSink: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readStreamIntoSink"]>; +declare const $handleDirectStreamError: RemoveThis<typeof import("./ts/ReadableStreamInternals")["handleDirectStreamError"]>; +declare const $handleDirectStreamErrorReject: RemoveThis<typeof import("./ts/ReadableStreamInternals")["handleDirectStreamErrorReject"]>; +declare const $onPullDirectStream: RemoveThis<typeof import("./ts/ReadableStreamInternals")["onPullDirectStream"]>; +declare const $noopDoneFunction: RemoveThis<typeof import("./ts/ReadableStreamInternals")["noopDoneFunction"]>; +declare const $onReadableStreamDirectControllerClosed: RemoveThis<typeof import("./ts/ReadableStreamInternals")["onReadableStreamDirectControllerClosed"]>; +declare const $onCloseDirectStream: RemoveThis<typeof import("./ts/ReadableStreamInternals")["onCloseDirectStream"]>; +declare const $onFlushDirectStream: RemoveThis<typeof import("./ts/ReadableStreamInternals")["onFlushDirectStream"]>; +declare const $createTextStream: RemoveThis<typeof import("./ts/ReadableStreamInternals")["createTextStream"]>; +declare const $initializeTextStream: RemoveThis<typeof import("./ts/ReadableStreamInternals")["initializeTextStream"]>; +declare const $initializeArrayStream: RemoveThis<typeof import("./ts/ReadableStreamInternals")["initializeArrayStream"]>; +declare const $initializeArrayBufferStream: RemoveThis<typeof import("./ts/ReadableStreamInternals")["initializeArrayBufferStream"]>; +declare const $readableStreamError: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamError"]>; +declare const $readableStreamDefaultControllerShouldCallPull: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamDefaultControllerShouldCallPull"]>; +declare const $readableStreamDefaultControllerCallPullIfNeeded: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamDefaultControllerCallPullIfNeeded"]>; +declare const $isReadableStreamLocked: RemoveThis<typeof import("./ts/ReadableStreamInternals")["isReadableStreamLocked"]>; +declare const $readableStreamDefaultControllerGetDesiredSize: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamDefaultControllerGetDesiredSize"]>; +declare const $readableStreamReaderGenericCancel: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamReaderGenericCancel"]>; +declare const $readableStreamCancel: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamCancel"]>; +declare const $readableStreamDefaultControllerCancel: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamDefaultControllerCancel"]>; +declare const $readableStreamDefaultControllerPull: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamDefaultControllerPull"]>; +declare const $readableStreamDefaultControllerClose: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamDefaultControllerClose"]>; +declare const $readableStreamClose: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamClose"]>; +declare const $readableStreamFulfillReadRequest: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamFulfillReadRequest"]>; +declare const $readableStreamDefaultControllerEnqueue: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamDefaultControllerEnqueue"]>; +declare const $readableStreamDefaultReaderRead: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamDefaultReaderRead"]>; +declare const $readableStreamAddReadRequest: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamAddReadRequest"]>; +declare const $isReadableStreamDisturbed: RemoveThis<typeof import("./ts/ReadableStreamInternals")["isReadableStreamDisturbed"]>; +declare const $readableStreamReaderGenericRelease: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamReaderGenericRelease"]>; +declare const $readableStreamDefaultControllerCanCloseOrEnqueue: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamDefaultControllerCanCloseOrEnqueue"]>; +declare const $lazyLoadStream: RemoveThis<typeof import("./ts/ReadableStreamInternals")["lazyLoadStream"]>; +declare const $readableStreamIntoArray: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamIntoArray"]>; +declare const $readableStreamIntoText: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamIntoText"]>; +declare const $readableStreamToArrayBufferDirect: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamToArrayBufferDirect"]>; +declare const $readableStreamToTextDirect: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamToTextDirect"]>; +declare const $readableStreamToArrayDirect: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamToArrayDirect"]>; +declare const $readableStreamDefineLazyIterators: RemoveThis<typeof import("./ts/ReadableStreamInternals")["readableStreamDefineLazyIterators"]>; + +// StreamInternals.ts +declare const $markPromiseAsHandled: RemoveThis<typeof import("./ts/StreamInternals")["markPromiseAsHandled"]>; +declare const $shieldingPromiseResolve: RemoveThis<typeof import("./ts/StreamInternals")["shieldingPromiseResolve"]>; +declare const $promiseInvokeOrNoopMethodNoCatch: RemoveThis<typeof import("./ts/StreamInternals")["promiseInvokeOrNoopMethodNoCatch"]>; +declare const $promiseInvokeOrNoopNoCatch: RemoveThis<typeof import("./ts/StreamInternals")["promiseInvokeOrNoopNoCatch"]>; +declare const $promiseInvokeOrNoopMethod: RemoveThis<typeof import("./ts/StreamInternals")["promiseInvokeOrNoopMethod"]>; +declare const $promiseInvokeOrNoop: RemoveThis<typeof import("./ts/StreamInternals")["promiseInvokeOrNoop"]>; +declare const $promiseInvokeOrFallbackOrNoop: RemoveThis<typeof import("./ts/StreamInternals")["promiseInvokeOrFallbackOrNoop"]>; +declare const $validateAndNormalizeQueuingStrategy: RemoveThis<typeof import("./ts/StreamInternals")["validateAndNormalizeQueuingStrategy"]>; +declare const $createFIFO: RemoveThis<typeof import("./ts/StreamInternals")["createFIFO"]>; +declare const $newQueue: RemoveThis<typeof import("./ts/StreamInternals")["newQueue"]>; +declare const $dequeueValue: RemoveThis<typeof import("./ts/StreamInternals")["dequeueValue"]>; +declare const $enqueueValueWithSize: RemoveThis<typeof import("./ts/StreamInternals")["enqueueValueWithSize"]>; +declare const $peekQueueValue: RemoveThis<typeof import("./ts/StreamInternals")["peekQueueValue"]>; +declare const $resetQueue: RemoveThis<typeof import("./ts/StreamInternals")["resetQueue"]>; +declare const $extractSizeAlgorithm: RemoveThis<typeof import("./ts/StreamInternals")["extractSizeAlgorithm"]>; +declare const $extractHighWaterMark: RemoveThis<typeof import("./ts/StreamInternals")["extractHighWaterMark"]>; +declare const $extractHighWaterMarkFromQueuingStrategyInit: RemoveThis<typeof import("./ts/StreamInternals")["extractHighWaterMarkFromQueuingStrategyInit"]>; +declare const $createFulfilledPromise: RemoveThis<typeof import("./ts/StreamInternals")["createFulfilledPromise"]>; +declare const $toDictionary: RemoveThis<typeof import("./ts/StreamInternals")["toDictionary"]>; + +// ReadableByteStreamInternals.ts +declare const $privateInitializeReadableByteStreamController: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["privateInitializeReadableByteStreamController"]>; +declare const $readableStreamByteStreamControllerStart: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableStreamByteStreamControllerStart"]>; +declare const $privateInitializeReadableStreamBYOBRequest: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["privateInitializeReadableStreamBYOBRequest"]>; +declare const $isReadableByteStreamController: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["isReadableByteStreamController"]>; +declare const $isReadableStreamBYOBRequest: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["isReadableStreamBYOBRequest"]>; +declare const $isReadableStreamBYOBReader: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["isReadableStreamBYOBReader"]>; +declare const $readableByteStreamControllerCancel: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerCancel"]>; +declare const $readableByteStreamControllerError: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerError"]>; +declare const $readableByteStreamControllerClose: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerClose"]>; +declare const $readableByteStreamControllerClearPendingPullIntos: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerClearPendingPullIntos"]>; +declare const $readableByteStreamControllerGetDesiredSize: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerGetDesiredSize"]>; +declare const $readableStreamHasBYOBReader: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableStreamHasBYOBReader"]>; +declare const $readableStreamHasDefaultReader: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableStreamHasDefaultReader"]>; +declare const $readableByteStreamControllerHandleQueueDrain: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerHandleQueueDrain"]>; +declare const $readableByteStreamControllerPull: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerPull"]>; +declare const $readableByteStreamControllerShouldCallPull: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerShouldCallPull"]>; +declare const $readableByteStreamControllerCallPullIfNeeded: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerCallPullIfNeeded"]>; +declare const $transferBufferToCurrentRealm: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["transferBufferToCurrentRealm"]>; +declare const $readableStreamReaderKind: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableStreamReaderKind"]>; +declare const $readableByteStreamControllerEnqueue: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerEnqueue"]>; +declare const $readableByteStreamControllerEnqueueChunk: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerEnqueueChunk"]>; +declare const $readableByteStreamControllerRespondWithNewView: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerRespondWithNewView"]>; +declare const $readableByteStreamControllerRespond: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerRespond"]>; +declare const $readableByteStreamControllerRespondInternal: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerRespondInternal"]>; +declare const $readableByteStreamControllerRespondInReadableState: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerRespondInReadableState"]>; +declare const $readableByteStreamControllerRespondInClosedState: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerRespondInClosedState"]>; +declare const $readableByteStreamControllerProcessPullDescriptors: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerProcessPullDescriptors"]>; +declare const $readableByteStreamControllerFillDescriptorFromQueue: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerFillDescriptorFromQueue"]>; +declare const $readableByteStreamControllerShiftPendingDescriptor: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerShiftPendingDescriptor"]>; +declare const $readableByteStreamControllerInvalidateBYOBRequest: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerInvalidateBYOBRequest"]>; +declare const $readableByteStreamControllerCommitDescriptor: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerCommitDescriptor"]>; +declare const $readableByteStreamControllerConvertDescriptor: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerConvertDescriptor"]>; +declare const $readableStreamFulfillReadIntoRequest: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableStreamFulfillReadIntoRequest"]>; +declare const $readableStreamBYOBReaderRead: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableStreamBYOBReaderRead"]>; +declare const $readableByteStreamControllerPullInto: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableByteStreamControllerPullInto"]>; +declare const $readableStreamAddReadIntoRequest: RemoveThis<typeof import("./ts/ReadableByteStreamInternals")["readableStreamAddReadIntoRequest"]>; diff --git a/src/bun.js/builtins/WebCoreJSBuiltins.h b/src/bun.js/builtins/WebCoreJSBuiltins.h new file mode 100644 index 000000000..2f1fd3816 --- /dev/null +++ b/src/bun.js/builtins/WebCoreJSBuiltins.h @@ -0,0 +1,5501 @@ +// Generated by `bun src/bun.js/builtins/codegen/index.js` +// Do not edit by hand. +#pragma once +namespace Zig { class GlobalObject; } +#include "root.h" +#include <JavaScriptCore/BuiltinUtils.h> +#include <JavaScriptCore/Identifier.h> +#include <JavaScriptCore/JSFunction.h> +#include <JavaScriptCore/UnlinkedFunctionExecutable.h> +#include <JavaScriptCore/VM.h> +#include <JavaScriptCore/WeakInlines.h> + +namespace JSC { +class FunctionExecutable; +} + +namespace WebCore { +/* BundlerPlugin.ts */ +// runSetupFunction +#define WEBCORE_BUILTIN_BUNDLERPLUGIN_RUNSETUPFUNCTION 1 +extern const char* const s_bundlerPluginRunSetupFunctionCode; +extern const int s_bundlerPluginRunSetupFunctionCodeLength; +extern const JSC::ConstructAbility s_bundlerPluginRunSetupFunctionCodeConstructAbility; +extern const JSC::ConstructorKind s_bundlerPluginRunSetupFunctionCodeConstructorKind; +extern const JSC::ImplementationVisibility s_bundlerPluginRunSetupFunctionCodeImplementationVisibility; + +// runOnResolvePlugins +#define WEBCORE_BUILTIN_BUNDLERPLUGIN_RUNONRESOLVEPLUGINS 1 +extern const char* const s_bundlerPluginRunOnResolvePluginsCode; +extern const int s_bundlerPluginRunOnResolvePluginsCodeLength; +extern const JSC::ConstructAbility s_bundlerPluginRunOnResolvePluginsCodeConstructAbility; +extern const JSC::ConstructorKind s_bundlerPluginRunOnResolvePluginsCodeConstructorKind; +extern const JSC::ImplementationVisibility s_bundlerPluginRunOnResolvePluginsCodeImplementationVisibility; + +// runOnLoadPlugins +#define WEBCORE_BUILTIN_BUNDLERPLUGIN_RUNONLOADPLUGINS 1 +extern const char* const s_bundlerPluginRunOnLoadPluginsCode; +extern const int s_bundlerPluginRunOnLoadPluginsCodeLength; +extern const JSC::ConstructAbility s_bundlerPluginRunOnLoadPluginsCodeConstructAbility; +extern const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind; +extern const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility; + +#define WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_DATA(macro) \ + macro(runSetupFunction, bundlerPluginRunSetupFunction, 2) \ + macro(runOnResolvePlugins, bundlerPluginRunOnResolvePlugins, 5) \ + macro(runOnLoadPlugins, bundlerPluginRunOnLoadPlugins, 4) \ + +#define WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_CODE(macro) \ + macro(bundlerPluginRunSetupFunctionCode, runSetupFunction, ASCIILiteral(), s_bundlerPluginRunSetupFunctionCodeLength) \ + macro(bundlerPluginRunOnResolvePluginsCode, runOnResolvePlugins, ASCIILiteral(), s_bundlerPluginRunOnResolvePluginsCodeLength) \ + macro(bundlerPluginRunOnLoadPluginsCode, runOnLoadPlugins, ASCIILiteral(), s_bundlerPluginRunOnLoadPluginsCodeLength) \ + +#define WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_FUNCTION_NAME(macro) \ + macro(runSetupFunction) \ + macro(runOnResolvePlugins) \ + macro(runOnLoadPlugins) \ + +#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ + JSC::FunctionExecutable* codeName##Generator(JSC::VM&); + +WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) +#undef DECLARE_BUILTIN_GENERATOR + +class BundlerPluginBuiltinsWrapper : private JSC::WeakHandleOwner { +public: + explicit BundlerPluginBuiltinsWrapper(JSC::VM& vm) + : m_vm(vm) + WEBCORE_FOREACH_BUNDLERPLUGIN_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_BUNDLERPLUGIN_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_BUNDLERPLUGIN_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) +#undef EXPOSE_BUILTIN_EXECUTABLES + + WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) + + void exportNames(); + +private: + JSC::VM& m_vm; + + WEBCORE_FOREACH_BUNDLERPLUGIN_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_BUNDLERPLUGIN_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) +#undef DECLARE_BUILTIN_SOURCE_MEMBERS + +}; + +#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ +inline JSC::UnlinkedFunctionExecutable* BundlerPluginBuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ + }\ + return m_##name##Executable.get();\ +} +WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) +#undef DEFINE_BUILTIN_EXECUTABLES + +inline void BundlerPluginBuiltinsWrapper::exportNames() +{ +#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); + WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) +#undef EXPORT_FUNCTION_NAME +} +/* ByteLengthQueuingStrategy.ts */ +// highWaterMark +#define WEBCORE_BUILTIN_BYTELENGTHQUEUINGSTRATEGY_HIGHWATERMARK 1 +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 JSC::ImplementationVisibility s_byteLengthQueuingStrategyHighWaterMarkCodeImplementationVisibility; + +// size +#define WEBCORE_BUILTIN_BYTELENGTHQUEUINGSTRATEGY_SIZE 1 +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 JSC::ImplementationVisibility s_byteLengthQueuingStrategySizeCodeImplementationVisibility; + +// initializeByteLengthQueuingStrategy +#define WEBCORE_BUILTIN_BYTELENGTHQUEUINGSTRATEGY_INITIALIZEBYTELENGTHQUEUINGSTRATEGY 1 +extern const char* const s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCode; +extern const int s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeLength; +extern const JSC::ConstructAbility s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructAbility; +extern const JSC::ConstructorKind s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructorKind; +extern const JSC::ImplementationVisibility s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeImplementationVisibility; + +#define WEBCORE_FOREACH_BYTELENGTHQUEUINGSTRATEGY_BUILTIN_DATA(macro) \ + macro(highWaterMark, byteLengthQueuingStrategyHighWaterMark, 0) \ + macro(size, byteLengthQueuingStrategySize, 1) \ + macro(initializeByteLengthQueuingStrategy, byteLengthQueuingStrategyInitializeByteLengthQueuingStrategy, 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(size) \ + macro(initializeByteLengthQueuingStrategy) \ + +#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##ImplementationVisibility, 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 +} +/* WritableStreamInternals.ts */ +// isWritableStream +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ISWRITABLESTREAM 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsIsWritableStreamCodeImplementationVisibility; + +// isWritableStreamDefaultWriter +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ISWRITABLESTREAMDEFAULTWRITER 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsIsWritableStreamDefaultWriterCodeImplementationVisibility; + +// acquireWritableStreamDefaultWriter +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ACQUIREWRITABLESTREAMDEFAULTWRITER 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeImplementationVisibility; + +// createWritableStream +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_CREATEWRITABLESTREAM 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsCreateWritableStreamCodeImplementationVisibility; + +// createInternalWritableStreamFromUnderlyingSink +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_CREATEINTERNALWRITABLESTREAMFROMUNDERLYINGSINK 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeImplementationVisibility; + +// initializeWritableStreamSlots +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_INITIALIZEWRITABLESTREAMSLOTS 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsInitializeWritableStreamSlotsCodeImplementationVisibility; + +// writableStreamCloseForBindings +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMCLOSEFORBINDINGS 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseForBindingsCodeImplementationVisibility; + +// writableStreamAbortForBindings +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMABORTFORBINDINGS 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAbortForBindingsCodeImplementationVisibility; + +// isWritableStreamLocked +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ISWRITABLESTREAMLOCKED 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsIsWritableStreamLockedCodeImplementationVisibility; + +// setUpWritableStreamDefaultWriter +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_SETUPWRITABLESTREAMDEFAULTWRITER 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeImplementationVisibility; + +// writableStreamAbort +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMABORT 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAbortCodeImplementationVisibility; + +// writableStreamClose +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMCLOSE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseCodeImplementationVisibility; + +// writableStreamAddWriteRequest +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMADDWRITEREQUEST 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAddWriteRequestCodeImplementationVisibility; + +// writableStreamCloseQueuedOrInFlight +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMCLOSEQUEUEDORINFLIGHT 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeImplementationVisibility; + +// writableStreamDealWithRejection +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEALWITHREJECTION 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDealWithRejectionCodeImplementationVisibility; + +// writableStreamFinishErroring +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHERRORING 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishErroringCodeImplementationVisibility; + +// writableStreamFinishInFlightClose +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHINFLIGHTCLOSE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility; + +// writableStreamFinishInFlightCloseWithError +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHINFLIGHTCLOSEWITHERROR 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeImplementationVisibility; + +// writableStreamFinishInFlightWrite +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHINFLIGHTWRITE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeImplementationVisibility; + +// writableStreamFinishInFlightWriteWithError +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMFINISHINFLIGHTWRITEWITHERROR 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeImplementationVisibility; + +// writableStreamHasOperationMarkedInFlight +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMHASOPERATIONMARKEDINFLIGHT 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeImplementationVisibility; + +// writableStreamMarkCloseRequestInFlight +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMMARKCLOSEREQUESTINFLIGHT 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeImplementationVisibility; + +// writableStreamMarkFirstWriteRequestInFlight +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMMARKFIRSTWRITEREQUESTINFLIGHT 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeImplementationVisibility; + +// writableStreamRejectCloseAndClosedPromiseIfNeeded +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMREJECTCLOSEANDCLOSEDPROMISEIFNEEDED 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeImplementationVisibility; + +// writableStreamStartErroring +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMSTARTERRORING 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamStartErroringCodeImplementationVisibility; + +// writableStreamUpdateBackpressure +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMUPDATEBACKPRESSURE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeImplementationVisibility; + +// writableStreamDefaultWriterAbort +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERABORT 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeImplementationVisibility; + +// writableStreamDefaultWriterClose +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERCLOSE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeImplementationVisibility; + +// writableStreamDefaultWriterCloseWithErrorPropagation +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERCLOSEWITHERRORPROPAGATION 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeImplementationVisibility; + +// writableStreamDefaultWriterEnsureClosedPromiseRejected +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERENSURECLOSEDPROMISEREJECTED 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeImplementationVisibility; + +// writableStreamDefaultWriterEnsureReadyPromiseRejected +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERENSUREREADYPROMISEREJECTED 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeImplementationVisibility; + +// writableStreamDefaultWriterGetDesiredSize +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERGETDESIREDSIZE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeImplementationVisibility; + +// writableStreamDefaultWriterRelease +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERRELEASE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeImplementationVisibility; + +// writableStreamDefaultWriterWrite +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTWRITERWRITE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeImplementationVisibility; + +// setUpWritableStreamDefaultController +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_SETUPWRITABLESTREAMDEFAULTCONTROLLER 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeImplementationVisibility; + +// writableStreamDefaultControllerStart +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERSTART 1 +extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode; +extern const int s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength; +extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility; +extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructorKind; +extern const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeImplementationVisibility; + +// setUpWritableStreamDefaultControllerFromUnderlyingSink +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_SETUPWRITABLESTREAMDEFAULTCONTROLLERFROMUNDERLYINGSINK 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility; + +// writableStreamDefaultControllerAdvanceQueueIfNeeded +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERADVANCEQUEUEIFNEEDED 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeImplementationVisibility; + +// isCloseSentinel +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_ISCLOSESENTINEL 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsIsCloseSentinelCodeImplementationVisibility; + +// writableStreamDefaultControllerClearAlgorithms +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERCLEARALGORITHMS 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeImplementationVisibility; + +// writableStreamDefaultControllerClose +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERCLOSE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeImplementationVisibility; + +// writableStreamDefaultControllerError +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERERROR 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeImplementationVisibility; + +// writableStreamDefaultControllerErrorIfNeeded +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERERRORIFNEEDED 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeImplementationVisibility; + +// writableStreamDefaultControllerGetBackpressure +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERGETBACKPRESSURE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeImplementationVisibility; + +// writableStreamDefaultControllerGetChunkSize +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERGETCHUNKSIZE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeImplementationVisibility; + +// writableStreamDefaultControllerGetDesiredSize +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERGETDESIREDSIZE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility; + +// writableStreamDefaultControllerProcessClose +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERPROCESSCLOSE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeImplementationVisibility; + +// writableStreamDefaultControllerProcessWrite +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERPROCESSWRITE 1 +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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeImplementationVisibility; + +// writableStreamDefaultControllerWrite +#define WEBCORE_BUILTIN_WRITABLESTREAMINTERNALS_WRITABLESTREAMDEFAULTCONTROLLERWRITE 1 +extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode; +extern const int s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeLength; +extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructAbility; +extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructorKind; +extern const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeImplementationVisibility; + +#define WEBCORE_FOREACH_WRITABLESTREAMINTERNALS_BUILTIN_DATA(macro) \ + macro(isWritableStream, writableStreamInternalsIsWritableStream, 1) \ + macro(isWritableStreamDefaultWriter, writableStreamInternalsIsWritableStreamDefaultWriter, 1) \ + macro(acquireWritableStreamDefaultWriter, writableStreamInternalsAcquireWritableStreamDefaultWriter, 1) \ + macro(createWritableStream, writableStreamInternalsCreateWritableStream, 7) \ + 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, 9) \ + macro(writableStreamDefaultControllerStart, writableStreamInternalsWritableStreamDefaultControllerStart, 1) \ + macro(setUpWritableStreamDefaultControllerFromUnderlyingSink, writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSink, 6) \ + 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_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(writableStreamInternalsWritableStreamDefaultControllerStartCode, writableStreamDefaultControllerStart, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength) \ + 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(isWritableStream) \ + macro(isWritableStreamDefaultWriter) \ + macro(acquireWritableStreamDefaultWriter) \ + macro(createWritableStream) \ + macro(createInternalWritableStreamFromUnderlyingSink) \ + macro(initializeWritableStreamSlots) \ + macro(writableStreamCloseForBindings) \ + macro(writableStreamAbortForBindings) \ + macro(isWritableStreamLocked) \ + macro(setUpWritableStreamDefaultWriter) \ + macro(writableStreamAbort) \ + macro(writableStreamClose) \ + macro(writableStreamAddWriteRequest) \ + macro(writableStreamCloseQueuedOrInFlight) \ + macro(writableStreamDealWithRejection) \ + macro(writableStreamFinishErroring) \ + macro(writableStreamFinishInFlightClose) \ + macro(writableStreamFinishInFlightCloseWithError) \ + macro(writableStreamFinishInFlightWrite) \ + macro(writableStreamFinishInFlightWriteWithError) \ + macro(writableStreamHasOperationMarkedInFlight) \ + macro(writableStreamMarkCloseRequestInFlight) \ + macro(writableStreamMarkFirstWriteRequestInFlight) \ + macro(writableStreamRejectCloseAndClosedPromiseIfNeeded) \ + macro(writableStreamStartErroring) \ + macro(writableStreamUpdateBackpressure) \ + macro(writableStreamDefaultWriterAbort) \ + macro(writableStreamDefaultWriterClose) \ + macro(writableStreamDefaultWriterCloseWithErrorPropagation) \ + macro(writableStreamDefaultWriterEnsureClosedPromiseRejected) \ + macro(writableStreamDefaultWriterEnsureReadyPromiseRejected) \ + macro(writableStreamDefaultWriterGetDesiredSize) \ + macro(writableStreamDefaultWriterRelease) \ + macro(writableStreamDefaultWriterWrite) \ + macro(setUpWritableStreamDefaultController) \ + macro(writableStreamDefaultControllerStart) \ + macro(setUpWritableStreamDefaultControllerFromUnderlyingSink) \ + macro(writableStreamDefaultControllerAdvanceQueueIfNeeded) \ + macro(isCloseSentinel) \ + macro(writableStreamDefaultControllerClearAlgorithms) \ + macro(writableStreamDefaultControllerClose) \ + macro(writableStreamDefaultControllerError) \ + macro(writableStreamDefaultControllerErrorIfNeeded) \ + macro(writableStreamDefaultControllerGetBackpressure) \ + macro(writableStreamDefaultControllerGetChunkSize) \ + macro(writableStreamDefaultControllerGetDesiredSize) \ + macro(writableStreamDefaultControllerProcessClose) \ + macro(writableStreamDefaultControllerProcessWrite) \ + macro(writableStreamDefaultControllerWrite) \ + +#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##ImplementationVisibility, 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&); + /* TransformStreamInternals.ts */ +// isTransformStream +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_ISTRANSFORMSTREAM 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsIsTransformStreamCodeImplementationVisibility; + +// isTransformStreamDefaultController +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_ISTRANSFORMSTREAMDEFAULTCONTROLLER 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsIsTransformStreamDefaultControllerCodeImplementationVisibility; + +// createTransformStream +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_CREATETRANSFORMSTREAM 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsCreateTransformStreamCodeImplementationVisibility; + +// initializeTransformStream +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_INITIALIZETRANSFORMSTREAM 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsInitializeTransformStreamCodeImplementationVisibility; + +// transformStreamError +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMERROR 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorCodeImplementationVisibility; + +// transformStreamErrorWritableAndUnblockWrite +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMERRORWRITABLEANDUNBLOCKWRITE 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeImplementationVisibility; + +// transformStreamSetBackpressure +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMSETBACKPRESSURE 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamSetBackpressureCodeImplementationVisibility; + +// setUpTransformStreamDefaultController +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_SETUPTRANSFORMSTREAMDEFAULTCONTROLLER 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeImplementationVisibility; + +// setUpTransformStreamDefaultControllerFromTransformer +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_SETUPTRANSFORMSTREAMDEFAULTCONTROLLERFROMTRANSFORMER 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility; + +// transformStreamDefaultControllerClearAlgorithms +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERCLEARALGORITHMS 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeImplementationVisibility; + +// transformStreamDefaultControllerEnqueue +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERENQUEUE 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeImplementationVisibility; + +// transformStreamDefaultControllerError +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERERROR 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeImplementationVisibility; + +// transformStreamDefaultControllerPerformTransform +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERPERFORMTRANSFORM 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeImplementationVisibility; + +// transformStreamDefaultControllerTerminate +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTCONTROLLERTERMINATE 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeImplementationVisibility; + +// transformStreamDefaultSinkWriteAlgorithm +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTSINKWRITEALGORITHM 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeImplementationVisibility; + +// transformStreamDefaultSinkAbortAlgorithm +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTSINKABORTALGORITHM 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeImplementationVisibility; + +// transformStreamDefaultSinkCloseAlgorithm +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTSINKCLOSEALGORITHM 1 +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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeImplementationVisibility; + +// transformStreamDefaultSourcePullAlgorithm +#define WEBCORE_BUILTIN_TRANSFORMSTREAMINTERNALS_TRANSFORMSTREAMDEFAULTSOURCEPULLALGORITHM 1 +extern const char* const s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCode; +extern const int s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeLength; +extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility; +extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructorKind; +extern const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeImplementationVisibility; + +#define WEBCORE_FOREACH_TRANSFORMSTREAMINTERNALS_BUILTIN_DATA(macro) \ + macro(isTransformStream, transformStreamInternalsIsTransformStream, 1) \ + macro(isTransformStreamDefaultController, transformStreamInternalsIsTransformStreamDefaultController, 1) \ + macro(createTransformStream, transformStreamInternalsCreateTransformStream, 8) \ + macro(initializeTransformStream, transformStreamInternalsInitializeTransformStream, 7) \ + 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_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(isTransformStream) \ + macro(isTransformStreamDefaultController) \ + macro(createTransformStream) \ + macro(initializeTransformStream) \ + macro(transformStreamError) \ + macro(transformStreamErrorWritableAndUnblockWrite) \ + macro(transformStreamSetBackpressure) \ + macro(setUpTransformStreamDefaultController) \ + macro(setUpTransformStreamDefaultControllerFromTransformer) \ + macro(transformStreamDefaultControllerClearAlgorithms) \ + macro(transformStreamDefaultControllerEnqueue) \ + macro(transformStreamDefaultControllerError) \ + macro(transformStreamDefaultControllerPerformTransform) \ + macro(transformStreamDefaultControllerTerminate) \ + macro(transformStreamDefaultSinkWriteAlgorithm) \ + macro(transformStreamDefaultSinkAbortAlgorithm) \ + macro(transformStreamDefaultSinkCloseAlgorithm) \ + macro(transformStreamDefaultSourcePullAlgorithm) \ + +#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##ImplementationVisibility, 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&); + /* ProcessObjectInternals.ts */ +// binding +#define WEBCORE_BUILTIN_PROCESSOBJECTINTERNALS_BINDING 1 +extern const char* const s_processObjectInternalsBindingCode; +extern const int s_processObjectInternalsBindingCodeLength; +extern const JSC::ConstructAbility s_processObjectInternalsBindingCodeConstructAbility; +extern const JSC::ConstructorKind s_processObjectInternalsBindingCodeConstructorKind; +extern const JSC::ImplementationVisibility s_processObjectInternalsBindingCodeImplementationVisibility; + +// getStdioWriteStream +#define WEBCORE_BUILTIN_PROCESSOBJECTINTERNALS_GETSTDIOWRITESTREAM 1 +extern const char* const s_processObjectInternalsGetStdioWriteStreamCode; +extern const int s_processObjectInternalsGetStdioWriteStreamCodeLength; +extern const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility; +extern const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstructorKind; +extern const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility; + +// getStdinStream +#define WEBCORE_BUILTIN_PROCESSOBJECTINTERNALS_GETSTDINSTREAM 1 +extern const char* const s_processObjectInternalsGetStdinStreamCode; +extern const int s_processObjectInternalsGetStdinStreamCodeLength; +extern const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility; +extern const JSC::ConstructorKind s_processObjectInternalsGetStdinStreamCodeConstructorKind; +extern const JSC::ImplementationVisibility s_processObjectInternalsGetStdinStreamCodeImplementationVisibility; + +#define WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_DATA(macro) \ + macro(binding, processObjectInternalsBinding, 1) \ + macro(getStdioWriteStream, processObjectInternalsGetStdioWriteStream, 2) \ + macro(getStdinStream, processObjectInternalsGetStdinStream, 3) \ + +#define WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_CODE(macro) \ + macro(processObjectInternalsBindingCode, binding, ASCIILiteral(), s_processObjectInternalsBindingCodeLength) \ + macro(processObjectInternalsGetStdioWriteStreamCode, getStdioWriteStream, ASCIILiteral(), s_processObjectInternalsGetStdioWriteStreamCodeLength) \ + macro(processObjectInternalsGetStdinStreamCode, getStdinStream, ASCIILiteral(), s_processObjectInternalsGetStdinStreamCodeLength) \ + +#define WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_FUNCTION_NAME(macro) \ + macro(binding) \ + macro(getStdioWriteStream) \ + macro(getStdinStream) \ + +#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ + JSC::FunctionExecutable* codeName##Generator(JSC::VM&); + +WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) +#undef DECLARE_BUILTIN_GENERATOR + +class ProcessObjectInternalsBuiltinsWrapper : private JSC::WeakHandleOwner { +public: + explicit ProcessObjectInternalsBuiltinsWrapper(JSC::VM& vm) + : m_vm(vm) + WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_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_PROCESSOBJECTINTERNALS_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_PROCESSOBJECTINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) +#undef EXPOSE_BUILTIN_EXECUTABLES + + WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) + + void exportNames(); + +private: + JSC::VM& m_vm; + + WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_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_PROCESSOBJECTINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) +#undef DECLARE_BUILTIN_SOURCE_MEMBERS + +}; + +#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ +inline JSC::UnlinkedFunctionExecutable* ProcessObjectInternalsBuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ + }\ + return m_##name##Executable.get();\ +} +WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) +#undef DEFINE_BUILTIN_EXECUTABLES + +inline void ProcessObjectInternalsBuiltinsWrapper::exportNames() +{ +#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); + WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) +#undef EXPORT_FUNCTION_NAME +} +/* TransformStream.ts */ +// initializeTransformStream +#define WEBCORE_BUILTIN_TRANSFORMSTREAM_INITIALIZETRANSFORMSTREAM 1 +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 JSC::ImplementationVisibility s_transformStreamInitializeTransformStreamCodeImplementationVisibility; + +// readable +#define WEBCORE_BUILTIN_TRANSFORMSTREAM_READABLE 1 +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 JSC::ImplementationVisibility s_transformStreamReadableCodeImplementationVisibility; + +// writable +#define WEBCORE_BUILTIN_TRANSFORMSTREAM_WRITABLE 1 +extern const char* const s_transformStreamWritableCode; +extern const int s_transformStreamWritableCodeLength; +extern const JSC::ConstructAbility s_transformStreamWritableCodeConstructAbility; +extern const JSC::ConstructorKind s_transformStreamWritableCodeConstructorKind; +extern const JSC::ImplementationVisibility s_transformStreamWritableCodeImplementationVisibility; + +#define WEBCORE_FOREACH_TRANSFORMSTREAM_BUILTIN_DATA(macro) \ + macro(initializeTransformStream, transformStreamInitializeTransformStream, 0) \ + macro(readable, transformStreamReadable, 0) \ + macro(writable, transformStreamWritable, 0) \ + +#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##ImplementationVisibility, 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 +} +/* JSBufferPrototype.ts */ +// setBigUint64 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_SETBIGUINT64 1 +extern const char* const s_jsBufferPrototypeSetBigUint64Code; +extern const int s_jsBufferPrototypeSetBigUint64CodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeSetBigUint64CodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeSetBigUint64CodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeSetBigUint64CodeImplementationVisibility; + +// readInt8 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT8 1 +extern const char* const s_jsBufferPrototypeReadInt8Code; +extern const int s_jsBufferPrototypeReadInt8CodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt8CodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt8CodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt8CodeImplementationVisibility; + +// readUInt8 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT8 1 +extern const char* const s_jsBufferPrototypeReadUInt8Code; +extern const int s_jsBufferPrototypeReadUInt8CodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt8CodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt8CodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt8CodeImplementationVisibility; + +// readInt16LE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT16LE 1 +extern const char* const s_jsBufferPrototypeReadInt16LECode; +extern const int s_jsBufferPrototypeReadInt16LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt16LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt16LECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt16LECodeImplementationVisibility; + +// readInt16BE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT16BE 1 +extern const char* const s_jsBufferPrototypeReadInt16BECode; +extern const int s_jsBufferPrototypeReadInt16BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt16BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt16BECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt16BECodeImplementationVisibility; + +// readUInt16LE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT16LE 1 +extern const char* const s_jsBufferPrototypeReadUInt16LECode; +extern const int s_jsBufferPrototypeReadUInt16LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16LECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt16LECodeImplementationVisibility; + +// readUInt16BE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT16BE 1 +extern const char* const s_jsBufferPrototypeReadUInt16BECode; +extern const int s_jsBufferPrototypeReadUInt16BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16BECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt16BECodeImplementationVisibility; + +// readInt32LE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT32LE 1 +extern const char* const s_jsBufferPrototypeReadInt32LECode; +extern const int s_jsBufferPrototypeReadInt32LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt32LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt32LECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt32LECodeImplementationVisibility; + +// readInt32BE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT32BE 1 +extern const char* const s_jsBufferPrototypeReadInt32BECode; +extern const int s_jsBufferPrototypeReadInt32BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt32BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt32BECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt32BECodeImplementationVisibility; + +// readUInt32LE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT32LE 1 +extern const char* const s_jsBufferPrototypeReadUInt32LECode; +extern const int s_jsBufferPrototypeReadUInt32LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32LECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt32LECodeImplementationVisibility; + +// readUInt32BE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT32BE 1 +extern const char* const s_jsBufferPrototypeReadUInt32BECode; +extern const int s_jsBufferPrototypeReadUInt32BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32BECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt32BECodeImplementationVisibility; + +// readIntLE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINTLE 1 +extern const char* const s_jsBufferPrototypeReadIntLECode; +extern const int s_jsBufferPrototypeReadIntLECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadIntLECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility; + +// readIntBE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINTBE 1 +extern const char* const s_jsBufferPrototypeReadIntBECode; +extern const int s_jsBufferPrototypeReadIntBECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadIntBECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntBECodeImplementationVisibility; + +// readUIntLE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINTLE 1 +extern const char* const s_jsBufferPrototypeReadUIntLECode; +extern const int s_jsBufferPrototypeReadUIntLECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadUIntLECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadUIntLECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntLECodeImplementationVisibility; + +// readUIntBE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINTBE 1 +extern const char* const s_jsBufferPrototypeReadUIntBECode; +extern const int s_jsBufferPrototypeReadUIntBECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadUIntBECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadUIntBECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntBECodeImplementationVisibility; + +// readFloatLE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READFLOATLE 1 +extern const char* const s_jsBufferPrototypeReadFloatLECode; +extern const int s_jsBufferPrototypeReadFloatLECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadFloatLECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadFloatLECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadFloatLECodeImplementationVisibility; + +// readFloatBE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READFLOATBE 1 +extern const char* const s_jsBufferPrototypeReadFloatBECode; +extern const int s_jsBufferPrototypeReadFloatBECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadFloatBECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadFloatBECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadFloatBECodeImplementationVisibility; + +// readDoubleLE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READDOUBLELE 1 +extern const char* const s_jsBufferPrototypeReadDoubleLECode; +extern const int s_jsBufferPrototypeReadDoubleLECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleLECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleLECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadDoubleLECodeImplementationVisibility; + +// readDoubleBE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READDOUBLEBE 1 +extern const char* const s_jsBufferPrototypeReadDoubleBECode; +extern const int s_jsBufferPrototypeReadDoubleBECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleBECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleBECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadDoubleBECodeImplementationVisibility; + +// readBigInt64LE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READBIGINT64LE 1 +extern const char* const s_jsBufferPrototypeReadBigInt64LECode; +extern const int s_jsBufferPrototypeReadBigInt64LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64LECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigInt64LECodeImplementationVisibility; + +// readBigInt64BE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READBIGINT64BE 1 +extern const char* const s_jsBufferPrototypeReadBigInt64BECode; +extern const int s_jsBufferPrototypeReadBigInt64BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64BECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigInt64BECodeImplementationVisibility; + +// readBigUInt64LE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READBIGUINT64LE 1 +extern const char* const s_jsBufferPrototypeReadBigUInt64LECode; +extern const int s_jsBufferPrototypeReadBigUInt64LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64LECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigUInt64LECodeImplementationVisibility; + +// readBigUInt64BE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READBIGUINT64BE 1 +extern const char* const s_jsBufferPrototypeReadBigUInt64BECode; +extern const int s_jsBufferPrototypeReadBigUInt64BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64BECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigUInt64BECodeImplementationVisibility; + +// writeInt8 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT8 1 +extern const char* const s_jsBufferPrototypeWriteInt8Code; +extern const int s_jsBufferPrototypeWriteInt8CodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt8CodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt8CodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt8CodeImplementationVisibility; + +// writeUInt8 +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT8 1 +extern const char* const s_jsBufferPrototypeWriteUInt8Code; +extern const int s_jsBufferPrototypeWriteUInt8CodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt8CodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt8CodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt8CodeImplementationVisibility; + +// writeInt16LE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT16LE 1 +extern const char* const s_jsBufferPrototypeWriteInt16LECode; +extern const int s_jsBufferPrototypeWriteInt16LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16LECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16LECodeImplementationVisibility; + +// writeInt16BE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT16BE 1 +extern const char* const s_jsBufferPrototypeWriteInt16BECode; +extern const int s_jsBufferPrototypeWriteInt16BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16BECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16BECodeImplementationVisibility; + +// writeUInt16LE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT16LE 1 +extern const char* const s_jsBufferPrototypeWriteUInt16LECode; +extern const int s_jsBufferPrototypeWriteUInt16LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16LECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16LECodeImplementationVisibility; + +// writeUInt16BE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT16BE 1 +extern const char* const s_jsBufferPrototypeWriteUInt16BECode; +extern const int s_jsBufferPrototypeWriteUInt16BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16BECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16BECodeImplementationVisibility; + +// writeInt32LE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT32LE 1 +extern const char* const s_jsBufferPrototypeWriteInt32LECode; +extern const int s_jsBufferPrototypeWriteInt32LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32LECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32LECodeImplementationVisibility; + +// writeInt32BE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT32BE 1 +extern const char* const s_jsBufferPrototypeWriteInt32BECode; +extern const int s_jsBufferPrototypeWriteInt32BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32BECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32BECodeImplementationVisibility; + +// writeUInt32LE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT32LE 1 +extern const char* const s_jsBufferPrototypeWriteUInt32LECode; +extern const int s_jsBufferPrototypeWriteUInt32LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32LECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32LECodeImplementationVisibility; + +// writeUInt32BE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT32BE 1 +extern const char* const s_jsBufferPrototypeWriteUInt32BECode; +extern const int s_jsBufferPrototypeWriteUInt32BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32BECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32BECodeImplementationVisibility; + +// writeIntLE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINTLE 1 +extern const char* const s_jsBufferPrototypeWriteIntLECode; +extern const int s_jsBufferPrototypeWriteIntLECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteIntLECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteIntLECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteIntLECodeImplementationVisibility; + +// writeIntBE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINTBE 1 +extern const char* const s_jsBufferPrototypeWriteIntBECode; +extern const int s_jsBufferPrototypeWriteIntBECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteIntBECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteIntBECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteIntBECodeImplementationVisibility; + +// writeUIntLE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINTLE 1 +extern const char* const s_jsBufferPrototypeWriteUIntLECode; +extern const int s_jsBufferPrototypeWriteUIntLECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntLECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntLECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntLECodeImplementationVisibility; + +// writeUIntBE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINTBE 1 +extern const char* const s_jsBufferPrototypeWriteUIntBECode; +extern const int s_jsBufferPrototypeWriteUIntBECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntBECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntBECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntBECodeImplementationVisibility; + +// writeFloatLE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEFLOATLE 1 +extern const char* const s_jsBufferPrototypeWriteFloatLECode; +extern const int s_jsBufferPrototypeWriteFloatLECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatLECodeImplementationVisibility; + +// writeFloatBE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEFLOATBE 1 +extern const char* const s_jsBufferPrototypeWriteFloatBECode; +extern const int s_jsBufferPrototypeWriteFloatBECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatBECodeImplementationVisibility; + +// writeDoubleLE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEDOUBLELE 1 +extern const char* const s_jsBufferPrototypeWriteDoubleLECode; +extern const int s_jsBufferPrototypeWriteDoubleLECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleLECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleLECodeImplementationVisibility; + +// writeDoubleBE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEDOUBLEBE 1 +extern const char* const s_jsBufferPrototypeWriteDoubleBECode; +extern const int s_jsBufferPrototypeWriteDoubleBECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleBECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleBECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleBECodeImplementationVisibility; + +// writeBigInt64LE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEBIGINT64LE 1 +extern const char* const s_jsBufferPrototypeWriteBigInt64LECode; +extern const int s_jsBufferPrototypeWriteBigInt64LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64LECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64LECodeImplementationVisibility; + +// writeBigInt64BE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEBIGINT64BE 1 +extern const char* const s_jsBufferPrototypeWriteBigInt64BECode; +extern const int s_jsBufferPrototypeWriteBigInt64BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64BECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64BECodeImplementationVisibility; + +// writeBigUInt64LE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEBIGUINT64LE 1 +extern const char* const s_jsBufferPrototypeWriteBigUInt64LECode; +extern const int s_jsBufferPrototypeWriteBigUInt64LECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64LECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64LECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64LECodeImplementationVisibility; + +// writeBigUInt64BE +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEBIGUINT64BE 1 +extern const char* const s_jsBufferPrototypeWriteBigUInt64BECode; +extern const int s_jsBufferPrototypeWriteBigUInt64BECodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64BECodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64BECodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64BECodeImplementationVisibility; + +// utf8Write +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UTF8WRITE 1 +extern const char* const s_jsBufferPrototypeUtf8WriteCode; +extern const int s_jsBufferPrototypeUtf8WriteCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeUtf8WriteCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeUtf8WriteCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeUtf8WriteCodeImplementationVisibility; + +// ucs2Write +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UCS2WRITE 1 +extern const char* const s_jsBufferPrototypeUcs2WriteCode; +extern const int s_jsBufferPrototypeUcs2WriteCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeUcs2WriteCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeUcs2WriteCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeUcs2WriteCodeImplementationVisibility; + +// utf16leWrite +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UTF16LEWRITE 1 +extern const char* const s_jsBufferPrototypeUtf16leWriteCode; +extern const int s_jsBufferPrototypeUtf16leWriteCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeUtf16leWriteCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeUtf16leWriteCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leWriteCodeImplementationVisibility; + +// latin1Write +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_LATIN1WRITE 1 +extern const char* const s_jsBufferPrototypeLatin1WriteCode; +extern const int s_jsBufferPrototypeLatin1WriteCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeLatin1WriteCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeLatin1WriteCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1WriteCodeImplementationVisibility; + +// asciiWrite +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_ASCIIWRITE 1 +extern const char* const s_jsBufferPrototypeAsciiWriteCode; +extern const int s_jsBufferPrototypeAsciiWriteCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeAsciiWriteCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeAsciiWriteCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeAsciiWriteCodeImplementationVisibility; + +// base64Write +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BASE64WRITE 1 +extern const char* const s_jsBufferPrototypeBase64WriteCode; +extern const int s_jsBufferPrototypeBase64WriteCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeBase64WriteCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeBase64WriteCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeBase64WriteCodeImplementationVisibility; + +// base64urlWrite +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BASE64URLWRITE 1 +extern const char* const s_jsBufferPrototypeBase64urlWriteCode; +extern const int s_jsBufferPrototypeBase64urlWriteCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeBase64urlWriteCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeBase64urlWriteCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlWriteCodeImplementationVisibility; + +// hexWrite +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_HEXWRITE 1 +extern const char* const s_jsBufferPrototypeHexWriteCode; +extern const int s_jsBufferPrototypeHexWriteCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeHexWriteCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeHexWriteCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeHexWriteCodeImplementationVisibility; + +// utf8Slice +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UTF8SLICE 1 +extern const char* const s_jsBufferPrototypeUtf8SliceCode; +extern const int s_jsBufferPrototypeUtf8SliceCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeUtf8SliceCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeUtf8SliceCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeUtf8SliceCodeImplementationVisibility; + +// ucs2Slice +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UCS2SLICE 1 +extern const char* const s_jsBufferPrototypeUcs2SliceCode; +extern const int s_jsBufferPrototypeUcs2SliceCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeUcs2SliceCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeUcs2SliceCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeUcs2SliceCodeImplementationVisibility; + +// utf16leSlice +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UTF16LESLICE 1 +extern const char* const s_jsBufferPrototypeUtf16leSliceCode; +extern const int s_jsBufferPrototypeUtf16leSliceCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeUtf16leSliceCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeUtf16leSliceCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leSliceCodeImplementationVisibility; + +// latin1Slice +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_LATIN1SLICE 1 +extern const char* const s_jsBufferPrototypeLatin1SliceCode; +extern const int s_jsBufferPrototypeLatin1SliceCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeLatin1SliceCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeLatin1SliceCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1SliceCodeImplementationVisibility; + +// asciiSlice +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_ASCIISLICE 1 +extern const char* const s_jsBufferPrototypeAsciiSliceCode; +extern const int s_jsBufferPrototypeAsciiSliceCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeAsciiSliceCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeAsciiSliceCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeAsciiSliceCodeImplementationVisibility; + +// base64Slice +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BASE64SLICE 1 +extern const char* const s_jsBufferPrototypeBase64SliceCode; +extern const int s_jsBufferPrototypeBase64SliceCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeBase64SliceCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeBase64SliceCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeBase64SliceCodeImplementationVisibility; + +// base64urlSlice +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BASE64URLSLICE 1 +extern const char* const s_jsBufferPrototypeBase64urlSliceCode; +extern const int s_jsBufferPrototypeBase64urlSliceCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeBase64urlSliceCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeBase64urlSliceCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlSliceCodeImplementationVisibility; + +// hexSlice +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_HEXSLICE 1 +extern const char* const s_jsBufferPrototypeHexSliceCode; +extern const int s_jsBufferPrototypeHexSliceCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeHexSliceCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeHexSliceCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeHexSliceCodeImplementationVisibility; + +// toJSON +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_TOJSON 1 +extern const char* const s_jsBufferPrototypeToJSONCode; +extern const int s_jsBufferPrototypeToJSONCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeToJSONCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeToJSONCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeToJSONCodeImplementationVisibility; + +// slice +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_SLICE 1 +extern const char* const s_jsBufferPrototypeSliceCode; +extern const int s_jsBufferPrototypeSliceCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeSliceCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility; + +// parent +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_PARENT 1 +extern const char* const s_jsBufferPrototypeParentCode; +extern const int s_jsBufferPrototypeParentCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeParentCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeParentCodeImplementationVisibility; + +// offset +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_OFFSET 1 +extern const char* const s_jsBufferPrototypeOffsetCode; +extern const int s_jsBufferPrototypeOffsetCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeOffsetCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeOffsetCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeOffsetCodeImplementationVisibility; + +// inspect +#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_INSPECT 1 +extern const char* const s_jsBufferPrototypeInspectCode; +extern const int s_jsBufferPrototypeInspectCodeLength; +extern const JSC::ConstructAbility s_jsBufferPrototypeInspectCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferPrototypeInspectCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferPrototypeInspectCodeImplementationVisibility; + +#define WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_DATA(macro) \ + macro(setBigUint64, jsBufferPrototypeSetBigUint64, 3) \ + macro(readInt8, jsBufferPrototypeReadInt8, 1) \ + macro(readUInt8, jsBufferPrototypeReadUInt8, 1) \ + macro(readInt16LE, jsBufferPrototypeReadInt16LE, 1) \ + macro(readInt16BE, jsBufferPrototypeReadInt16BE, 1) \ + macro(readUInt16LE, jsBufferPrototypeReadUInt16LE, 1) \ + macro(readUInt16BE, jsBufferPrototypeReadUInt16BE, 1) \ + macro(readInt32LE, jsBufferPrototypeReadInt32LE, 1) \ + macro(readInt32BE, jsBufferPrototypeReadInt32BE, 1) \ + macro(readUInt32LE, jsBufferPrototypeReadUInt32LE, 1) \ + macro(readUInt32BE, jsBufferPrototypeReadUInt32BE, 1) \ + macro(readIntLE, jsBufferPrototypeReadIntLE, 2) \ + macro(readIntBE, jsBufferPrototypeReadIntBE, 2) \ + macro(readUIntLE, jsBufferPrototypeReadUIntLE, 2) \ + macro(readUIntBE, jsBufferPrototypeReadUIntBE, 2) \ + macro(readFloatLE, jsBufferPrototypeReadFloatLE, 1) \ + macro(readFloatBE, jsBufferPrototypeReadFloatBE, 1) \ + macro(readDoubleLE, jsBufferPrototypeReadDoubleLE, 1) \ + macro(readDoubleBE, jsBufferPrototypeReadDoubleBE, 1) \ + macro(readBigInt64LE, jsBufferPrototypeReadBigInt64LE, 1) \ + macro(readBigInt64BE, jsBufferPrototypeReadBigInt64BE, 1) \ + macro(readBigUInt64LE, jsBufferPrototypeReadBigUInt64LE, 1) \ + macro(readBigUInt64BE, jsBufferPrototypeReadBigUInt64BE, 1) \ + macro(writeInt8, jsBufferPrototypeWriteInt8, 2) \ + macro(writeUInt8, jsBufferPrototypeWriteUInt8, 2) \ + macro(writeInt16LE, jsBufferPrototypeWriteInt16LE, 2) \ + macro(writeInt16BE, jsBufferPrototypeWriteInt16BE, 2) \ + macro(writeUInt16LE, jsBufferPrototypeWriteUInt16LE, 2) \ + macro(writeUInt16BE, jsBufferPrototypeWriteUInt16BE, 2) \ + macro(writeInt32LE, jsBufferPrototypeWriteInt32LE, 2) \ + macro(writeInt32BE, jsBufferPrototypeWriteInt32BE, 2) \ + macro(writeUInt32LE, jsBufferPrototypeWriteUInt32LE, 2) \ + macro(writeUInt32BE, jsBufferPrototypeWriteUInt32BE, 2) \ + macro(writeIntLE, jsBufferPrototypeWriteIntLE, 3) \ + macro(writeIntBE, jsBufferPrototypeWriteIntBE, 3) \ + macro(writeUIntLE, jsBufferPrototypeWriteUIntLE, 3) \ + macro(writeUIntBE, jsBufferPrototypeWriteUIntBE, 3) \ + macro(writeFloatLE, jsBufferPrototypeWriteFloatLE, 2) \ + macro(writeFloatBE, jsBufferPrototypeWriteFloatBE, 2) \ + macro(writeDoubleLE, jsBufferPrototypeWriteDoubleLE, 2) \ + macro(writeDoubleBE, jsBufferPrototypeWriteDoubleBE, 2) \ + macro(writeBigInt64LE, jsBufferPrototypeWriteBigInt64LE, 2) \ + macro(writeBigInt64BE, jsBufferPrototypeWriteBigInt64BE, 2) \ + macro(writeBigUInt64LE, jsBufferPrototypeWriteBigUInt64LE, 2) \ + macro(writeBigUInt64BE, jsBufferPrototypeWriteBigUInt64BE, 2) \ + macro(utf8Write, jsBufferPrototypeUtf8Write, 3) \ + macro(ucs2Write, jsBufferPrototypeUcs2Write, 3) \ + macro(utf16leWrite, jsBufferPrototypeUtf16leWrite, 3) \ + macro(latin1Write, jsBufferPrototypeLatin1Write, 3) \ + macro(asciiWrite, jsBufferPrototypeAsciiWrite, 3) \ + macro(base64Write, jsBufferPrototypeBase64Write, 3) \ + macro(base64urlWrite, jsBufferPrototypeBase64urlWrite, 3) \ + macro(hexWrite, jsBufferPrototypeHexWrite, 3) \ + macro(utf8Slice, jsBufferPrototypeUtf8Slice, 2) \ + macro(ucs2Slice, jsBufferPrototypeUcs2Slice, 2) \ + macro(utf16leSlice, jsBufferPrototypeUtf16leSlice, 2) \ + macro(latin1Slice, jsBufferPrototypeLatin1Slice, 2) \ + macro(asciiSlice, jsBufferPrototypeAsciiSlice, 2) \ + macro(base64Slice, jsBufferPrototypeBase64Slice, 2) \ + macro(base64urlSlice, jsBufferPrototypeBase64urlSlice, 2) \ + macro(hexSlice, jsBufferPrototypeHexSlice, 2) \ + macro(toJSON, jsBufferPrototypeToJSON, 0) \ + macro(slice, jsBufferPrototypeSlice, 2) \ + macro(parent, jsBufferPrototypeParent, 0) \ + macro(offset, jsBufferPrototypeOffset, 0) \ + macro(inspect, jsBufferPrototypeInspect, 2) \ + +#define WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_CODE(macro) \ + macro(jsBufferPrototypeSetBigUint64Code, setBigUint64, ASCIILiteral(), s_jsBufferPrototypeSetBigUint64CodeLength) \ + macro(jsBufferPrototypeReadInt8Code, readInt8, ASCIILiteral(), s_jsBufferPrototypeReadInt8CodeLength) \ + macro(jsBufferPrototypeReadUInt8Code, readUInt8, ASCIILiteral(), s_jsBufferPrototypeReadUInt8CodeLength) \ + macro(jsBufferPrototypeReadInt16LECode, readInt16LE, ASCIILiteral(), s_jsBufferPrototypeReadInt16LECodeLength) \ + macro(jsBufferPrototypeReadInt16BECode, readInt16BE, ASCIILiteral(), s_jsBufferPrototypeReadInt16BECodeLength) \ + macro(jsBufferPrototypeReadUInt16LECode, readUInt16LE, ASCIILiteral(), s_jsBufferPrototypeReadUInt16LECodeLength) \ + macro(jsBufferPrototypeReadUInt16BECode, readUInt16BE, ASCIILiteral(), s_jsBufferPrototypeReadUInt16BECodeLength) \ + macro(jsBufferPrototypeReadInt32LECode, readInt32LE, ASCIILiteral(), s_jsBufferPrototypeReadInt32LECodeLength) \ + macro(jsBufferPrototypeReadInt32BECode, readInt32BE, ASCIILiteral(), s_jsBufferPrototypeReadInt32BECodeLength) \ + macro(jsBufferPrototypeReadUInt32LECode, readUInt32LE, ASCIILiteral(), s_jsBufferPrototypeReadUInt32LECodeLength) \ + macro(jsBufferPrototypeReadUInt32BECode, readUInt32BE, ASCIILiteral(), s_jsBufferPrototypeReadUInt32BECodeLength) \ + macro(jsBufferPrototypeReadIntLECode, readIntLE, ASCIILiteral(), s_jsBufferPrototypeReadIntLECodeLength) \ + macro(jsBufferPrototypeReadIntBECode, readIntBE, ASCIILiteral(), s_jsBufferPrototypeReadIntBECodeLength) \ + macro(jsBufferPrototypeReadUIntLECode, readUIntLE, ASCIILiteral(), s_jsBufferPrototypeReadUIntLECodeLength) \ + macro(jsBufferPrototypeReadUIntBECode, readUIntBE, ASCIILiteral(), s_jsBufferPrototypeReadUIntBECodeLength) \ + macro(jsBufferPrototypeReadFloatLECode, readFloatLE, ASCIILiteral(), s_jsBufferPrototypeReadFloatLECodeLength) \ + macro(jsBufferPrototypeReadFloatBECode, readFloatBE, ASCIILiteral(), s_jsBufferPrototypeReadFloatBECodeLength) \ + macro(jsBufferPrototypeReadDoubleLECode, readDoubleLE, ASCIILiteral(), s_jsBufferPrototypeReadDoubleLECodeLength) \ + macro(jsBufferPrototypeReadDoubleBECode, readDoubleBE, ASCIILiteral(), s_jsBufferPrototypeReadDoubleBECodeLength) \ + macro(jsBufferPrototypeReadBigInt64LECode, readBigInt64LE, ASCIILiteral(), s_jsBufferPrototypeReadBigInt64LECodeLength) \ + macro(jsBufferPrototypeReadBigInt64BECode, readBigInt64BE, ASCIILiteral(), s_jsBufferPrototypeReadBigInt64BECodeLength) \ + macro(jsBufferPrototypeReadBigUInt64LECode, readBigUInt64LE, ASCIILiteral(), s_jsBufferPrototypeReadBigUInt64LECodeLength) \ + macro(jsBufferPrototypeReadBigUInt64BECode, readBigUInt64BE, ASCIILiteral(), s_jsBufferPrototypeReadBigUInt64BECodeLength) \ + macro(jsBufferPrototypeWriteInt8Code, writeInt8, ASCIILiteral(), s_jsBufferPrototypeWriteInt8CodeLength) \ + macro(jsBufferPrototypeWriteUInt8Code, writeUInt8, ASCIILiteral(), s_jsBufferPrototypeWriteUInt8CodeLength) \ + macro(jsBufferPrototypeWriteInt16LECode, writeInt16LE, ASCIILiteral(), s_jsBufferPrototypeWriteInt16LECodeLength) \ + macro(jsBufferPrototypeWriteInt16BECode, writeInt16BE, ASCIILiteral(), s_jsBufferPrototypeWriteInt16BECodeLength) \ + macro(jsBufferPrototypeWriteUInt16LECode, writeUInt16LE, ASCIILiteral(), s_jsBufferPrototypeWriteUInt16LECodeLength) \ + macro(jsBufferPrototypeWriteUInt16BECode, writeUInt16BE, ASCIILiteral(), s_jsBufferPrototypeWriteUInt16BECodeLength) \ + macro(jsBufferPrototypeWriteInt32LECode, writeInt32LE, ASCIILiteral(), s_jsBufferPrototypeWriteInt32LECodeLength) \ + macro(jsBufferPrototypeWriteInt32BECode, writeInt32BE, ASCIILiteral(), s_jsBufferPrototypeWriteInt32BECodeLength) \ + macro(jsBufferPrototypeWriteUInt32LECode, writeUInt32LE, ASCIILiteral(), s_jsBufferPrototypeWriteUInt32LECodeLength) \ + macro(jsBufferPrototypeWriteUInt32BECode, writeUInt32BE, ASCIILiteral(), s_jsBufferPrototypeWriteUInt32BECodeLength) \ + macro(jsBufferPrototypeWriteIntLECode, writeIntLE, ASCIILiteral(), s_jsBufferPrototypeWriteIntLECodeLength) \ + macro(jsBufferPrototypeWriteIntBECode, writeIntBE, ASCIILiteral(), s_jsBufferPrototypeWriteIntBECodeLength) \ + macro(jsBufferPrototypeWriteUIntLECode, writeUIntLE, ASCIILiteral(), s_jsBufferPrototypeWriteUIntLECodeLength) \ + macro(jsBufferPrototypeWriteUIntBECode, writeUIntBE, ASCIILiteral(), s_jsBufferPrototypeWriteUIntBECodeLength) \ + macro(jsBufferPrototypeWriteFloatLECode, writeFloatLE, ASCIILiteral(), s_jsBufferPrototypeWriteFloatLECodeLength) \ + macro(jsBufferPrototypeWriteFloatBECode, writeFloatBE, ASCIILiteral(), s_jsBufferPrototypeWriteFloatBECodeLength) \ + macro(jsBufferPrototypeWriteDoubleLECode, writeDoubleLE, ASCIILiteral(), s_jsBufferPrototypeWriteDoubleLECodeLength) \ + macro(jsBufferPrototypeWriteDoubleBECode, writeDoubleBE, ASCIILiteral(), s_jsBufferPrototypeWriteDoubleBECodeLength) \ + macro(jsBufferPrototypeWriteBigInt64LECode, writeBigInt64LE, ASCIILiteral(), s_jsBufferPrototypeWriteBigInt64LECodeLength) \ + macro(jsBufferPrototypeWriteBigInt64BECode, writeBigInt64BE, ASCIILiteral(), s_jsBufferPrototypeWriteBigInt64BECodeLength) \ + macro(jsBufferPrototypeWriteBigUInt64LECode, writeBigUInt64LE, ASCIILiteral(), s_jsBufferPrototypeWriteBigUInt64LECodeLength) \ + macro(jsBufferPrototypeWriteBigUInt64BECode, writeBigUInt64BE, ASCIILiteral(), s_jsBufferPrototypeWriteBigUInt64BECodeLength) \ + macro(jsBufferPrototypeUtf8WriteCode, utf8Write, ASCIILiteral(), s_jsBufferPrototypeUtf8WriteCodeLength) \ + macro(jsBufferPrototypeUcs2WriteCode, ucs2Write, ASCIILiteral(), s_jsBufferPrototypeUcs2WriteCodeLength) \ + macro(jsBufferPrototypeUtf16leWriteCode, utf16leWrite, ASCIILiteral(), s_jsBufferPrototypeUtf16leWriteCodeLength) \ + macro(jsBufferPrototypeLatin1WriteCode, latin1Write, ASCIILiteral(), s_jsBufferPrototypeLatin1WriteCodeLength) \ + macro(jsBufferPrototypeAsciiWriteCode, asciiWrite, ASCIILiteral(), s_jsBufferPrototypeAsciiWriteCodeLength) \ + macro(jsBufferPrototypeBase64WriteCode, base64Write, ASCIILiteral(), s_jsBufferPrototypeBase64WriteCodeLength) \ + macro(jsBufferPrototypeBase64urlWriteCode, base64urlWrite, ASCIILiteral(), s_jsBufferPrototypeBase64urlWriteCodeLength) \ + macro(jsBufferPrototypeHexWriteCode, hexWrite, ASCIILiteral(), s_jsBufferPrototypeHexWriteCodeLength) \ + macro(jsBufferPrototypeUtf8SliceCode, utf8Slice, ASCIILiteral(), s_jsBufferPrototypeUtf8SliceCodeLength) \ + macro(jsBufferPrototypeUcs2SliceCode, ucs2Slice, ASCIILiteral(), s_jsBufferPrototypeUcs2SliceCodeLength) \ + macro(jsBufferPrototypeUtf16leSliceCode, utf16leSlice, ASCIILiteral(), s_jsBufferPrototypeUtf16leSliceCodeLength) \ + macro(jsBufferPrototypeLatin1SliceCode, latin1Slice, ASCIILiteral(), s_jsBufferPrototypeLatin1SliceCodeLength) \ + macro(jsBufferPrototypeAsciiSliceCode, asciiSlice, ASCIILiteral(), s_jsBufferPrototypeAsciiSliceCodeLength) \ + macro(jsBufferPrototypeBase64SliceCode, base64Slice, ASCIILiteral(), s_jsBufferPrototypeBase64SliceCodeLength) \ + macro(jsBufferPrototypeBase64urlSliceCode, base64urlSlice, ASCIILiteral(), s_jsBufferPrototypeBase64urlSliceCodeLength) \ + macro(jsBufferPrototypeHexSliceCode, hexSlice, ASCIILiteral(), s_jsBufferPrototypeHexSliceCodeLength) \ + macro(jsBufferPrototypeToJSONCode, toJSON, ASCIILiteral(), s_jsBufferPrototypeToJSONCodeLength) \ + macro(jsBufferPrototypeSliceCode, slice, ASCIILiteral(), s_jsBufferPrototypeSliceCodeLength) \ + macro(jsBufferPrototypeParentCode, parent, "get parent"_s, s_jsBufferPrototypeParentCodeLength) \ + macro(jsBufferPrototypeOffsetCode, offset, "get offset"_s, s_jsBufferPrototypeOffsetCodeLength) \ + macro(jsBufferPrototypeInspectCode, inspect, ASCIILiteral(), s_jsBufferPrototypeInspectCodeLength) \ + +#define WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_FUNCTION_NAME(macro) \ + macro(setBigUint64) \ + macro(readInt8) \ + macro(readUInt8) \ + macro(readInt16LE) \ + macro(readInt16BE) \ + macro(readUInt16LE) \ + macro(readUInt16BE) \ + macro(readInt32LE) \ + macro(readInt32BE) \ + macro(readUInt32LE) \ + macro(readUInt32BE) \ + macro(readIntLE) \ + macro(readIntBE) \ + macro(readUIntLE) \ + macro(readUIntBE) \ + macro(readFloatLE) \ + macro(readFloatBE) \ + macro(readDoubleLE) \ + macro(readDoubleBE) \ + macro(readBigInt64LE) \ + macro(readBigInt64BE) \ + macro(readBigUInt64LE) \ + macro(readBigUInt64BE) \ + macro(writeInt8) \ + macro(writeUInt8) \ + macro(writeInt16LE) \ + macro(writeInt16BE) \ + macro(writeUInt16LE) \ + macro(writeUInt16BE) \ + macro(writeInt32LE) \ + macro(writeInt32BE) \ + macro(writeUInt32LE) \ + macro(writeUInt32BE) \ + macro(writeIntLE) \ + macro(writeIntBE) \ + macro(writeUIntLE) \ + macro(writeUIntBE) \ + macro(writeFloatLE) \ + macro(writeFloatBE) \ + macro(writeDoubleLE) \ + macro(writeDoubleBE) \ + macro(writeBigInt64LE) \ + macro(writeBigInt64BE) \ + macro(writeBigUInt64LE) \ + macro(writeBigUInt64BE) \ + macro(utf8Write) \ + macro(ucs2Write) \ + macro(utf16leWrite) \ + macro(latin1Write) \ + macro(asciiWrite) \ + macro(base64Write) \ + macro(base64urlWrite) \ + macro(hexWrite) \ + macro(utf8Slice) \ + macro(ucs2Slice) \ + macro(utf16leSlice) \ + macro(latin1Slice) \ + macro(asciiSlice) \ + macro(base64Slice) \ + macro(base64urlSlice) \ + macro(hexSlice) \ + macro(toJSON) \ + macro(slice) \ + macro(parent) \ + macro(offset) \ + macro(inspect) \ + +#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ + JSC::FunctionExecutable* codeName##Generator(JSC::VM&); + +WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) +#undef DECLARE_BUILTIN_GENERATOR + +class JSBufferPrototypeBuiltinsWrapper : private JSC::WeakHandleOwner { +public: + explicit JSBufferPrototypeBuiltinsWrapper(JSC::VM& vm) + : m_vm(vm) + WEBCORE_FOREACH_JSBUFFERPROTOTYPE_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_JSBUFFERPROTOTYPE_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_JSBUFFERPROTOTYPE_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) +#undef EXPOSE_BUILTIN_EXECUTABLES + + WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) + + void exportNames(); + +private: + JSC::VM& m_vm; + + WEBCORE_FOREACH_JSBUFFERPROTOTYPE_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_JSBUFFERPROTOTYPE_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) +#undef DECLARE_BUILTIN_SOURCE_MEMBERS + +}; + +#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ +inline JSC::UnlinkedFunctionExecutable* JSBufferPrototypeBuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ + }\ + return m_##name##Executable.get();\ +} +WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) +#undef DEFINE_BUILTIN_EXECUTABLES + +inline void JSBufferPrototypeBuiltinsWrapper::exportNames() +{ +#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); + WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) +#undef EXPORT_FUNCTION_NAME +} +/* ReadableByteStreamController.ts */ +// initializeReadableByteStreamController +#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_INITIALIZEREADABLEBYTESTREAMCONTROLLER 1 +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 JSC::ImplementationVisibility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeImplementationVisibility; + +// enqueue +#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_ENQUEUE 1 +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 JSC::ImplementationVisibility s_readableByteStreamControllerEnqueueCodeImplementationVisibility; + +// error +#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_ERROR 1 +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 JSC::ImplementationVisibility s_readableByteStreamControllerErrorCodeImplementationVisibility; + +// close +#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_CLOSE 1 +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 JSC::ImplementationVisibility s_readableByteStreamControllerCloseCodeImplementationVisibility; + +// byobRequest +#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_BYOBREQUEST 1 +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 JSC::ImplementationVisibility s_readableByteStreamControllerByobRequestCodeImplementationVisibility; + +// desiredSize +#define WEBCORE_BUILTIN_READABLEBYTESTREAMCONTROLLER_DESIREDSIZE 1 +extern const char* const s_readableByteStreamControllerDesiredSizeCode; +extern const int s_readableByteStreamControllerDesiredSizeCodeLength; +extern const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility; +extern const JSC::ConstructorKind s_readableByteStreamControllerDesiredSizeCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableByteStreamControllerDesiredSizeCodeImplementationVisibility; + +#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_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(initializeReadableByteStreamController) \ + macro(enqueue) \ + macro(error) \ + macro(close) \ + macro(byobRequest) \ + macro(desiredSize) \ + +#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##ImplementationVisibility, 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 +} +/* ConsoleObject.ts */ +// asyncIterator +#define WEBCORE_BUILTIN_CONSOLEOBJECT_ASYNCITERATOR 1 +extern const char* const s_consoleObjectAsyncIteratorCode; +extern const int s_consoleObjectAsyncIteratorCodeLength; +extern const JSC::ConstructAbility s_consoleObjectAsyncIteratorCodeConstructAbility; +extern const JSC::ConstructorKind s_consoleObjectAsyncIteratorCodeConstructorKind; +extern const JSC::ImplementationVisibility s_consoleObjectAsyncIteratorCodeImplementationVisibility; + +// write +#define WEBCORE_BUILTIN_CONSOLEOBJECT_WRITE 1 +extern const char* const s_consoleObjectWriteCode; +extern const int s_consoleObjectWriteCodeLength; +extern const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility; +extern const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind; +extern const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility; + +#define WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_DATA(macro) \ + macro(asyncIterator, consoleObjectAsyncIterator, 0) \ + macro(write, consoleObjectWrite, 1) \ + +#define WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_CODE(macro) \ + macro(consoleObjectAsyncIteratorCode, asyncIterator, "[Symbol.asyncIterator]"_s, s_consoleObjectAsyncIteratorCodeLength) \ + macro(consoleObjectWriteCode, write, ASCIILiteral(), s_consoleObjectWriteCodeLength) \ + +#define WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_FUNCTION_NAME(macro) \ + macro(asyncIterator) \ + macro(write) \ + +#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ + JSC::FunctionExecutable* codeName##Generator(JSC::VM&); + +WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) +#undef DECLARE_BUILTIN_GENERATOR + +class ConsoleObjectBuiltinsWrapper : private JSC::WeakHandleOwner { +public: + explicit ConsoleObjectBuiltinsWrapper(JSC::VM& vm) + : m_vm(vm) + WEBCORE_FOREACH_CONSOLEOBJECT_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_CONSOLEOBJECT_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_CONSOLEOBJECT_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) +#undef EXPOSE_BUILTIN_EXECUTABLES + + WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) + + void exportNames(); + +private: + JSC::VM& m_vm; + + WEBCORE_FOREACH_CONSOLEOBJECT_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_CONSOLEOBJECT_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) +#undef DECLARE_BUILTIN_SOURCE_MEMBERS + +}; + +#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ +inline JSC::UnlinkedFunctionExecutable* ConsoleObjectBuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ + }\ + return m_##name##Executable.get();\ +} +WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) +#undef DEFINE_BUILTIN_EXECUTABLES + +inline void ConsoleObjectBuiltinsWrapper::exportNames() +{ +#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); + WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) +#undef EXPORT_FUNCTION_NAME +} +/* ReadableStreamInternals.ts */ +// readableStreamReaderGenericInitialize +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMREADERGENERICINITIALIZE 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeImplementationVisibility; + +// privateInitializeReadableStreamDefaultController +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PRIVATEINITIALIZEREADABLESTREAMDEFAULTCONTROLLER 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeImplementationVisibility; + +// readableStreamDefaultControllerError +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERERROR 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeImplementationVisibility; + +// readableStreamPipeTo +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMPIPETO 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamPipeToCodeImplementationVisibility; + +// acquireReadableStreamDefaultReader +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ACQUIREREADABLESTREAMDEFAULTREADER 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeImplementationVisibility; + +// setupReadableStreamDefaultController +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_SETUPREADABLESTREAMDEFAULTCONTROLLER 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeImplementationVisibility; + +// createReadableStreamController +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_CREATEREADABLESTREAMCONTROLLER 1 +extern const char* const s_readableStreamInternalsCreateReadableStreamControllerCode; +extern const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControllerCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility; + +// readableStreamDefaultControllerStart +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERSTART 1 +extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerStartCode; +extern const int s_readableStreamInternalsReadableStreamDefaultControllerStartCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeImplementationVisibility; + +// readableStreamPipeToWritableStream +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMPIPETOWRITABLESTREAM 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeImplementationVisibility; + +// pipeToLoop +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOLOOP 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToLoopCodeImplementationVisibility; + +// pipeToDoReadWrite +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETODOREADWRITE 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToDoReadWriteCodeImplementationVisibility; + +// pipeToErrorsMustBePropagatedForward +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOERRORSMUSTBEPROPAGATEDFORWARD 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeImplementationVisibility; + +// pipeToErrorsMustBePropagatedBackward +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOERRORSMUSTBEPROPAGATEDBACKWARD 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeImplementationVisibility; + +// pipeToClosingMustBePropagatedForward +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOCLOSINGMUSTBEPROPAGATEDFORWARD 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeImplementationVisibility; + +// pipeToClosingMustBePropagatedBackward +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOCLOSINGMUSTBEPROPAGATEDBACKWARD 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeImplementationVisibility; + +// pipeToShutdownWithAction +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOSHUTDOWNWITHACTION 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownWithActionCodeImplementationVisibility; + +// pipeToShutdown +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOSHUTDOWN 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownCodeImplementationVisibility; + +// pipeToFinalize +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PIPETOFINALIZE 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToFinalizeCodeImplementationVisibility; + +// readableStreamTee +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTEE 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility; + +// readableStreamTeePullFunction +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTEEPULLFUNCTION 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeePullFunctionCodeImplementationVisibility; + +// readableStreamTeeBranch1CancelFunction +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTEEBRANCH1CANCELFUNCTION 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeImplementationVisibility; + +// readableStreamTeeBranch2CancelFunction +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTEEBRANCH2CANCELFUNCTION 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeImplementationVisibility; + +// isReadableStream +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAM 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamCodeImplementationVisibility; + +// isReadableStreamDefaultReader +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAMDEFAULTREADER 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamDefaultReaderCodeImplementationVisibility; + +// isReadableStreamDefaultController +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAMDEFAULTCONTROLLER 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamDefaultControllerCodeImplementationVisibility; + +// readDirectStream +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READDIRECTSTREAM 1 +extern const char* const s_readableStreamInternalsReadDirectStreamCode; +extern const int s_readableStreamInternalsReadDirectStreamCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsReadDirectStreamCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsReadDirectStreamCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsReadDirectStreamCodeImplementationVisibility; + +// assignToStream +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ASSIGNTOSTREAM 1 +extern const char* const s_readableStreamInternalsAssignToStreamCode; +extern const int s_readableStreamInternalsAssignToStreamCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsAssignToStreamCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsAssignToStreamCodeImplementationVisibility; + +// readStreamIntoSink +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READSTREAMINTOSINK 1 +extern const char* const s_readableStreamInternalsReadStreamIntoSinkCode; +extern const int s_readableStreamInternalsReadStreamIntoSinkCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsReadStreamIntoSinkCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsReadStreamIntoSinkCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsReadStreamIntoSinkCodeImplementationVisibility; + +// handleDirectStreamError +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_HANDLEDIRECTSTREAMERROR 1 +extern const char* const s_readableStreamInternalsHandleDirectStreamErrorCode; +extern const int s_readableStreamInternalsHandleDirectStreamErrorCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsHandleDirectStreamErrorCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsHandleDirectStreamErrorCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsHandleDirectStreamErrorCodeImplementationVisibility; + +// handleDirectStreamErrorReject +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_HANDLEDIRECTSTREAMERRORREJECT 1 +extern const char* const s_readableStreamInternalsHandleDirectStreamErrorRejectCode; +extern const int s_readableStreamInternalsHandleDirectStreamErrorRejectCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsHandleDirectStreamErrorRejectCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsHandleDirectStreamErrorRejectCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsHandleDirectStreamErrorRejectCodeImplementationVisibility; + +// onPullDirectStream +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ONPULLDIRECTSTREAM 1 +extern const char* const s_readableStreamInternalsOnPullDirectStreamCode; +extern const int s_readableStreamInternalsOnPullDirectStreamCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsOnPullDirectStreamCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsOnPullDirectStreamCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsOnPullDirectStreamCodeImplementationVisibility; + +// noopDoneFunction +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_NOOPDONEFUNCTION 1 +extern const char* const s_readableStreamInternalsNoopDoneFunctionCode; +extern const int s_readableStreamInternalsNoopDoneFunctionCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsNoopDoneFunctionCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsNoopDoneFunctionCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsNoopDoneFunctionCodeImplementationVisibility; + +// onReadableStreamDirectControllerClosed +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ONREADABLESTREAMDIRECTCONTROLLERCLOSED 1 +extern const char* const s_readableStreamInternalsOnReadableStreamDirectControllerClosedCode; +extern const int s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeImplementationVisibility; + +// onCloseDirectStream +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ONCLOSEDIRECTSTREAM 1 +extern const char* const s_readableStreamInternalsOnCloseDirectStreamCode; +extern const int s_readableStreamInternalsOnCloseDirectStreamCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsOnCloseDirectStreamCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsOnCloseDirectStreamCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsOnCloseDirectStreamCodeImplementationVisibility; + +// onFlushDirectStream +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ONFLUSHDIRECTSTREAM 1 +extern const char* const s_readableStreamInternalsOnFlushDirectStreamCode; +extern const int s_readableStreamInternalsOnFlushDirectStreamCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility; + +// createTextStream +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_CREATETEXTSTREAM 1 +extern const char* const s_readableStreamInternalsCreateTextStreamCode; +extern const int s_readableStreamInternalsCreateTextStreamCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsCreateTextStreamCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsCreateTextStreamCodeImplementationVisibility; + +// initializeTextStream +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_INITIALIZETEXTSTREAM 1 +extern const char* const s_readableStreamInternalsInitializeTextStreamCode; +extern const int s_readableStreamInternalsInitializeTextStreamCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility; + +// initializeArrayStream +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_INITIALIZEARRAYSTREAM 1 +extern const char* const s_readableStreamInternalsInitializeArrayStreamCode; +extern const int s_readableStreamInternalsInitializeArrayStreamCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayStreamCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayStreamCodeImplementationVisibility; + +// initializeArrayBufferStream +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_INITIALIZEARRAYBUFFERSTREAM 1 +extern const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode; +extern const int s_readableStreamInternalsInitializeArrayBufferStreamCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayBufferStreamCodeImplementationVisibility; + +// readableStreamError +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMERROR 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility; + +// readableStreamDefaultControllerShouldCallPull +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERSHOULDCALLPULL 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeImplementationVisibility; + +// readableStreamDefaultControllerCallPullIfNeeded +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERCALLPULLIFNEEDED 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeImplementationVisibility; + +// isReadableStreamLocked +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAMLOCKED 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamLockedCodeImplementationVisibility; + +// readableStreamDefaultControllerGetDesiredSize +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERGETDESIREDSIZE 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility; + +// readableStreamReaderGenericCancel +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMREADERGENERICCANCEL 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeImplementationVisibility; + +// readableStreamCancel +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMCANCEL 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility; + +// readableStreamDefaultControllerCancel +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERCANCEL 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeImplementationVisibility; + +// readableStreamDefaultControllerPull +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERPULL 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeImplementationVisibility; + +// readableStreamDefaultControllerClose +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERCLOSE 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeImplementationVisibility; + +// readableStreamClose +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMCLOSE 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility; + +// readableStreamFulfillReadRequest +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMFULFILLREADREQUEST 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeImplementationVisibility; + +// readableStreamDefaultControllerEnqueue +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERENQUEUE 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility; + +// readableStreamDefaultReaderRead +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTREADERREAD 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility; + +// readableStreamAddReadRequest +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMADDREADREQUEST 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamAddReadRequestCodeImplementationVisibility; + +// isReadableStreamDisturbed +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ISREADABLESTREAMDISTURBED 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamDisturbedCodeImplementationVisibility; + +// readableStreamReaderGenericRelease +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMREADERGENERICRELEASE 1 +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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeImplementationVisibility; + +// readableStreamDefaultControllerCanCloseOrEnqueue +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERCANCLOSEORENQUEUE 1 +extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCode; +extern const int s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeImplementationVisibility; + +// lazyLoadStream +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_LAZYLOADSTREAM 1 +extern const char* const s_readableStreamInternalsLazyLoadStreamCode; +extern const int s_readableStreamInternalsLazyLoadStreamCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsLazyLoadStreamCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsLazyLoadStreamCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsLazyLoadStreamCodeImplementationVisibility; + +// readableStreamIntoArray +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMINTOARRAY 1 +extern const char* const s_readableStreamInternalsReadableStreamIntoArrayCode; +extern const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility; + +// readableStreamIntoText +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMINTOTEXT 1 +extern const char* const s_readableStreamInternalsReadableStreamIntoTextCode; +extern const int s_readableStreamInternalsReadableStreamIntoTextCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoTextCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoTextCodeImplementationVisibility; + +// readableStreamToArrayBufferDirect +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTOARRAYBUFFERDIRECT 1 +extern const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode; +extern const int s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeImplementationVisibility; + +// readableStreamToTextDirect +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTOTEXTDIRECT 1 +extern const char* const s_readableStreamInternalsReadableStreamToTextDirectCode; +extern const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility; + +// readableStreamToArrayDirect +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTOARRAYDIRECT 1 +extern const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode; +extern const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility; + +// readableStreamDefineLazyIterators +#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFINELAZYITERATORS 1 +extern const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode; +extern const int s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength; +extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeImplementationVisibility; + +#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_DATA(macro) \ + macro(readableStreamReaderGenericInitialize, readableStreamInternalsReadableStreamReaderGenericInitialize, 2) \ + macro(privateInitializeReadableStreamDefaultController, readableStreamInternalsPrivateInitializeReadableStreamDefaultController, 4) \ + macro(readableStreamDefaultControllerError, readableStreamInternalsReadableStreamDefaultControllerError, 2) \ + macro(readableStreamPipeTo, readableStreamInternalsReadableStreamPipeTo, 2) \ + macro(acquireReadableStreamDefaultReader, readableStreamInternalsAcquireReadableStreamDefaultReader, 1) \ + macro(setupReadableStreamDefaultController, readableStreamInternalsSetupReadableStreamDefaultController, 8) \ + macro(createReadableStreamController, readableStreamInternalsCreateReadableStreamController, 3) \ + macro(readableStreamDefaultControllerStart, readableStreamInternalsReadableStreamDefaultControllerStart, 1) \ + macro(readableStreamPipeToWritableStream, readableStreamInternalsReadableStreamPipeToWritableStream, 7) \ + 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(readDirectStream, readableStreamInternalsReadDirectStream, 3) \ + macro(assignToStream, readableStreamInternalsAssignToStream, 2) \ + macro(readStreamIntoSink, readableStreamInternalsReadStreamIntoSink, 3) \ + macro(handleDirectStreamError, readableStreamInternalsHandleDirectStreamError, 1) \ + macro(handleDirectStreamErrorReject, readableStreamInternalsHandleDirectStreamErrorReject, 1) \ + macro(onPullDirectStream, readableStreamInternalsOnPullDirectStream, 1) \ + macro(noopDoneFunction, readableStreamInternalsNoopDoneFunction, 0) \ + macro(onReadableStreamDirectControllerClosed, readableStreamInternalsOnReadableStreamDirectControllerClosed, 1) \ + macro(onCloseDirectStream, readableStreamInternalsOnCloseDirectStream, 1) \ + macro(onFlushDirectStream, readableStreamInternalsOnFlushDirectStream, 0) \ + macro(createTextStream, readableStreamInternalsCreateTextStream, 1) \ + macro(initializeTextStream, readableStreamInternalsInitializeTextStream, 2) \ + macro(initializeArrayStream, readableStreamInternalsInitializeArrayStream, 2) \ + macro(initializeArrayBufferStream, readableStreamInternalsInitializeArrayBufferStream, 2) \ + 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) \ + macro(lazyLoadStream, readableStreamInternalsLazyLoadStream, 2) \ + macro(readableStreamIntoArray, readableStreamInternalsReadableStreamIntoArray, 1) \ + macro(readableStreamIntoText, readableStreamInternalsReadableStreamIntoText, 1) \ + macro(readableStreamToArrayBufferDirect, readableStreamInternalsReadableStreamToArrayBufferDirect, 2) \ + macro(readableStreamToTextDirect, readableStreamInternalsReadableStreamToTextDirect, 2) \ + macro(readableStreamToArrayDirect, readableStreamInternalsReadableStreamToArrayDirect, 2) \ + macro(readableStreamDefineLazyIterators, readableStreamInternalsReadableStreamDefineLazyIterators, 1) \ + +#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(macro) \ + macro(readableStreamInternalsReadableStreamReaderGenericInitializeCode, readableStreamReaderGenericInitialize, ASCIILiteral(), s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeLength) \ + macro(readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCode, privateInitializeReadableStreamDefaultController, ASCIILiteral(), s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeLength) \ + macro(readableStreamInternalsReadableStreamDefaultControllerErrorCode, readableStreamDefaultControllerError, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeLength) \ + macro(readableStreamInternalsReadableStreamPipeToCode, readableStreamPipeTo, ASCIILiteral(), s_readableStreamInternalsReadableStreamPipeToCodeLength) \ + macro(readableStreamInternalsAcquireReadableStreamDefaultReaderCode, acquireReadableStreamDefaultReader, ASCIILiteral(), s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeLength) \ + macro(readableStreamInternalsSetupReadableStreamDefaultControllerCode, setupReadableStreamDefaultController, ASCIILiteral(), s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeLength) \ + macro(readableStreamInternalsCreateReadableStreamControllerCode, createReadableStreamController, ASCIILiteral(), s_readableStreamInternalsCreateReadableStreamControllerCodeLength) \ + macro(readableStreamInternalsReadableStreamDefaultControllerStartCode, readableStreamDefaultControllerStart, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerStartCodeLength) \ + 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(readableStreamInternalsReadDirectStreamCode, readDirectStream, ASCIILiteral(), s_readableStreamInternalsReadDirectStreamCodeLength) \ + macro(readableStreamInternalsAssignToStreamCode, assignToStream, ASCIILiteral(), s_readableStreamInternalsAssignToStreamCodeLength) \ + macro(readableStreamInternalsReadStreamIntoSinkCode, readStreamIntoSink, ASCIILiteral(), s_readableStreamInternalsReadStreamIntoSinkCodeLength) \ + macro(readableStreamInternalsHandleDirectStreamErrorCode, handleDirectStreamError, ASCIILiteral(), s_readableStreamInternalsHandleDirectStreamErrorCodeLength) \ + macro(readableStreamInternalsHandleDirectStreamErrorRejectCode, handleDirectStreamErrorReject, ASCIILiteral(), s_readableStreamInternalsHandleDirectStreamErrorRejectCodeLength) \ + macro(readableStreamInternalsOnPullDirectStreamCode, onPullDirectStream, ASCIILiteral(), s_readableStreamInternalsOnPullDirectStreamCodeLength) \ + macro(readableStreamInternalsNoopDoneFunctionCode, noopDoneFunction, ASCIILiteral(), s_readableStreamInternalsNoopDoneFunctionCodeLength) \ + macro(readableStreamInternalsOnReadableStreamDirectControllerClosedCode, onReadableStreamDirectControllerClosed, ASCIILiteral(), s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeLength) \ + macro(readableStreamInternalsOnCloseDirectStreamCode, onCloseDirectStream, ASCIILiteral(), s_readableStreamInternalsOnCloseDirectStreamCodeLength) \ + macro(readableStreamInternalsOnFlushDirectStreamCode, onFlushDirectStream, ASCIILiteral(), s_readableStreamInternalsOnFlushDirectStreamCodeLength) \ + macro(readableStreamInternalsCreateTextStreamCode, createTextStream, ASCIILiteral(), s_readableStreamInternalsCreateTextStreamCodeLength) \ + macro(readableStreamInternalsInitializeTextStreamCode, initializeTextStream, ASCIILiteral(), s_readableStreamInternalsInitializeTextStreamCodeLength) \ + macro(readableStreamInternalsInitializeArrayStreamCode, initializeArrayStream, ASCIILiteral(), s_readableStreamInternalsInitializeArrayStreamCodeLength) \ + macro(readableStreamInternalsInitializeArrayBufferStreamCode, initializeArrayBufferStream, ASCIILiteral(), s_readableStreamInternalsInitializeArrayBufferStreamCodeLength) \ + 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) \ + macro(readableStreamInternalsLazyLoadStreamCode, lazyLoadStream, ASCIILiteral(), s_readableStreamInternalsLazyLoadStreamCodeLength) \ + macro(readableStreamInternalsReadableStreamIntoArrayCode, readableStreamIntoArray, ASCIILiteral(), s_readableStreamInternalsReadableStreamIntoArrayCodeLength) \ + macro(readableStreamInternalsReadableStreamIntoTextCode, readableStreamIntoText, ASCIILiteral(), s_readableStreamInternalsReadableStreamIntoTextCodeLength) \ + macro(readableStreamInternalsReadableStreamToArrayBufferDirectCode, readableStreamToArrayBufferDirect, ASCIILiteral(), s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeLength) \ + macro(readableStreamInternalsReadableStreamToTextDirectCode, readableStreamToTextDirect, ASCIILiteral(), s_readableStreamInternalsReadableStreamToTextDirectCodeLength) \ + macro(readableStreamInternalsReadableStreamToArrayDirectCode, readableStreamToArrayDirect, ASCIILiteral(), s_readableStreamInternalsReadableStreamToArrayDirectCodeLength) \ + macro(readableStreamInternalsReadableStreamDefineLazyIteratorsCode, readableStreamDefineLazyIterators, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength) \ + +#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \ + macro(readableStreamReaderGenericInitialize) \ + macro(privateInitializeReadableStreamDefaultController) \ + macro(readableStreamDefaultControllerError) \ + macro(readableStreamPipeTo) \ + macro(acquireReadableStreamDefaultReader) \ + macro(setupReadableStreamDefaultController) \ + macro(createReadableStreamController) \ + macro(readableStreamDefaultControllerStart) \ + macro(readableStreamPipeToWritableStream) \ + macro(pipeToLoop) \ + macro(pipeToDoReadWrite) \ + macro(pipeToErrorsMustBePropagatedForward) \ + macro(pipeToErrorsMustBePropagatedBackward) \ + macro(pipeToClosingMustBePropagatedForward) \ + macro(pipeToClosingMustBePropagatedBackward) \ + macro(pipeToShutdownWithAction) \ + macro(pipeToShutdown) \ + macro(pipeToFinalize) \ + macro(readableStreamTee) \ + macro(readableStreamTeePullFunction) \ + macro(readableStreamTeeBranch1CancelFunction) \ + macro(readableStreamTeeBranch2CancelFunction) \ + macro(isReadableStream) \ + macro(isReadableStreamDefaultReader) \ + macro(isReadableStreamDefaultController) \ + macro(readDirectStream) \ + macro(assignToStream) \ + macro(readStreamIntoSink) \ + macro(handleDirectStreamError) \ + macro(handleDirectStreamErrorReject) \ + macro(onPullDirectStream) \ + macro(noopDoneFunction) \ + macro(onReadableStreamDirectControllerClosed) \ + macro(onCloseDirectStream) \ + macro(onFlushDirectStream) \ + macro(createTextStream) \ + macro(initializeTextStream) \ + macro(initializeArrayStream) \ + macro(initializeArrayBufferStream) \ + macro(readableStreamError) \ + macro(readableStreamDefaultControllerShouldCallPull) \ + macro(readableStreamDefaultControllerCallPullIfNeeded) \ + macro(isReadableStreamLocked) \ + macro(readableStreamDefaultControllerGetDesiredSize) \ + macro(readableStreamReaderGenericCancel) \ + macro(readableStreamCancel) \ + macro(readableStreamDefaultControllerCancel) \ + macro(readableStreamDefaultControllerPull) \ + macro(readableStreamDefaultControllerClose) \ + macro(readableStreamClose) \ + macro(readableStreamFulfillReadRequest) \ + macro(readableStreamDefaultControllerEnqueue) \ + macro(readableStreamDefaultReaderRead) \ + macro(readableStreamAddReadRequest) \ + macro(isReadableStreamDisturbed) \ + macro(readableStreamReaderGenericRelease) \ + macro(readableStreamDefaultControllerCanCloseOrEnqueue) \ + macro(lazyLoadStream) \ + macro(readableStreamIntoArray) \ + macro(readableStreamIntoText) \ + macro(readableStreamToArrayBufferDirect) \ + macro(readableStreamToTextDirect) \ + macro(readableStreamToArrayDirect) \ + macro(readableStreamDefineLazyIterators) \ + +#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##ImplementationVisibility, 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&); + /* TransformStreamDefaultController.ts */ +// initializeTransformStreamDefaultController +#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_INITIALIZETRANSFORMSTREAMDEFAULTCONTROLLER 1 +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 JSC::ImplementationVisibility s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeImplementationVisibility; + +// desiredSize +#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_DESIREDSIZE 1 +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 JSC::ImplementationVisibility s_transformStreamDefaultControllerDesiredSizeCodeImplementationVisibility; + +// enqueue +#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_ENQUEUE 1 +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 JSC::ImplementationVisibility s_transformStreamDefaultControllerEnqueueCodeImplementationVisibility; + +// error +#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_ERROR 1 +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 JSC::ImplementationVisibility s_transformStreamDefaultControllerErrorCodeImplementationVisibility; + +// terminate +#define WEBCORE_BUILTIN_TRANSFORMSTREAMDEFAULTCONTROLLER_TERMINATE 1 +extern const char* const s_transformStreamDefaultControllerTerminateCode; +extern const int s_transformStreamDefaultControllerTerminateCodeLength; +extern const JSC::ConstructAbility s_transformStreamDefaultControllerTerminateCodeConstructAbility; +extern const JSC::ConstructorKind s_transformStreamDefaultControllerTerminateCodeConstructorKind; +extern const JSC::ImplementationVisibility s_transformStreamDefaultControllerTerminateCodeImplementationVisibility; + +#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_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(initializeTransformStreamDefaultController) \ + macro(desiredSize) \ + macro(enqueue) \ + macro(error) \ + 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##ImplementationVisibility, 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 +} +/* ReadableStreamBYOBReader.ts */ +// initializeReadableStreamBYOBReader +#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_INITIALIZEREADABLESTREAMBYOBREADER 1 +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 JSC::ImplementationVisibility s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeImplementationVisibility; + +// cancel +#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_CANCEL 1 +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 JSC::ImplementationVisibility s_readableStreamBYOBReaderCancelCodeImplementationVisibility; + +// read +#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_READ 1 +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 JSC::ImplementationVisibility s_readableStreamBYOBReaderReadCodeImplementationVisibility; + +// releaseLock +#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_RELEASELOCK 1 +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 JSC::ImplementationVisibility s_readableStreamBYOBReaderReleaseLockCodeImplementationVisibility; + +// closed +#define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_CLOSED 1 +extern const char* const s_readableStreamBYOBReaderClosedCode; +extern const int s_readableStreamBYOBReaderClosedCodeLength; +extern const JSC::ConstructAbility s_readableStreamBYOBReaderClosedCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamBYOBReaderClosedCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamBYOBReaderClosedCodeImplementationVisibility; + +#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_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(initializeReadableStreamBYOBReader) \ + macro(cancel) \ + macro(read) \ + macro(releaseLock) \ + macro(closed) \ + +#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##ImplementationVisibility, 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 +} +/* JSBufferConstructor.ts */ +// from +#define WEBCORE_BUILTIN_JSBUFFERCONSTRUCTOR_FROM 1 +extern const char* const s_jsBufferConstructorFromCode; +extern const int s_jsBufferConstructorFromCodeLength; +extern const JSC::ConstructAbility s_jsBufferConstructorFromCodeConstructAbility; +extern const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind; +extern const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility; + +#define WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_DATA(macro) \ + macro(from, jsBufferConstructorFrom, 1) \ + +#define WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(macro) \ + macro(jsBufferConstructorFromCode, from, ASCIILiteral(), s_jsBufferConstructorFromCodeLength) \ + +#define WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_FUNCTION_NAME(macro) \ + macro(from) \ + +#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ + JSC::FunctionExecutable* codeName##Generator(JSC::VM&); + +WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) +#undef DECLARE_BUILTIN_GENERATOR + +class JSBufferConstructorBuiltinsWrapper : private JSC::WeakHandleOwner { +public: + explicit JSBufferConstructorBuiltinsWrapper(JSC::VM& vm) + : m_vm(vm) + WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_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_JSBUFFERCONSTRUCTOR_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_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) +#undef EXPOSE_BUILTIN_EXECUTABLES + + WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) + + void exportNames(); + +private: + JSC::VM& m_vm; + + WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_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_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) +#undef DECLARE_BUILTIN_SOURCE_MEMBERS + +}; + +#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ +inline JSC::UnlinkedFunctionExecutable* JSBufferConstructorBuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ + }\ + return m_##name##Executable.get();\ +} +WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) +#undef DEFINE_BUILTIN_EXECUTABLES + +inline void JSBufferConstructorBuiltinsWrapper::exportNames() +{ +#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); + WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) +#undef EXPORT_FUNCTION_NAME +} +/* ReadableStreamDefaultReader.ts */ +// initializeReadableStreamDefaultReader +#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_INITIALIZEREADABLESTREAMDEFAULTREADER 1 +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 JSC::ImplementationVisibility s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeImplementationVisibility; + +// cancel +#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_CANCEL 1 +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 JSC::ImplementationVisibility s_readableStreamDefaultReaderCancelCodeImplementationVisibility; + +// readMany +#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_READMANY 1 +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 JSC::ImplementationVisibility s_readableStreamDefaultReaderReadManyCodeImplementationVisibility; + +// read +#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_READ 1 +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 JSC::ImplementationVisibility s_readableStreamDefaultReaderReadCodeImplementationVisibility; + +// releaseLock +#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_RELEASELOCK 1 +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 JSC::ImplementationVisibility s_readableStreamDefaultReaderReleaseLockCodeImplementationVisibility; + +// closed +#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTREADER_CLOSED 1 +extern const char* const s_readableStreamDefaultReaderClosedCode; +extern const int s_readableStreamDefaultReaderClosedCodeLength; +extern const JSC::ConstructAbility s_readableStreamDefaultReaderClosedCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamDefaultReaderClosedCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamDefaultReaderClosedCodeImplementationVisibility; + +#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_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(initializeReadableStreamDefaultReader) \ + macro(cancel) \ + macro(readMany) \ + macro(read) \ + macro(releaseLock) \ + macro(closed) \ + +#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##ImplementationVisibility, 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 +} +/* StreamInternals.ts */ +// markPromiseAsHandled +#define WEBCORE_BUILTIN_STREAMINTERNALS_MARKPROMISEASHANDLED 1 +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 JSC::ImplementationVisibility s_streamInternalsMarkPromiseAsHandledCodeImplementationVisibility; + +// shieldingPromiseResolve +#define WEBCORE_BUILTIN_STREAMINTERNALS_SHIELDINGPROMISERESOLVE 1 +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 JSC::ImplementationVisibility s_streamInternalsShieldingPromiseResolveCodeImplementationVisibility; + +// promiseInvokeOrNoopMethodNoCatch +#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOPMETHODNOCATCH 1 +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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeImplementationVisibility; + +// promiseInvokeOrNoopNoCatch +#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOPNOCATCH 1 +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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopNoCatchCodeImplementationVisibility; + +// promiseInvokeOrNoopMethod +#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOPMETHOD 1 +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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopMethodCodeImplementationVisibility; + +// promiseInvokeOrNoop +#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORNOOP 1 +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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopCodeImplementationVisibility; + +// promiseInvokeOrFallbackOrNoop +#define WEBCORE_BUILTIN_STREAMINTERNALS_PROMISEINVOKEORFALLBACKORNOOP 1 +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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeImplementationVisibility; + +// validateAndNormalizeQueuingStrategy +#define WEBCORE_BUILTIN_STREAMINTERNALS_VALIDATEANDNORMALIZEQUEUINGSTRATEGY 1 +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 JSC::ImplementationVisibility s_streamInternalsValidateAndNormalizeQueuingStrategyCodeImplementationVisibility; + +// createFIFO +#define WEBCORE_BUILTIN_STREAMINTERNALS_CREATEFIFO 1 +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 JSC::ImplementationVisibility s_streamInternalsCreateFIFOCodeImplementationVisibility; + +// newQueue +#define WEBCORE_BUILTIN_STREAMINTERNALS_NEWQUEUE 1 +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 JSC::ImplementationVisibility s_streamInternalsNewQueueCodeImplementationVisibility; + +// dequeueValue +#define WEBCORE_BUILTIN_STREAMINTERNALS_DEQUEUEVALUE 1 +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 JSC::ImplementationVisibility s_streamInternalsDequeueValueCodeImplementationVisibility; + +// enqueueValueWithSize +#define WEBCORE_BUILTIN_STREAMINTERNALS_ENQUEUEVALUEWITHSIZE 1 +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 JSC::ImplementationVisibility s_streamInternalsEnqueueValueWithSizeCodeImplementationVisibility; + +// peekQueueValue +#define WEBCORE_BUILTIN_STREAMINTERNALS_PEEKQUEUEVALUE 1 +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 JSC::ImplementationVisibility s_streamInternalsPeekQueueValueCodeImplementationVisibility; + +// resetQueue +#define WEBCORE_BUILTIN_STREAMINTERNALS_RESETQUEUE 1 +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 JSC::ImplementationVisibility s_streamInternalsResetQueueCodeImplementationVisibility; + +// extractSizeAlgorithm +#define WEBCORE_BUILTIN_STREAMINTERNALS_EXTRACTSIZEALGORITHM 1 +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 JSC::ImplementationVisibility s_streamInternalsExtractSizeAlgorithmCodeImplementationVisibility; + +// extractHighWaterMark +#define WEBCORE_BUILTIN_STREAMINTERNALS_EXTRACTHIGHWATERMARK 1 +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 JSC::ImplementationVisibility s_streamInternalsExtractHighWaterMarkCodeImplementationVisibility; + +// extractHighWaterMarkFromQueuingStrategyInit +#define WEBCORE_BUILTIN_STREAMINTERNALS_EXTRACTHIGHWATERMARKFROMQUEUINGSTRATEGYINIT 1 +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 JSC::ImplementationVisibility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeImplementationVisibility; + +// createFulfilledPromise +#define WEBCORE_BUILTIN_STREAMINTERNALS_CREATEFULFILLEDPROMISE 1 +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 JSC::ImplementationVisibility s_streamInternalsCreateFulfilledPromiseCodeImplementationVisibility; + +// toDictionary +#define WEBCORE_BUILTIN_STREAMINTERNALS_TODICTIONARY 1 +extern const char* const s_streamInternalsToDictionaryCode; +extern const int s_streamInternalsToDictionaryCodeLength; +extern const JSC::ConstructAbility s_streamInternalsToDictionaryCodeConstructAbility; +extern const JSC::ConstructorKind s_streamInternalsToDictionaryCodeConstructorKind; +extern const JSC::ImplementationVisibility s_streamInternalsToDictionaryCodeImplementationVisibility; + +#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_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(markPromiseAsHandled) \ + macro(shieldingPromiseResolve) \ + macro(promiseInvokeOrNoopMethodNoCatch) \ + macro(promiseInvokeOrNoopNoCatch) \ + macro(promiseInvokeOrNoopMethod) \ + macro(promiseInvokeOrNoop) \ + macro(promiseInvokeOrFallbackOrNoop) \ + macro(validateAndNormalizeQueuingStrategy) \ + macro(createFIFO) \ + macro(newQueue) \ + macro(dequeueValue) \ + macro(enqueueValueWithSize) \ + macro(peekQueueValue) \ + macro(resetQueue) \ + macro(extractSizeAlgorithm) \ + macro(extractHighWaterMark) \ + macro(extractHighWaterMarkFromQueuingStrategyInit) \ + macro(createFulfilledPromise) \ + macro(toDictionary) \ + +#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##ImplementationVisibility, 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&); + /* ImportMetaObject.ts */ +// loadCJS2ESM +#define WEBCORE_BUILTIN_IMPORTMETAOBJECT_LOADCJS2ESM 1 +extern const char* const s_importMetaObjectLoadCJS2ESMCode; +extern const int s_importMetaObjectLoadCJS2ESMCodeLength; +extern const JSC::ConstructAbility s_importMetaObjectLoadCJS2ESMCodeConstructAbility; +extern const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind; +extern const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility; + +// requireESM +#define WEBCORE_BUILTIN_IMPORTMETAOBJECT_REQUIREESM 1 +extern const char* const s_importMetaObjectRequireESMCode; +extern const int s_importMetaObjectRequireESMCodeLength; +extern const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility; +extern const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind; +extern const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility; + +// internalRequire +#define WEBCORE_BUILTIN_IMPORTMETAOBJECT_INTERNALREQUIRE 1 +extern const char* const s_importMetaObjectInternalRequireCode; +extern const int s_importMetaObjectInternalRequireCodeLength; +extern const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility; +extern const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind; +extern const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility; + +// require +#define WEBCORE_BUILTIN_IMPORTMETAOBJECT_REQUIRE 1 +extern const char* const s_importMetaObjectRequireCode; +extern const int s_importMetaObjectRequireCodeLength; +extern const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility; +extern const JSC::ConstructorKind s_importMetaObjectRequireCodeConstructorKind; +extern const JSC::ImplementationVisibility s_importMetaObjectRequireCodeImplementationVisibility; + +// main +#define WEBCORE_BUILTIN_IMPORTMETAOBJECT_MAIN 1 +extern const char* const s_importMetaObjectMainCode; +extern const int s_importMetaObjectMainCodeLength; +extern const JSC::ConstructAbility s_importMetaObjectMainCodeConstructAbility; +extern const JSC::ConstructorKind s_importMetaObjectMainCodeConstructorKind; +extern const JSC::ImplementationVisibility s_importMetaObjectMainCodeImplementationVisibility; + +#define WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_DATA(macro) \ + macro(loadCJS2ESM, importMetaObjectLoadCJS2ESM, 1) \ + macro(requireESM, importMetaObjectRequireESM, 1) \ + macro(internalRequire, importMetaObjectInternalRequire, 1) \ + macro(require, importMetaObjectRequire, 1) \ + macro(main, importMetaObjectMain, 0) \ + +#define WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_CODE(macro) \ + macro(importMetaObjectLoadCJS2ESMCode, loadCJS2ESM, ASCIILiteral(), s_importMetaObjectLoadCJS2ESMCodeLength) \ + macro(importMetaObjectRequireESMCode, requireESM, ASCIILiteral(), s_importMetaObjectRequireESMCodeLength) \ + macro(importMetaObjectInternalRequireCode, internalRequire, ASCIILiteral(), s_importMetaObjectInternalRequireCodeLength) \ + macro(importMetaObjectRequireCode, require, ASCIILiteral(), s_importMetaObjectRequireCodeLength) \ + macro(importMetaObjectMainCode, main, "get main"_s, s_importMetaObjectMainCodeLength) \ + +#define WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_FUNCTION_NAME(macro) \ + macro(loadCJS2ESM) \ + macro(requireESM) \ + macro(internalRequire) \ + macro(require) \ + macro(main) \ + +#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ + JSC::FunctionExecutable* codeName##Generator(JSC::VM&); + +WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) +#undef DECLARE_BUILTIN_GENERATOR + +class ImportMetaObjectBuiltinsWrapper : private JSC::WeakHandleOwner { +public: + explicit ImportMetaObjectBuiltinsWrapper(JSC::VM& vm) + : m_vm(vm) + WEBCORE_FOREACH_IMPORTMETAOBJECT_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_IMPORTMETAOBJECT_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_IMPORTMETAOBJECT_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) +#undef EXPOSE_BUILTIN_EXECUTABLES + + WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) + + void exportNames(); + +private: + JSC::VM& m_vm; + + WEBCORE_FOREACH_IMPORTMETAOBJECT_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_IMPORTMETAOBJECT_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) +#undef DECLARE_BUILTIN_SOURCE_MEMBERS + +}; + +#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ +inline JSC::UnlinkedFunctionExecutable* ImportMetaObjectBuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ + }\ + return m_##name##Executable.get();\ +} +WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) +#undef DEFINE_BUILTIN_EXECUTABLES + +inline void ImportMetaObjectBuiltinsWrapper::exportNames() +{ +#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); + WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) +#undef EXPORT_FUNCTION_NAME +} +/* CountQueuingStrategy.ts */ +// highWaterMark +#define WEBCORE_BUILTIN_COUNTQUEUINGSTRATEGY_HIGHWATERMARK 1 +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 JSC::ImplementationVisibility s_countQueuingStrategyHighWaterMarkCodeImplementationVisibility; + +// size +#define WEBCORE_BUILTIN_COUNTQUEUINGSTRATEGY_SIZE 1 +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 JSC::ImplementationVisibility s_countQueuingStrategySizeCodeImplementationVisibility; + +// initializeCountQueuingStrategy +#define WEBCORE_BUILTIN_COUNTQUEUINGSTRATEGY_INITIALIZECOUNTQUEUINGSTRATEGY 1 +extern const char* const s_countQueuingStrategyInitializeCountQueuingStrategyCode; +extern const int s_countQueuingStrategyInitializeCountQueuingStrategyCodeLength; +extern const JSC::ConstructAbility s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructAbility; +extern const JSC::ConstructorKind s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructorKind; +extern const JSC::ImplementationVisibility s_countQueuingStrategyInitializeCountQueuingStrategyCodeImplementationVisibility; + +#define WEBCORE_FOREACH_COUNTQUEUINGSTRATEGY_BUILTIN_DATA(macro) \ + macro(highWaterMark, countQueuingStrategyHighWaterMark, 0) \ + macro(size, countQueuingStrategySize, 0) \ + macro(initializeCountQueuingStrategy, countQueuingStrategyInitializeCountQueuingStrategy, 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(size) \ + macro(initializeCountQueuingStrategy) \ + +#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##ImplementationVisibility, 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 +} +/* ReadableStreamBYOBRequest.ts */ +// initializeReadableStreamBYOBRequest +#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_INITIALIZEREADABLESTREAMBYOBREQUEST 1 +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 JSC::ImplementationVisibility s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeImplementationVisibility; + +// respond +#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_RESPOND 1 +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 JSC::ImplementationVisibility s_readableStreamBYOBRequestRespondCodeImplementationVisibility; + +// respondWithNewView +#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_RESPONDWITHNEWVIEW 1 +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 JSC::ImplementationVisibility s_readableStreamBYOBRequestRespondWithNewViewCodeImplementationVisibility; + +// view +#define WEBCORE_BUILTIN_READABLESTREAMBYOBREQUEST_VIEW 1 +extern const char* const s_readableStreamBYOBRequestViewCode; +extern const int s_readableStreamBYOBRequestViewCodeLength; +extern const JSC::ConstructAbility s_readableStreamBYOBRequestViewCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamBYOBRequestViewCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamBYOBRequestViewCodeImplementationVisibility; + +#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_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##ImplementationVisibility, 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 +} +/* WritableStreamDefaultWriter.ts */ +// initializeWritableStreamDefaultWriter +#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_INITIALIZEWRITABLESTREAMDEFAULTWRITER 1 +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 JSC::ImplementationVisibility s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeImplementationVisibility; + +// closed +#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_CLOSED 1 +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 JSC::ImplementationVisibility s_writableStreamDefaultWriterClosedCodeImplementationVisibility; + +// desiredSize +#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_DESIREDSIZE 1 +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 JSC::ImplementationVisibility s_writableStreamDefaultWriterDesiredSizeCodeImplementationVisibility; + +// ready +#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_READY 1 +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 JSC::ImplementationVisibility s_writableStreamDefaultWriterReadyCodeImplementationVisibility; + +// abort +#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_ABORT 1 +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 JSC::ImplementationVisibility s_writableStreamDefaultWriterAbortCodeImplementationVisibility; + +// close +#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_CLOSE 1 +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 JSC::ImplementationVisibility s_writableStreamDefaultWriterCloseCodeImplementationVisibility; + +// releaseLock +#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_RELEASELOCK 1 +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 JSC::ImplementationVisibility s_writableStreamDefaultWriterReleaseLockCodeImplementationVisibility; + +// write +#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTWRITER_WRITE 1 +extern const char* const s_writableStreamDefaultWriterWriteCode; +extern const int s_writableStreamDefaultWriterWriteCodeLength; +extern const JSC::ConstructAbility s_writableStreamDefaultWriterWriteCodeConstructAbility; +extern const JSC::ConstructorKind s_writableStreamDefaultWriterWriteCodeConstructorKind; +extern const JSC::ImplementationVisibility s_writableStreamDefaultWriterWriteCodeImplementationVisibility; + +#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_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(initializeWritableStreamDefaultWriter) \ + macro(closed) \ + macro(desiredSize) \ + macro(ready) \ + macro(abort) \ + macro(close) \ + 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##ImplementationVisibility, 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 +} +/* ReadableStream.ts */ +// initializeReadableStream +#define WEBCORE_BUILTIN_READABLESTREAM_INITIALIZEREADABLESTREAM 1 +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 JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility; + +// readableStreamToArray +#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOARRAY 1 +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 JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayCodeImplementationVisibility; + +// readableStreamToText +#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOTEXT 1 +extern const char* const s_readableStreamReadableStreamToTextCode; +extern const int s_readableStreamReadableStreamToTextCodeLength; +extern const JSC::ConstructAbility s_readableStreamReadableStreamToTextCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamReadableStreamToTextCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamReadableStreamToTextCodeImplementationVisibility; + +// readableStreamToArrayBuffer +#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOARRAYBUFFER 1 +extern const char* const s_readableStreamReadableStreamToArrayBufferCode; +extern const int s_readableStreamReadableStreamToArrayBufferCodeLength; +extern const JSC::ConstructAbility s_readableStreamReadableStreamToArrayBufferCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility; + +// readableStreamToJSON +#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOJSON 1 +extern const char* const s_readableStreamReadableStreamToJSONCode; +extern const int s_readableStreamReadableStreamToJSONCodeLength; +extern const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamReadableStreamToJSONCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamReadableStreamToJSONCodeImplementationVisibility; + +// readableStreamToBlob +#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOBLOB 1 +extern const char* const s_readableStreamReadableStreamToBlobCode; +extern const int s_readableStreamReadableStreamToBlobCodeLength; +extern const JSC::ConstructAbility s_readableStreamReadableStreamToBlobCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamReadableStreamToBlobCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamReadableStreamToBlobCodeImplementationVisibility; + +// consumeReadableStream +#define WEBCORE_BUILTIN_READABLESTREAM_CONSUMEREADABLESTREAM 1 +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 JSC::ImplementationVisibility s_readableStreamConsumeReadableStreamCodeImplementationVisibility; + +// createEmptyReadableStream +#define WEBCORE_BUILTIN_READABLESTREAM_CREATEEMPTYREADABLESTREAM 1 +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 JSC::ImplementationVisibility s_readableStreamCreateEmptyReadableStreamCodeImplementationVisibility; + +// createNativeReadableStream +#define WEBCORE_BUILTIN_READABLESTREAM_CREATENATIVEREADABLESTREAM 1 +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 JSC::ImplementationVisibility s_readableStreamCreateNativeReadableStreamCodeImplementationVisibility; + +// cancel +#define WEBCORE_BUILTIN_READABLESTREAM_CANCEL 1 +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 JSC::ImplementationVisibility s_readableStreamCancelCodeImplementationVisibility; + +// getReader +#define WEBCORE_BUILTIN_READABLESTREAM_GETREADER 1 +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 JSC::ImplementationVisibility s_readableStreamGetReaderCodeImplementationVisibility; + +// pipeThrough +#define WEBCORE_BUILTIN_READABLESTREAM_PIPETHROUGH 1 +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 JSC::ImplementationVisibility s_readableStreamPipeThroughCodeImplementationVisibility; + +// pipeTo +#define WEBCORE_BUILTIN_READABLESTREAM_PIPETO 1 +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 JSC::ImplementationVisibility s_readableStreamPipeToCodeImplementationVisibility; + +// tee +#define WEBCORE_BUILTIN_READABLESTREAM_TEE 1 +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 JSC::ImplementationVisibility s_readableStreamTeeCodeImplementationVisibility; + +// locked +#define WEBCORE_BUILTIN_READABLESTREAM_LOCKED 1 +extern const char* const s_readableStreamLockedCode; +extern const int s_readableStreamLockedCodeLength; +extern const JSC::ConstructAbility s_readableStreamLockedCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamLockedCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamLockedCodeImplementationVisibility; + +// values +#define WEBCORE_BUILTIN_READABLESTREAM_VALUES 1 +extern const char* const s_readableStreamValuesCode; +extern const int s_readableStreamValuesCodeLength; +extern const JSC::ConstructAbility s_readableStreamValuesCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamValuesCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamValuesCodeImplementationVisibility; + +// lazyAsyncIterator +#define WEBCORE_BUILTIN_READABLESTREAM_LAZYASYNCITERATOR 1 +extern const char* const s_readableStreamLazyAsyncIteratorCode; +extern const int s_readableStreamLazyAsyncIteratorCodeLength; +extern const JSC::ConstructAbility s_readableStreamLazyAsyncIteratorCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamLazyAsyncIteratorCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamLazyAsyncIteratorCodeImplementationVisibility; + +#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_DATA(macro) \ + macro(initializeReadableStream, readableStreamInitializeReadableStream, 2) \ + macro(readableStreamToArray, readableStreamReadableStreamToArray, 1) \ + macro(readableStreamToText, readableStreamReadableStreamToText, 1) \ + macro(readableStreamToArrayBuffer, readableStreamReadableStreamToArrayBuffer, 1) \ + macro(readableStreamToJSON, readableStreamReadableStreamToJSON, 1) \ + macro(readableStreamToBlob, readableStreamReadableStreamToBlob, 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) \ + macro(values, readableStreamValues, 1) \ + macro(lazyAsyncIterator, readableStreamLazyAsyncIterator, 0) \ + +#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(macro) \ + macro(readableStreamInitializeReadableStreamCode, initializeReadableStream, ASCIILiteral(), s_readableStreamInitializeReadableStreamCodeLength) \ + macro(readableStreamReadableStreamToArrayCode, readableStreamToArray, ASCIILiteral(), s_readableStreamReadableStreamToArrayCodeLength) \ + macro(readableStreamReadableStreamToTextCode, readableStreamToText, ASCIILiteral(), s_readableStreamReadableStreamToTextCodeLength) \ + macro(readableStreamReadableStreamToArrayBufferCode, readableStreamToArrayBuffer, ASCIILiteral(), s_readableStreamReadableStreamToArrayBufferCodeLength) \ + macro(readableStreamReadableStreamToJSONCode, readableStreamToJSON, ASCIILiteral(), s_readableStreamReadableStreamToJSONCodeLength) \ + macro(readableStreamReadableStreamToBlobCode, readableStreamToBlob, ASCIILiteral(), s_readableStreamReadableStreamToBlobCodeLength) \ + 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) \ + macro(readableStreamValuesCode, values, ASCIILiteral(), s_readableStreamValuesCodeLength) \ + macro(readableStreamLazyAsyncIteratorCode, lazyAsyncIterator, ASCIILiteral(), s_readableStreamLazyAsyncIteratorCodeLength) \ + +#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_FUNCTION_NAME(macro) \ + macro(initializeReadableStream) \ + macro(readableStreamToArray) \ + macro(readableStreamToText) \ + macro(readableStreamToArrayBuffer) \ + macro(readableStreamToJSON) \ + macro(readableStreamToBlob) \ + macro(consumeReadableStream) \ + macro(createEmptyReadableStream) \ + macro(createNativeReadableStream) \ + macro(cancel) \ + macro(getReader) \ + macro(pipeThrough) \ + macro(pipeTo) \ + macro(tee) \ + macro(locked) \ + macro(values) \ + macro(lazyAsyncIterator) \ + +#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##ImplementationVisibility, 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 +} +/* ReadableStreamDefaultController.ts */ +// initializeReadableStreamDefaultController +#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_INITIALIZEREADABLESTREAMDEFAULTCONTROLLER 1 +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 JSC::ImplementationVisibility s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeImplementationVisibility; + +// enqueue +#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_ENQUEUE 1 +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 JSC::ImplementationVisibility s_readableStreamDefaultControllerEnqueueCodeImplementationVisibility; + +// error +#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_ERROR 1 +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 JSC::ImplementationVisibility s_readableStreamDefaultControllerErrorCodeImplementationVisibility; + +// close +#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_CLOSE 1 +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 JSC::ImplementationVisibility s_readableStreamDefaultControllerCloseCodeImplementationVisibility; + +// desiredSize +#define WEBCORE_BUILTIN_READABLESTREAMDEFAULTCONTROLLER_DESIREDSIZE 1 +extern const char* const s_readableStreamDefaultControllerDesiredSizeCode; +extern const int s_readableStreamDefaultControllerDesiredSizeCodeLength; +extern const JSC::ConstructAbility s_readableStreamDefaultControllerDesiredSizeCodeConstructAbility; +extern const JSC::ConstructorKind s_readableStreamDefaultControllerDesiredSizeCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableStreamDefaultControllerDesiredSizeCodeImplementationVisibility; + +#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_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(initializeReadableStreamDefaultController) \ + macro(enqueue) \ + macro(error) \ + macro(close) \ + macro(desiredSize) \ + +#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##ImplementationVisibility, 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 +} +/* ReadableByteStreamInternals.ts */ +// privateInitializeReadableByteStreamController +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_PRIVATEINITIALIZEREADABLEBYTESTREAMCONTROLLER 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeImplementationVisibility; + +// readableStreamByteStreamControllerStart +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMBYTESTREAMCONTROLLERSTART 1 +extern const char* const s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCode; +extern const int s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeLength; +extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility; +extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeImplementationVisibility; + +// privateInitializeReadableStreamBYOBRequest +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_PRIVATEINITIALIZEREADABLESTREAMBYOBREQUEST 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeImplementationVisibility; + +// isReadableByteStreamController +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_ISREADABLEBYTESTREAMCONTROLLER 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsIsReadableByteStreamControllerCodeImplementationVisibility; + +// isReadableStreamBYOBRequest +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_ISREADABLESTREAMBYOBREQUEST 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeImplementationVisibility; + +// isReadableStreamBYOBReader +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_ISREADABLESTREAMBYOBREADER 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeImplementationVisibility; + +// readableByteStreamControllerCancel +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCANCEL 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility; + +// readableByteStreamControllerError +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERERROR 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeImplementationVisibility; + +// readableByteStreamControllerClose +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCLOSE 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeImplementationVisibility; + +// readableByteStreamControllerClearPendingPullIntos +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCLEARPENDINGPULLINTOS 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeImplementationVisibility; + +// readableByteStreamControllerGetDesiredSize +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERGETDESIREDSIZE 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeImplementationVisibility; + +// readableStreamHasBYOBReader +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMHASBYOBREADER 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeImplementationVisibility; + +// readableStreamHasDefaultReader +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMHASDEFAULTREADER 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeImplementationVisibility; + +// readableByteStreamControllerHandleQueueDrain +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERHANDLEQUEUEDRAIN 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeImplementationVisibility; + +// readableByteStreamControllerPull +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERPULL 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility; + +// readableByteStreamControllerShouldCallPull +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERSHOULDCALLPULL 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeImplementationVisibility; + +// readableByteStreamControllerCallPullIfNeeded +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCALLPULLIFNEEDED 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeImplementationVisibility; + +// transferBufferToCurrentRealm +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_TRANSFERBUFFERTOCURRENTREALM 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeImplementationVisibility; + +// readableStreamReaderKind +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMREADERKIND 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamReaderKindCodeImplementationVisibility; + +// readableByteStreamControllerEnqueue +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERENQUEUE 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeImplementationVisibility; + +// readableByteStreamControllerEnqueueChunk +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERENQUEUECHUNK 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeImplementationVisibility; + +// readableByteStreamControllerRespondWithNewView +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPONDWITHNEWVIEW 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeImplementationVisibility; + +// readableByteStreamControllerRespond +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPOND 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeImplementationVisibility; + +// readableByteStreamControllerRespondInternal +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPONDINTERNAL 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeImplementationVisibility; + +// readableByteStreamControllerRespondInReadableState +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPONDINREADABLESTATE 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility; + +// readableByteStreamControllerRespondInClosedState +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERRESPONDINCLOSEDSTATE 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeImplementationVisibility; + +// readableByteStreamControllerProcessPullDescriptors +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERPROCESSPULLDESCRIPTORS 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeImplementationVisibility; + +// readableByteStreamControllerFillDescriptorFromQueue +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERFILLDESCRIPTORFROMQUEUE 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeImplementationVisibility; + +// readableByteStreamControllerShiftPendingDescriptor +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERSHIFTPENDINGDESCRIPTOR 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeImplementationVisibility; + +// readableByteStreamControllerInvalidateBYOBRequest +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERINVALIDATEBYOBREQUEST 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeImplementationVisibility; + +// readableByteStreamControllerCommitDescriptor +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCOMMITDESCRIPTOR 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeImplementationVisibility; + +// readableByteStreamControllerConvertDescriptor +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERCONVERTDESCRIPTOR 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeImplementationVisibility; + +// readableStreamFulfillReadIntoRequest +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMFULFILLREADINTOREQUEST 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeImplementationVisibility; + +// readableStreamBYOBReaderRead +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMBYOBREADERREAD 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeImplementationVisibility; + +// readableByteStreamControllerPullInto +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLEBYTESTREAMCONTROLLERPULLINTO 1 +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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeImplementationVisibility; + +// readableStreamAddReadIntoRequest +#define WEBCORE_BUILTIN_READABLEBYTESTREAMINTERNALS_READABLESTREAMADDREADINTOREQUEST 1 +extern const char* const s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCode; +extern const int s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeLength; +extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility; +extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructorKind; +extern const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeImplementationVisibility; + +#define WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_DATA(macro) \ + macro(privateInitializeReadableByteStreamController, readableByteStreamInternalsPrivateInitializeReadableByteStreamController, 3) \ + macro(readableStreamByteStreamControllerStart, readableByteStreamInternalsReadableStreamByteStreamControllerStart, 1) \ + 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_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_CODE(macro) \ + macro(readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode, privateInitializeReadableByteStreamController, ASCIILiteral(), s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeLength) \ + macro(readableByteStreamInternalsReadableStreamByteStreamControllerStartCode, readableStreamByteStreamControllerStart, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeLength) \ + 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(privateInitializeReadableByteStreamController) \ + macro(readableStreamByteStreamControllerStart) \ + macro(privateInitializeReadableStreamBYOBRequest) \ + macro(isReadableByteStreamController) \ + macro(isReadableStreamBYOBRequest) \ + macro(isReadableStreamBYOBReader) \ + macro(readableByteStreamControllerCancel) \ + macro(readableByteStreamControllerError) \ + macro(readableByteStreamControllerClose) \ + macro(readableByteStreamControllerClearPendingPullIntos) \ + macro(readableByteStreamControllerGetDesiredSize) \ + macro(readableStreamHasBYOBReader) \ + macro(readableStreamHasDefaultReader) \ + macro(readableByteStreamControllerHandleQueueDrain) \ + macro(readableByteStreamControllerPull) \ + macro(readableByteStreamControllerShouldCallPull) \ + macro(readableByteStreamControllerCallPullIfNeeded) \ + macro(transferBufferToCurrentRealm) \ + macro(readableStreamReaderKind) \ + macro(readableByteStreamControllerEnqueue) \ + macro(readableByteStreamControllerEnqueueChunk) \ + macro(readableByteStreamControllerRespondWithNewView) \ + macro(readableByteStreamControllerRespond) \ + macro(readableByteStreamControllerRespondInternal) \ + macro(readableByteStreamControllerRespondInReadableState) \ + macro(readableByteStreamControllerRespondInClosedState) \ + macro(readableByteStreamControllerProcessPullDescriptors) \ + macro(readableByteStreamControllerFillDescriptorFromQueue) \ + macro(readableByteStreamControllerShiftPendingDescriptor) \ + macro(readableByteStreamControllerInvalidateBYOBRequest) \ + macro(readableByteStreamControllerCommitDescriptor) \ + macro(readableByteStreamControllerConvertDescriptor) \ + macro(readableStreamFulfillReadIntoRequest) \ + macro(readableStreamBYOBReaderRead) \ + macro(readableByteStreamControllerPullInto) \ + macro(readableStreamAddReadIntoRequest) \ + +#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##ImplementationVisibility, 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&); + /* WritableStreamDefaultController.ts */ +// initializeWritableStreamDefaultController +#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTCONTROLLER_INITIALIZEWRITABLESTREAMDEFAULTCONTROLLER 1 +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 JSC::ImplementationVisibility s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeImplementationVisibility; + +// error +#define WEBCORE_BUILTIN_WRITABLESTREAMDEFAULTCONTROLLER_ERROR 1 +extern const char* const s_writableStreamDefaultControllerErrorCode; +extern const int s_writableStreamDefaultControllerErrorCodeLength; +extern const JSC::ConstructAbility s_writableStreamDefaultControllerErrorCodeConstructAbility; +extern const JSC::ConstructorKind s_writableStreamDefaultControllerErrorCodeConstructorKind; +extern const JSC::ImplementationVisibility s_writableStreamDefaultControllerErrorCodeImplementationVisibility; + +#define WEBCORE_FOREACH_WRITABLESTREAMDEFAULTCONTROLLER_BUILTIN_DATA(macro) \ + macro(initializeWritableStreamDefaultController, writableStreamDefaultControllerInitializeWritableStreamDefaultController, 0) \ + macro(error, writableStreamDefaultControllerError, 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(initializeWritableStreamDefaultController) \ + macro(error) \ + +#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##ImplementationVisibility, 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 +} +class JSBuiltinFunctions { +public: + explicit JSBuiltinFunctions(JSC::VM& vm) + : m_vm(vm) + , m_bundlerPluginBuiltins(m_vm) + , m_byteLengthQueuingStrategyBuiltins(m_vm) + , m_writableStreamInternalsBuiltins(m_vm) + , m_transformStreamInternalsBuiltins(m_vm) + , m_processObjectInternalsBuiltins(m_vm) + , m_transformStreamBuiltins(m_vm) + , m_jsBufferPrototypeBuiltins(m_vm) + , m_readableByteStreamControllerBuiltins(m_vm) + , m_consoleObjectBuiltins(m_vm) + , m_readableStreamInternalsBuiltins(m_vm) + , m_transformStreamDefaultControllerBuiltins(m_vm) + , m_readableStreamBYOBReaderBuiltins(m_vm) + , m_jsBufferConstructorBuiltins(m_vm) + , m_readableStreamDefaultReaderBuiltins(m_vm) + , m_streamInternalsBuiltins(m_vm) + , m_importMetaObjectBuiltins(m_vm) + , m_countQueuingStrategyBuiltins(m_vm) + , m_readableStreamBYOBRequestBuiltins(m_vm) + , m_writableStreamDefaultWriterBuiltins(m_vm) + , m_readableStreamBuiltins(m_vm) + , m_readableStreamDefaultControllerBuiltins(m_vm) + , m_readableByteStreamInternalsBuiltins(m_vm) + , m_writableStreamDefaultControllerBuiltins(m_vm) + + { + m_writableStreamInternalsBuiltins.exportNames(); + m_transformStreamInternalsBuiltins.exportNames(); + m_readableStreamInternalsBuiltins.exportNames(); + m_streamInternalsBuiltins.exportNames(); + m_readableByteStreamInternalsBuiltins.exportNames(); + } + BundlerPluginBuiltinsWrapper& bundlerPluginBuiltins() { return m_bundlerPluginBuiltins; } + ByteLengthQueuingStrategyBuiltinsWrapper& byteLengthQueuingStrategyBuiltins() { return m_byteLengthQueuingStrategyBuiltins; } + WritableStreamInternalsBuiltinsWrapper& writableStreamInternalsBuiltins() { return m_writableStreamInternalsBuiltins; } + TransformStreamInternalsBuiltinsWrapper& transformStreamInternalsBuiltins() { return m_transformStreamInternalsBuiltins; } + ProcessObjectInternalsBuiltinsWrapper& processObjectInternalsBuiltins() { return m_processObjectInternalsBuiltins; } + TransformStreamBuiltinsWrapper& transformStreamBuiltins() { return m_transformStreamBuiltins; } + JSBufferPrototypeBuiltinsWrapper& jsBufferPrototypeBuiltins() { return m_jsBufferPrototypeBuiltins; } + ReadableByteStreamControllerBuiltinsWrapper& readableByteStreamControllerBuiltins() { return m_readableByteStreamControllerBuiltins; } + ConsoleObjectBuiltinsWrapper& consoleObjectBuiltins() { return m_consoleObjectBuiltins; } + ReadableStreamInternalsBuiltinsWrapper& readableStreamInternalsBuiltins() { return m_readableStreamInternalsBuiltins; } + TransformStreamDefaultControllerBuiltinsWrapper& transformStreamDefaultControllerBuiltins() { return m_transformStreamDefaultControllerBuiltins; } + ReadableStreamBYOBReaderBuiltinsWrapper& readableStreamBYOBReaderBuiltins() { return m_readableStreamBYOBReaderBuiltins; } + JSBufferConstructorBuiltinsWrapper& jsBufferConstructorBuiltins() { return m_jsBufferConstructorBuiltins; } + ReadableStreamDefaultReaderBuiltinsWrapper& readableStreamDefaultReaderBuiltins() { return m_readableStreamDefaultReaderBuiltins; } + StreamInternalsBuiltinsWrapper& streamInternalsBuiltins() { return m_streamInternalsBuiltins; } + ImportMetaObjectBuiltinsWrapper& importMetaObjectBuiltins() { return m_importMetaObjectBuiltins; } + CountQueuingStrategyBuiltinsWrapper& countQueuingStrategyBuiltins() { return m_countQueuingStrategyBuiltins; } + ReadableStreamBYOBRequestBuiltinsWrapper& readableStreamBYOBRequestBuiltins() { return m_readableStreamBYOBRequestBuiltins; } + WritableStreamDefaultWriterBuiltinsWrapper& writableStreamDefaultWriterBuiltins() { return m_writableStreamDefaultWriterBuiltins; } + ReadableStreamBuiltinsWrapper& readableStreamBuiltins() { return m_readableStreamBuiltins; } + ReadableStreamDefaultControllerBuiltinsWrapper& readableStreamDefaultControllerBuiltins() { return m_readableStreamDefaultControllerBuiltins; } + ReadableByteStreamInternalsBuiltinsWrapper& readableByteStreamInternalsBuiltins() { return m_readableByteStreamInternalsBuiltins; } + WritableStreamDefaultControllerBuiltinsWrapper& writableStreamDefaultControllerBuiltins() { return m_writableStreamDefaultControllerBuiltins; } + +private: + JSC::VM& m_vm; + BundlerPluginBuiltinsWrapper m_bundlerPluginBuiltins; + ByteLengthQueuingStrategyBuiltinsWrapper m_byteLengthQueuingStrategyBuiltins; + WritableStreamInternalsBuiltinsWrapper m_writableStreamInternalsBuiltins; + TransformStreamInternalsBuiltinsWrapper m_transformStreamInternalsBuiltins; + ProcessObjectInternalsBuiltinsWrapper m_processObjectInternalsBuiltins; + TransformStreamBuiltinsWrapper m_transformStreamBuiltins; + JSBufferPrototypeBuiltinsWrapper m_jsBufferPrototypeBuiltins; + ReadableByteStreamControllerBuiltinsWrapper m_readableByteStreamControllerBuiltins; + ConsoleObjectBuiltinsWrapper m_consoleObjectBuiltins; + ReadableStreamInternalsBuiltinsWrapper m_readableStreamInternalsBuiltins; + TransformStreamDefaultControllerBuiltinsWrapper m_transformStreamDefaultControllerBuiltins; + ReadableStreamBYOBReaderBuiltinsWrapper m_readableStreamBYOBReaderBuiltins; + JSBufferConstructorBuiltinsWrapper m_jsBufferConstructorBuiltins; + ReadableStreamDefaultReaderBuiltinsWrapper m_readableStreamDefaultReaderBuiltins; + StreamInternalsBuiltinsWrapper m_streamInternalsBuiltins; + ImportMetaObjectBuiltinsWrapper m_importMetaObjectBuiltins; + CountQueuingStrategyBuiltinsWrapper m_countQueuingStrategyBuiltins; + ReadableStreamBYOBRequestBuiltinsWrapper m_readableStreamBYOBRequestBuiltins; + WritableStreamDefaultWriterBuiltinsWrapper m_writableStreamDefaultWriterBuiltins; + ReadableStreamBuiltinsWrapper m_readableStreamBuiltins; + ReadableStreamDefaultControllerBuiltinsWrapper m_readableStreamDefaultControllerBuiltins; + ReadableByteStreamInternalsBuiltinsWrapper m_readableByteStreamInternalsBuiltins; + WritableStreamDefaultControllerBuiltinsWrapper m_writableStreamDefaultControllerBuiltins; +; +}; + +class JSBuiltinInternalFunctions { +public: + explicit JSBuiltinInternalFunctions(JSC::VM&); + + template<typename Visitor> void visit(Visitor&); + void initialize(Zig::GlobalObject&); + WritableStreamInternalsBuiltinFunctions& writableStreamInternals() { return m_writableStreamInternals; } + TransformStreamInternalsBuiltinFunctions& transformStreamInternals() { return m_transformStreamInternals; } + ReadableStreamInternalsBuiltinFunctions& readableStreamInternals() { return m_readableStreamInternals; } + StreamInternalsBuiltinFunctions& streamInternals() { return m_streamInternals; } + ReadableByteStreamInternalsBuiltinFunctions& readableByteStreamInternals() { return m_readableByteStreamInternals; } + +private: + JSC::VM& m_vm; + WritableStreamInternalsBuiltinFunctions m_writableStreamInternals; + TransformStreamInternalsBuiltinFunctions m_transformStreamInternals; + ReadableStreamInternalsBuiltinFunctions m_readableStreamInternals; + StreamInternalsBuiltinFunctions m_streamInternals; + ReadableByteStreamInternalsBuiltinFunctions m_readableByteStreamInternals; + +}; + +} // namespace WebCore diff --git a/src/bun.js/builtins/builtins.d.ts b/src/bun.js/builtins/builtins.d.ts new file mode 100644 index 000000000..da92c18bd --- /dev/null +++ b/src/bun.js/builtins/builtins.d.ts @@ -0,0 +1,537 @@ +// Typedefs for JSC intrinsics. Instead of @, we use $ +type TODO = any; + +/** Place this directly above a function declaration (like a decorator) to make it a getter. */ +declare const $getter: never; +/** Assign to this directly above a function declaration (like a decorator) to override the function's display name. */ +declare var $overriddenName: string; +/** ??? */ +declare var $linkTimeConstant: never; +/** Assign to this directly above a function declaration (like a decorator) to set visibility */ +declare var $visibility: "Public" | "Private"; +/** ??? */ +declare var $nakedConstructor: never; +/** Assign to this directly above a function declaration (like a decorator) to set intrinsic */ +declare var $intrinsic: string; +declare var $constructor; +/** Place this directly above a function declaration (like a decorator) to NOT include "use strict" */ +declare var $sloppy; + +declare function $extractHighWaterMarkFromQueuingStrategyInit(obj: any): any; + +// JSC defines their intrinsics in a nice list here: +// https://github.com/WebKit/WebKit/blob/main/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h +// +// And implemented here: (search for "emit_intrinsic_<name>", like "emit_intrinsic_arrayPush") +// https://github.com/WebKit/WebKit/blob/main/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp + +/** Assert a value is true */ +declare function $assert(index: any): void; +/** returns `arguments[index]` */ +declare function $argument<T = any>(index: number): any; +/** returns number of arguments */ +declare function $argumentCount(): number; +/** array.push(item) */ +declare function $arrayPush(array: T[], item: T): void; +/** gets a property on an object */ +declare function $getByIdDirect<T = any>(obj: any, key: string): T; +/** + * gets a private property on an object. translates to the `op_get_by_id_direct` bytecode. + * + * TODO: clarify what private means exactly. + */ +declare function $getByIdDirectPrivate<T = any>(obj: any, key: string): T; +/** + * gets a property on an object + */ +declare function $getByValWithThis(target: any, receiver: any, propertyKey: string): void; +/** gets the prototype of an object */ +declare function $getPrototypeOf(value: any): any; +/** gets an internal property on a promise + * + * You can pass + * - $promiseFieldFlags - get a number with flags + * - $promiseFieldReactionsOrResult - get the result (like Bun.peek) + */ +declare function $getPromiseInternalField<K extends PromiseFieldType, V>( + promise: Promise<V>, + key: K, +): PromiseFieldToValue<K, V>; +declare function $getGeneratorInternalField(): TODO; +declare function $getAsyncGeneratorInternalField(): TODO; +declare function $getAbstractModuleRecordInternalField(): TODO; +declare function $getArrayIteratorInternalField(): TODO; +declare function $getStringIteratorInternalField(): TODO; +declare function $getMapIteratorInternalField(): TODO; +declare function $getSetIteratorInternalField(): TODO; +declare function $getProxyInternalField(): TODO; +declare function $idWithProfile(): TODO; +declare function $isObject(obj: unknown): obj is object; +declare function $isCallable(fn: unknown): fn is CallableFunction; +declare function $isConstructor(fn: unknown): fn is { new (...args: any[]): any }; +declare function $isJSArray(obj: unknown): obj is any[]; +declare function $isProxyObject(obj: unknown): obj is Proxy; +declare function $isDerivedArray(): TODO; +declare function $isGenerator(obj: unknown): obj is Generator<any, any, any>; +declare function $isAsyncGenerator(obj: unknown): obj is AsyncGenerator<any, any, any>; +declare function $isPromise(obj: unknown): obj is Promise<any>; +declare function $isRegExpObject(obj: unknown): obj is RegExp; +declare function $isMap<K, V>(obj: unknown): obj is Map<K, V>; +declare function $isSet<V>(obj: unknown): obj is Set<V>; +declare function $isShadowRealm(obj: unknown): obj is ShadowRealm; +declare function $isStringIterator(obj: unknown): obj is Iterator<string>; +declare function $isArrayIterator(obj: unknown): obj is Iterator<any>; +declare function $isMapIterator(obj: unknown): obj is Iterator<any>; +declare function $isSetIterator(obj: unknown): obj is Iterator<any>; +declare function $isUndefinedOrNull(obj: unknown): obj is null | undefined; +declare function $tailCallForwardArguments(): TODO; +/** + * **NOTE** - use `throw new TypeError()` instead. it compiles to the same builtin + * @deprecated + */ +declare function $throwTypeError(message: string): never; +/** + * **NOTE** - use `throw new RangeError()` instead. it compiles to the same builtin + * @deprecated + */ +declare function $throwRangeError(message: string): never; +/** + * **NOTE** - use `throw new OutOfMemoryError()` instead. it compiles to the same builtin + * @deprecated + */ +declare function $throwOutOfMemoryError(): never; +declare function $tryGetById(): TODO; +declare function $tryGetByIdWithWellKnownSymbol(obj: any, key: WellKnownSymbol): any; +declare function $putByIdDirect(obj: any, key: PropertyKey, value: any): void; +declare function $putByIdDirectPrivate(obj: any, key: PropertyKey, value: any): void; +declare function $putByValDirect(obj: any, key: PropertyKey, value: any): void; +declare function $putByValWithThisSloppy(): TODO; +declare function $putByValWithThisStrict(): TODO; +declare function $putPromiseInternalField<T extends PromiseFieldType, P extends Promise<any>>( + promise: P, + key: T, + value: PromiseFieldToValue<T, P>, +): void; +declare function $putGeneratorInternalField(): TODO; +declare function $putAsyncGeneratorInternalField(): TODO; +declare function $putArrayIteratorInternalField(): TODO; +declare function $putStringIteratorInternalField(): TODO; +declare function $putMapIteratorInternalField(): TODO; +declare function $putSetIteratorInternalField(): TODO; +declare function $superSamplerBegin(): TODO; +declare function $superSamplerEnd(): TODO; +declare function $toNumber(x: any): number; +declare function $toString(x: any): string; +declare function $toPropertyKey(x: any): PropertyKey; +/** + * Often used like + * `$toObject(this, "Class.prototype.method requires that |this| not be null or undefined");` + */ +declare function $toObject(object: any, errorMessage?: string): object; +declare function $newArrayWithSize<T>(size: number): T[]; +declare function $newArrayWithSpecies(): TODO; +declare function $newPromise(): TODO; +declare function $createPromise(): TODO; +declare const $iterationKindKey: TODO; +declare const $iterationKindValue: TODO; +declare const $iterationKindEntries: TODO; +declare const $MAX_ARRAY_INDEX: number; +declare const $MAX_STRING_LENGTH: number; +declare const $MAX_SAFE_INTEGER: number; +declare const $ModuleFetch: number; +declare const $ModuleTranslate: number; +declare const $ModuleInstantiate: number; +declare const $ModuleSatisfy: number; +declare const $ModuleLink: number; +declare const $ModuleReady: number; +declare const $promiseRejectionReject: TODO; +declare const $promiseRejectionHandle: TODO; +declare const $promiseStatePending: number; +declare const $promiseStateFulfilled: number; +declare const $promiseStateRejected: number; +declare const $promiseStateMask: number; +declare const $promiseFlagsIsHandled: number; +declare const $promiseFlagsIsFirstResolvingFunctionCalled: number; +declare const $promiseFieldFlags: unique symbol; +declare const $promiseFieldReactionsOrResult: unique symbol; +declare const $proxyFieldTarget: TODO; +declare const $proxyFieldHandler: TODO; +declare const $generatorFieldState: TODO; +declare const $generatorFieldNext: TODO; +declare const $generatorFieldThis: TODO; +declare const $generatorFieldFrame: TODO; +declare const $generatorFieldContext: TODO; +declare const $GeneratorResumeModeNormal: TODO; +declare const $GeneratorResumeModeThrow: TODO; +declare const $GeneratorResumeModeReturn: TODO; +declare const $GeneratorStateCompleted: TODO; +declare const $GeneratorStateExecuting: TODO; +declare const $arrayIteratorFieldIndex: TODO; +declare const $arrayIteratorFieldIteratedObject: TODO; +declare const $arrayIteratorFieldKind: TODO; +declare const $mapIteratorFieldMapBucket: TODO; +declare const $mapIteratorFieldKind: TODO; +declare const $setIteratorFieldSetBucket: TODO; +declare const $setIteratorFieldKind: TODO; +declare const $stringIteratorFieldIndex: TODO; +declare const $stringIteratorFieldIteratedString: TODO; +declare const $asyncGeneratorFieldSuspendReason: TODO; +declare const $asyncGeneratorFieldQueueFirst: TODO; +declare const $asyncGeneratorFieldQueueLast: TODO; +declare const $AsyncGeneratorStateCompleted: TODO; +declare const $AsyncGeneratorStateExecuting: TODO; +declare const $AsyncGeneratorStateAwaitingReturn: TODO; +declare const $AsyncGeneratorStateSuspendedStart: TODO; +declare const $AsyncGeneratorStateSuspendedYield: TODO; +declare const $AsyncGeneratorSuspendReasonYield: TODO; +declare const $AsyncGeneratorSuspendReasonAwait: TODO; +declare const $AsyncGeneratorSuspendReasonNone: TODO; +declare const $abstractModuleRecordFieldState: TODO; + +// We define our intrinsics in ./BunBuiltinNames.h. Some of those are globals. + +declare var $_events: TODO; +declare function $abortAlgorithm(): TODO; +declare function $abortSteps(): TODO; +declare function $addEventListener(): TODO; +declare function $appendFromJS(): TODO; +declare function $argv(): TODO; +declare function $assignToStream(): TODO; +declare function $associatedReadableByteStreamController(): TODO; +declare function $autoAllocateChunkSize(): TODO; +declare function $backpressure(): TODO; +declare function $backpressureChangePromise(): TODO; +declare function $basename(): TODO; +declare function $body(): TODO; +declare function $bunNativePtr(): TODO; +declare function $bunNativeType(): TODO; +declare function $byobRequest(): TODO; +declare function $cancel(): TODO; +declare function $cancelAlgorithm(): TODO; +declare function $chdir(): TODO; +declare function $cloneArrayBuffer(a, b, c): TODO; +declare function $close(): TODO; +declare function $closeAlgorithm(): TODO; +declare function $closeRequest(): TODO; +declare function $closeRequested(): TODO; +declare function $closed(): TODO; +declare function $closedPromise(): TODO; +declare function $closedPromiseCapability(): TODO; +declare function $code(): TODO; +declare const $commonJSSymbol: unique symbol; +declare function $connect(): TODO; +declare function $consumeReadableStream(): TODO; +declare function $controlledReadableStream(): TODO; +declare function $controller(): TODO; +declare function $cork(): TODO; +declare function $createEmptyReadableStream(): TODO; +declare function $createFIFO(): TODO; +declare function $createNativeReadableStream(): TODO; +declare function $createReadableStream(): TODO; +declare function $createUninitializedArrayBuffer(size: number): ArrayBuffer; +declare function $createWritableStreamFromInternal(): TODO; +declare function $cwd(): TODO; +declare function $data(): TODO; +declare function $dataView(): TODO; +declare function $decode(): TODO; +declare function $delimiter(): TODO; +declare function $destroy(): TODO; +declare function $dir(): TODO; +declare function $direct(): TODO; +declare function $dirname(): TODO; +declare function $disturbed(): TODO; +declare function $document(): TODO; +declare function $encode(): TODO; +declare function $encoding(): TODO; +declare function $end(): TODO; +declare function $errno(): TODO; +declare function $errorSteps(): TODO; +declare function $execArgv(): TODO; +declare function $extname(): TODO; +declare function $failureKind(): TODO; +declare function $fatal(): TODO; +declare function $fetch(): TODO; +declare function $fetchRequest(): TODO; +declare function $file(): TODO; +declare function $filePath(): TODO; +declare function $fillFromJS(): TODO; +declare function $filter(): TODO; +declare function $finishConsumingStream(): TODO; +declare function $flush(): TODO; +declare function $flushAlgorithm(): TODO; +declare function $format(): TODO; +declare function $fulfillModuleSync(key: string): void; +declare function $get(): TODO; +declare function $getInternalWritableStream(writable: WritableStream): TODO; +declare function $handleEvent(): TODO; +declare function $hash(): TODO; +declare function $header(): TODO; +declare function $headers(): TODO; +declare function $highWaterMark(): TODO; +declare function $host(): TODO; +declare function $hostname(): TODO; +declare function $href(): TODO; +declare function $ignoreBOM(): TODO; +declare function $importer(): TODO; +declare function $inFlightCloseRequest(): TODO; +declare function $inFlightWriteRequest(): TODO; +declare function $initializeWith(): TODO; +declare function $internalRequire(path: string): TODO; +declare function $internalStream(): TODO; +declare function $internalWritable(): TODO; +declare function $isAbortSignal(signal: unknown): signal is AbortSignal; +declare function $isAbsolute(): TODO; +declare function $isDisturbed(): TODO; +declare function $isPaused(): TODO; +declare function $isWindows(): TODO; +declare function $join(): TODO; +declare function $kind(): TODO; +declare function $lazy(): TODO; +declare function $lazyLoad(): TODO; +declare function $lazyStreamPrototypeMap(): TODO; +declare function $loadModule(): TODO; +declare function $localStreams(): TODO; +declare function $main(): TODO; +declare function $makeDOMException(): TODO; +declare function $makeGetterTypeError(className: string, prop: string): Error; +declare function $makeThisTypeError(className: string, method: string): Error; +declare function $map(): TODO; +declare function $method(): TODO; +declare function $nextTick(): TODO; +declare function $normalize(): TODO; +declare function $on(): TODO; +declare function $once(): TODO; +declare function $options(): TODO; +declare function $origin(): TODO; +declare function $ownerReadableStream(): TODO; +declare function $parse(): TODO; +declare function $password(): TODO; +declare function $patch(): TODO; +declare function $path(): TODO; +declare function $pathname(): TODO; +declare function $pause(): TODO; +declare function $pendingAbortRequest(): TODO; +declare function $pendingPullIntos(): TODO; +declare function $pid(): TODO; +declare function $pipe(): TODO; +declare function $port(): TODO; +declare function $post(): TODO; +declare function $ppid(): TODO; +declare function $prependEventListener(): TODO; +declare function $process(): TODO; +declare function $protocol(): TODO; +declare function $pull(): TODO; +declare function $pullAgain(): TODO; +declare function $pullAlgorithm(): TODO; +declare function $pulling(): TODO; +declare function $put(): TODO; +declare function $queue(): TODO; +declare function $read(): TODO; +declare function $readIntoRequests(): TODO; +declare function $readRequests(): TODO; +declare function $readable(): TODO; +declare function $readableStreamController(): TODO; +declare function $readableStreamToArray(): TODO; +declare function $reader(): TODO; +declare function $readyPromise(): TODO; +declare function $readyPromiseCapability(): TODO; +declare function $redirect(): TODO; +declare function $relative(): TODO; +declare function $releaseLock(): TODO; +declare function $removeEventListener(): TODO; +declare function $require(): TODO; +declare function $requireESM(path: string): any; +declare const $requireMap: Map<string, TODO>; +declare function $resolve(name: string, from: string): Promise<string>; +declare function $resolveSync(name: string, from: string): string; +declare function $resume(): TODO; +declare function $search(): TODO; +declare function $searchParams(): TODO; +declare function $self(): TODO; +declare function $sep(): TODO; +declare function $setBody(): TODO; +declare function $setStatus(): TODO; +declare function $setup(): TODO; +declare function $sink(): TODO; +declare function $size(): TODO; +declare function $start(): TODO; +declare function $startAlgorithm(): TODO; +declare function $startConsumingStream(): TODO; +declare function $startDirectStream(): TODO; +declare function $started(): TODO; +declare function $startedPromise(): TODO; +declare function $state(): TODO; +declare function $status(): TODO; +declare function $storedError(): TODO; +declare function $strategy(): TODO; +declare function $strategyHWM(): TODO; +declare function $strategySizeAlgorithm(): TODO; +declare function $stream(): TODO; +declare function $streamClosed(): TODO; +declare function $streamClosing(): TODO; +declare function $streamErrored(): TODO; +declare function $streamReadable(): TODO; +declare function $streamWaiting(): TODO; +declare function $streamWritable(): TODO; +declare function $structuredCloneForStream(): TODO; +declare function $syscall(): TODO; +declare function $textDecoderStreamDecoder(): TODO; +declare function $textDecoderStreamTransform(): TODO; +declare function $textEncoderStreamEncoder(): TODO; +declare function $textEncoderStreamTransform(): TODO; +declare function $toNamespacedPath(): TODO; +declare function $trace(): TODO; +declare function $transformAlgorithm(): TODO; +declare function $uncork(): TODO; +declare function $underlyingByteSource(): TODO; +declare function $underlyingSink(): TODO; +declare function $underlyingSource(): TODO; +declare function $unpipe(): TODO; +declare function $unshift(): TODO; +declare function $url(): TODO; +declare function $username(): TODO; +declare function $version(): TODO; +declare function $versions(): TODO; +declare function $view(): TODO; +declare function $whenSignalAborted(signal: AbortSignal, cb: (reason: any) => void): TODO; +declare function $writable(): TODO; +declare function $write(): TODO; +declare function $writeAlgorithm(): TODO; +declare function $writeRequests(): TODO; +declare function $writer(): TODO; +declare function $writing(): TODO; +declare function $written(): TODO; + +// The following I cannot find any definitions of, but they are functional. +declare function $toLength(length: number): number; +declare function $isTypedArrayView(obj: unknown): obj is ArrayBufferView | DataView | Uint8Array; +declare function $setStateToMax(target: any, state: number): void; +declare function $trunc(target: number): number; +declare function $newPromiseCapability(C: PromiseConstructor): TODO; +/** @deprecated, use new TypeError instead */ +declare function $makeTypeError(message: string): TypeError; +declare function $newHandledRejectedPromise(error: unknown): Promise<never>; + +// Types used in the above functions +type PromiseFieldType = typeof $promiseFieldFlags | typeof $promiseFieldReactionsOrResult; +type PromiseFieldToValue<X extends PromiseFieldType, V> = X extends typeof $promiseFieldFlags + ? number + : X extends typeof $promiseFieldReactionsOrResult + ? V | any + : any; +type WellKnownSymbol = keyof { [K in keyof SymbolConstructor as SymbolConstructor[K] extends symbol ? K : never]: K }; + +// You can also `@` on any method on a classes to avoid prototype pollution and secret internals +type ClassWithIntrinsics<T> = { [K in keyof T as T[K] extends Function ? `$${K}` : never]: T[K] }; + +declare interface Map<K, V> extends ClassWithIntrinsics<Map<K, V>> {} +declare interface CallableFunction extends ClassWithIntrinsics<CallableFunction> {} +declare interface Promise<T> extends ClassWithIntrinsics<Promise<T>> {} +declare interface ArrayBufferConstructor<T> extends ClassWithIntrinsics<ArrayBufferConstructor<T>> {} +declare interface PromiseConstructor<T> extends ClassWithIntrinsics<PromiseConstructor<T>> {} + +declare interface UnderlyingSource { + $lazy: boolean; + $bunNativeType: number; + $bunNativePtr: number; + autoAllocateChunkSize?: number; +} + +declare class OutOfMemoryError { + constructor(); +} + +declare class ReadableStream { + constructor(stream: unknown, view?: unknown); + values(options?: unknown): AsyncIterableIterator<unknown>; +} +declare class ReadableStreamDefaultController { + constructor( + stream: unknown, + underlyingSource: unknown, + size: unknown, + highWaterMark: unknown, + $isReadableStream: typeof $isReadableStream, + ); +} +declare class ReadableByteStreamController { + constructor( + stream: unknown, + underlyingSource: unknown, + strategy: unknown, + $isReadableStream: typeof $isReadableStream, + ); +} +declare class ReadableStreamBYOBRequest { + constructor(stream: unknown, view: unknown, $isReadableStream: typeof $isReadableStream); +} +declare class ReadableStreamBYOBReader { + constructor(stream: unknown); +} + +// Inlining our enum types +declare const $ImportKindIdToLabel: Array<import("bun").ImportKind>; +declare const $ImportKindLabelToId: Record<import("bun").ImportKind, number>; +declare const $LoaderIdToLabel: Array<import("bun").Loader>; +declare const $LoaderLabelToId: Record<import("bun").Loader, number>; + +// not a builtin, but a build-time macro of our own +/** Returns a not implemented error that points to a github issue. */ +declare function notImplementedIssue(issueNumber: number, description: string): Error; +/** Return a function that throws a not implemented error that points to a github issue */ +declare function notImplementedIssueFn(issueNumber: number, description: string): (...args: any[]) => never; + +declare type JSCSourceCodeObject = unique symbol; + +declare var Loader: { + registry: Map<string, LoaderEntry>; + + parseModule(key: string, sourceCodeObject: JSCSourceCodeObject): Promise<LoaderModule> | LoaderModule; + linkAndEvaluateModule(resolvedSpecifier: string, unknown: any); + getModuleNamespaceObject(module: LoaderModule): any; + requestedModules(module: LoaderModule): string[]; + dependencyKeysIfEvaluated(specifier: string): string[]; + resolve(specifier: string, referrer: string): string; + ensureRegistered(key: string): LoaderEntry; +}; + +interface LoaderEntry { + key: string; + state: number; + fetch: Promise<JSCSourceCodeObject>; + instantiate: Promise<any>; + satisfy: Promise<any>; + dependencies: string[]; + module: LoaderModule; + linkError?: any; + linkSucceeded: boolean; + evaluated: boolean; + then?: any; + isAsync: boolean; +} + +interface LoaderModule { + dependenciesMap: Map<string, LoaderEntry>; +} + +declare module "bun" { + var TOML: { + parse(contents: string): any; + }; + function fs(): typeof import("node:fs"); + function _Os(): typeof import("node:os"); + var main: string; + var tty: Array<{ hasColors: boolean }>; +} + +declare interface Function { + path: string; +} + +declare var $Buffer: { + new (a: any, b?: any, c?: any): Buffer; +}; + +declare interface Error { + code?: string; +} diff --git a/src/bun.js/builtins/codegen/builtin-parser.ts b/src/bun.js/builtins/codegen/builtin-parser.ts new file mode 100644 index 000000000..e96d79c63 --- /dev/null +++ b/src/bun.js/builtins/codegen/builtin-parser.ts @@ -0,0 +1,89 @@ +import { applyReplacements } from "./replacements"; + +/** + * Slices a string until it hits a }, but keeping in mind JS comments, + * regex, template literals, comments, and matching { + * + * Used to extract function bodies without parsing the code. + * + * If you pass replace=true, it will run replacements on the code + */ +export function sliceSourceCode( + contents: string, + replace: boolean, +): { result: string; rest: string; usesThis: boolean } { + let bracketCount = 0; + let i = 0; + let result = ""; + let usesThis = false; + while (contents.length) { + // TODO: template literal, regexp + // these are important because our replacement logic would replace intrinsics + // within these, when it should remain as the literal dollar. + // but this isn't used in the codebase + i = contents.match(/\/\*|\/\/|'|"|{|}|`/)?.index ?? contents.length; + const chunk = replace ? applyReplacements(contents.slice(0, i)) : contents.slice(0, i); + if (chunk.includes("this")) usesThis = true; + result += chunk; + contents = contents.slice(i); + if (!contents.length) break; + if (contents.startsWith("/*")) { + i = contents.slice(2).indexOf("*/") + 2; + } else if (contents.startsWith("//")) { + i = contents.slice(2).indexOf("\n") + 2; + } else if (contents.startsWith("'")) { + i = contents.slice(1).match(/(?<!\\)'/)!.index! + 2; + } else if (contents.startsWith('"')) { + i = contents.slice(1).match(/(?<!\\)"/)!.index! + 2; + } else if (contents.startsWith("`")) { + const { result: result2, rest } = sliceTemplateLiteralSourceCode(contents.slice(1), replace); + result += "`" + result2; + contents = rest; + continue; + } else if (contents.startsWith("{")) { + bracketCount++; + i = 1; + } else if (contents.startsWith("}")) { + bracketCount--; + if (bracketCount <= 0) { + result += "}"; + contents = contents.slice(1); + break; + } + i = 1; + } else { + throw new Error("TODO"); + } + result += contents.slice(0, i); + contents = contents.slice(i); + } + + return { result, rest: contents, usesThis }; +} + +function sliceTemplateLiteralSourceCode(contents: string, replace: boolean) { + let i = 0; + let result = ""; + let usesThis = false; + while (contents.length) { + i = contents.match(/`|\${/)!.index!; + result += contents.slice(0, i); + contents = contents.slice(i); + if (!contents.length) break; + if (contents.startsWith("`")) { + result += "`"; + contents = contents.slice(1); + break; + } else if (contents.startsWith("$")) { + const { result: result2, rest, usesThis: usesThisVal } = sliceSourceCode(contents.slice(1), replace); + result += "$" + result2; + contents = rest; + usesThis ||= usesThisVal; + continue; + } else { + throw new Error("TODO"); + } + } + + return { result, rest: contents, usesThis }; +} diff --git a/src/bun.js/builtins/codegen/helpers.ts b/src/bun.js/builtins/codegen/helpers.ts new file mode 100644 index 000000000..6345f8ffa --- /dev/null +++ b/src/bun.js/builtins/codegen/helpers.ts @@ -0,0 +1,25 @@ +export function fmtCPPString(str: string) { + return ( + '"' + + str + .replace(/\\/g, "\\\\") + .replace(/"/g, '\\"') + .replace(/\n/g, "\\n") + .replace(/\r/g, "\\r") + .replace(/\t/g, "\\t") + .replace(/\?/g, "\\?") + // https://stackoverflow.com/questions/1234582 + '"' + ); +} + +export function cap(str: string) { + return str[0].toUpperCase() + str.slice(1); +} + +export function low(str: string) { + if (str.startsWith("JS")) { + return "js" + str.slice(2); + } + + return str[0].toLowerCase() + str.slice(1); +} diff --git a/src/bun.js/builtins/codegen/index.ts b/src/bun.js/builtins/codegen/index.ts new file mode 100644 index 000000000..c9e44ec06 --- /dev/null +++ b/src/bun.js/builtins/codegen/index.ts @@ -0,0 +1,624 @@ +import { existsSync, mkdirSync, readdirSync, rmSync, writeFileSync } from "fs"; +import path from "path"; +import { sliceSourceCode } from "./builtin-parser"; +import { applyGlobalReplacements, enums, globalsToPrefix } from "./replacements"; +import { cap, fmtCPPString, low } from "./helpers"; + +console.log("Bundling Bun builtins..."); + +const MINIFY = process.argv.includes("--minify") || process.argv.includes("-m"); +const PARALLEL = process.argv.includes("--parallel") || process.argv.includes("-p"); +const KEEP_TMP = process.argv.includes("--keep-tmp") || process.argv.includes("-k"); + +const SRC_DIR = path.join(import.meta.dir, "../ts"); +const OUT_DIR = path.join(import.meta.dir, "../"); +const TMP_DIR = path.join(import.meta.dir, "../out"); + +if (existsSync(TMP_DIR)) rmSync(TMP_DIR, { recursive: true }); +mkdirSync(TMP_DIR); + +const define = { + "process.env.NODE_ENV": "development", + "process.platform": process.platform, + "process.arch": process.arch, +}; + +for (const name in enums) { + const value = enums[name]; + if (typeof value !== "object") throw new Error("Invalid enum object " + name + " defined in " + import.meta.file); + if (typeof value === null) throw new Error("Invalid enum object " + name + " defined in " + import.meta.file); + const keys = Array.isArray(value) ? value : Object.keys(value).filter(k => !k.match(/^[0-9]+$/)); + define[`__intrinsic__${name}IdToLabel`] = "[" + keys.map(k => `"${k}"`).join(", ") + "]"; + define[`__intrinsic__${name}LabelToId`] = "{" + keys.map(k => `"${k}": ${keys.indexOf(k)}`).join(", ") + "}"; +} + +for (const name of globalsToPrefix) { + define[name] = "__intrinsic__" + name; +} + +interface ParsedBuiltin { + name: string; + params: string[]; + directives: Record<string, any>; + source: string; + async: boolean; +} +interface BundledBuiltin { + name: string; + directives: Record<string, any>; + isGetter: boolean; + isConstructor: boolean; + isLinkTimeConstant: boolean; + isNakedConstructor: boolean; + intrinsic: string; + overriddenName: string; + source: string; + params: string[]; + visibility: string; +} + +/** + * Source .ts file --> Array<bundled js function code> + */ +async function processFileSplit(filename: string): Promise<{ functions: BundledBuiltin[]; internal: boolean }> { + const basename = path.basename(filename, ".ts"); + let contents = await Bun.file(filename).text(); + + contents = applyGlobalReplacements(contents); + + // first approach doesnt work perfectly because we actually need to split each function declaration + // and then compile those separately + + const consumeWhitespace = /^\s*/; + const consumeTopLevelContent = /^(\/\*|\/\/|type|import|interface|\$|export (?:async )?function|(?:async )?function)/; + const consumeEndOfType = /;|.(?=export|type|interface|\$|\/\/|\/\*|function)/; + + const functions: ParsedBuiltin[] = []; + let directives: Record<string, any> = {}; + const bundledFunctions: BundledBuiltin[] = []; + let internal = false; + + while (contents.length) { + contents = contents.replace(consumeWhitespace, ""); + if (!contents.length) break; + const match = contents.match(consumeTopLevelContent); + if (!match) { + throw new SyntaxError("Could not process input:\n" + contents.slice(0, contents.indexOf("\n"))); + } + contents = contents.slice(match.index!); + if (match[1] === "import") { + // TODO: we may want to do stuff with these + const i = contents.indexOf(";"); + contents = contents.slice(i + 1); + } else if (match[1] === "/*") { + const i = contents.indexOf("*/") + 2; + internal ||= contents.slice(0, i).includes("@internal"); + contents = contents.slice(i); + } else if (match[1] === "//") { + const i = contents.indexOf("\n") + 1; + internal ||= contents.slice(0, i).includes("@internal"); + contents = contents.slice(i); + } else if (match[1] === "type" || match[1] === "export type") { + const i = contents.search(consumeEndOfType); + contents = contents.slice(i + 1); + } else if (match[1] === "interface") { + contents = sliceSourceCode(contents, false).rest; + } else if (match[1] === "$") { + const directive = contents.match(/^\$([a-zA-Z0-9]+)(?:\s*=\s*([^\n]+?))?\s*;?\n/); + if (!directive) { + throw new SyntaxError("Could not parse directive:\n" + contents.slice(0, contents.indexOf("\n"))); + } + const name = directive[1]; + let value; + try { + value = directive[2] ? JSON.parse(directive[2]) : true; + } catch (error) { + throw new SyntaxError("Could not parse directive value " + directive[2] + " (must be JSON parsable)"); + } + if (name === "constructor") { + throw new SyntaxError("$constructor not implemented"); + } + if (name === "nakedConstructor") { + throw new SyntaxError("$nakedConstructor not implemented"); + } + directives[name] = value; + contents = contents.slice(directive[0].length); + } else if (match[1] === "export function" || match[1] === "export async function") { + const declaration = contents.match( + /^export\s+(async\s+)?function\s+([a-zA-Z0-9]+)\s*\(([^)]*)\)(?:\s*:\s*([^{\n]+))?\s*{?/, + ); + if (!declaration) + throw new SyntaxError("Could not parse function declaration:\n" + contents.slice(0, contents.indexOf("\n"))); + + const async = !!declaration[1]; + const name = declaration[2]; + const paramString = declaration[3]; + const params = + paramString.trim().length === 0 ? [] : paramString.split(",").map(x => x.replace(/:.+$/, "").trim()); + if (params[0] === "this") { + params.shift(); + } + + const { result, rest } = sliceSourceCode(contents.slice(declaration[0].length - 1), true); + functions.push({ + name, + params, + directives, + source: result.trim().slice(1, -1), + async, + }); + contents = rest; + directives = {}; + } else if (match[1] === "function" || match[1] === "async function") { + const fnname = contents.match(/^function ([a-zA-Z0-9]+)\(([^)]*)\)(?:\s*:\s*([^{\n]+))?\s*{?/)![1]; + throw new SyntaxError("All top level functions must be exported: " + fnname); + } else { + throw new Error("TODO: parse " + match[1]); + } + } + + for (const fn of functions) { + const tmpFile = path.join(TMP_DIR, `${basename}.${fn.name}.ts`); + + // not sure if this optimization works properly in jsc builtins + // const useThis = fn.usesThis; + const useThis = true; + + // TODO: we should use format=IIFE so we could bundle imports and extra functions. + await Bun.write( + tmpFile, + `// @ts-nocheck +// GENERATED TEMP FILE - DO NOT EDIT +// Sourced from ${path.relative(TMP_DIR, filename)} + +// do not allow the bundler to rename a symbol to $ +($); + +$$capture_start$$(${fn.async ? "async " : ""}${ + useThis + ? `function(${fn.params.join(",")})` + : `${fn.params.length === 1 ? fn.params[0] : `(${fn.params.join(",")})`}=>` + } {${fn.source}}).$$capture_end$$; +`, + ); + await Bun.sleep(1); + const build = await Bun.build({ + entrypoints: [tmpFile], + define, + minify: true, + }); + if (!build.success) { + throw new AggregateError(build.logs, "Failed bundling builtin function " + fn.name + " from " + basename + ".ts"); + } + if (build.outputs.length !== 1) { + throw new Error("expected one output"); + } + const output = await build.outputs[0].text(); + const captured = output.match(/\$\$capture_start\$\$([\s\S]+)\.\$\$capture_end\$\$/)![1]; + const finalReplacement = + (fn.directives.sloppy ? captured : captured.replace(/function\s*\(.*?\)\s*{/, '$&"use strict";')) + .replace(/^\((async )?function\(/, "($1function (") + .replace(/__intrinsic__/g, "@") + "\n"; + + bundledFunctions.push({ + name: fn.name, + directives: fn.directives, + source: finalReplacement, + params: fn.params, + visibility: fn.directives.visibility ?? (fn.directives.linkTimeConstant ? "Private" : "Public"), + isGetter: !!fn.directives.getter, + isConstructor: !!fn.directives.constructor, + isLinkTimeConstant: !!fn.directives.linkTimeConstant, + isNakedConstructor: !!fn.directives.nakedConstructor, + intrinsic: fn.directives.intrinsic ?? "NoIntrinsic", + overriddenName: fn.directives.getter + ? `"get ${fn.name}"_s` + : fn.directives.overriddenName + ? `"${fn.directives.overriddenName}"_s` + : "ASCIILiteral()", + }); + } + + return { + functions: bundledFunctions, + internal, + }; +} + +const filesToProcess = readdirSync(SRC_DIR).filter(x => x.endsWith(".ts")); + +const files: Array<{ basename: string; functions: BundledBuiltin[]; internal: boolean }> = []; +async function processFile(x: string) { + const basename = path.basename(x, ".ts"); + try { + files.push({ + basename, + ...(await processFileSplit(path.join(SRC_DIR, x))), + }); + } catch (error) { + console.error("Failed to process file: " + basename + ".ts"); + console.error(error); + process.exit(1); + } +} + +// Bun seems to crash if this is parallelized, :( +if (PARALLEL) { + await Promise.all(filesToProcess.map(processFile)); +} else { + for (const x of filesToProcess) { + await processFile(x); + } +} + +// C++ codegen +let bundledCPP = `// Generated by \`bun src/bun.js/builtins/codegen/index.js\` +// Do not edit by hand. +namespace Zig { class GlobalObject; } +#include "root.h" +#include "config.h" +#include "JSDOMGlobalObject.h" +#include "WebCoreJSClientData.h" +#include <JavaScriptCore/JSObjectInlines.h> + +namespace WebCore { + +`; + +for (const { basename, functions } of files) { + bundledCPP += `/* ${basename}.ts */\n`; + const lowerBasename = low(basename); + for (const fn of functions) { + const name = `${lowerBasename}${cap(fn.name)}Code`; + bundledCPP += `// ${fn.name} +const JSC::ConstructAbility s_${name}ConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_${name}ConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_${name}ImplementationVisibility = JSC::ImplementationVisibility::${fn.visibility}; +const int s_${name}Length = ${fn.source.length}; +static const JSC::Intrinsic s_${name}Intrinsic = JSC::NoIntrinsic; +const char* const s_${name} = ${fmtCPPString(fn.source)}; + +`; + } + bundledCPP += `#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().${lowerBasename}Builtins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().${lowerBasename}Builtins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \\ +} +WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) +#undef DEFINE_BUILTIN_GENERATOR + +`; +} + +bundledCPP += ` + +JSBuiltinInternalFunctions::JSBuiltinInternalFunctions(JSC::VM& vm) + : m_vm(vm) +`; + +for (const { basename, internal } of files) { + if (internal) { + bundledCPP += ` , m_${low(basename)}(vm)\n`; + } +} + +bundledCPP += ` +{ + UNUSED_PARAM(vm); +} + +template<typename Visitor> +void JSBuiltinInternalFunctions::visit(Visitor& visitor) +{ +`; +for (const { basename, internal } of files) { + if (internal) bundledCPP += ` m_${low(basename)}.visit(visitor);\n`; +} + +bundledCPP += ` + UNUSED_PARAM(visitor); +} + +template void JSBuiltinInternalFunctions::visit(AbstractSlotVisitor&); +template void JSBuiltinInternalFunctions::visit(SlotVisitor&); + +SUPPRESS_ASAN void JSBuiltinInternalFunctions::initialize(Zig::GlobalObject& globalObject) +{ + UNUSED_PARAM(globalObject); +`; + +for (const { basename, internal } of files) { + if (internal) { + bundledCPP += ` m_${low(basename)}.init(globalObject);\n`; + } +} + +bundledCPP += ` + JSVMClientData& clientData = *static_cast<JSVMClientData*>(m_vm.clientData); + Zig::GlobalObject::GlobalPropertyInfo staticGlobals[] = { +`; + +for (const { basename, internal } of files) { + if (internal) { + bundledCPP += `#define DECLARE_GLOBAL_STATIC(name) \\ + Zig::GlobalObject::GlobalPropertyInfo( \\ + clientData.builtinFunctions().${low(basename)}Builtins().name##PrivateName(), ${low( + basename, + )}().m_##name##Function.get() , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly), + WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_FUNCTION_NAME(DECLARE_GLOBAL_STATIC) + #undef DECLARE_GLOBAL_STATIC + `; + } +} + +bundledCPP += ` + }; + globalObject.addStaticGlobals(staticGlobals, std::size(staticGlobals)); + UNUSED_PARAM(clientData); +} + +} // namespace WebCore +`; + +// C++ Header codegen +let bundledHeader = `// Generated by \`bun src/bun.js/builtins/codegen/index.js\` +// Do not edit by hand. +#pragma once +namespace Zig { class GlobalObject; } +#include "root.h" +#include <JavaScriptCore/BuiltinUtils.h> +#include <JavaScriptCore/Identifier.h> +#include <JavaScriptCore/JSFunction.h> +#include <JavaScriptCore/UnlinkedFunctionExecutable.h> +#include <JavaScriptCore/VM.h> +#include <JavaScriptCore/WeakInlines.h> + +namespace JSC { +class FunctionExecutable; +} + +namespace WebCore { +`; +for (const { basename, functions, internal } of files) { + bundledHeader += `/* ${basename}.ts */ +`; + const lowerBasename = low(basename); + + for (const fn of functions) { + const name = `${lowerBasename}${cap(fn.name)}Code`; + bundledHeader += `// ${fn.name} +#define WEBCORE_BUILTIN_${basename.toUpperCase()}_${fn.name.toUpperCase()} 1 +extern const char* const s_${name}; +extern const int s_${name}Length; +extern const JSC::ConstructAbility s_${name}ConstructAbility; +extern const JSC::ConstructorKind s_${name}ConstructorKind; +extern const JSC::ImplementationVisibility s_${name}ImplementationVisibility; + +`; + } + bundledHeader += `#define WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_DATA(macro) \\\n`; + for (const fn of functions) { + bundledHeader += ` macro(${fn.name}, ${lowerBasename}${cap(fn.name)}, ${fn.params.length}) \\\n`; + } + bundledHeader += "\n"; + bundledHeader += `#define WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_CODE(macro) \\\n`; + for (const fn of functions) { + const name = `${lowerBasename}${cap(fn.name)}Code`; + bundledHeader += ` macro(${name}, ${fn.name}, ${fn.overriddenName}, s_${name}Length) \\\n`; + } + bundledHeader += "\n"; + bundledHeader += `#define WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_FUNCTION_NAME(macro) \\\n`; + for (const fn of functions) { + bundledHeader += ` macro(${fn.name}) \\\n`; + } + bundledHeader += ` +#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\ + JSC::FunctionExecutable* codeName##Generator(JSC::VM&); + +WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) +#undef DECLARE_BUILTIN_GENERATOR + +class ${basename}BuiltinsWrapper : private JSC::WeakHandleOwner { +public: + explicit ${basename}BuiltinsWrapper(JSC::VM& vm) + : m_vm(vm) + WEBCORE_FOREACH_${basename.toUpperCase()}_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_${basename.toUpperCase()}_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_${basename.toUpperCase()}_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) +#undef EXPOSE_BUILTIN_EXECUTABLES + + WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) + + void exportNames(); + +private: + JSC::VM& m_vm; + + WEBCORE_FOREACH_${basename.toUpperCase()}_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_${basename.toUpperCase()}_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) +#undef DECLARE_BUILTIN_SOURCE_MEMBERS + +}; + +#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \\ +inline JSC::UnlinkedFunctionExecutable* ${basename}BuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\\ + }\\ + return m_##name##Executable.get();\\ +} +WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) +#undef DEFINE_BUILTIN_EXECUTABLES + +inline void ${basename}BuiltinsWrapper::exportNames() +{ +#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); + WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) +#undef EXPORT_FUNCTION_NAME +} +`; + + if (internal) { + bundledHeader += `class ${basename}BuiltinFunctions { +public: + explicit ${basename}BuiltinFunctions(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_${basename.toUpperCase()}_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_SOURCE_MEMBERS) +#undef DECLARE_BUILTIN_SOURCE_MEMBERS +}; + +inline void ${basename}BuiltinFunctions::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_${basename.toUpperCase()}_BUILTIN_CODE(EXPORT_FUNCTION) +#undef EXPORT_FUNCTION +} + +template<typename Visitor> +inline void ${basename}BuiltinFunctions::visit(Visitor& visitor) +{ +#define VISIT_FUNCTION(name) visitor.append(m_##name##Function); + WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_FUNCTION_NAME(VISIT_FUNCTION) +#undef VISIT_FUNCTION +} + +template void ${basename}BuiltinFunctions::visit(JSC::AbstractSlotVisitor&); +template void ${basename}BuiltinFunctions::visit(JSC::SlotVisitor&); + `; + } +} +bundledHeader += `class JSBuiltinFunctions { +public: + explicit JSBuiltinFunctions(JSC::VM& vm) + : m_vm(vm) +`; + +for (const { basename } of files) { + bundledHeader += ` , m_${low(basename)}Builtins(m_vm)\n`; +} + +bundledHeader += ` + { +`; + +for (const { basename, internal } of files) { + if (internal) { + bundledHeader += ` m_${low(basename)}Builtins.exportNames();\n`; + } +} + +bundledHeader += ` } +`; + +for (const { basename } of files) { + bundledHeader += ` ${basename}BuiltinsWrapper& ${low(basename)}Builtins() { return m_${low( + basename, + )}Builtins; }\n`; +} + +bundledHeader += ` +private: + JSC::VM& m_vm; +`; + +for (const { basename } of files) { + bundledHeader += ` ${basename}BuiltinsWrapper m_${low(basename)}Builtins;\n`; +} + +bundledHeader += `; +}; + +class JSBuiltinInternalFunctions { +public: + explicit JSBuiltinInternalFunctions(JSC::VM&); + + template<typename Visitor> void visit(Visitor&); + void initialize(Zig::GlobalObject&); +`; + +for (const { basename, internal } of files) { + if (internal) { + bundledHeader += ` ${basename}BuiltinFunctions& ${low(basename)}() { return m_${low(basename)}; }\n`; + } +} + +bundledHeader += ` +private: + JSC::VM& m_vm; +`; + +for (const { basename, internal } of files) { + if (internal) { + bundledHeader += ` ${basename}BuiltinFunctions m_${low(basename)};\n`; + } +} + +bundledHeader += ` +}; + +} // namespace WebCore +`; + +await Bun.write(path.join(OUT_DIR, "WebCoreJSBuiltins.h"), bundledHeader); +await Bun.write(path.join(OUT_DIR, "WebCoreJSBuiltins.cpp"), bundledCPP); + +// Generate TS types +let dts = `// Generated by \`bun src/bun.js/builtins/codegen/index.js\` +// Do not edit by hand. +type RemoveThis<F> = F extends (this: infer T, ...args: infer A) => infer R ? (...args: A) => R : F; +`; + +for (const { basename, functions, internal } of files) { + if (internal) { + dts += `\n// ${basename}.ts\n`; + for (const fn of functions) { + dts += `declare const \$${fn.name}: RemoveThis<typeof import("./ts/${basename}")[${JSON.stringify(fn.name)}]>;\n`; + } + } +} + +await Bun.write(path.join(OUT_DIR, "WebCoreJSBuiltins.d.ts"), dts); + +const totalJSSize = files.reduce( + (acc, { functions }) => acc + functions.reduce((acc, fn) => acc + fn.source.length, 0), + 0, +); + +if (!KEEP_TMP) { + await rmSync(TMP_DIR, { recursive: true }); +} + +console.log( + `Embedded JS size: %s bytes (across %s functions, %s files)`, + totalJSSize, + files.reduce((acc, { functions }) => acc + functions.length, 0), + files.length, +); +console.log(`[${performance.now().toFixed(1)}ms]`); diff --git a/src/bun.js/builtins/codegen/replacements.ts b/src/bun.js/builtins/codegen/replacements.ts new file mode 100644 index 000000000..05c81b901 --- /dev/null +++ b/src/bun.js/builtins/codegen/replacements.ts @@ -0,0 +1,100 @@ +import { LoaderKeys } from "../../../api/schema"; + +// This is a list of extra syntax replacements to do. Kind of like macros +// These are only run on code itself, not string contents or comments. +export const replacements: ReplacementRule[] = [ + { from: /\bthrow new TypeError\b/g, to: "$throwTypeError" }, + { from: /\bthrow new RangeError\b/g, to: "$throwRangeError" }, + { from: /\bthrow new OutOfMemoryError\b/g, to: "$throwOutOfMemoryError" }, + { from: /\bnew TypeError\b/g, to: "$makeTypeError" }, +]; + +// These rules are run on the entire file, including within strings. +export const globalReplacements: ReplacementRule[] = [ + { + from: /\bnotImplementedIssue\(\s*([0-9]+)\s*,\s*((?:"[^"]*"|'[^']+'))\s*\)/g, + to: "new TypeError(`${$2} is not implemented yet. See https://github.com/oven-sh/bun/issues/$1`)", + }, + { + from: /\bnotImplementedIssueFn\(\s*([0-9]+)\s*,\s*((?:"[^"]*"|'[^']+'))\s*\)/g, + to: "() => $throwTypeError(`${$2} is not implemented yet. See https://github.com/oven-sh/bun/issues/$1`)", + }, +]; + +// This is a list of globals we should access using @ notation +// undefined -> __intrinsic__undefined -> @undefined +export const globalsToPrefix = [ + "AbortSignal", + "Array", + "ArrayBuffer", + "Buffer", + "Bun", + "Infinity", + "Loader", + "Promise", + "ReadableByteStreamController", + "ReadableStream", + "ReadableStreamBYOBReader", + "ReadableStreamBYOBRequest", + "ReadableStreamDefaultController", + "ReadableStreamDefaultReader", + "TransformStream", + "TransformStreamDefaultController", + "Uint8Array", + "WritableStream", + "WritableStreamDefaultController", + "WritableStreamDefaultWriter", + "isFinite", + "isNaN", + "undefined", +]; + +// These enums map to $<enum>IdToLabel and $<enum>LabelToId +// Make sure to define in ./builtins.d.ts +export const enums = { + Loader: LoaderKeys, + ImportKind: [ + "entry-point", + "import-statement", + "require-call", + "dynamic-import", + "require-resolve", + "import-rule", + "url-token", + "internal", + ], +}; + +// These identifiers have typedef but not present at runtime (converted with replacements) +// If they are present in the bundle after runtime, we warn at the user. +// TODO: implement this check. +export const warnOnIdentifiersNotPresentAtRuntime = [ + // + "OutOfMemoryError", + "notImplementedIssue", + "notImplementedIssueFn", +]; + +export interface ReplacementRule { + from: RegExp; + to: string; + global?: boolean; +} + +/** Applies source code replacements as defined in `replacements` */ +export function applyReplacements(src: string) { + let result = src.replace(/\$([a-zA-Z0-9_]+)\b/gm, `__intrinsic__$1`); + for (const replacement of replacements) { + result = result.replace(replacement.from, replacement.to.replaceAll("$", "__intrinsic__")); + } + return result; +} + +/** Applies source code replacements as defined in `globalReplacements` */ +export function applyGlobalReplacements(src: string) { + let result = src; + for (const replacement of globalReplacements) { + result = result.replace(replacement.from, replacement.to.replaceAll("$", "__intrinsic__")); + } + return result; +} diff --git a/src/bun.js/builtins/cpp/BundlerPluginBuiltins.cpp b/src/bun.js/builtins/cpp/BundlerPluginBuiltins.cpp deleted file mode 100644 index ec6ce4070..000000000 --- a/src/bun.js/builtins/cpp/BundlerPluginBuiltins.cpp +++ /dev/null @@ -1,515 +0,0 @@ -/* - * 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) 2023 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 "BundlerPluginBuiltins.h" - -#include "WebCoreJSClientData.h" -#include <JavaScriptCore/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_bundlerPluginRunOnResolvePluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_bundlerPluginRunOnResolvePluginsCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_bundlerPluginRunOnResolvePluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_bundlerPluginRunOnResolvePluginsCodeLength = 3619; -static const JSC::Intrinsic s_bundlerPluginRunOnResolvePluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnResolvePluginsCode = - "(function (\n" \ - " specifier,\n" \ - " inputNamespace,\n" \ - " importer,\n" \ - " internalID,\n" \ - " kindId\n" \ - ") {\n" \ - " \"use strict\";\n" \ - "\n" \ - " //\n" \ - " const kind = [\n" \ - " \"entry-point\",\n" \ - " \"import-statement\",\n" \ - " \"require-call\",\n" \ - " \"dynamic-import\",\n" \ - " \"require-resolve\",\n" \ - " \"import-rule\",\n" \ - " \"url-token\",\n" \ - " \"internal\",\n" \ - " ][kindId];\n" \ - "\n" \ - " var promiseResult = (async (inputPath, inputNamespace, importer, kind) => {\n" \ - " var {onResolve, onLoad} = this;\n" \ - " var results = onResolve.@get(inputNamespace);\n" \ - " if (!results) {\n" \ - " this.onResolveAsync(internalID, null, null, null);\n" \ - " return null;\n" \ - " }\n" \ - "\n" \ - " for (let [filter, callback] of results) {\n" \ - " if (filter.test(inputPath)) {\n" \ - " var result = callback({\n" \ - " path: inputPath,\n" \ - " importer,\n" \ - " namespace: inputNamespace,\n" \ - " //\n" \ - " kind,\n" \ - " //\n" \ - " });\n" \ - "\n" \ - " while (\n" \ - " result &&\n" \ - " @isPromise(result) &&\n" \ - " (@getPromiseInternalField(result, @promiseFieldFlags) &\n" \ - " @promiseStateMask) ===\n" \ - " @promiseStateFulfilled\n" \ - " ) {\n" \ - " result = @getPromiseInternalField(\n" \ - " result,\n" \ - " @promiseFieldReactionsOrResult\n" \ - " );\n" \ - " }\n" \ - "\n" \ - " if (result && @isPromise(result)) {\n" \ - " result = await result;\n" \ - " }\n" \ - "\n" \ - " if (!result || !@isObject(result)) {\n" \ - " continue;\n" \ - " }\n" \ - "\n" \ - "\n" \ - " var {\n" \ - " path,\n" \ - " namespace: userNamespace = inputNamespace,\n" \ - " external,\n" \ - " } = result;\n" \ - " if (\n" \ - " !(typeof path === \"string\") ||\n" \ - " !(typeof userNamespace === \"string\")\n" \ - " ) {\n" \ - " @throwTypeError(\n" \ - " \"onResolve plugins must return an object with a string 'path' and string 'loader' field\"\n" \ - " );\n" \ - " }\n" \ - "\n" \ - " if (!path) {\n" \ - " continue;\n" \ - " }\n" \ - "\n" \ - " if (!userNamespace) {\n" \ - " userNamespace = inputNamespace;\n" \ - " }\n" \ - " if (typeof external !== \"boolean\" && !@isUndefinedOrNull(external)) {\n" \ - " @throwTypeError(\n" \ - " 'onResolve plugins \"external\" field must be boolean or unspecified'\n" \ - " );\n" \ - " }\n" \ - "\n" \ - "\n" \ - " if (!external) {\n" \ - " if (userNamespace === \"file\") {\n" \ - " //\n" \ - " \n" \ - " if (path[0] !== \"/\" || path.includes(\"..\")) {\n" \ - " @throwTypeError(\n" \ - " 'onResolve plugin \"path\" must be absolute when the namespace is \"file\"'\n" \ - " );\n" \ - " }\n" \ - " }\n" \ - " if (userNamespace === \"dataurl\") {\n" \ - " if (!path.startsWith(\"data:\")) {\n" \ - " @throwTypeError(\n" \ - " 'onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"'\n" \ - " );\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " if (userNamespace && userNamespace !== \"file\" && (!onLoad || !onLoad.@has(userNamespace))) {\n" \ - " @throwTypeError(\n" \ - " `Expected onLoad plugin for namespace ${@jsonStringify(userNamespace, \" \")} to exist`\n" \ - " );\n" \ - " }\n" \ - "\n" \ - " }\n" \ - " this.onResolveAsync(internalID, path, userNamespace, external);\n" \ - " return null;\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " this.onResolveAsync(internalID, null, null, null);\n" \ - " return null;\n" \ - " })(specifier, inputNamespace, importer, kind);\n" \ - "\n" \ - " while (\n" \ - " promiseResult &&\n" \ - " @isPromise(promiseResult) &&\n" \ - " (@getPromiseInternalField(promiseResult, @promiseFieldFlags) &\n" \ - " @promiseStateMask) ===\n" \ - " @promiseStateFulfilled\n" \ - " ) {\n" \ - " promiseResult = @getPromiseInternalField(\n" \ - " promiseResult,\n" \ - " @promiseFieldReactionsOrResult\n" \ - " );\n" \ - " }\n" \ - "\n" \ - " if (promiseResult && @isPromise(promiseResult)) {\n" \ - " promiseResult.then(\n" \ - " () => {},\n" \ - " (e) => {\n" \ - " this.addError(internalID, e, 0);\n" \ - " }\n" \ - " );\n" \ - " }\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_bundlerPluginRunSetupFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_bundlerPluginRunSetupFunctionCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_bundlerPluginRunSetupFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_bundlerPluginRunSetupFunctionCodeLength = 4549; -static const JSC::Intrinsic s_bundlerPluginRunSetupFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunSetupFunctionCode = - "(function (setup, config) {\n" \ - " \"use strict\";\n" \ - " var onLoadPlugins = new Map(),\n" \ - " onResolvePlugins = new Map();\n" \ - "\n" \ - " function validate(filterObject, callback, map) {\n" \ - " if (!filterObject || !@isObject(filterObject)) {\n" \ - " @throwTypeError('Expected an object with \"filter\" RegExp');\n" \ - " }\n" \ - "\n" \ - " if (!callback || !@isCallable(callback)) {\n" \ - " @throwTypeError(\"callback must be a function\");\n" \ - " }\n" \ - "\n" \ - " var { filter, namespace = \"file\" } = filterObject;\n" \ - "\n" \ - " if (!filter) {\n" \ - " @throwTypeError('Expected an object with \"filter\" RegExp');\n" \ - " }\n" \ - "\n" \ - " if (!@isRegExpObject(filter)) {\n" \ - " @throwTypeError(\"filter must be a RegExp\");\n" \ - " }\n" \ - "\n" \ - " if (namespace && !(typeof namespace === \"string\")) {\n" \ - " @throwTypeError(\"namespace must be a string\");\n" \ - " }\n" \ - "\n" \ - " if ((namespace?.length ?? 0) === 0) {\n" \ - " namespace = \"file\";\n" \ - " }\n" \ - "\n" \ - " if (!/^([/@a-zA-Z0-9_\\\\-]+)$/.test(namespace)) {\n" \ - " @throwTypeError(\"namespace can only contain @a-zA-Z0-9_\\\\-\");\n" \ - " }\n" \ - "\n" \ - " var callbacks = map.@get(namespace);\n" \ - "\n" \ - " if (!callbacks) {\n" \ - " map.@set(namespace, [[filter, callback]]);\n" \ - " } else {\n" \ - " @arrayPush(callbacks, [filter, callback]);\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " function onLoad(filterObject, callback) {\n" \ - " validate(filterObject, callback, onLoadPlugins);\n" \ - " }\n" \ - "\n" \ - " function onResolve(filterObject, callback) {\n" \ - " validate(filterObject, callback, onResolvePlugins);\n" \ - " }\n" \ - "\n" \ - " function onStart(callback) {\n" \ - " //\n" \ - " @throwTypeError(\"On-start callbacks are not implemented yet. See https:/\\/github.com/oven-sh/bun/issues/2771\");\n" \ - " }\n" \ - "\n" \ - " function onEnd(callback) {\n" \ - " @throwTypeError(\"On-end callbacks are not implemented yet. See https:/\\/github.com/oven-sh/bun/issues/2771\");\n" \ - " }\n" \ - "\n" \ - " function onDispose(callback) {\n" \ - " @throwTypeError(\"On-dispose callbacks are not implemented yet. See https:/\\/github.com/oven-sh/bun/issues/2771\");\n" \ - " }\n" \ - "\n" \ - " function resolve(callback) {\n" \ - " @throwTypeError(\"build.resolve() is not implemented yet. See https:/\\/github.com/oven-sh/bun/issues/2771\");\n" \ - " }\n" \ - "\n" \ - " const processSetupResult = () => {\n" \ - " var anyOnLoad = false,\n" \ - " anyOnResolve = false;\n" \ - "\n" \ - " for (var [namespace, callbacks] of onLoadPlugins.entries()) {\n" \ - " for (var [filter] of callbacks) {\n" \ - " this.addFilter(filter, namespace, 1);\n" \ - " anyOnLoad = true;\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " for (var [namespace, callbacks] of onResolvePlugins.entries()) {\n" \ - " for (var [filter] of callbacks) {\n" \ - " this.addFilter(filter, namespace, 0);\n" \ - " anyOnResolve = true;\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " if (anyOnResolve) {\n" \ - " var onResolveObject = this.onResolve;\n" \ - " if (!onResolveObject) {\n" \ - " this.onResolve = onResolvePlugins;\n" \ - " } else {\n" \ - " for (var [namespace, callbacks] of onResolvePlugins.entries()) {\n" \ - " var existing = onResolveObject.@get(namespace);\n" \ - "\n" \ - " if (!existing) {\n" \ - " onResolveObject.@set(namespace, callbacks);\n" \ - " } else {\n" \ - " onResolveObject.@set(namespace, existing.concat(callbacks));\n" \ - " }\n" \ - " }\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " if (anyOnLoad) {\n" \ - " var onLoadObject = this.onLoad;\n" \ - " if (!onLoadObject) {\n" \ - " this.onLoad = onLoadPlugins;\n" \ - " } else {\n" \ - " for (var [namespace, callbacks] of onLoadPlugins.entries()) {\n" \ - " var existing = onLoadObject.@get(namespace);\n" \ - "\n" \ - " if (!existing) {\n" \ - " onLoadObject.@set(namespace, callbacks);\n" \ - " } else {\n" \ - " onLoadObject.@set(namespace, existing.concat(callbacks));\n" \ - " }\n" \ - " }\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " return anyOnLoad || anyOnResolve;\n" \ - " };\n" \ - "\n" \ - " var setupResult = setup({\n" \ - " config,\n" \ - " onDispose,\n" \ - " onEnd,\n" \ - " onLoad,\n" \ - " onResolve,\n" \ - " onStart,\n" \ - " resolve,\n" \ - " //\n" \ - " initialOptions: {\n" \ - " ...config,\n" \ - " bundle: true,\n" \ - " entryPoints: config.entrypoints ?? config.entryPoints ?? [],\n" \ - " minify: typeof config.minify === 'boolean' ? config.minify : false,\n" \ - " minifyIdentifiers: config.minify === true || config.minify?.identifiers,\n" \ - " minifyWhitespace: config.minify === true || config.minify?.whitespace,\n" \ - " minifySyntax: config.minify === true || config.minify?.syntax,\n" \ - " outbase: config.root,\n" \ - " platform: config.target === 'bun' ? 'node' : config.target,\n" \ - " root: undefined,\n" \ - " },\n" \ - " esbuild: {},\n" \ - " });\n" \ - "\n" \ - " if (setupResult && @isPromise(setupResult)) {\n" \ - " if (\n" \ - " @getPromiseInternalField(setupResult, @promiseFieldFlags) &\n" \ - " @promiseStateFulfilled\n" \ - " ) {\n" \ - " setupResult = @getPromiseInternalField(\n" \ - " setupResult,\n" \ - " @promiseFieldReactionsOrResult\n" \ - " );\n" \ - " } else {\n" \ - " return setupResult.@then(processSetupResult);\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " return processSetupResult();\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_bundlerPluginRunOnLoadPluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_bundlerPluginRunOnLoadPluginsCodeLength = 2766; -static const JSC::Intrinsic s_bundlerPluginRunOnLoadPluginsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_bundlerPluginRunOnLoadPluginsCode = - "(function (internalID, path, namespace, defaultLoaderId) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " const LOADERS_MAP = {\n" \ - " jsx: 0,\n" \ - " js: 1,\n" \ - " ts: 2,\n" \ - " tsx: 3,\n" \ - " css: 4,\n" \ - " file: 5,\n" \ - " json: 6,\n" \ - " toml: 7,\n" \ - " wasm: 8,\n" \ - " napi: 9,\n" \ - " base64: 10,\n" \ - " dataurl: 11,\n" \ - " text: 12,\n" \ - " };\n" \ - " const loaderName = [\n" \ - " \"jsx\",\n" \ - " \"js\",\n" \ - " \"ts\",\n" \ - " \"tsx\",\n" \ - " \"css\",\n" \ - " \"file\",\n" \ - " \"json\",\n" \ - " \"toml\",\n" \ - " \"wasm\",\n" \ - " \"napi\",\n" \ - " \"base64\",\n" \ - " \"dataurl\",\n" \ - " \"text\",\n" \ - " ][defaultLoaderId];\n" \ - "\n" \ - " var promiseResult = (async (internalID, path, namespace, defaultLoader) => {\n" \ - " var results = this.onLoad.@get(namespace);\n" \ - " if (!results) {\n" \ - " this.onLoadAsync(internalID, null, null, null);\n" \ - " return null;\n" \ - " }\n" \ - "\n" \ - " for (let [filter, callback] of results) {\n" \ - " if (filter.test(path)) {\n" \ - " var result = callback({\n" \ - " path,\n" \ - " namespace,\n" \ - " //\n" \ - " //\n" \ - " loader: defaultLoader,\n" \ - " });\n" \ - "\n" \ - " while (\n" \ - " result &&\n" \ - " @isPromise(result) &&\n" \ - " (@getPromiseInternalField(result, @promiseFieldFlags) &\n" \ - " @promiseStateMask) ===\n" \ - " @promiseStateFulfilled\n" \ - " ) {\n" \ - " result = @getPromiseInternalField(\n" \ - " result,\n" \ - " @promiseFieldReactionsOrResult\n" \ - " );\n" \ - " }\n" \ - "\n" \ - " if (result && @isPromise(result)) {\n" \ - " result = await result;\n" \ - " }\n" \ - "\n" \ - " if (!result || !@isObject(result)) {\n" \ - " continue;\n" \ - " }\n" \ - "\n" \ - " var { contents, loader = defaultLoader } = result;\n" \ - " if (!(typeof contents === \"string\") && !@isTypedArrayView(contents)) {\n" \ - " @throwTypeError(\n" \ - " 'onLoad plugins must return an object with \"contents\" as a string or Uint8Array'\n" \ - " );\n" \ - " }\n" \ - "\n" \ - " if (!(typeof loader === \"string\")) {\n" \ - " @throwTypeError(\n" \ - " 'onLoad plugins must return an object with \"loader\" as a string'\n" \ - " );\n" \ - " }\n" \ - "\n" \ - " const chosenLoader = LOADERS_MAP[loader];\n" \ - " if (chosenLoader === @undefined) {\n" \ - " @throwTypeError(`Loader ${@jsonStringify(loader, \" \")} is not supported.`);\n" \ - " }\n" \ - "\n" \ - " this.onLoadAsync(internalID, contents, chosenLoader);\n" \ - " return null;\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " this.onLoadAsync(internalID, null, null);\n" \ - " return null;\n" \ - " })(internalID, path, namespace, loaderName);\n" \ - "\n" \ - " while (\n" \ - " promiseResult &&\n" \ - " @isPromise(promiseResult) &&\n" \ - " (@getPromiseInternalField(promiseResult, @promiseFieldFlags) &\n" \ - " @promiseStateMask) ===\n" \ - " @promiseStateFulfilled\n" \ - " ) {\n" \ - " promiseResult = @getPromiseInternalField(\n" \ - " promiseResult,\n" \ - " @promiseFieldReactionsOrResult\n" \ - " );\n" \ - " }\n" \ - "\n" \ - " if (promiseResult && @isPromise(promiseResult)) {\n" \ - " promiseResult.then(\n" \ - " () => {},\n" \ - " (e) => {\n" \ - " this.addError(internalID, e, 1);\n" \ - " }\n" \ - " );\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().bundlerPluginBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().bundlerPluginBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ -} -WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) -#undef DEFINE_BUILTIN_GENERATOR - - -} // namespace WebCore diff --git a/src/bun.js/builtins/cpp/BundlerPluginBuiltins.h b/src/bun.js/builtins/cpp/BundlerPluginBuiltins.h deleted file mode 100644 index d1fdaf4ec..000000000 --- a/src/bun.js/builtins/cpp/BundlerPluginBuiltins.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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) 2023 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 { - -/* BundlerPlugin */ -extern const char* const s_bundlerPluginRunOnResolvePluginsCode; -extern const int s_bundlerPluginRunOnResolvePluginsCodeLength; -extern const JSC::ConstructAbility s_bundlerPluginRunOnResolvePluginsCodeConstructAbility; -extern const JSC::ConstructorKind s_bundlerPluginRunOnResolvePluginsCodeConstructorKind; -extern const JSC::ImplementationVisibility s_bundlerPluginRunOnResolvePluginsCodeImplementationVisibility; -extern const char* const s_bundlerPluginRunSetupFunctionCode; -extern const int s_bundlerPluginRunSetupFunctionCodeLength; -extern const JSC::ConstructAbility s_bundlerPluginRunSetupFunctionCodeConstructAbility; -extern const JSC::ConstructorKind s_bundlerPluginRunSetupFunctionCodeConstructorKind; -extern const JSC::ImplementationVisibility s_bundlerPluginRunSetupFunctionCodeImplementationVisibility; -extern const char* const s_bundlerPluginRunOnLoadPluginsCode; -extern const int s_bundlerPluginRunOnLoadPluginsCodeLength; -extern const JSC::ConstructAbility s_bundlerPluginRunOnLoadPluginsCodeConstructAbility; -extern const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind; -extern const JSC::ImplementationVisibility s_bundlerPluginRunOnLoadPluginsCodeImplementationVisibility; - -#define WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_DATA(macro) \ - macro(runOnResolvePlugins, bundlerPluginRunOnResolvePlugins, 5) \ - macro(runSetupFunction, bundlerPluginRunSetupFunction, 2) \ - macro(runOnLoadPlugins, bundlerPluginRunOnLoadPlugins, 4) \ - -#define WEBCORE_BUILTIN_BUNDLERPLUGIN_RUNONRESOLVEPLUGINS 1 -#define WEBCORE_BUILTIN_BUNDLERPLUGIN_RUNSETUPFUNCTION 1 -#define WEBCORE_BUILTIN_BUNDLERPLUGIN_RUNONLOADPLUGINS 1 - -#define WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_CODE(macro) \ - macro(bundlerPluginRunOnResolvePluginsCode, runOnResolvePlugins, ASCIILiteral(), s_bundlerPluginRunOnResolvePluginsCodeLength) \ - macro(bundlerPluginRunSetupFunctionCode, runSetupFunction, ASCIILiteral(), s_bundlerPluginRunSetupFunctionCodeLength) \ - macro(bundlerPluginRunOnLoadPluginsCode, runOnLoadPlugins, ASCIILiteral(), s_bundlerPluginRunOnLoadPluginsCodeLength) \ - -#define WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_FUNCTION_NAME(macro) \ - macro(runOnLoadPlugins) \ - macro(runOnResolvePlugins) \ - macro(runSetupFunction) \ - -#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ - JSC::FunctionExecutable* codeName##Generator(JSC::VM&); - -WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) -#undef DECLARE_BUILTIN_GENERATOR - -class BundlerPluginBuiltinsWrapper : private JSC::WeakHandleOwner { -public: - explicit BundlerPluginBuiltinsWrapper(JSC::VM& vm) - : m_vm(vm) - WEBCORE_FOREACH_BUNDLERPLUGIN_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_BUNDLERPLUGIN_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_BUNDLERPLUGIN_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) -#undef EXPOSE_BUILTIN_EXECUTABLES - - WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) - - void exportNames(); - -private: - JSC::VM& m_vm; - - WEBCORE_FOREACH_BUNDLERPLUGIN_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_BUNDLERPLUGIN_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) -#undef DECLARE_BUILTIN_SOURCE_MEMBERS - -}; - -#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ -inline JSC::UnlinkedFunctionExecutable* BundlerPluginBuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ - }\ - return m_##name##Executable.get();\ -} -WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) -#undef DEFINE_BUILTIN_EXECUTABLES - -inline void BundlerPluginBuiltinsWrapper::exportNames() -{ -#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); - WEBCORE_FOREACH_BUNDLERPLUGIN_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) -#undef EXPORT_FUNCTION_NAME -} - -} // namespace WebCore diff --git a/src/bun.js/builtins/cpp/ByteLengthQueuingStrategyBuiltins.cpp b/src/bun.js/builtins/cpp/ByteLengthQueuingStrategyBuiltins.cpp deleted file mode 100644 index 3f5c2e8d7..000000000 --- a/src/bun.js/builtins/cpp/ByteLengthQueuingStrategyBuiltins.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_byteLengthQueuingStrategyHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_byteLengthQueuingStrategyHighWaterMarkCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_byteLengthQueuingStrategyHighWaterMarkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_byteLengthQueuingStrategySizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/ByteLengthQueuingStrategyBuiltins.h b/src/bun.js/builtins/cpp/ByteLengthQueuingStrategyBuiltins.h deleted file mode 100644 index 29c6f2830..000000000 --- a/src/bun.js/builtins/cpp/ByteLengthQueuingStrategyBuiltins.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_byteLengthQueuingStrategyHighWaterMarkCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_byteLengthQueuingStrategySizeCodeImplementationVisibility; -extern const char* const s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCode; -extern const int s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeLength; -extern const JSC::ConstructAbility s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructAbility; -extern const JSC::ConstructorKind s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeConstructorKind; -extern const JSC::ImplementationVisibility s_byteLengthQueuingStrategyInitializeByteLengthQueuingStrategyCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/ConsoleObjectBuiltins.cpp b/src/bun.js/builtins/cpp/ConsoleObjectBuiltins.cpp deleted file mode 100644 index 438c84b67..000000000 --- a/src/bun.js/builtins/cpp/ConsoleObjectBuiltins.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * 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) 2023 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 "ConsoleObjectBuiltins.h" - -#include "WebCoreJSClientData.h" -#include <JavaScriptCore/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_consoleObjectAsyncIteratorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_consoleObjectAsyncIteratorCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_consoleObjectAsyncIteratorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_consoleObjectAsyncIteratorCodeLength = 2004; -static const JSC::Intrinsic s_consoleObjectAsyncIteratorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectAsyncIteratorCode = - "(function () {\n" \ - " \"use strict\";\n" \ - "\n" \ - " const Iterator = async function* ConsoleAsyncIterator() {\n" \ - " \"use strict\";\n" \ - "\n" \ - " const stream = @Bun.stdin.stream();\n" \ - " var reader = stream.getReader();\n" \ - "\n" \ - " //\n" \ - " var decoder = new globalThis.TextDecoder(\"utf-8\", { fatal: false });\n" \ - " var deferredError;\n" \ - " var indexOf = @Bun.indexOfLine;\n" \ - "\n" \ - " try {\n" \ - " while (true) {\n" \ - " var done, value;\n" \ - " var pendingChunk;\n" \ - " const firstResult = reader.readMany();\n" \ - " if (@isPromise(firstResult)) {\n" \ - " ({done, value} = await firstResult);\n" \ - " } else {\n" \ - " ({done, value} = firstResult);\n" \ - " }\n" \ - "\n" \ - " if (done) {\n" \ - " if (pendingChunk) {\n" \ - " yield decoder.decode(pendingChunk);\n" \ - " }\n" \ - " return;\n" \ - " }\n" \ - " \n" \ - " var actualChunk;\n" \ - " //\n" \ - " for (const chunk of value) {\n" \ - " actualChunk = chunk;\n" \ - " if (pendingChunk) {\n" \ - " actualChunk = Buffer.concat([pendingChunk, chunk]);\n" \ - " pendingChunk = null;\n" \ - " }\n" \ - "\n" \ - " var last = 0;\n" \ - " //\n" \ - " var i = indexOf(actualChunk, last);\n" \ - " while (i !== -1) {\n" \ - " yield decoder.decode(actualChunk.subarray(last, i));\n" \ - " last = i + 1;\n" \ - " i = indexOf(actualChunk, last);\n" \ - " }\n" \ - "\n" \ - " pendingChunk = actualChunk.subarray(last);\n" \ - " }\n" \ - " }\n" \ - " } catch(e) {\n" \ - " deferredError = e;\n" \ - " } finally {\n" \ - " reader.releaseLock();\n" \ - "\n" \ - " if (deferredError) {\n" \ - " throw deferredError;\n" \ - " }\n" \ - " }\n" \ - " };\n" \ - "\n" \ - " const symbol = globalThis.Symbol.asyncIterator;\n" \ - " this[symbol] = Iterator;\n" \ - " return Iterator();\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_consoleObjectWriteCodeLength = 524; -static const JSC::Intrinsic s_consoleObjectWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_consoleObjectWriteCode = - "(function (input) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var writer = @getByIdDirectPrivate(this, \"writer\");\n" \ - " if (!writer) {\n" \ - " var length = @toLength(input?.length ?? 0);\n" \ - " writer = @Bun.stdout.writer({highWaterMark: length > 65536 ? length : 65536});\n" \ - " @putByIdDirectPrivate(this, \"writer\", writer);\n" \ - " }\n" \ - "\n" \ - " var wrote = writer.write(input);\n" \ - "\n" \ - " const count = @argumentCount();\n" \ - " for (var i = 1; i < count; i++) {\n" \ - " wrote += writer.write(@argument(i));\n" \ - " }\n" \ - "\n" \ - " writer.flush(true);\n" \ - " return wrote;\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().consoleObjectBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().consoleObjectBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ -} -WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) -#undef DEFINE_BUILTIN_GENERATOR - - -} // namespace WebCore diff --git a/src/bun.js/builtins/cpp/ConsoleObjectBuiltins.h b/src/bun.js/builtins/cpp/ConsoleObjectBuiltins.h deleted file mode 100644 index 128468602..000000000 --- a/src/bun.js/builtins/cpp/ConsoleObjectBuiltins.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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) 2023 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 { - -/* ConsoleObject */ -extern const char* const s_consoleObjectAsyncIteratorCode; -extern const int s_consoleObjectAsyncIteratorCodeLength; -extern const JSC::ConstructAbility s_consoleObjectAsyncIteratorCodeConstructAbility; -extern const JSC::ConstructorKind s_consoleObjectAsyncIteratorCodeConstructorKind; -extern const JSC::ImplementationVisibility s_consoleObjectAsyncIteratorCodeImplementationVisibility; -extern const char* const s_consoleObjectWriteCode; -extern const int s_consoleObjectWriteCodeLength; -extern const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility; -extern const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind; -extern const JSC::ImplementationVisibility s_consoleObjectWriteCodeImplementationVisibility; - -#define WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_DATA(macro) \ - macro(asyncIterator, consoleObjectAsyncIterator, 0) \ - macro(write, consoleObjectWrite, 1) \ - -#define WEBCORE_BUILTIN_CONSOLEOBJECT_ASYNCITERATOR 1 -#define WEBCORE_BUILTIN_CONSOLEOBJECT_WRITE 1 - -#define WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_CODE(macro) \ - macro(consoleObjectAsyncIteratorCode, asyncIterator, "[Symbol.asyncIterator]"_s, s_consoleObjectAsyncIteratorCodeLength) \ - macro(consoleObjectWriteCode, write, ASCIILiteral(), s_consoleObjectWriteCodeLength) \ - -#define WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_FUNCTION_NAME(macro) \ - macro(asyncIterator) \ - macro(write) \ - -#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ - JSC::FunctionExecutable* codeName##Generator(JSC::VM&); - -WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) -#undef DECLARE_BUILTIN_GENERATOR - -class ConsoleObjectBuiltinsWrapper : private JSC::WeakHandleOwner { -public: - explicit ConsoleObjectBuiltinsWrapper(JSC::VM& vm) - : m_vm(vm) - WEBCORE_FOREACH_CONSOLEOBJECT_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_CONSOLEOBJECT_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_CONSOLEOBJECT_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) -#undef EXPOSE_BUILTIN_EXECUTABLES - - WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) - - void exportNames(); - -private: - JSC::VM& m_vm; - - WEBCORE_FOREACH_CONSOLEOBJECT_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_CONSOLEOBJECT_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) -#undef DECLARE_BUILTIN_SOURCE_MEMBERS - -}; - -#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ -inline JSC::UnlinkedFunctionExecutable* ConsoleObjectBuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ - }\ - return m_##name##Executable.get();\ -} -WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) -#undef DEFINE_BUILTIN_EXECUTABLES - -inline void ConsoleObjectBuiltinsWrapper::exportNames() -{ -#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); - WEBCORE_FOREACH_CONSOLEOBJECT_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) -#undef EXPORT_FUNCTION_NAME -} - -} // namespace WebCore diff --git a/src/bun.js/builtins/cpp/CountQueuingStrategyBuiltins.cpp b/src/bun.js/builtins/cpp/CountQueuingStrategyBuiltins.cpp deleted file mode 100644 index 7690a83de..000000000 --- a/src/bun.js/builtins/cpp/CountQueuingStrategyBuiltins.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_countQueuingStrategyHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_countQueuingStrategyHighWaterMarkCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_countQueuingStrategyHighWaterMarkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_countQueuingStrategySizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_countQueuingStrategyInitializeCountQueuingStrategyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/CountQueuingStrategyBuiltins.h b/src/bun.js/builtins/cpp/CountQueuingStrategyBuiltins.h deleted file mode 100644 index b03125a76..000000000 --- a/src/bun.js/builtins/cpp/CountQueuingStrategyBuiltins.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_countQueuingStrategyHighWaterMarkCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_countQueuingStrategySizeCodeImplementationVisibility; -extern const char* const s_countQueuingStrategyInitializeCountQueuingStrategyCode; -extern const int s_countQueuingStrategyInitializeCountQueuingStrategyCodeLength; -extern const JSC::ConstructAbility s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructAbility; -extern const JSC::ConstructorKind s_countQueuingStrategyInitializeCountQueuingStrategyCodeConstructorKind; -extern const JSC::ImplementationVisibility s_countQueuingStrategyInitializeCountQueuingStrategyCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/ImportMetaObjectBuiltins.cpp b/src/bun.js/builtins/cpp/ImportMetaObjectBuiltins.cpp deleted file mode 100644 index 83a2ba8c2..000000000 --- a/src/bun.js/builtins/cpp/ImportMetaObjectBuiltins.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/* - * 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) 2023 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 "ImportMetaObjectBuiltins.h" - -#include "WebCoreJSClientData.h" -#include <JavaScriptCore/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_importMetaObjectLoadCJS2ESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_importMetaObjectLoadCJS2ESMCodeLength = 2943; -static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectLoadCJS2ESMCode = - "(function (resolvedSpecifier) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var loader = @Loader;\n" \ - " var queue = @createFIFO();\n" \ - " var key = resolvedSpecifier;\n" \ - " while (key) {\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " var entry = loader.registry.@get(key);\n" \ - "\n" \ - " if (!entry || !entry.state || entry.state <= @ModuleFetch) {\n" \ - " @fulfillModuleSync(key);\n" \ - " entry = loader.registry.@get(key);\n" \ - " }\n" \ - "\n" \ - "\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " var sourceCodeObject = @getPromiseInternalField(\n" \ - " entry.fetch,\n" \ - " @promiseFieldReactionsOrResult\n" \ - " );\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " var moduleRecordPromise = loader.parseModule(key, sourceCodeObject);\n" \ - " var module = entry.module;\n" \ - " if (!module && moduleRecordPromise && @isPromise(moduleRecordPromise)) {\n" \ - " var reactionsOrResult = @getPromiseInternalField(\n" \ - " moduleRecordPromise,\n" \ - " @promiseFieldReactionsOrResult\n" \ - " );\n" \ - " var flags = @getPromiseInternalField(\n" \ - " moduleRecordPromise,\n" \ - " @promiseFieldFlags\n" \ - " );\n" \ - " var state = flags & @promiseStateMask;\n" \ - " //\n" \ - " if (\n" \ - " state === @promiseStatePending ||\n" \ - " (reactionsOrResult && @isPromise(reactionsOrResult))\n" \ - " ) {\n" \ - " @throwTypeError(`require() async module \\\"${key}\\\" is unsupported`);\n" \ - " } else if (state === @promiseStateRejected) {\n" \ - " //\n" \ - " //\n" \ - " @throwTypeError(\n" \ - " `${\n" \ - " reactionsOrResult?.message ?? \"An error occurred\"\n" \ - " } while parsing module \\\"${key}\\\"`\n" \ - " );\n" \ - " }\n" \ - " entry.module = module = reactionsOrResult;\n" \ - " } else if (moduleRecordPromise && !module) {\n" \ - " entry.module = module = moduleRecordPromise;\n" \ - " }\n" \ - "\n" \ - " //\n" \ - " @setStateToMax(entry, @ModuleLink);\n" \ - " var dependenciesMap = module.dependenciesMap;\n" \ - " var requestedModules = loader.requestedModules(module);\n" \ - " var dependencies = @newArrayWithSize(requestedModules.length);\n" \ - " for (var i = 0, length = requestedModules.length; i < length; ++i) {\n" \ - " var depName = requestedModules[i];\n" \ - " //\n" \ - " //\n" \ - " var depKey =\n" \ - " depName[0] === \"/\"\n" \ - " ? depName\n" \ - " : loader.resolve(depName, key, @undefined);\n" \ - " var depEntry = loader.ensureRegistered(depKey);\n" \ - " if (depEntry.state < @ModuleLink) {\n" \ - " queue.push(depKey);\n" \ - " }\n" \ - "\n" \ - " @putByValDirect(dependencies, i, depEntry);\n" \ - " dependenciesMap.@set(depName, depEntry);\n" \ - " }\n" \ - "\n" \ - " entry.dependencies = dependencies;\n" \ - " //\n" \ - " entry.instantiate = @Promise.resolve(entry)\n" \ - " entry.satisfy = @Promise.resolve(entry);\n" \ - " key = queue.shift();\n" \ - " while (key && (loader.registry.@get(key)?.state ?? @ModuleFetch) >= @ModuleLink) {\n" \ - " key = queue.shift();\n" \ - " }\n" \ - "\n" \ - " }\n" \ - "\n" \ - " var linkAndEvaluateResult = loader.linkAndEvaluateModule(\n" \ - " resolvedSpecifier,\n" \ - " @undefined\n" \ - " );\n" \ - " if (linkAndEvaluateResult && @isPromise(linkAndEvaluateResult)) {\n" \ - " //\n" \ - " //\n" \ - " @throwTypeError(\n" \ - " `require() async module \\\"${resolvedSpecifier}\\\" is unsupported`\n" \ - " );\n" \ - " }\n" \ - "\n" \ - " return loader.registry.@get(resolvedSpecifier);\n" \ - "\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_importMetaObjectRequireESMCodeLength = 616; -static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireESMCode = - "(function (resolved) {\n" \ - " \"use strict\";\n" \ - " var entry = @Loader.registry.@get(resolved);\n" \ - "\n" \ - " if (!entry || !entry.evaluated) {\n" \ - " entry = @loadCJS2ESM(resolved); \n" \ - " }\n" \ - "\n" \ - " if (!entry || !entry.evaluated || !entry.module) {\n" \ - " @throwTypeError(`require() failed to evaluate module \\\"${resolved}\\\". This is an internal consistentency error.`);\n" \ - " }\n" \ - " var exports = @Loader.getModuleNamespaceObject(entry.module);\n" \ - " var commonJS = exports.default;\n" \ - " var cjs = commonJS?.[@commonJSSymbol];\n" \ - " if (cjs === 0) {\n" \ - " return commonJS;\n" \ - " } else if (cjs && @isCallable(commonJS)) {\n" \ - " return commonJS();\n" \ - " }\n" \ - " \n" \ - " return exports;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_importMetaObjectInternalRequireCodeLength = 983; -static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectInternalRequireCode = - "(function (resolved) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var cached = @requireMap.@get(resolved);\n" \ - " const last5 = resolved.substring(resolved.length - 5);\n" \ - " if (cached) {\n" \ - " if (last5 === \".node\") {\n" \ - " return cached.exports;\n" \ - " }\n" \ - "\n" \ - " return cached;\n" \ - " }\n" \ - " \n" \ - " //\n" \ - " if (last5 === \".json\") {\n" \ - " var fs = (globalThis[Symbol.for(\"_fs\")] ||= @Bun.fs());\n" \ - " var exports = JSON.parse(fs.readFileSync(resolved, \"utf8\"));\n" \ - " @requireMap.@set(resolved, exports);\n" \ - " return exports;\n" \ - " } else if (last5 === \".node\") {\n" \ - " var module = { exports: {} };\n" \ - " process.dlopen(module, resolved);\n" \ - " @requireMap.@set(resolved, module);\n" \ - " return module.exports;\n" \ - " } else if (last5 === \".toml\") {\n" \ - " var fs = (globalThis[Symbol.for(\"_fs\")] ||= @Bun.fs());\n" \ - " var exports = @Bun.TOML.parse(fs.readFileSync(resolved, \"utf8\"));\n" \ - " @requireMap.@set(resolved, exports);\n" \ - " return exports;\n" \ - " } else {\n" \ - " var exports = @requireESM(resolved);\n" \ - " @requireMap.@set(resolved, exports);\n" \ - " return exports;\n" \ - " }\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_importMetaObjectRequireCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_importMetaObjectRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_importMetaObjectRequireCodeLength = 222; -static const JSC::Intrinsic s_importMetaObjectRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireCode = - "(function (name) {\n" \ - " const from = this?.path ?? arguments.callee.path;\n" \ - "\n" \ - " if (typeof name !== \"string\") {\n" \ - " @throwTypeError(\"require(name) must be a string\");\n" \ - " }\n" \ - "\n" \ - " return @internalRequire(@resolveSync(name, from));\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_importMetaObjectMainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_importMetaObjectMainCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_importMetaObjectMainCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_importMetaObjectMainCodeLength = 52; -static const JSC::Intrinsic s_importMetaObjectMainCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectMainCode = - "(function () {\n" \ - " return this.path === @Bun.main;\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().importMetaObjectBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().importMetaObjectBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ -} -WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) -#undef DEFINE_BUILTIN_GENERATOR - - -} // namespace WebCore diff --git a/src/bun.js/builtins/cpp/ImportMetaObjectBuiltins.h b/src/bun.js/builtins/cpp/ImportMetaObjectBuiltins.h deleted file mode 100644 index b5a4f6e6b..000000000 --- a/src/bun.js/builtins/cpp/ImportMetaObjectBuiltins.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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) 2023 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 { - -/* ImportMetaObject */ -extern const char* const s_importMetaObjectLoadCJS2ESMCode; -extern const int s_importMetaObjectLoadCJS2ESMCodeLength; -extern const JSC::ConstructAbility s_importMetaObjectLoadCJS2ESMCodeConstructAbility; -extern const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind; -extern const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility; -extern const char* const s_importMetaObjectRequireESMCode; -extern const int s_importMetaObjectRequireESMCodeLength; -extern const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility; -extern const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind; -extern const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility; -extern const char* const s_importMetaObjectInternalRequireCode; -extern const int s_importMetaObjectInternalRequireCodeLength; -extern const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility; -extern const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind; -extern const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility; -extern const char* const s_importMetaObjectRequireCode; -extern const int s_importMetaObjectRequireCodeLength; -extern const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility; -extern const JSC::ConstructorKind s_importMetaObjectRequireCodeConstructorKind; -extern const JSC::ImplementationVisibility s_importMetaObjectRequireCodeImplementationVisibility; -extern const char* const s_importMetaObjectMainCode; -extern const int s_importMetaObjectMainCodeLength; -extern const JSC::ConstructAbility s_importMetaObjectMainCodeConstructAbility; -extern const JSC::ConstructorKind s_importMetaObjectMainCodeConstructorKind; -extern const JSC::ImplementationVisibility s_importMetaObjectMainCodeImplementationVisibility; - -#define WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_DATA(macro) \ - macro(loadCJS2ESM, importMetaObjectLoadCJS2ESM, 1) \ - macro(requireESM, importMetaObjectRequireESM, 1) \ - macro(internalRequire, importMetaObjectInternalRequire, 1) \ - macro(require, importMetaObjectRequire, 1) \ - macro(main, importMetaObjectMain, 0) \ - -#define WEBCORE_BUILTIN_IMPORTMETAOBJECT_LOADCJS2ESM 1 -#define WEBCORE_BUILTIN_IMPORTMETAOBJECT_REQUIREESM 1 -#define WEBCORE_BUILTIN_IMPORTMETAOBJECT_INTERNALREQUIRE 1 -#define WEBCORE_BUILTIN_IMPORTMETAOBJECT_REQUIRE 1 -#define WEBCORE_BUILTIN_IMPORTMETAOBJECT_MAIN 1 - -#define WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_CODE(macro) \ - macro(importMetaObjectLoadCJS2ESMCode, loadCJS2ESM, ASCIILiteral(), s_importMetaObjectLoadCJS2ESMCodeLength) \ - macro(importMetaObjectRequireESMCode, requireESM, ASCIILiteral(), s_importMetaObjectRequireESMCodeLength) \ - macro(importMetaObjectInternalRequireCode, internalRequire, ASCIILiteral(), s_importMetaObjectInternalRequireCodeLength) \ - macro(importMetaObjectRequireCode, require, ASCIILiteral(), s_importMetaObjectRequireCodeLength) \ - macro(importMetaObjectMainCode, main, "get main"_s, s_importMetaObjectMainCodeLength) \ - -#define WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_FUNCTION_NAME(macro) \ - macro(internalRequire) \ - macro(loadCJS2ESM) \ - macro(main) \ - macro(require) \ - macro(requireESM) \ - -#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ - JSC::FunctionExecutable* codeName##Generator(JSC::VM&); - -WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) -#undef DECLARE_BUILTIN_GENERATOR - -class ImportMetaObjectBuiltinsWrapper : private JSC::WeakHandleOwner { -public: - explicit ImportMetaObjectBuiltinsWrapper(JSC::VM& vm) - : m_vm(vm) - WEBCORE_FOREACH_IMPORTMETAOBJECT_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_IMPORTMETAOBJECT_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_IMPORTMETAOBJECT_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) -#undef EXPOSE_BUILTIN_EXECUTABLES - - WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) - - void exportNames(); - -private: - JSC::VM& m_vm; - - WEBCORE_FOREACH_IMPORTMETAOBJECT_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_IMPORTMETAOBJECT_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) -#undef DECLARE_BUILTIN_SOURCE_MEMBERS - -}; - -#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ -inline JSC::UnlinkedFunctionExecutable* ImportMetaObjectBuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ - }\ - return m_##name##Executable.get();\ -} -WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) -#undef DEFINE_BUILTIN_EXECUTABLES - -inline void ImportMetaObjectBuiltinsWrapper::exportNames() -{ -#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); - WEBCORE_FOREACH_IMPORTMETAOBJECT_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) -#undef EXPORT_FUNCTION_NAME -} - -} // namespace WebCore diff --git a/src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.cpp b/src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.cpp deleted file mode 100644 index 6e663afce..000000000 --- a/src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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) 2023 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 "JSBufferConstructorBuiltins.h" - -#include "WebCoreJSClientData.h" -#include <JavaScriptCore/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_jsBufferConstructorFromCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferConstructorFromCodeLength = 1762; -static const JSC::Intrinsic s_jsBufferConstructorFromCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferConstructorFromCode = - "(function (items) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " if (@isUndefinedOrNull(items)) {\n" \ - " @throwTypeError(\n" \ - " \"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\",\n" \ - " );\n" \ - " }\n" \ - " \n" \ - "\n" \ - " //\n" \ - " if (\n" \ - " typeof items === \"string\" ||\n" \ - " (typeof items === \"object\" &&\n" \ - " (@isTypedArrayView(items) ||\n" \ - " items instanceof ArrayBuffer ||\n" \ - " items instanceof SharedArrayBuffer ||\n" \ - " items instanceof @String))\n" \ - " ) {\n" \ - " switch (@argumentCount()) {\n" \ - " case 1: {\n" \ - " return new @Buffer(items);\n" \ - " }\n" \ - " case 2: {\n" \ - " return new @Buffer(items, @argument(1));\n" \ - " }\n" \ - " default: {\n" \ - " return new @Buffer(items, @argument(1), @argument(2));\n" \ - " }\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " var arrayLike = @toObject(\n" \ - " items,\n" \ - " \"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\",\n" \ - " );\n" \ - "\n" \ - " if (!@isJSArray(arrayLike)) {\n" \ - " const toPrimitive = @tryGetByIdWithWellKnownSymbol(items, \"toPrimitive\");\n" \ - "\n" \ - " if (toPrimitive) {\n" \ - " const primitive = toPrimitive.@call(items, \"string\");\n" \ - "\n" \ - " if (typeof primitive === \"string\") {\n" \ - " switch (@argumentCount()) {\n" \ - " case 1: {\n" \ - " return new @Buffer(primitive);\n" \ - " }\n" \ - " case 2: {\n" \ - " return new @Buffer(primitive, @argument(1));\n" \ - " }\n" \ - " default: {\n" \ - " return new @Buffer(primitive, @argument(1), @argument(2));\n" \ - " }\n" \ - " }\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " if (!(\"length\" in arrayLike) || @isCallable(arrayLike)) {\n" \ - " @throwTypeError(\n" \ - " \"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\",\n" \ - " );\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " return new @Buffer(@Uint8Array.from(arrayLike).buffer);\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().jsBufferConstructorBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().jsBufferConstructorBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ -} -WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) -#undef DEFINE_BUILTIN_GENERATOR - - -} // namespace WebCore diff --git a/src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.h b/src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.h deleted file mode 100644 index da990268b..000000000 --- a/src/bun.js/builtins/cpp/JSBufferConstructorBuiltins.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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) 2023 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 { - -/* JSBufferConstructor */ -extern const char* const s_jsBufferConstructorFromCode; -extern const int s_jsBufferConstructorFromCodeLength; -extern const JSC::ConstructAbility s_jsBufferConstructorFromCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferConstructorFromCodeImplementationVisibility; - -#define WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_DATA(macro) \ - macro(from, jsBufferConstructorFrom, 1) \ - -#define WEBCORE_BUILTIN_JSBUFFERCONSTRUCTOR_FROM 1 - -#define WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(macro) \ - macro(jsBufferConstructorFromCode, from, ASCIILiteral(), s_jsBufferConstructorFromCodeLength) \ - -#define WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_FUNCTION_NAME(macro) \ - macro(from) \ - -#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ - JSC::FunctionExecutable* codeName##Generator(JSC::VM&); - -WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) -#undef DECLARE_BUILTIN_GENERATOR - -class JSBufferConstructorBuiltinsWrapper : private JSC::WeakHandleOwner { -public: - explicit JSBufferConstructorBuiltinsWrapper(JSC::VM& vm) - : m_vm(vm) - WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_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_JSBUFFERCONSTRUCTOR_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_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) -#undef EXPOSE_BUILTIN_EXECUTABLES - - WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) - - void exportNames(); - -private: - JSC::VM& m_vm; - - WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_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_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) -#undef DECLARE_BUILTIN_SOURCE_MEMBERS - -}; - -#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ -inline JSC::UnlinkedFunctionExecutable* JSBufferConstructorBuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ - }\ - return m_##name##Executable.get();\ -} -WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) -#undef DEFINE_BUILTIN_EXECUTABLES - -inline void JSBufferConstructorBuiltinsWrapper::exportNames() -{ -#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); - WEBCORE_FOREACH_JSBUFFERCONSTRUCTOR_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) -#undef EXPORT_FUNCTION_NAME -} - -} // namespace WebCore diff --git a/src/bun.js/builtins/cpp/JSBufferPrototypeBuiltins.cpp b/src/bun.js/builtins/cpp/JSBufferPrototypeBuiltins.cpp deleted file mode 100644 index 19ce8a395..000000000 --- a/src/bun.js/builtins/cpp/JSBufferPrototypeBuiltins.cpp +++ /dev/null @@ -1,1114 +0,0 @@ -/* - * 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) 2023 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 "JSBufferPrototypeBuiltins.h" - -#include "WebCoreJSClientData.h" -#include <JavaScriptCore/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_jsBufferPrototypeSetBigUint64CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeSetBigUint64CodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeSetBigUint64CodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeSetBigUint64CodeLength = 174; -static const JSC::Intrinsic s_jsBufferPrototypeSetBigUint64CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSetBigUint64Code = - "(function (offset, value, le) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value, le);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadInt8CodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadInt8CodeLength = 147; -static const JSC::Intrinsic s_jsBufferPrototypeReadInt8CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadInt8Code = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt8(offset);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadUInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadUInt8CodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadUInt8CodeLength = 148; -static const JSC::Intrinsic s_jsBufferPrototypeReadUInt8CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUInt8Code = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint8(offset);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadInt16LECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadInt16LECodeLength = 154; -static const JSC::Intrinsic s_jsBufferPrototypeReadInt16LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadInt16LECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt16(offset, true);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadInt16BECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadInt16BECodeLength = 155; -static const JSC::Intrinsic s_jsBufferPrototypeReadInt16BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadInt16BECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt16(offset, false);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16LECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadUInt16LECodeLength = 155; -static const JSC::Intrinsic s_jsBufferPrototypeReadUInt16LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUInt16LECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint16(offset, true);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16BECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadUInt16BECodeLength = 156; -static const JSC::Intrinsic s_jsBufferPrototypeReadUInt16BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUInt16BECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint16(offset, false);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadInt32LECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadInt32LECodeLength = 154; -static const JSC::Intrinsic s_jsBufferPrototypeReadInt32LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadInt32LECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt32(offset, true);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadInt32BECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadInt32BECodeLength = 155; -static const JSC::Intrinsic s_jsBufferPrototypeReadInt32BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadInt32BECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt32(offset, false);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32LECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadUInt32LECodeLength = 155; -static const JSC::Intrinsic s_jsBufferPrototypeReadUInt32LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUInt32LECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint32(offset, true);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32BECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadUInt32BECodeLength = 156; -static const JSC::Intrinsic s_jsBufferPrototypeReadUInt32BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUInt32BECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint32(offset, false);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadIntLECodeLength = 882; -static const JSC::Intrinsic s_jsBufferPrototypeReadIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntLECode = - "(function (offset, byteLength) {\n" \ - " \"use strict\";\n" \ - " const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength);\n" \ - " switch (byteLength) {\n" \ - " case 1: {\n" \ - " return view.getInt8(offset);\n" \ - " }\n" \ - " case 2: {\n" \ - " return view.getInt16(offset, true);\n" \ - " }\n" \ - " case 3: {\n" \ - " const val = view.getUint16(offset, true) + view.getUint8(offset + 2) * 2 ** 16;\n" \ - " return val | (val & 2 ** 23) * 0x1fe;\n" \ - " }\n" \ - " case 4: {\n" \ - " return view.getInt32(offset, true);\n" \ - " }\n" \ - " case 5: {\n" \ - " const last = view.getUint8(offset + 4);\n" \ - " return (last | (last & 2 ** 7) * 0x1fffffe) * 2 ** 32 + view.getUint32(offset, true);\n" \ - " }\n" \ - " case 6: {\n" \ - " const last = view.getUint16(offset + 4, true);\n" \ - " return (last | (last & 2 ** 15) * 0x1fffe) * 2 ** 32 + view.getUint32(offset, true);\n" \ - " }\n" \ - " }\n" \ - " @throwRangeError(\"byteLength must be >= 1 and <= 6\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadIntBECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadIntBECodeLength = 888; -static const JSC::Intrinsic s_jsBufferPrototypeReadIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadIntBECode = - "(function (offset, byteLength) {\n" \ - " \"use strict\";\n" \ - " const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength);\n" \ - " switch (byteLength) {\n" \ - " case 1: {\n" \ - " return view.getInt8(offset);\n" \ - " }\n" \ - " case 2: {\n" \ - " return view.getInt16(offset, false);\n" \ - " }\n" \ - " case 3: {\n" \ - " const val = view.getUint16(offset + 1, false) + view.getUint8(offset) * 2 ** 16;\n" \ - " return val | (val & 2 ** 23) * 0x1fe;\n" \ - " }\n" \ - " case 4: {\n" \ - " return view.getInt32(offset, false);\n" \ - " }\n" \ - " case 5: {\n" \ - " const last = view.getUint8(offset);\n" \ - " return (last | (last & 2 ** 7) * 0x1fffffe) * 2 ** 32 + view.getUint32(offset + 1, false);\n" \ - " }\n" \ - " case 6: {\n" \ - " const last = view.getUint16(offset, false);\n" \ - " return (last | (last & 2 ** 15) * 0x1fffe) * 2 ** 32 + view.getUint32(offset + 2, false);\n" \ - " }\n" \ - " }\n" \ - " @throwRangeError(\"byteLength must be >= 1 and <= 6\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadUIntLECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadUIntLECodeLength = 723; -static const JSC::Intrinsic s_jsBufferPrototypeReadUIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUIntLECode = - "(function (offset, byteLength) {\n" \ - " \"use strict\";\n" \ - " const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength);\n" \ - " switch (byteLength) {\n" \ - " case 1: {\n" \ - " return view.getUint8(offset);\n" \ - " }\n" \ - " case 2: {\n" \ - " return view.getUint16(offset, true);\n" \ - " }\n" \ - " case 3: {\n" \ - " return view.getUint16(offset, true) + view.getUint8(offset + 2) * 2 ** 16;\n" \ - " }\n" \ - " case 4: {\n" \ - " return view.getUint32(offset, true);\n" \ - " }\n" \ - " case 5: {\n" \ - " return view.getUint8(offset + 4) * 2 ** 32 + view.getUint32(offset, true);\n" \ - " }\n" \ - " case 6: {\n" \ - " return view.getUint16(offset + 4, true) * 2 ** 32 + view.getUint32(offset, true);\n" \ - " }\n" \ - " }\n" \ - " @throwRangeError(\"byteLength must be >= 1 and <= 6\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeInspectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeInspectCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeInspectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeInspectCodeLength = 81; -static const JSC::Intrinsic s_jsBufferPrototypeInspectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeInspectCode = - "(function (recurseTimes, ctx) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " return @Bun.inspect(this);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadUIntBECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadUIntBECodeLength = 842; -static const JSC::Intrinsic s_jsBufferPrototypeReadUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadUIntBECode = - "(function (offset, byteLength) {\n" \ - " \"use strict\";\n" \ - " const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength);\n" \ - " switch (byteLength) {\n" \ - " case 1: {\n" \ - " return view.getUint8(offset);\n" \ - " }\n" \ - " case 2: {\n" \ - " return view.getUint16(offset, false);\n" \ - " }\n" \ - " case 3: {\n" \ - " return view.getUint16(offset + 1, false) + view.getUint8(offset) * 2 ** 16;\n" \ - " }\n" \ - " case 4: {\n" \ - " return view.getUint32(offset, false);\n" \ - " }\n" \ - " case 5: {\n" \ - " const last = view.getUint8(offset);\n" \ - " return (last | (last & 2 ** 7) * 0x1fffffe) * 2 ** 32 + view.getUint32(offset + 1, false);\n" \ - " }\n" \ - " case 6: {\n" \ - " const last = view.getUint16(offset, false);\n" \ - " return (last | (last & 2 ** 15) * 0x1fffe) * 2 ** 32 + view.getUint32(offset + 2, false);\n" \ - " }\n" \ - " }\n" \ - " @throwRangeError(\"byteLength must be >= 1 and <= 6\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadFloatLECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadFloatLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadFloatLECodeLength = 156; -static const JSC::Intrinsic s_jsBufferPrototypeReadFloatLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadFloatLECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat32(offset, true);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadFloatBECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadFloatBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadFloatBECodeLength = 157; -static const JSC::Intrinsic s_jsBufferPrototypeReadFloatBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadFloatBECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat32(offset, false);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleLECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadDoubleLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadDoubleLECodeLength = 156; -static const JSC::Intrinsic s_jsBufferPrototypeReadDoubleLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadDoubleLECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat64(offset, true);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleBECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadDoubleBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadDoubleBECodeLength = 157; -static const JSC::Intrinsic s_jsBufferPrototypeReadDoubleBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadDoubleBECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat64(offset, false);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64LECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadBigInt64LECodeLength = 157; -static const JSC::Intrinsic s_jsBufferPrototypeReadBigInt64LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadBigInt64LECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigInt64(offset, true);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64BECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadBigInt64BECodeLength = 158; -static const JSC::Intrinsic s_jsBufferPrototypeReadBigInt64BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadBigInt64BECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigInt64(offset, false);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64LECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigUInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadBigUInt64LECodeLength = 158; -static const JSC::Intrinsic s_jsBufferPrototypeReadBigUInt64LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadBigUInt64LECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigUint64(offset, true);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64BECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigUInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeReadBigUInt64BECodeLength = 159; -static const JSC::Intrinsic s_jsBufferPrototypeReadBigUInt64BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeReadBigUInt64BECode = - "(function (offset) {\n" \ - " \"use strict\";\n" \ - " return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigUint64(offset, false);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteInt8CodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteInt8CodeLength = 175; -static const JSC::Intrinsic s_jsBufferPrototypeWriteInt8CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt8Code = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt8(offset, value);\n" \ - " return offset + 1;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt8CodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt8CodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteUInt8CodeLength = 176; -static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt8CodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt8Code = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint8(offset, value);\n" \ - " return offset + 1;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16LECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteInt16LECodeLength = 182; -static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt16LECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt16(offset, value, true);\n" \ - " return offset + 2;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16BECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteInt16BECodeLength = 183; -static const JSC::Intrinsic s_jsBufferPrototypeWriteInt16BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt16BECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt16(offset, value, false);\n" \ - " return offset + 2;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16LECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteUInt16LECodeLength = 183; -static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt16LECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint16(offset, value, true);\n" \ - " return offset + 2;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16BECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteUInt16BECodeLength = 184; -static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt16BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt16BECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint16(offset, value, false);\n" \ - " return offset + 2;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32LECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteInt32LECodeLength = 182; -static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt32LECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt32(offset, value, true);\n" \ - " return offset + 4;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32BECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteInt32BECodeLength = 183; -static const JSC::Intrinsic s_jsBufferPrototypeWriteInt32BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteInt32BECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt32(offset, value, false);\n" \ - " return offset + 4;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32LECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteUInt32LECodeLength = 183; -static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt32LECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint32(offset, value, true);\n" \ - " return offset + 4;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32BECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteUInt32BECodeLength = 184; -static const JSC::Intrinsic s_jsBufferPrototypeWriteUInt32BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUInt32BECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint32(offset, value, false);\n" \ - " return offset + 4;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteIntLECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteIntLECodeLength = 949; -static const JSC::Intrinsic s_jsBufferPrototypeWriteIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteIntLECode = - "(function (value, offset, byteLength) {\n" \ - " \"use strict\";\n" \ - " const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength);\n" \ - " switch (byteLength) {\n" \ - " case 1: {\n" \ - " view.setInt8(offset, value);\n" \ - " break;\n" \ - " }\n" \ - " case 2: {\n" \ - " view.setInt16(offset, value, true);\n" \ - " break;\n" \ - " }\n" \ - " case 3: {\n" \ - " view.setUint16(offset, value & 0xFFFF, true);\n" \ - " view.setInt8(offset + 2, Math.floor(value * 2 ** -16));\n" \ - " break;\n" \ - " }\n" \ - " case 4: {\n" \ - " view.setInt32(offset, value, true);\n" \ - " break;\n" \ - " }\n" \ - " case 5: {\n" \ - " view.setUint32(offset, value | 0, true);\n" \ - " view.setInt8(offset + 4, Math.floor(value * 2 ** -32));\n" \ - " break;\n" \ - " }\n" \ - " case 6: {\n" \ - " view.setUint32(offset, value | 0, true);\n" \ - " view.setInt16(offset + 4, Math.floor(value * 2 ** -32), true);\n" \ - " break;\n" \ - " }\n" \ - " default: {\n" \ - " @throwRangeError(\"byteLength must be >= 1 and <= 6\");\n" \ - " }\n" \ - " }\n" \ - " return offset + byteLength;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteIntBECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteIntBECodeLength = 955; -static const JSC::Intrinsic s_jsBufferPrototypeWriteIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteIntBECode = - "(function (value, offset, byteLength) {\n" \ - " \"use strict\";\n" \ - " const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength);\n" \ - " switch (byteLength) {\n" \ - " case 1: {\n" \ - " view.setInt8(offset, value);\n" \ - " break;\n" \ - " }\n" \ - " case 2: {\n" \ - " view.setInt16(offset, value, false);\n" \ - " break;\n" \ - " }\n" \ - " case 3: {\n" \ - " view.setUint16(offset + 1, value & 0xFFFF, false);\n" \ - " view.setInt8(offset, Math.floor(value * 2 ** -16));\n" \ - " break;\n" \ - " }\n" \ - " case 4: {\n" \ - " view.setInt32(offset, value, false);\n" \ - " break;\n" \ - " }\n" \ - " case 5: {\n" \ - " view.setUint32(offset + 1, value | 0, false);\n" \ - " view.setInt8(offset, Math.floor(value * 2 ** -32));\n" \ - " break;\n" \ - " }\n" \ - " case 6: {\n" \ - " view.setUint32(offset + 2, value | 0, false);\n" \ - " view.setInt16(offset, Math.floor(value * 2 ** -32), false);\n" \ - " break;\n" \ - " }\n" \ - " default: {\n" \ - " @throwRangeError(\"byteLength must be >= 1 and <= 6\");\n" \ - " }\n" \ - " }\n" \ - " return offset + byteLength;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntLECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteUIntLECodeLength = 955; -static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUIntLECode = - "(function (value, offset, byteLength) {\n" \ - " \"use strict\";\n" \ - " const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength);\n" \ - " switch (byteLength) {\n" \ - " case 1: {\n" \ - " view.setUint8(offset, value);\n" \ - " break;\n" \ - " }\n" \ - " case 2: {\n" \ - " view.setUint16(offset, value, true);\n" \ - " break;\n" \ - " }\n" \ - " case 3: {\n" \ - " view.setUint16(offset, value & 0xFFFF, true);\n" \ - " view.setUint8(offset + 2, Math.floor(value * 2 ** -16));\n" \ - " break;\n" \ - " }\n" \ - " case 4: {\n" \ - " view.setUint32(offset, value, true);\n" \ - " break;\n" \ - " }\n" \ - " case 5: {\n" \ - " view.setUint32(offset, value | 0, true);\n" \ - " view.setUint8(offset + 4, Math.floor(value * 2 ** -32));\n" \ - " break;\n" \ - " }\n" \ - " case 6: {\n" \ - " view.setUint32(offset, value | 0, true);\n" \ - " view.setUint16(offset + 4, Math.floor(value * 2 ** -32), true);\n" \ - " break;\n" \ - " }\n" \ - " default: {\n" \ - " @throwRangeError(\"byteLength must be >= 1 and <= 6\");\n" \ - " }\n" \ - " }\n" \ - " return offset + byteLength;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntBECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteUIntBECodeLength = 961; -static const JSC::Intrinsic s_jsBufferPrototypeWriteUIntBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteUIntBECode = - "(function (value, offset, byteLength) {\n" \ - " \"use strict\";\n" \ - " const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength);\n" \ - " switch (byteLength) {\n" \ - " case 1: {\n" \ - " view.setUint8(offset, value);\n" \ - " break;\n" \ - " }\n" \ - " case 2: {\n" \ - " view.setUint16(offset, value, false);\n" \ - " break;\n" \ - " }\n" \ - " case 3: {\n" \ - " view.setUint16(offset + 1, value & 0xFFFF, false);\n" \ - " view.setUint8(offset, Math.floor(value * 2 ** -16));\n" \ - " break;\n" \ - " }\n" \ - " case 4: {\n" \ - " view.setUint32(offset, value, false);\n" \ - " break;\n" \ - " }\n" \ - " case 5: {\n" \ - " view.setUint32(offset + 1, value | 0, false);\n" \ - " view.setUint8(offset, Math.floor(value * 2 ** -32));\n" \ - " break;\n" \ - " }\n" \ - " case 6: {\n" \ - " view.setUint32(offset + 2, value | 0, false);\n" \ - " view.setUint16(offset, Math.floor(value * 2 ** -32), false);\n" \ - " break;\n" \ - " }\n" \ - " default: {\n" \ - " @throwRangeError(\"byteLength must be >= 1 and <= 6\");\n" \ - " }\n" \ - " }\n" \ - " return offset + byteLength;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteFloatLECodeLength = 184; -static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatLECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat32(offset, value, true);\n" \ - " return offset + 4;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteFloatBECodeLength = 185; -static const JSC::Intrinsic s_jsBufferPrototypeWriteFloatBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteFloatBECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat32(offset, value, false);\n" \ - " return offset + 4;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleLECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleLECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteDoubleLECodeLength = 184; -static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleLECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteDoubleLECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat64(offset, value, true);\n" \ - " return offset + 8;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleBECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleBECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteDoubleBECodeLength = 185; -static const JSC::Intrinsic s_jsBufferPrototypeWriteDoubleBECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteDoubleBECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat64(offset, value, false);\n" \ - " return offset + 8;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64LECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteBigInt64LECodeLength = 185; -static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigInt64LECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigInt64(offset, value, true);\n" \ - " return offset + 8;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64BECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteBigInt64BECodeLength = 186; -static const JSC::Intrinsic s_jsBufferPrototypeWriteBigInt64BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigInt64BECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigInt64(offset, value, false);\n" \ - " return offset + 8;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64LECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64LECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteBigUInt64LECodeLength = 186; -static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64LECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigUInt64LECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value, true);\n" \ - " return offset + 8;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64BECodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64BECodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeWriteBigUInt64BECodeLength = 187; -static const JSC::Intrinsic s_jsBufferPrototypeWriteBigUInt64BECodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeWriteBigUInt64BECode = - "(function (value, offset) {\n" \ - " \"use strict\";\n" \ - " (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value, false);\n" \ - " return offset + 8;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeUtf8WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeUtf8WriteCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeUtf8WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeUtf8WriteCodeLength = 105; -static const JSC::Intrinsic s_jsBufferPrototypeUtf8WriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf8WriteCode = - "(function (text, offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.write(text, offset, length, \"utf8\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeUcs2WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeUcs2WriteCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeUcs2WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeUcs2WriteCodeLength = 105; -static const JSC::Intrinsic s_jsBufferPrototypeUcs2WriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUcs2WriteCode = - "(function (text, offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.write(text, offset, length, \"ucs2\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeUtf16leWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeUtf16leWriteCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeUtf16leWriteCodeLength = 108; -static const JSC::Intrinsic s_jsBufferPrototypeUtf16leWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf16leWriteCode = - "(function (text, offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.write(text, offset, length, \"utf16le\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeLatin1WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeLatin1WriteCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeLatin1WriteCodeLength = 107; -static const JSC::Intrinsic s_jsBufferPrototypeLatin1WriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeLatin1WriteCode = - "(function (text, offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.write(text, offset, length, \"latin1\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeAsciiWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeAsciiWriteCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeAsciiWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeAsciiWriteCodeLength = 106; -static const JSC::Intrinsic s_jsBufferPrototypeAsciiWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeAsciiWriteCode = - "(function (text, offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.write(text, offset, length, \"ascii\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeBase64WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeBase64WriteCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeBase64WriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeBase64WriteCodeLength = 107; -static const JSC::Intrinsic s_jsBufferPrototypeBase64WriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64WriteCode = - "(function (text, offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.write(text, offset, length, \"base64\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeBase64urlWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeBase64urlWriteCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeBase64urlWriteCodeLength = 110; -static const JSC::Intrinsic s_jsBufferPrototypeBase64urlWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64urlWriteCode = - "(function (text, offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.write(text, offset, length, \"base64url\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeHexWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeHexWriteCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeHexWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeHexWriteCodeLength = 104; -static const JSC::Intrinsic s_jsBufferPrototypeHexWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeHexWriteCode = - "(function (text, offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.write(text, offset, length, \"hex\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeUtf8SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeUtf8SliceCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeUtf8SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeUtf8SliceCodeLength = 96; -static const JSC::Intrinsic s_jsBufferPrototypeUtf8SliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf8SliceCode = - "(function (offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.toString(offset, length, \"utf8\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeUcs2SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeUcs2SliceCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeUcs2SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeUcs2SliceCodeLength = 96; -static const JSC::Intrinsic s_jsBufferPrototypeUcs2SliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUcs2SliceCode = - "(function (offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.toString(offset, length, \"ucs2\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeUtf16leSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeUtf16leSliceCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeUtf16leSliceCodeLength = 99; -static const JSC::Intrinsic s_jsBufferPrototypeUtf16leSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeUtf16leSliceCode = - "(function (offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.toString(offset, length, \"utf16le\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeLatin1SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeLatin1SliceCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeLatin1SliceCodeLength = 98; -static const JSC::Intrinsic s_jsBufferPrototypeLatin1SliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeLatin1SliceCode = - "(function (offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.toString(offset, length, \"latin1\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeAsciiSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeAsciiSliceCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeAsciiSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeAsciiSliceCodeLength = 97; -static const JSC::Intrinsic s_jsBufferPrototypeAsciiSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeAsciiSliceCode = - "(function (offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.toString(offset, length, \"ascii\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeBase64SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeBase64SliceCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeBase64SliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeBase64SliceCodeLength = 98; -static const JSC::Intrinsic s_jsBufferPrototypeBase64SliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64SliceCode = - "(function (offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.toString(offset, length, \"base64\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeBase64urlSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeBase64urlSliceCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeBase64urlSliceCodeLength = 101; -static const JSC::Intrinsic s_jsBufferPrototypeBase64urlSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeBase64urlSliceCode = - "(function (offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.toString(offset, length, \"base64url\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeHexSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeHexSliceCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeHexSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeHexSliceCodeLength = 95; -static const JSC::Intrinsic s_jsBufferPrototypeHexSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeHexSliceCode = - "(function (offset, length) {\n" \ - " \"use strict\";\n" \ - " return this.toString(offset, length, \"hex\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeToJSONCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeToJSONCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeToJSONCodeLength = 118; -static const JSC::Intrinsic s_jsBufferPrototypeToJSONCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeToJSONCode = - "(function () {\n" \ - " \"use strict\";\n" \ - " const type = \"Buffer\";\n" \ - " const data = @Array.from(this);\n" \ - " return { type, data };\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeSliceCodeLength = 613; -static const JSC::Intrinsic s_jsBufferPrototypeSliceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeSliceCode = - "(function (start, end) {\n" \ - " \"use strict\";\n" \ - " var { buffer, byteOffset, byteLength } = this;\n" \ - "\n" \ - " function adjustOffset(offset, length) {\n" \ - " //\n" \ - " //\n" \ - " offset = @trunc(offset);\n" \ - " if (offset === 0 || @isNaN(offset)) {\n" \ - " return 0;\n" \ - " } else if (offset < 0) {\n" \ - " offset += length;\n" \ - " return offset > 0 ? offset : 0;\n" \ - " } else {\n" \ - " return offset < length ? offset : length;\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " var start_ = adjustOffset(start, byteLength);\n" \ - " var end_ = end !== @undefined ? adjustOffset(end, byteLength) : byteLength;\n" \ - " return new Buffer(buffer, byteOffset + start_, end_ > start_ ? (end_ - start_) : 0);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeParentCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeParentCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeParentCodeLength = 114; -static const JSC::Intrinsic s_jsBufferPrototypeParentCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeParentCode = - "(function () {\n" \ - " \"use strict\";\n" \ - " return @isObject(this) && this instanceof @Buffer ? this.buffer : @undefined;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_jsBufferPrototypeOffsetCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_jsBufferPrototypeOffsetCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_jsBufferPrototypeOffsetCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_jsBufferPrototypeOffsetCodeLength = 118; -static const JSC::Intrinsic s_jsBufferPrototypeOffsetCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_jsBufferPrototypeOffsetCode = - "(function () {\n" \ - " \"use strict\";\n" \ - " return @isObject(this) && this instanceof @Buffer ? this.byteOffset : @undefined;\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().jsBufferPrototypeBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().jsBufferPrototypeBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ -} -WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) -#undef DEFINE_BUILTIN_GENERATOR - - -} // namespace WebCore diff --git a/src/bun.js/builtins/cpp/JSBufferPrototypeBuiltins.h b/src/bun.js/builtins/cpp/JSBufferPrototypeBuiltins.h deleted file mode 100644 index 47e720468..000000000 --- a/src/bun.js/builtins/cpp/JSBufferPrototypeBuiltins.h +++ /dev/null @@ -1,713 +0,0 @@ -/* - * 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) 2023 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 { - -/* JSBufferPrototype */ -extern const char* const s_jsBufferPrototypeSetBigUint64Code; -extern const int s_jsBufferPrototypeSetBigUint64CodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeSetBigUint64CodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeSetBigUint64CodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeSetBigUint64CodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadInt8Code; -extern const int s_jsBufferPrototypeReadInt8CodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt8CodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt8CodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt8CodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadUInt8Code; -extern const int s_jsBufferPrototypeReadUInt8CodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt8CodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt8CodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt8CodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadInt16LECode; -extern const int s_jsBufferPrototypeReadInt16LECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt16LECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt16LECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt16LECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadInt16BECode; -extern const int s_jsBufferPrototypeReadInt16BECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt16BECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt16BECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt16BECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadUInt16LECode; -extern const int s_jsBufferPrototypeReadUInt16LECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16LECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16LECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt16LECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadUInt16BECode; -extern const int s_jsBufferPrototypeReadUInt16BECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt16BECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt16BECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt16BECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadInt32LECode; -extern const int s_jsBufferPrototypeReadInt32LECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt32LECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt32LECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt32LECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadInt32BECode; -extern const int s_jsBufferPrototypeReadInt32BECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadInt32BECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadInt32BECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadInt32BECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadUInt32LECode; -extern const int s_jsBufferPrototypeReadUInt32LECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32LECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32LECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt32LECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadUInt32BECode; -extern const int s_jsBufferPrototypeReadUInt32BECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadUInt32BECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadUInt32BECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUInt32BECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadIntLECode; -extern const int s_jsBufferPrototypeReadIntLECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadIntLECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntLECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadIntBECode; -extern const int s_jsBufferPrototypeReadIntBECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadIntBECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadIntBECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadUIntLECode; -extern const int s_jsBufferPrototypeReadUIntLECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadUIntLECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadUIntLECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntLECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeInspectCode; -extern const int s_jsBufferPrototypeInspectCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeInspectCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeInspectCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeInspectCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadUIntBECode; -extern const int s_jsBufferPrototypeReadUIntBECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadUIntBECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadUIntBECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadUIntBECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadFloatLECode; -extern const int s_jsBufferPrototypeReadFloatLECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadFloatLECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadFloatLECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadFloatLECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadFloatBECode; -extern const int s_jsBufferPrototypeReadFloatBECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadFloatBECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadFloatBECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadFloatBECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadDoubleLECode; -extern const int s_jsBufferPrototypeReadDoubleLECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleLECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleLECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadDoubleLECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadDoubleBECode; -extern const int s_jsBufferPrototypeReadDoubleBECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadDoubleBECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadDoubleBECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadDoubleBECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadBigInt64LECode; -extern const int s_jsBufferPrototypeReadBigInt64LECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64LECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64LECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigInt64LECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadBigInt64BECode; -extern const int s_jsBufferPrototypeReadBigInt64BECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadBigInt64BECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadBigInt64BECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigInt64BECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadBigUInt64LECode; -extern const int s_jsBufferPrototypeReadBigUInt64LECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64LECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64LECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigUInt64LECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeReadBigUInt64BECode; -extern const int s_jsBufferPrototypeReadBigUInt64BECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeReadBigUInt64BECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeReadBigUInt64BECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeReadBigUInt64BECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteInt8Code; -extern const int s_jsBufferPrototypeWriteInt8CodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt8CodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt8CodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt8CodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteUInt8Code; -extern const int s_jsBufferPrototypeWriteUInt8CodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt8CodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt8CodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt8CodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteInt16LECode; -extern const int s_jsBufferPrototypeWriteInt16LECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16LECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16LECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16LECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteInt16BECode; -extern const int s_jsBufferPrototypeWriteInt16BECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16BECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16BECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt16BECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteUInt16LECode; -extern const int s_jsBufferPrototypeWriteUInt16LECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16LECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16LECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16LECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteUInt16BECode; -extern const int s_jsBufferPrototypeWriteUInt16BECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16BECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16BECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt16BECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteInt32LECode; -extern const int s_jsBufferPrototypeWriteInt32LECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32LECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32LECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32LECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteInt32BECode; -extern const int s_jsBufferPrototypeWriteInt32BECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32BECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32BECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteInt32BECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteUInt32LECode; -extern const int s_jsBufferPrototypeWriteUInt32LECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32LECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32LECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32LECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteUInt32BECode; -extern const int s_jsBufferPrototypeWriteUInt32BECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32BECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32BECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUInt32BECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteIntLECode; -extern const int s_jsBufferPrototypeWriteIntLECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteIntLECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteIntLECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteIntLECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteIntBECode; -extern const int s_jsBufferPrototypeWriteIntBECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteIntBECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteIntBECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteIntBECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteUIntLECode; -extern const int s_jsBufferPrototypeWriteUIntLECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntLECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntLECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntLECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteUIntBECode; -extern const int s_jsBufferPrototypeWriteUIntBECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntBECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntBECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteUIntBECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteFloatLECode; -extern const int s_jsBufferPrototypeWriteFloatLECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatLECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteFloatBECode; -extern const int s_jsBufferPrototypeWriteFloatBECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteFloatBECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteDoubleLECode; -extern const int s_jsBufferPrototypeWriteDoubleLECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleLECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleLECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteDoubleBECode; -extern const int s_jsBufferPrototypeWriteDoubleBECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleBECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleBECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteDoubleBECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteBigInt64LECode; -extern const int s_jsBufferPrototypeWriteBigInt64LECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64LECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64LECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64LECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteBigInt64BECode; -extern const int s_jsBufferPrototypeWriteBigInt64BECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64BECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64BECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigInt64BECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteBigUInt64LECode; -extern const int s_jsBufferPrototypeWriteBigUInt64LECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64LECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64LECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64LECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeWriteBigUInt64BECode; -extern const int s_jsBufferPrototypeWriteBigUInt64BECodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64BECodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64BECodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeWriteBigUInt64BECodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeUtf8WriteCode; -extern const int s_jsBufferPrototypeUtf8WriteCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeUtf8WriteCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeUtf8WriteCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeUtf8WriteCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeUcs2WriteCode; -extern const int s_jsBufferPrototypeUcs2WriteCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeUcs2WriteCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeUcs2WriteCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeUcs2WriteCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeUtf16leWriteCode; -extern const int s_jsBufferPrototypeUtf16leWriteCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeUtf16leWriteCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeUtf16leWriteCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leWriteCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeLatin1WriteCode; -extern const int s_jsBufferPrototypeLatin1WriteCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeLatin1WriteCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeLatin1WriteCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1WriteCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeAsciiWriteCode; -extern const int s_jsBufferPrototypeAsciiWriteCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeAsciiWriteCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeAsciiWriteCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeAsciiWriteCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeBase64WriteCode; -extern const int s_jsBufferPrototypeBase64WriteCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeBase64WriteCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeBase64WriteCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeBase64WriteCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeBase64urlWriteCode; -extern const int s_jsBufferPrototypeBase64urlWriteCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeBase64urlWriteCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeBase64urlWriteCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlWriteCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeHexWriteCode; -extern const int s_jsBufferPrototypeHexWriteCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeHexWriteCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeHexWriteCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeHexWriteCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeUtf8SliceCode; -extern const int s_jsBufferPrototypeUtf8SliceCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeUtf8SliceCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeUtf8SliceCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeUtf8SliceCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeUcs2SliceCode; -extern const int s_jsBufferPrototypeUcs2SliceCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeUcs2SliceCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeUcs2SliceCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeUcs2SliceCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeUtf16leSliceCode; -extern const int s_jsBufferPrototypeUtf16leSliceCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeUtf16leSliceCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeUtf16leSliceCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeUtf16leSliceCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeLatin1SliceCode; -extern const int s_jsBufferPrototypeLatin1SliceCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeLatin1SliceCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeLatin1SliceCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeLatin1SliceCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeAsciiSliceCode; -extern const int s_jsBufferPrototypeAsciiSliceCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeAsciiSliceCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeAsciiSliceCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeAsciiSliceCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeBase64SliceCode; -extern const int s_jsBufferPrototypeBase64SliceCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeBase64SliceCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeBase64SliceCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeBase64SliceCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeBase64urlSliceCode; -extern const int s_jsBufferPrototypeBase64urlSliceCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeBase64urlSliceCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeBase64urlSliceCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeBase64urlSliceCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeHexSliceCode; -extern const int s_jsBufferPrototypeHexSliceCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeHexSliceCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeHexSliceCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeHexSliceCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeToJSONCode; -extern const int s_jsBufferPrototypeToJSONCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeToJSONCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeToJSONCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeToJSONCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeSliceCode; -extern const int s_jsBufferPrototypeSliceCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeSliceCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeSliceCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeParentCode; -extern const int s_jsBufferPrototypeParentCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeParentCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeParentCodeImplementationVisibility; -extern const char* const s_jsBufferPrototypeOffsetCode; -extern const int s_jsBufferPrototypeOffsetCodeLength; -extern const JSC::ConstructAbility s_jsBufferPrototypeOffsetCodeConstructAbility; -extern const JSC::ConstructorKind s_jsBufferPrototypeOffsetCodeConstructorKind; -extern const JSC::ImplementationVisibility s_jsBufferPrototypeOffsetCodeImplementationVisibility; - -#define WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_DATA(macro) \ - macro(setBigUint64, jsBufferPrototypeSetBigUint64, 3) \ - macro(readInt8, jsBufferPrototypeReadInt8, 1) \ - macro(readUInt8, jsBufferPrototypeReadUInt8, 1) \ - macro(readInt16LE, jsBufferPrototypeReadInt16LE, 1) \ - macro(readInt16BE, jsBufferPrototypeReadInt16BE, 1) \ - macro(readUInt16LE, jsBufferPrototypeReadUInt16LE, 1) \ - macro(readUInt16BE, jsBufferPrototypeReadUInt16BE, 1) \ - macro(readInt32LE, jsBufferPrototypeReadInt32LE, 1) \ - macro(readInt32BE, jsBufferPrototypeReadInt32BE, 1) \ - macro(readUInt32LE, jsBufferPrototypeReadUInt32LE, 1) \ - macro(readUInt32BE, jsBufferPrototypeReadUInt32BE, 1) \ - macro(readIntLE, jsBufferPrototypeReadIntLE, 2) \ - macro(readIntBE, jsBufferPrototypeReadIntBE, 2) \ - macro(readUIntLE, jsBufferPrototypeReadUIntLE, 2) \ - macro(inspect, jsBufferPrototypeInspect, 2) \ - macro(readUIntBE, jsBufferPrototypeReadUIntBE, 2) \ - macro(readFloatLE, jsBufferPrototypeReadFloatLE, 1) \ - macro(readFloatBE, jsBufferPrototypeReadFloatBE, 1) \ - macro(readDoubleLE, jsBufferPrototypeReadDoubleLE, 1) \ - macro(readDoubleBE, jsBufferPrototypeReadDoubleBE, 1) \ - macro(readBigInt64LE, jsBufferPrototypeReadBigInt64LE, 1) \ - macro(readBigInt64BE, jsBufferPrototypeReadBigInt64BE, 1) \ - macro(readBigUInt64LE, jsBufferPrototypeReadBigUInt64LE, 1) \ - macro(readBigUInt64BE, jsBufferPrototypeReadBigUInt64BE, 1) \ - macro(writeInt8, jsBufferPrototypeWriteInt8, 2) \ - macro(writeUInt8, jsBufferPrototypeWriteUInt8, 2) \ - macro(writeInt16LE, jsBufferPrototypeWriteInt16LE, 2) \ - macro(writeInt16BE, jsBufferPrototypeWriteInt16BE, 2) \ - macro(writeUInt16LE, jsBufferPrototypeWriteUInt16LE, 2) \ - macro(writeUInt16BE, jsBufferPrototypeWriteUInt16BE, 2) \ - macro(writeInt32LE, jsBufferPrototypeWriteInt32LE, 2) \ - macro(writeInt32BE, jsBufferPrototypeWriteInt32BE, 2) \ - macro(writeUInt32LE, jsBufferPrototypeWriteUInt32LE, 2) \ - macro(writeUInt32BE, jsBufferPrototypeWriteUInt32BE, 2) \ - macro(writeIntLE, jsBufferPrototypeWriteIntLE, 3) \ - macro(writeIntBE, jsBufferPrototypeWriteIntBE, 3) \ - macro(writeUIntLE, jsBufferPrototypeWriteUIntLE, 3) \ - macro(writeUIntBE, jsBufferPrototypeWriteUIntBE, 3) \ - macro(writeFloatLE, jsBufferPrototypeWriteFloatLE, 2) \ - macro(writeFloatBE, jsBufferPrototypeWriteFloatBE, 2) \ - macro(writeDoubleLE, jsBufferPrototypeWriteDoubleLE, 2) \ - macro(writeDoubleBE, jsBufferPrototypeWriteDoubleBE, 2) \ - macro(writeBigInt64LE, jsBufferPrototypeWriteBigInt64LE, 2) \ - macro(writeBigInt64BE, jsBufferPrototypeWriteBigInt64BE, 2) \ - macro(writeBigUInt64LE, jsBufferPrototypeWriteBigUInt64LE, 2) \ - macro(writeBigUInt64BE, jsBufferPrototypeWriteBigUInt64BE, 2) \ - macro(utf8Write, jsBufferPrototypeUtf8Write, 3) \ - macro(ucs2Write, jsBufferPrototypeUcs2Write, 3) \ - macro(utf16leWrite, jsBufferPrototypeUtf16leWrite, 3) \ - macro(latin1Write, jsBufferPrototypeLatin1Write, 3) \ - macro(asciiWrite, jsBufferPrototypeAsciiWrite, 3) \ - macro(base64Write, jsBufferPrototypeBase64Write, 3) \ - macro(base64urlWrite, jsBufferPrototypeBase64urlWrite, 3) \ - macro(hexWrite, jsBufferPrototypeHexWrite, 3) \ - macro(utf8Slice, jsBufferPrototypeUtf8Slice, 2) \ - macro(ucs2Slice, jsBufferPrototypeUcs2Slice, 2) \ - macro(utf16leSlice, jsBufferPrototypeUtf16leSlice, 2) \ - macro(latin1Slice, jsBufferPrototypeLatin1Slice, 2) \ - macro(asciiSlice, jsBufferPrototypeAsciiSlice, 2) \ - macro(base64Slice, jsBufferPrototypeBase64Slice, 2) \ - macro(base64urlSlice, jsBufferPrototypeBase64urlSlice, 2) \ - macro(hexSlice, jsBufferPrototypeHexSlice, 2) \ - macro(toJSON, jsBufferPrototypeToJSON, 0) \ - macro(slice, jsBufferPrototypeSlice, 2) \ - macro(parent, jsBufferPrototypeParent, 0) \ - macro(offset, jsBufferPrototypeOffset, 0) \ - -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_SETBIGUINT64 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT8 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT8 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT16LE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT16BE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT16LE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT16BE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT32LE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINT32BE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT32LE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINT32BE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINTLE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READINTBE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINTLE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_INSPECT 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READUINTBE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READFLOATLE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READFLOATBE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READDOUBLELE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READDOUBLEBE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READBIGINT64LE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READBIGINT64BE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READBIGUINT64LE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_READBIGUINT64BE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT8 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT8 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT16LE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT16BE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT16LE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT16BE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT32LE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINT32BE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT32LE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINT32BE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINTLE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEINTBE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINTLE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEUINTBE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEFLOATLE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEFLOATBE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEDOUBLELE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEDOUBLEBE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEBIGINT64LE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEBIGINT64BE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEBIGUINT64LE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_WRITEBIGUINT64BE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UTF8WRITE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UCS2WRITE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UTF16LEWRITE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_LATIN1WRITE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_ASCIIWRITE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BASE64WRITE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BASE64URLWRITE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_HEXWRITE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UTF8SLICE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UCS2SLICE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_UTF16LESLICE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_LATIN1SLICE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_ASCIISLICE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BASE64SLICE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_BASE64URLSLICE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_HEXSLICE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_TOJSON 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_SLICE 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_PARENT 1 -#define WEBCORE_BUILTIN_JSBUFFERPROTOTYPE_OFFSET 1 - -#define WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_CODE(macro) \ - macro(jsBufferPrototypeSetBigUint64Code, setBigUint64, ASCIILiteral(), s_jsBufferPrototypeSetBigUint64CodeLength) \ - macro(jsBufferPrototypeReadInt8Code, readInt8, ASCIILiteral(), s_jsBufferPrototypeReadInt8CodeLength) \ - macro(jsBufferPrototypeReadUInt8Code, readUInt8, ASCIILiteral(), s_jsBufferPrototypeReadUInt8CodeLength) \ - macro(jsBufferPrototypeReadInt16LECode, readInt16LE, ASCIILiteral(), s_jsBufferPrototypeReadInt16LECodeLength) \ - macro(jsBufferPrototypeReadInt16BECode, readInt16BE, ASCIILiteral(), s_jsBufferPrototypeReadInt16BECodeLength) \ - macro(jsBufferPrototypeReadUInt16LECode, readUInt16LE, ASCIILiteral(), s_jsBufferPrototypeReadUInt16LECodeLength) \ - macro(jsBufferPrototypeReadUInt16BECode, readUInt16BE, ASCIILiteral(), s_jsBufferPrototypeReadUInt16BECodeLength) \ - macro(jsBufferPrototypeReadInt32LECode, readInt32LE, ASCIILiteral(), s_jsBufferPrototypeReadInt32LECodeLength) \ - macro(jsBufferPrototypeReadInt32BECode, readInt32BE, ASCIILiteral(), s_jsBufferPrototypeReadInt32BECodeLength) \ - macro(jsBufferPrototypeReadUInt32LECode, readUInt32LE, ASCIILiteral(), s_jsBufferPrototypeReadUInt32LECodeLength) \ - macro(jsBufferPrototypeReadUInt32BECode, readUInt32BE, ASCIILiteral(), s_jsBufferPrototypeReadUInt32BECodeLength) \ - macro(jsBufferPrototypeReadIntLECode, readIntLE, ASCIILiteral(), s_jsBufferPrototypeReadIntLECodeLength) \ - macro(jsBufferPrototypeReadIntBECode, readIntBE, ASCIILiteral(), s_jsBufferPrototypeReadIntBECodeLength) \ - macro(jsBufferPrototypeReadUIntLECode, readUIntLE, ASCIILiteral(), s_jsBufferPrototypeReadUIntLECodeLength) \ - macro(jsBufferPrototypeInspectCode, inspect, ASCIILiteral(), s_jsBufferPrototypeInspectCodeLength) \ - macro(jsBufferPrototypeReadUIntBECode, readUIntBE, ASCIILiteral(), s_jsBufferPrototypeReadUIntBECodeLength) \ - macro(jsBufferPrototypeReadFloatLECode, readFloatLE, ASCIILiteral(), s_jsBufferPrototypeReadFloatLECodeLength) \ - macro(jsBufferPrototypeReadFloatBECode, readFloatBE, ASCIILiteral(), s_jsBufferPrototypeReadFloatBECodeLength) \ - macro(jsBufferPrototypeReadDoubleLECode, readDoubleLE, ASCIILiteral(), s_jsBufferPrototypeReadDoubleLECodeLength) \ - macro(jsBufferPrototypeReadDoubleBECode, readDoubleBE, ASCIILiteral(), s_jsBufferPrototypeReadDoubleBECodeLength) \ - macro(jsBufferPrototypeReadBigInt64LECode, readBigInt64LE, ASCIILiteral(), s_jsBufferPrototypeReadBigInt64LECodeLength) \ - macro(jsBufferPrototypeReadBigInt64BECode, readBigInt64BE, ASCIILiteral(), s_jsBufferPrototypeReadBigInt64BECodeLength) \ - macro(jsBufferPrototypeReadBigUInt64LECode, readBigUInt64LE, ASCIILiteral(), s_jsBufferPrototypeReadBigUInt64LECodeLength) \ - macro(jsBufferPrototypeReadBigUInt64BECode, readBigUInt64BE, ASCIILiteral(), s_jsBufferPrototypeReadBigUInt64BECodeLength) \ - macro(jsBufferPrototypeWriteInt8Code, writeInt8, ASCIILiteral(), s_jsBufferPrototypeWriteInt8CodeLength) \ - macro(jsBufferPrototypeWriteUInt8Code, writeUInt8, ASCIILiteral(), s_jsBufferPrototypeWriteUInt8CodeLength) \ - macro(jsBufferPrototypeWriteInt16LECode, writeInt16LE, ASCIILiteral(), s_jsBufferPrototypeWriteInt16LECodeLength) \ - macro(jsBufferPrototypeWriteInt16BECode, writeInt16BE, ASCIILiteral(), s_jsBufferPrototypeWriteInt16BECodeLength) \ - macro(jsBufferPrototypeWriteUInt16LECode, writeUInt16LE, ASCIILiteral(), s_jsBufferPrototypeWriteUInt16LECodeLength) \ - macro(jsBufferPrototypeWriteUInt16BECode, writeUInt16BE, ASCIILiteral(), s_jsBufferPrototypeWriteUInt16BECodeLength) \ - macro(jsBufferPrototypeWriteInt32LECode, writeInt32LE, ASCIILiteral(), s_jsBufferPrototypeWriteInt32LECodeLength) \ - macro(jsBufferPrototypeWriteInt32BECode, writeInt32BE, ASCIILiteral(), s_jsBufferPrototypeWriteInt32BECodeLength) \ - macro(jsBufferPrototypeWriteUInt32LECode, writeUInt32LE, ASCIILiteral(), s_jsBufferPrototypeWriteUInt32LECodeLength) \ - macro(jsBufferPrototypeWriteUInt32BECode, writeUInt32BE, ASCIILiteral(), s_jsBufferPrototypeWriteUInt32BECodeLength) \ - macro(jsBufferPrototypeWriteIntLECode, writeIntLE, ASCIILiteral(), s_jsBufferPrototypeWriteIntLECodeLength) \ - macro(jsBufferPrototypeWriteIntBECode, writeIntBE, ASCIILiteral(), s_jsBufferPrototypeWriteIntBECodeLength) \ - macro(jsBufferPrototypeWriteUIntLECode, writeUIntLE, ASCIILiteral(), s_jsBufferPrototypeWriteUIntLECodeLength) \ - macro(jsBufferPrototypeWriteUIntBECode, writeUIntBE, ASCIILiteral(), s_jsBufferPrototypeWriteUIntBECodeLength) \ - macro(jsBufferPrototypeWriteFloatLECode, writeFloatLE, ASCIILiteral(), s_jsBufferPrototypeWriteFloatLECodeLength) \ - macro(jsBufferPrototypeWriteFloatBECode, writeFloatBE, ASCIILiteral(), s_jsBufferPrototypeWriteFloatBECodeLength) \ - macro(jsBufferPrototypeWriteDoubleLECode, writeDoubleLE, ASCIILiteral(), s_jsBufferPrototypeWriteDoubleLECodeLength) \ - macro(jsBufferPrototypeWriteDoubleBECode, writeDoubleBE, ASCIILiteral(), s_jsBufferPrototypeWriteDoubleBECodeLength) \ - macro(jsBufferPrototypeWriteBigInt64LECode, writeBigInt64LE, ASCIILiteral(), s_jsBufferPrototypeWriteBigInt64LECodeLength) \ - macro(jsBufferPrototypeWriteBigInt64BECode, writeBigInt64BE, ASCIILiteral(), s_jsBufferPrototypeWriteBigInt64BECodeLength) \ - macro(jsBufferPrototypeWriteBigUInt64LECode, writeBigUInt64LE, ASCIILiteral(), s_jsBufferPrototypeWriteBigUInt64LECodeLength) \ - macro(jsBufferPrototypeWriteBigUInt64BECode, writeBigUInt64BE, ASCIILiteral(), s_jsBufferPrototypeWriteBigUInt64BECodeLength) \ - macro(jsBufferPrototypeUtf8WriteCode, utf8Write, ASCIILiteral(), s_jsBufferPrototypeUtf8WriteCodeLength) \ - macro(jsBufferPrototypeUcs2WriteCode, ucs2Write, ASCIILiteral(), s_jsBufferPrototypeUcs2WriteCodeLength) \ - macro(jsBufferPrototypeUtf16leWriteCode, utf16leWrite, ASCIILiteral(), s_jsBufferPrototypeUtf16leWriteCodeLength) \ - macro(jsBufferPrototypeLatin1WriteCode, latin1Write, ASCIILiteral(), s_jsBufferPrototypeLatin1WriteCodeLength) \ - macro(jsBufferPrototypeAsciiWriteCode, asciiWrite, ASCIILiteral(), s_jsBufferPrototypeAsciiWriteCodeLength) \ - macro(jsBufferPrototypeBase64WriteCode, base64Write, ASCIILiteral(), s_jsBufferPrototypeBase64WriteCodeLength) \ - macro(jsBufferPrototypeBase64urlWriteCode, base64urlWrite, ASCIILiteral(), s_jsBufferPrototypeBase64urlWriteCodeLength) \ - macro(jsBufferPrototypeHexWriteCode, hexWrite, ASCIILiteral(), s_jsBufferPrototypeHexWriteCodeLength) \ - macro(jsBufferPrototypeUtf8SliceCode, utf8Slice, ASCIILiteral(), s_jsBufferPrototypeUtf8SliceCodeLength) \ - macro(jsBufferPrototypeUcs2SliceCode, ucs2Slice, ASCIILiteral(), s_jsBufferPrototypeUcs2SliceCodeLength) \ - macro(jsBufferPrototypeUtf16leSliceCode, utf16leSlice, ASCIILiteral(), s_jsBufferPrototypeUtf16leSliceCodeLength) \ - macro(jsBufferPrototypeLatin1SliceCode, latin1Slice, ASCIILiteral(), s_jsBufferPrototypeLatin1SliceCodeLength) \ - macro(jsBufferPrototypeAsciiSliceCode, asciiSlice, ASCIILiteral(), s_jsBufferPrototypeAsciiSliceCodeLength) \ - macro(jsBufferPrototypeBase64SliceCode, base64Slice, ASCIILiteral(), s_jsBufferPrototypeBase64SliceCodeLength) \ - macro(jsBufferPrototypeBase64urlSliceCode, base64urlSlice, ASCIILiteral(), s_jsBufferPrototypeBase64urlSliceCodeLength) \ - macro(jsBufferPrototypeHexSliceCode, hexSlice, ASCIILiteral(), s_jsBufferPrototypeHexSliceCodeLength) \ - macro(jsBufferPrototypeToJSONCode, toJSON, ASCIILiteral(), s_jsBufferPrototypeToJSONCodeLength) \ - macro(jsBufferPrototypeSliceCode, slice, ASCIILiteral(), s_jsBufferPrototypeSliceCodeLength) \ - macro(jsBufferPrototypeParentCode, parent, "get parent"_s, s_jsBufferPrototypeParentCodeLength) \ - macro(jsBufferPrototypeOffsetCode, offset, "get offset"_s, s_jsBufferPrototypeOffsetCodeLength) \ - -#define WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_FUNCTION_NAME(macro) \ - macro(asciiSlice) \ - macro(asciiWrite) \ - macro(base64Slice) \ - macro(base64Write) \ - macro(base64urlSlice) \ - macro(base64urlWrite) \ - macro(hexSlice) \ - macro(hexWrite) \ - macro(inspect) \ - macro(latin1Slice) \ - macro(latin1Write) \ - macro(offset) \ - macro(parent) \ - macro(readBigInt64BE) \ - macro(readBigInt64LE) \ - macro(readBigUInt64BE) \ - macro(readBigUInt64LE) \ - macro(readDoubleBE) \ - macro(readDoubleLE) \ - macro(readFloatBE) \ - macro(readFloatLE) \ - macro(readInt16BE) \ - macro(readInt16LE) \ - macro(readInt32BE) \ - macro(readInt32LE) \ - macro(readInt8) \ - macro(readIntBE) \ - macro(readIntLE) \ - macro(readUInt16BE) \ - macro(readUInt16LE) \ - macro(readUInt32BE) \ - macro(readUInt32LE) \ - macro(readUInt8) \ - macro(readUIntBE) \ - macro(readUIntLE) \ - macro(setBigUint64) \ - macro(slice) \ - macro(toJSON) \ - macro(ucs2Slice) \ - macro(ucs2Write) \ - macro(utf16leSlice) \ - macro(utf16leWrite) \ - macro(utf8Slice) \ - macro(utf8Write) \ - macro(writeBigInt64BE) \ - macro(writeBigInt64LE) \ - macro(writeBigUInt64BE) \ - macro(writeBigUInt64LE) \ - macro(writeDoubleBE) \ - macro(writeDoubleLE) \ - macro(writeFloatBE) \ - macro(writeFloatLE) \ - macro(writeInt16BE) \ - macro(writeInt16LE) \ - macro(writeInt32BE) \ - macro(writeInt32LE) \ - macro(writeInt8) \ - macro(writeIntBE) \ - macro(writeIntLE) \ - macro(writeUInt16BE) \ - macro(writeUInt16LE) \ - macro(writeUInt32BE) \ - macro(writeUInt32LE) \ - macro(writeUInt8) \ - macro(writeUIntBE) \ - macro(writeUIntLE) \ - -#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ - JSC::FunctionExecutable* codeName##Generator(JSC::VM&); - -WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) -#undef DECLARE_BUILTIN_GENERATOR - -class JSBufferPrototypeBuiltinsWrapper : private JSC::WeakHandleOwner { -public: - explicit JSBufferPrototypeBuiltinsWrapper(JSC::VM& vm) - : m_vm(vm) - WEBCORE_FOREACH_JSBUFFERPROTOTYPE_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_JSBUFFERPROTOTYPE_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_JSBUFFERPROTOTYPE_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) -#undef EXPOSE_BUILTIN_EXECUTABLES - - WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) - - void exportNames(); - -private: - JSC::VM& m_vm; - - WEBCORE_FOREACH_JSBUFFERPROTOTYPE_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_JSBUFFERPROTOTYPE_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) -#undef DECLARE_BUILTIN_SOURCE_MEMBERS - -}; - -#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ -inline JSC::UnlinkedFunctionExecutable* JSBufferPrototypeBuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ - }\ - return m_##name##Executable.get();\ -} -WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) -#undef DEFINE_BUILTIN_EXECUTABLES - -inline void JSBufferPrototypeBuiltinsWrapper::exportNames() -{ -#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); - WEBCORE_FOREACH_JSBUFFERPROTOTYPE_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) -#undef EXPORT_FUNCTION_NAME -} - -} // namespace WebCore diff --git a/src/bun.js/builtins/cpp/ProcessObjectInternalsBuiltins.cpp b/src/bun.js/builtins/cpp/ProcessObjectInternalsBuiltins.cpp deleted file mode 100644 index ecd86f811..000000000 --- a/src/bun.js/builtins/cpp/ProcessObjectInternalsBuiltins.cpp +++ /dev/null @@ -1,737 +0,0 @@ -/* - * 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) 2023 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 "ProcessObjectInternalsBuiltins.h" - -#include "WebCoreJSClientData.h" -#include <JavaScriptCore/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_processObjectInternalsBindingCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_processObjectInternalsBindingCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_processObjectInternalsBindingCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_processObjectInternalsBindingCodeLength = 709; -static const JSC::Intrinsic s_processObjectInternalsBindingCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsBindingCode = - "(function (bindingName) {\n" \ - " \"use strict\";\n" \ - " bindingName !== \"constants\" &&\n" \ - " @throwTypeError(\n" \ - " 'process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.'\n" \ - " );\n" \ - "\n" \ - " var cache = globalThis.Symbol.for(\"process.bindings.constants\");\n" \ - " var constants = globalThis[cache];\n" \ - " if (!constants) {\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " const {constants: fs} = globalThis[globalThis.Symbol.for(\"Bun.lazy\")](\n" \ - " \"createImportMeta\",\n" \ - " \"node:process\"\n" \ - " ).require(\n" \ - " \"node:fs\"\n" \ - " )\n" \ - " constants = {\n" \ - " fs,\n" \ - " zlib: {},\n" \ - " crypto: {},\n" \ - " os: @Bun._Os().constants,\n" \ - " };\n" \ - " globalThis[cache] = constants;\n" \ - " }\n" \ - " return constants;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_processObjectInternalsGetStdioWriteStreamCodeLength = 10295; -static const JSC::Intrinsic s_processObjectInternalsGetStdioWriteStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdioWriteStreamCode = - "(function (fd_, rawRequire) {\n" \ - " var module = { path: \"node:process\", require: rawRequire };\n" \ - " var require = path => module.require(path);\n" \ - "\n" \ - " function createStdioWriteStream(fd_) {\n" \ - " var { Duplex, eos, destroy } = require(\"node:stream\");\n" \ - " var StdioWriteStream = class StdioWriteStream extends Duplex {\n" \ - " #writeStream;\n" \ - " #readStream;\n" \ - "\n" \ - " #readable = true;\n" \ - " #writable = true;\n" \ - " #fdPath;\n" \ - "\n" \ - " #onClose;\n" \ - " #onDrain;\n" \ - " #onFinish;\n" \ - " #onReadable;\n" \ - " #isTTY;\n" \ - "\n" \ - " get isTTY() {\n" \ - " return (this.#isTTY ??= require(\"node:tty\").isatty(fd_));\n" \ - " }\n" \ - "\n" \ - " get fd() {\n" \ - " return fd_;\n" \ - " }\n" \ - "\n" \ - " constructor(fd) {\n" \ - " super({ readable: true, writable: true });\n" \ - " this.#fdPath = `/dev/fd/${fd}`;\n" \ - " }\n" \ - "\n" \ - " #onFinished(err) {\n" \ - " const cb = this.#onClose;\n" \ - " this.#onClose = null;\n" \ - "\n" \ - " if (cb) {\n" \ - " cb(err);\n" \ - " } else if (err) {\n" \ - " this.destroy(err);\n" \ - " } else if (!this.#readable && !this.#writable) {\n" \ - " this.destroy();\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " _destroy(err, callback) {\n" \ - " if (!err && this.#onClose !== null) {\n" \ - " var AbortError = class AbortError extends Error {\n" \ - " constructor(message = \"The operation was aborted\", options = void 0) {\n" \ - " if (options !== void 0 && typeof options !== \"object\") {\n" \ - " throw new Error(`Invalid AbortError options:\\n" \ - "\\n" \ - "${JSON.stringify(options, null, 2)}`);\n" \ - " }\n" \ - " super(message, options);\n" \ - " this.code = \"ABORT_ERR\";\n" \ - " this.name = \"AbortError\";\n" \ - " }\n" \ - " };\n" \ - " err = new AbortError();\n" \ - " }\n" \ - "\n" \ - " this.#onDrain = null;\n" \ - " this.#onFinish = null;\n" \ - " if (this.#onClose === null) {\n" \ - " callback(err);\n" \ - " } else {\n" \ - " this.#onClose = callback;\n" \ - " if (this.#writeStream) destroy(this.#writeStream, err);\n" \ - " if (this.#readStream) destroy(this.#readStream, err);\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " _write(chunk, encoding, callback) {\n" \ - " if (!this.#writeStream) {\n" \ - " var { createWriteStream } = require(\"node:fs\");\n" \ - " var stream = (this.#writeStream = createWriteStream(this.#fdPath));\n" \ - "\n" \ - " stream.on(\"finish\", () => {\n" \ - " if (this.#onFinish) {\n" \ - " const cb = this.#onFinish;\n" \ - " this.#onFinish = null;\n" \ - " cb();\n" \ - " }\n" \ - " });\n" \ - "\n" \ - " stream.on(\"drain\", () => {\n" \ - " if (this.#onDrain) {\n" \ - " const cb = this.#onDrain;\n" \ - " this.#onDrain = null;\n" \ - " cb();\n" \ - " }\n" \ - " });\n" \ - "\n" \ - " eos(stream, err => {\n" \ - " this.#writable = false;\n" \ - " if (err) {\n" \ - " destroy(stream, err);\n" \ - " }\n" \ - " this.#onFinished(err);\n" \ - " });\n" \ - " }\n" \ - " if (stream.write(chunk, encoding)) {\n" \ - " callback();\n" \ - " } else {\n" \ - " this.#onDrain = callback;\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " _final(callback) {\n" \ - " this.#writeStream && this.#writeStream.end();\n" \ - " this.#onFinish = callback;\n" \ - " }\n" \ - "\n" \ - " #loadReadStream() {\n" \ - " var { createReadStream } = require(\"node:fs\");\n" \ - "\n" \ - " var readStream = (this.#readStream = createReadStream(this.#fdPath));\n" \ - "\n" \ - " readStream.on(\"readable\", () => {\n" \ - " if (this.#onReadable) {\n" \ - " const cb = this.#onReadable;\n" \ - " this.#onReadable = null;\n" \ - " cb();\n" \ - " } else {\n" \ - " this.read();\n" \ - " }\n" \ - " });\n" \ - "\n" \ - " readStream.on(\"end\", () => {\n" \ - " this.push(null);\n" \ - " });\n" \ - "\n" \ - " eos(readStream, err => {\n" \ - " this.#readable = false;\n" \ - " if (err) {\n" \ - " destroy(readStream, err);\n" \ - " }\n" \ - " this.#onFinished(err);\n" \ - " });\n" \ - " return readStream;\n" \ - " }\n" \ - "\n" \ - " _read() {\n" \ - " var stream = this.#readStream;\n" \ - " if (!stream) {\n" \ - " stream = this.#loadReadStream();\n" \ - " }\n" \ - "\n" \ - " while (true) {\n" \ - " const buf = stream.read();\n" \ - " if (buf === null || !this.push(buf)) {\n" \ - " return;\n" \ - " }\n" \ - " }\n" \ - " }\n" \ - " };\n" \ - " return new StdioWriteStream(fd_);\n" \ - " }\n" \ - "\n" \ - " var { EventEmitter } = require(\"node:events\");\n" \ - "\n" \ - " function isFastEncoding(encoding) {\n" \ - " if (!encoding) return true;\n" \ - "\n" \ - " var normalied = encoding.toLowerCase();\n" \ - " return normalied === \"utf8\" || normalied === \"utf-8\" || normalied === \"buffer\" || normalied === \"binary\";\n" \ - " }\n" \ - "\n" \ - " var readline;\n" \ - "\n" \ - " var FastStdioWriteStream = class StdioWriteStream extends EventEmitter {\n" \ - " #fd;\n" \ - " #innerStream;\n" \ - " #writer;\n" \ - " #isTTY;\n" \ - "\n" \ - " bytesWritten = 0;\n" \ - "\n" \ - " setDefaultEncoding(encoding) {\n" \ - " if (this.#innerStream || !isFastEncoding(encoding)) {\n" \ - " this.#ensureInnerStream();\n" \ - " return this.#innerStream.setDefaultEncoding(encoding);\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " #createWriter() {\n" \ - " switch (this.#fd) {\n" \ - " case 1: {\n" \ - " var writer = Bun.stdout.writer({ highWaterMark: 0 });\n" \ - " writer.unref();\n" \ - " return writer;\n" \ - " }\n" \ - "\n" \ - " case 2: {\n" \ - " var writer = Bun.stderr.writer({ highWaterMark: 0 });\n" \ - " writer.unref();\n" \ - " return writer;\n" \ - " }\n" \ - " default: {\n" \ - " throw new Error(\"Unsupported writer\");\n" \ - " }\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " #getWriter() {\n" \ - " return (this.#writer ??= this.#createWriter());\n" \ - " }\n" \ - "\n" \ - " constructor(fd_) {\n" \ - " super();\n" \ - " this.#fd = fd_;\n" \ - " }\n" \ - "\n" \ - " get fd() {\n" \ - " return this.#fd;\n" \ - " }\n" \ - "\n" \ - " get isTTY() {\n" \ - " return (this.#isTTY ??= require(\"node:tty\").isatty(this.#fd));\n" \ - " }\n" \ - "\n" \ - " cursorTo(x, y, callback) {\n" \ - " return (readline ??= require(\"readline\")).cursorTo(this, x, y, callback);\n" \ - " }\n" \ - "\n" \ - " moveCursor(dx, dy, callback) {\n" \ - " return (readline ??= require(\"readline\")).moveCursor(this, dx, dy, callback);\n" \ - " }\n" \ - "\n" \ - " clearLine(dir, callback) {\n" \ - " return (readline ??= require(\"readline\")).clearLine(this, dir, callback);\n" \ - " }\n" \ - "\n" \ - " clearScreenDown(callback) {\n" \ - " return (readline ??= require(\"readline\")).clearScreenDown(this, callback);\n" \ - " }\n" \ - "\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - "\n" \ - " ref() {\n" \ - " this.#getWriter().ref();\n" \ - " }\n" \ - "\n" \ - " unref() {\n" \ - " this.#getWriter().unref();\n" \ - " }\n" \ - "\n" \ - " on(event, listener) {\n" \ - " if (event === \"close\" || event === \"finish\") {\n" \ - " this.#ensureInnerStream();\n" \ - " return this.#innerStream.on(event, listener);\n" \ - " }\n" \ - "\n" \ - " if (event === \"drain\") {\n" \ - " return super.on(\"drain\", listener);\n" \ - " }\n" \ - "\n" \ - " if (event === \"error\") {\n" \ - " return super.on(\"error\", listener);\n" \ - " }\n" \ - "\n" \ - " return super.on(event, listener);\n" \ - " }\n" \ - "\n" \ - " get _writableState() {\n" \ - " this.#ensureInnerStream();\n" \ - " return this.#innerStream._writableState;\n" \ - " }\n" \ - "\n" \ - " get _readableState() {\n" \ - " this.#ensureInnerStream();\n" \ - " return this.#innerStream._readableState;\n" \ - " }\n" \ - "\n" \ - " pipe(destination) {\n" \ - " this.#ensureInnerStream();\n" \ - " return this.#innerStream.pipe(destination);\n" \ - " }\n" \ - "\n" \ - " unpipe(destination) {\n" \ - " this.#ensureInnerStream();\n" \ - " return this.#innerStream.unpipe(destination);\n" \ - " }\n" \ - "\n" \ - " #ensureInnerStream() {\n" \ - " if (this.#innerStream) return;\n" \ - " this.#innerStream = createStdioWriteStream(this.#fd);\n" \ - " const events = this.eventNames();\n" \ - " for (const event of events) {\n" \ - " this.#innerStream.on(event, (...args) => {\n" \ - " this.emit(event, ...args);\n" \ - " });\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " #write1(chunk) {\n" \ - " var writer = this.#getWriter();\n" \ - " const writeResult = writer.write(chunk);\n" \ - " this.bytesWritten += writeResult;\n" \ - " const flushResult = writer.flush(false);\n" \ - " return !!(writeResult || flushResult);\n" \ - " }\n" \ - "\n" \ - " #writeWithEncoding(chunk, encoding) {\n" \ - " if (!isFastEncoding(encoding)) {\n" \ - " this.#ensureInnerStream();\n" \ - " return this.#innerStream.write(chunk, encoding);\n" \ - " }\n" \ - "\n" \ - " return this.#write1(chunk);\n" \ - " }\n" \ - "\n" \ - " #performCallback(cb, err) {\n" \ - " if (err) {\n" \ - " this.emit(\"error\", err);\n" \ - " }\n" \ - "\n" \ - " try {\n" \ - " cb(err ? err : null);\n" \ - " } catch (err2) {\n" \ - " this.emit(\"error\", err2);\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " #writeWithCallbackAndEncoding(chunk, encoding, callback) {\n" \ - " if (!isFastEncoding(encoding)) {\n" \ - " this.#ensureInnerStream();\n" \ - " return this.#innerStream.write(chunk, encoding, callback);\n" \ - " }\n" \ - "\n" \ - " var writer = this.#getWriter();\n" \ - " const writeResult = writer.write(chunk);\n" \ - " const flushResult = writer.flush(true);\n" \ - " if (flushResult?.then) {\n" \ - " flushResult.then(\n" \ - " () => {\n" \ - " this.#performCallback(callback);\n" \ - " this.emit(\"drain\");\n" \ - " },\n" \ - " err => this.#performCallback(callback, err),\n" \ - " );\n" \ - " return false;\n" \ - " }\n" \ - "\n" \ - " queueMicrotask(() => {\n" \ - " this.#performCallback(callback);\n" \ - " });\n" \ - "\n" \ - " return !!(writeResult || flushResult);\n" \ - " }\n" \ - "\n" \ - " write(chunk, encoding, callback) {\n" \ - " const result = this._write(chunk, encoding, callback);\n" \ - "\n" \ - " if (result) {\n" \ - " this.emit(\"drain\");\n" \ - " }\n" \ - "\n" \ - " return result;\n" \ - " }\n" \ - "\n" \ - " get hasColors() {\n" \ - " return Bun.tty[this.#fd].hasColors;\n" \ - " }\n" \ - "\n" \ - " _write(chunk, encoding, callback) {\n" \ - " var inner = this.#innerStream;\n" \ - " if (inner) {\n" \ - " return inner.write(chunk, encoding, callback);\n" \ - " }\n" \ - "\n" \ - " switch (arguments.length) {\n" \ - " case 0: {\n" \ - " var error = new Error(\"Invalid arguments\");\n" \ - " error.code = \"ERR_INVALID_ARG_TYPE\";\n" \ - " throw error;\n" \ - " }\n" \ - " case 1: {\n" \ - " return this.#write1(chunk);\n" \ - " }\n" \ - " case 2: {\n" \ - " if (typeof encoding === \"function\") {\n" \ - " return this.#writeWithCallbackAndEncoding(chunk, \"\", encoding);\n" \ - " } else if (typeof encoding === \"string\") {\n" \ - " return this.#writeWithEncoding(chunk, encoding);\n" \ - " }\n" \ - " }\n" \ - " default: {\n" \ - " if (\n" \ - " (typeof encoding !== \"undefined\" && typeof encoding !== \"string\") ||\n" \ - " (typeof callback !== \"undefined\" && typeof callback !== \"function\")\n" \ - " ) {\n" \ - " var error = new Error(\"Invalid arguments\");\n" \ - " error.code = \"ERR_INVALID_ARG_TYPE\";\n" \ - " throw error;\n" \ - " }\n" \ - "\n" \ - " if (typeof callback === \"undefined\") {\n" \ - " return this.#writeWithEncoding(chunk, encoding);\n" \ - " }\n" \ - "\n" \ - " return this.#writeWithCallbackAndEncoding(chunk, encoding, callback);\n" \ - " }\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " destroy() {\n" \ - " return this;\n" \ - " }\n" \ - "\n" \ - " end() {\n" \ - " return this;\n" \ - " }\n" \ - " };\n" \ - "\n" \ - " return new FastStdioWriteStream(fd_);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_processObjectInternalsGetStdinStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_processObjectInternalsGetStdinStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_processObjectInternalsGetStdinStreamCodeLength = 4305; -static const JSC::Intrinsic s_processObjectInternalsGetStdinStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_processObjectInternalsGetStdinStreamCode = - "(function (fd_, rawRequire, Bun) {\n" \ - " var module = { path: \"node:process\", require: rawRequire };\n" \ - " var require = path => module.require(path);\n" \ - "\n" \ - " var { Duplex, eos, destroy } = require(\"node:stream\");\n" \ - "\n" \ - " var StdinStream = class StdinStream extends Duplex {\n" \ - " #reader;\n" \ - " //\n" \ - "\n" \ - " #readRef;\n" \ - " #writeStream;\n" \ - "\n" \ - " #readable = true;\n" \ - " #unrefOnRead = false;\n" \ - " #writable = true;\n" \ - "\n" \ - " #onFinish;\n" \ - " #onClose;\n" \ - " #onDrain;\n" \ - "\n" \ - " get isTTY() {\n" \ - " return require(\"tty\").isatty(fd_);\n" \ - " }\n" \ - "\n" \ - " get fd() {\n" \ - " return fd_;\n" \ - " }\n" \ - "\n" \ - " constructor() {\n" \ - " super({ readable: true, writable: true });\n" \ - " }\n" \ - "\n" \ - " #onFinished(err) {\n" \ - " const cb = this.#onClose;\n" \ - " this.#onClose = null;\n" \ - "\n" \ - " if (cb) {\n" \ - " cb(err);\n" \ - " } else if (err) {\n" \ - " this.destroy(err);\n" \ - " } else if (!this.#readable && !this.#writable) {\n" \ - " this.destroy();\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " _destroy(err, callback) {\n" \ - " if (!err && this.#onClose !== null) {\n" \ - " var AbortError = class AbortError extends Error {\n" \ - " constructor(message = \"The operation was aborted\", options = void 0) {\n" \ - " if (options !== void 0 && typeof options !== \"object\") {\n" \ - " throw new Error(`Invalid AbortError options:\\n" \ - "\\n" \ - "${JSON.stringify(options, null, 2)}`);\n" \ - " }\n" \ - " super(message, options);\n" \ - " this.code = \"ABORT_ERR\";\n" \ - " this.name = \"AbortError\";\n" \ - " }\n" \ - " };\n" \ - " err = new AbortError();\n" \ - " }\n" \ - "\n" \ - " if (this.#onClose === null) {\n" \ - " callback(err);\n" \ - " } else {\n" \ - " this.#onClose = callback;\n" \ - " if (this.#writeStream) destroy(this.#writeStream, err);\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " setRawMode(mode) {}\n" \ - " on(name, callback) {\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " if (name === \"readable\") {\n" \ - " this.ref();\n" \ - " this.#unrefOnRead = true;\n" \ - " }\n" \ - " return super.on(name, callback);\n" \ - " }\n" \ - "\n" \ - " pause() {\n" \ - " this.unref();\n" \ - " return super.pause();\n" \ - " }\n" \ - "\n" \ - " resume() {\n" \ - " this.ref();\n" \ - " return super.resume();\n" \ - " }\n" \ - "\n" \ - " ref() {\n" \ - " this.#reader ??= Bun.stdin.stream().getReader();\n" \ - " this.#readRef ??= setInterval(() => {}, 1 << 30);\n" \ - " }\n" \ - "\n" \ - " unref() {\n" \ - " if (this.#readRef) {\n" \ - " clearInterval(this.#readRef);\n" \ - " this.#readRef = null;\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " async #readInternal() {\n" \ - " try {\n" \ - " var done, value;\n" \ - " const read = this.#reader.readMany();\n" \ - "\n" \ - " //\n" \ - " if (!read?.then) {\n" \ - " ({ done, value } = read);\n" \ - " } else {\n" \ - " ({ done, value } = await read);\n" \ - " }\n" \ - "\n" \ - " if (!done) {\n" \ - " this.push(value[0]);\n" \ - "\n" \ - " //\n" \ - " const length = value.length;\n" \ - " for (let i = 1; i < length; i++) {\n" \ - " this.push(value[i]);\n" \ - " }\n" \ - " } else {\n" \ - " this.push(null);\n" \ - " this.pause();\n" \ - " this.#readable = false;\n" \ - " this.#onFinished();\n" \ - " }\n" \ - " } catch (err) {\n" \ - " this.#readable = false;\n" \ - " this.#onFinished(err);\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " _read(size) {\n" \ - " if (this.#unrefOnRead) {\n" \ - " this.unref();\n" \ - " this.#unrefOnRead = false;\n" \ - " }\n" \ - " this.#readInternal();\n" \ - " }\n" \ - "\n" \ - " #constructWriteStream() {\n" \ - " var { createWriteStream } = require(\"node:fs\");\n" \ - " var writeStream = (this.#writeStream = createWriteStream(\"/dev/fd/0\"));\n" \ - "\n" \ - " writeStream.on(\"finish\", () => {\n" \ - " if (this.#onFinish) {\n" \ - " const cb = this.#onFinish;\n" \ - " this.#onFinish = null;\n" \ - " cb();\n" \ - " }\n" \ - " });\n" \ - "\n" \ - " writeStream.on(\"drain\", () => {\n" \ - " if (this.#onDrain) {\n" \ - " const cb = this.#onDrain;\n" \ - " this.#onDrain = null;\n" \ - " cb();\n" \ - " }\n" \ - " });\n" \ - "\n" \ - " eos(writeStream, err => {\n" \ - " this.#writable = false;\n" \ - " if (err) {\n" \ - " destroy(writeStream, err);\n" \ - " }\n" \ - " this.#onFinished(err);\n" \ - " });\n" \ - "\n" \ - " return writeStream;\n" \ - " }\n" \ - "\n" \ - " _write(chunk, encoding, callback) {\n" \ - " var writeStream = this.#writeStream;\n" \ - " if (!writeStream) {\n" \ - " writeStream = this.#constructWriteStream();\n" \ - " }\n" \ - "\n" \ - " if (writeStream.write(chunk, encoding)) {\n" \ - " callback();\n" \ - " } else {\n" \ - " this.#onDrain = callback;\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " _final(callback) {\n" \ - " this.#writeStream.end();\n" \ - " this.#onFinish = (...args) => callback(...args);\n" \ - " }\n" \ - " };\n" \ - "\n" \ - " return new StdinStream();\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().processObjectInternalsBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().processObjectInternalsBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ -} -WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) -#undef DEFINE_BUILTIN_GENERATOR - - -} // namespace WebCore diff --git a/src/bun.js/builtins/cpp/ProcessObjectInternalsBuiltins.h b/src/bun.js/builtins/cpp/ProcessObjectInternalsBuiltins.h deleted file mode 100644 index 4fcdb4810..000000000 --- a/src/bun.js/builtins/cpp/ProcessObjectInternalsBuiltins.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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) 2023 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 { - -/* ProcessObjectInternals */ -extern const char* const s_processObjectInternalsBindingCode; -extern const int s_processObjectInternalsBindingCodeLength; -extern const JSC::ConstructAbility s_processObjectInternalsBindingCodeConstructAbility; -extern const JSC::ConstructorKind s_processObjectInternalsBindingCodeConstructorKind; -extern const JSC::ImplementationVisibility s_processObjectInternalsBindingCodeImplementationVisibility; -extern const char* const s_processObjectInternalsGetStdioWriteStreamCode; -extern const int s_processObjectInternalsGetStdioWriteStreamCodeLength; -extern const JSC::ConstructAbility s_processObjectInternalsGetStdioWriteStreamCodeConstructAbility; -extern const JSC::ConstructorKind s_processObjectInternalsGetStdioWriteStreamCodeConstructorKind; -extern const JSC::ImplementationVisibility s_processObjectInternalsGetStdioWriteStreamCodeImplementationVisibility; -extern const char* const s_processObjectInternalsGetStdinStreamCode; -extern const int s_processObjectInternalsGetStdinStreamCodeLength; -extern const JSC::ConstructAbility s_processObjectInternalsGetStdinStreamCodeConstructAbility; -extern const JSC::ConstructorKind s_processObjectInternalsGetStdinStreamCodeConstructorKind; -extern const JSC::ImplementationVisibility s_processObjectInternalsGetStdinStreamCodeImplementationVisibility; - -#define WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_DATA(macro) \ - macro(binding, processObjectInternalsBinding, 1) \ - macro(getStdioWriteStream, processObjectInternalsGetStdioWriteStream, 2) \ - macro(getStdinStream, processObjectInternalsGetStdinStream, 3) \ - -#define WEBCORE_BUILTIN_PROCESSOBJECTINTERNALS_BINDING 1 -#define WEBCORE_BUILTIN_PROCESSOBJECTINTERNALS_GETSTDIOWRITESTREAM 1 -#define WEBCORE_BUILTIN_PROCESSOBJECTINTERNALS_GETSTDINSTREAM 1 - -#define WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_CODE(macro) \ - macro(processObjectInternalsBindingCode, binding, ASCIILiteral(), s_processObjectInternalsBindingCodeLength) \ - macro(processObjectInternalsGetStdioWriteStreamCode, getStdioWriteStream, ASCIILiteral(), s_processObjectInternalsGetStdioWriteStreamCodeLength) \ - macro(processObjectInternalsGetStdinStreamCode, getStdinStream, ASCIILiteral(), s_processObjectInternalsGetStdinStreamCodeLength) \ - -#define WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_FUNCTION_NAME(macro) \ - macro(binding) \ - macro(getStdinStream) \ - macro(getStdioWriteStream) \ - -#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ - JSC::FunctionExecutable* codeName##Generator(JSC::VM&); - -WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) -#undef DECLARE_BUILTIN_GENERATOR - -class ProcessObjectInternalsBuiltinsWrapper : private JSC::WeakHandleOwner { -public: - explicit ProcessObjectInternalsBuiltinsWrapper(JSC::VM& vm) - : m_vm(vm) - WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_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_PROCESSOBJECTINTERNALS_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_PROCESSOBJECTINTERNALS_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) -#undef EXPOSE_BUILTIN_EXECUTABLES - - WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) - - void exportNames(); - -private: - JSC::VM& m_vm; - - WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_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_PROCESSOBJECTINTERNALS_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) -#undef DECLARE_BUILTIN_SOURCE_MEMBERS - -}; - -#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ -inline JSC::UnlinkedFunctionExecutable* ProcessObjectInternalsBuiltinsWrapper::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##ImplementationVisibility, s_##name##ConstructorKind, s_##name##ConstructAbility), this, &m_##name##Executable);\ - }\ - return m_##name##Executable.get();\ -} -WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) -#undef DEFINE_BUILTIN_EXECUTABLES - -inline void ProcessObjectInternalsBuiltinsWrapper::exportNames() -{ -#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); - WEBCORE_FOREACH_PROCESSOBJECTINTERNALS_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) -#undef EXPORT_FUNCTION_NAME -} - -} // namespace WebCore diff --git a/src/bun.js/builtins/cpp/ReadableByteStreamControllerBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableByteStreamControllerBuiltins.cpp deleted file mode 100644 index 9f431a8d0..000000000 --- a/src/bun.js/builtins/cpp/ReadableByteStreamControllerBuiltins.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamControllerCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamControllerByobRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/ReadableByteStreamControllerBuiltins.h b/src/bun.js/builtins/cpp/ReadableByteStreamControllerBuiltins.h deleted file mode 100644 index 20083abbb..000000000 --- a/src/bun.js/builtins/cpp/ReadableByteStreamControllerBuiltins.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_readableByteStreamControllerInitializeReadableByteStreamControllerCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamControllerEnqueueCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamControllerErrorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamControllerCloseCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamControllerByobRequestCodeImplementationVisibility; -extern const char* const s_readableByteStreamControllerDesiredSizeCode; -extern const int s_readableByteStreamControllerDesiredSizeCodeLength; -extern const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility; -extern const JSC::ConstructorKind s_readableByteStreamControllerDesiredSizeCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableByteStreamControllerDesiredSizeCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/ReadableByteStreamInternalsBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableByteStreamInternalsBuiltins.cpp deleted file mode 100644 index 5d7e20a5c..000000000 --- a/src/bun.js/builtins/cpp/ReadableByteStreamInternalsBuiltins.cpp +++ /dev/null @@ -1,992 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeLength = 2365; -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\", 0);\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" \ - "\n" \ - " const controller = this;\n" \ - " @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(controller, \"underlyingByteSource\"), \"start\", [controller]).@then(() => {\n" \ - " @putByIdDirectPrivate(controller, \"started\", 1);\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_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeLength = 107; -static const JSC::Intrinsic s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCode = - "(function (controller) {\n" \ - " \"use strict\";\n" \ - " @putByIdDirectPrivate(controller, \"start\", @undefined);\n" \ - "\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsIsReadableByteStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableByteStreamInternalsReadableByteStreamControllerPullCodeLength = 1610; -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" \ - " if (@getByIdDirectPrivate(controller, \"queue\").content?.isNotEmpty()) {\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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeLength = 879; -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\") > 0))\n" \ - " return false;\n" \ - " const reader = @getByIdDirectPrivate(stream, \"reader\");\n" \ - " \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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamReaderKindCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/ReadableByteStreamInternalsBuiltins.h b/src/bun.js/builtins/cpp/ReadableByteStreamInternalsBuiltins.h deleted file mode 100644 index aa140d53e..000000000 --- a/src/bun.js/builtins/cpp/ReadableByteStreamInternalsBuiltins.h +++ /dev/null @@ -1,480 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCodeImplementationVisibility; -extern const char* const s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCode; -extern const int s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeLength; -extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility; -extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsPrivateInitializeReadableStreamBYOBRequestCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsIsReadableByteStreamControllerCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsIsReadableStreamBYOBRequestCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsIsReadableStreamBYOBReaderCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCancelCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCloseCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamHasDefaultReaderCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsTransferBufferToCurrentRealmCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamReaderKindCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerProcessPullDescriptorsCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerInvalidateBYOBRequestCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerCommitDescriptorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerConvertDescriptorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeImplementationVisibility; -extern const char* const s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCode; -extern const int s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeLength; -extern const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility; -extern const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeImplementationVisibility; - -#define WEBCORE_FOREACH_READABLEBYTESTREAMINTERNALS_BUILTIN_DATA(macro) \ - macro(privateInitializeReadableByteStreamController, readableByteStreamInternalsPrivateInitializeReadableByteStreamController, 3) \ - macro(readableStreamByteStreamControllerStart, readableByteStreamInternalsReadableStreamByteStreamControllerStart, 1) \ - 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_READABLESTREAMBYTESTREAMCONTROLLERSTART 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(readableByteStreamInternalsReadableStreamByteStreamControllerStartCode, readableStreamByteStreamControllerStart, ASCIILiteral(), s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeLength) \ - 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(readableStreamByteStreamControllerStart) \ - 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##ImplementationVisibility, 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/bun.js/builtins/cpp/ReadableStreamBYOBReaderBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamBYOBReaderBuiltins.cpp deleted file mode 100644 index 04264fc40..000000000 --- a/src/bun.js/builtins/cpp/ReadableStreamBYOBReaderBuiltins.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamBYOBReaderCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamBYOBReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamBYOBReaderReleaseLockCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamBYOBReaderClosedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/ReadableStreamBYOBReaderBuiltins.h b/src/bun.js/builtins/cpp/ReadableStreamBYOBReaderBuiltins.h deleted file mode 100644 index 54f1985c7..000000000 --- a/src/bun.js/builtins/cpp/ReadableStreamBYOBReaderBuiltins.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamBYOBReaderCancelCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamBYOBReaderReadCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamBYOBReaderReleaseLockCodeImplementationVisibility; -extern const char* const s_readableStreamBYOBReaderClosedCode; -extern const int s_readableStreamBYOBReaderClosedCodeLength; -extern const JSC::ConstructAbility s_readableStreamBYOBReaderClosedCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamBYOBReaderClosedCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamBYOBReaderClosedCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/ReadableStreamBYOBRequestBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamBYOBRequestBuiltins.cpp deleted file mode 100644 index 7c67a3443..000000000 --- a/src/bun.js/builtins/cpp/ReadableStreamBYOBRequestBuiltins.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamBYOBRequestRespondCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamBYOBRequestRespondWithNewViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamBYOBRequestViewCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/ReadableStreamBYOBRequestBuiltins.h b/src/bun.js/builtins/cpp/ReadableStreamBYOBRequestBuiltins.h deleted file mode 100644 index 497a17bb0..000000000 --- a/src/bun.js/builtins/cpp/ReadableStreamBYOBRequestBuiltins.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_readableStreamBYOBRequestInitializeReadableStreamBYOBRequestCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamBYOBRequestRespondCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamBYOBRequestRespondWithNewViewCodeImplementationVisibility; -extern const char* const s_readableStreamBYOBRequestViewCode; -extern const int s_readableStreamBYOBRequestViewCodeLength; -extern const JSC::ConstructAbility s_readableStreamBYOBRequestViewCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamBYOBRequestViewCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamBYOBRequestViewCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp deleted file mode 100644 index 21c099c56..000000000 --- a/src/bun.js/builtins/cpp/ReadableStreamBuiltins.cpp +++ /dev/null @@ -1,601 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_readableStreamInitializeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInitializeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInitializeReadableStreamCodeLength = 3256; -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 = { @bunNativeType: 0, @bunNativePtr: 0, @lazy: false };\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" \ - " //\n" \ - " @putByIdDirectPrivate(this, \"readableStreamController\", null);\n" \ - " @putByIdDirectPrivate(this, \"bunNativeType\", @getByIdDirectPrivate(underlyingSource, \"bunNativeType\") ?? 0);\n" \ - " @putByIdDirectPrivate(this, \"bunNativePtr\", @getByIdDirectPrivate(underlyingSource, \"bunNativePtr\") ?? 0);\n" \ - "\n" \ - " const isDirect = underlyingSource.type === \"direct\";\n" \ - " //\n" \ - " const isUnderlyingSourceLazy = !!underlyingSource.@lazy;\n" \ - " const isLazy = isDirect || isUnderlyingSourceLazy;\n" \ - " \n" \ - " //\n" \ - " //\n" \ - " if (@getByIdDirectPrivate(underlyingSource, \"pull\") !== @undefined && !isLazy) {\n" \ - " const size = @getByIdDirectPrivate(strategy, \"size\");\n" \ - " const highWaterMark = @getByIdDirectPrivate(strategy, \"highWaterMark\");\n" \ - " @putByIdDirectPrivate(this, \"highWaterMark\", highWaterMark);\n" \ - " @putByIdDirectPrivate(this, \"underlyingSource\", @undefined);\n" \ - " @setupReadableStreamDefaultController(this, underlyingSource, size, highWaterMark !== @undefined ? highWaterMark : 1, @getByIdDirectPrivate(underlyingSource, \"start\"), @getByIdDirectPrivate(underlyingSource, \"pull\"), @getByIdDirectPrivate(underlyingSource, \"cancel\"));\n" \ - " \n" \ - " return this;\n" \ - " }\n" \ - " if (isDirect) {\n" \ - " @putByIdDirectPrivate(this, \"underlyingSource\", underlyingSource);\n" \ - " @putByIdDirectPrivate(this, \"highWaterMark\", @getByIdDirectPrivate(strategy, \"highWaterMark\"));\n" \ - " @putByIdDirectPrivate(this, \"start\", () => @createReadableStreamController(this, underlyingSource, strategy));\n" \ - " } else if (isLazy) {\n" \ - " const autoAllocateChunkSize = underlyingSource.autoAllocateChunkSize;\n" \ - " @putByIdDirectPrivate(this, \"highWaterMark\", @undefined);\n" \ - " @putByIdDirectPrivate(this, \"underlyingSource\", @undefined);\n" \ - " @putByIdDirectPrivate(this, \"highWaterMark\", autoAllocateChunkSize || @getByIdDirectPrivate(strategy, \"highWaterMark\"));\n" \ - "\n" \ - " \n" \ - " @putByIdDirectPrivate(this, \"start\", () => {\n" \ - " const instance = @lazyLoadStream(this, autoAllocateChunkSize);\n" \ - " if (instance) {\n" \ - " @createReadableStreamController(this, instance, strategy);\n" \ - " }\n" \ - " });\n" \ - " } else {\n" \ - " @putByIdDirectPrivate(this, \"underlyingSource\", @undefined);\n" \ - " @putByIdDirectPrivate(this, \"highWaterMark\", @getByIdDirectPrivate(strategy, \"highWaterMark\"));\n" \ - " @putByIdDirectPrivate(this, \"start\", @undefined);\n" \ - " @createReadableStreamController(this, underlyingSource, strategy);\n" \ - " }\n" \ - " \n" \ - "\n" \ - " return this;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamReadableStreamToArrayCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Private; -const int s_readableStreamReadableStreamToArrayCodeLength = 294; -static const JSC::Intrinsic s_readableStreamReadableStreamToArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayCode = - "(function (stream) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " //\n" \ - " var underlyingSource = @getByIdDirectPrivate(stream, \"underlyingSource\");\n" \ - " if (underlyingSource !== @undefined) {\n" \ - " return @readableStreamToArrayDirect(stream, underlyingSource);\n" \ - " }\n" \ - "\n" \ - " return @readableStreamIntoArray(stream);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamReadableStreamToTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamReadableStreamToTextCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamReadableStreamToTextCodeImplementationVisibility = JSC::ImplementationVisibility::Private; -const int s_readableStreamReadableStreamToTextCodeLength = 292; -static const JSC::Intrinsic s_readableStreamReadableStreamToTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToTextCode = - "(function (stream) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " //\n" \ - " var underlyingSource = @getByIdDirectPrivate(stream, \"underlyingSource\");\n" \ - " if (underlyingSource !== @undefined) {\n" \ - " return @readableStreamToTextDirect(stream, underlyingSource);\n" \ - " }\n" \ - "\n" \ - " return @readableStreamIntoText(stream);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamReadableStreamToArrayBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Private; -const int s_readableStreamReadableStreamToArrayBufferCodeLength = 334; -static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayBufferCode = - "(function (stream) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " //\n" \ - " var underlyingSource = @getByIdDirectPrivate(stream, \"underlyingSource\");\n" \ - "\n" \ - " if (underlyingSource !== @undefined) {\n" \ - " return @readableStreamToArrayBufferDirect(stream, underlyingSource);\n" \ - " }\n" \ - "\n" \ - " return @Bun.readableStreamToArray(stream).@then(@Bun.concatArrayBuffers);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamReadableStreamToJSONCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamReadableStreamToJSONCodeImplementationVisibility = JSC::ImplementationVisibility::Private; -const int s_readableStreamReadableStreamToJSONCodeLength = 118; -static const JSC::Intrinsic s_readableStreamReadableStreamToJSONCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToJSONCode = - "(function (stream) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " return @Bun.readableStreamToText(stream).@then(globalThis.JSON.parse);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamReadableStreamToBlobCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamReadableStreamToBlobCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamReadableStreamToBlobCodeImplementationVisibility = JSC::ImplementationVisibility::Private; -const int s_readableStreamReadableStreamToBlobCodeLength = 139; -static const JSC::Intrinsic s_readableStreamReadableStreamToBlobCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToBlobCode = - "(function (stream) {\n" \ - " \"use strict\";\n" \ - " return @Promise.resolve(@Bun.readableStreamToArray(stream)).@then(array => new Blob(array));\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamConsumeReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamConsumeReadableStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamConsumeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private; -const int s_readableStreamConsumeReadableStreamCodeLength = 3736; -static const JSC::Intrinsic s_readableStreamConsumeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamConsumeReadableStreamCode = - "(function (nativePtr, nativeType, inputStream) {\n" \ - " \"use strict\";\n" \ - " const symbol = globalThis.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[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" \ - " }\n" \ - "\n" \ - " readMany() {\n" \ - " if (!this.#ptr) return @throwTypeError(\"ReadableStreamSink is already closed\");\n" \ - " return this.processResult(this.#reader.readMany());\n" \ - " }\n" \ - "\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 JSC::ImplementationVisibility s_readableStreamCreateEmptyReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private; -const int s_readableStreamCreateEmptyReadableStreamCodeLength = 156; -static const JSC::Intrinsic s_readableStreamCreateEmptyReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamCreateEmptyReadableStreamCode = - "(function () {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var stream = new @ReadableStream({\n" \ - " pull() {},\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 JSC::ImplementationVisibility s_readableStreamCreateNativeReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Private; -const int s_readableStreamCreateNativeReadableStreamCodeLength = 266; -static const JSC::Intrinsic s_readableStreamCreateNativeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamCreateNativeReadableStreamCode = - "(function (nativePtr, nativeType, autoAllocateChunkSize) {\n" \ - " \"use strict\";\n" \ - " return new @ReadableStream({\n" \ - " @lazy: true,\n" \ - " @bunNativeType: nativeType,\n" \ - " @bunNativePtr: nativePtr,\n" \ - " autoAllocateChunkSize: autoAllocateChunkSize,\n" \ - " });\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamCancelCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamGetReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamGetReaderCodeLength = 680; -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" \ - " var start_ = @getByIdDirectPrivate(this, \"start\");\n" \ - " if (start_) {\n" \ - " @putByIdDirectPrivate(this, \"start\", @undefined);\n" \ - " start_();\n" \ - " }\n" \ - " \n" \ - " return new @ReadableStreamDefaultReader(this);\n" \ - " }\n" \ - " //\n" \ - " if (mode == 'byob') {\n" \ - " return new @ReadableStreamBYOBReader(this);\n" \ - " }\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 JSC::ImplementationVisibility s_readableStreamPipeThroughCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamPipeToCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamPipeToCodeLength = 1522; -static const JSC::Intrinsic s_readableStreamPipeToCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamPipeToCode = - "(function (destination)\n" \ - "{\n" \ - " \"use strict\";\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" \ - " //\n" \ - " //\n" \ - " let options = @argument(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 (@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 JSC::ImplementationVisibility s_readableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamLockedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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" \ -; - -const JSC::ConstructAbility s_readableStreamValuesCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamValuesCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamValuesCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamValuesCodeLength = 191; -static const JSC::Intrinsic s_readableStreamValuesCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamValuesCode = - "(function (options) {\n" \ - " \"use strict\";\n" \ - " var prototype = @ReadableStream.prototype;\n" \ - " @readableStreamDefineLazyIterators(prototype);\n" \ - " return prototype.values.@call(this, options);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamLazyAsyncIteratorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamLazyAsyncIteratorCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamLazyAsyncIteratorCodeImplementationVisibility = JSC::ImplementationVisibility::Private; -const int s_readableStreamLazyAsyncIteratorCodeLength = 201; -static const JSC::Intrinsic s_readableStreamLazyAsyncIteratorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamLazyAsyncIteratorCode = - "(function () {\n" \ - " \"use strict\";\n" \ - " var prototype = @ReadableStream.prototype;\n" \ - " @readableStreamDefineLazyIterators(prototype);\n" \ - " return prototype[globalThis.Symbol.asyncIterator].@call(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/bun.js/builtins/cpp/ReadableStreamBuiltins.h b/src/bun.js/builtins/cpp/ReadableStreamBuiltins.h deleted file mode 100644 index 47ebda954..000000000 --- a/src/bun.js/builtins/cpp/ReadableStreamBuiltins.h +++ /dev/null @@ -1,272 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_readableStreamInitializeReadableStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayCodeImplementationVisibility; -extern const char* const s_readableStreamReadableStreamToTextCode; -extern const int s_readableStreamReadableStreamToTextCodeLength; -extern const JSC::ConstructAbility s_readableStreamReadableStreamToTextCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamReadableStreamToTextCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamReadableStreamToTextCodeImplementationVisibility; -extern const char* const s_readableStreamReadableStreamToArrayBufferCode; -extern const int s_readableStreamReadableStreamToArrayBufferCodeLength; -extern const JSC::ConstructAbility s_readableStreamReadableStreamToArrayBufferCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility; -extern const char* const s_readableStreamReadableStreamToJSONCode; -extern const int s_readableStreamReadableStreamToJSONCodeLength; -extern const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamReadableStreamToJSONCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamReadableStreamToJSONCodeImplementationVisibility; -extern const char* const s_readableStreamReadableStreamToBlobCode; -extern const int s_readableStreamReadableStreamToBlobCodeLength; -extern const JSC::ConstructAbility s_readableStreamReadableStreamToBlobCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamReadableStreamToBlobCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamReadableStreamToBlobCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamConsumeReadableStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamCreateEmptyReadableStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamCreateNativeReadableStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamCancelCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamGetReaderCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamPipeThroughCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamPipeToCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamTeeCodeImplementationVisibility; -extern const char* const s_readableStreamLockedCode; -extern const int s_readableStreamLockedCodeLength; -extern const JSC::ConstructAbility s_readableStreamLockedCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamLockedCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamLockedCodeImplementationVisibility; -extern const char* const s_readableStreamValuesCode; -extern const int s_readableStreamValuesCodeLength; -extern const JSC::ConstructAbility s_readableStreamValuesCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamValuesCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamValuesCodeImplementationVisibility; -extern const char* const s_readableStreamLazyAsyncIteratorCode; -extern const int s_readableStreamLazyAsyncIteratorCodeLength; -extern const JSC::ConstructAbility s_readableStreamLazyAsyncIteratorCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamLazyAsyncIteratorCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamLazyAsyncIteratorCodeImplementationVisibility; - -#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_DATA(macro) \ - macro(initializeReadableStream, readableStreamInitializeReadableStream, 2) \ - macro(readableStreamToArray, readableStreamReadableStreamToArray, 1) \ - macro(readableStreamToText, readableStreamReadableStreamToText, 1) \ - macro(readableStreamToArrayBuffer, readableStreamReadableStreamToArrayBuffer, 1) \ - macro(readableStreamToJSON, readableStreamReadableStreamToJSON, 1) \ - macro(readableStreamToBlob, readableStreamReadableStreamToBlob, 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) \ - macro(values, readableStreamValues, 1) \ - macro(lazyAsyncIterator, readableStreamLazyAsyncIterator, 0) \ - -#define WEBCORE_BUILTIN_READABLESTREAM_INITIALIZEREADABLESTREAM 1 -#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOARRAY 1 -#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOTEXT 1 -#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOARRAYBUFFER 1 -#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOJSON 1 -#define WEBCORE_BUILTIN_READABLESTREAM_READABLESTREAMTOBLOB 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_BUILTIN_READABLESTREAM_VALUES 1 -#define WEBCORE_BUILTIN_READABLESTREAM_LAZYASYNCITERATOR 1 - -#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_CODE(macro) \ - macro(readableStreamInitializeReadableStreamCode, initializeReadableStream, ASCIILiteral(), s_readableStreamInitializeReadableStreamCodeLength) \ - macro(readableStreamReadableStreamToArrayCode, readableStreamToArray, ASCIILiteral(), s_readableStreamReadableStreamToArrayCodeLength) \ - macro(readableStreamReadableStreamToTextCode, readableStreamToText, ASCIILiteral(), s_readableStreamReadableStreamToTextCodeLength) \ - macro(readableStreamReadableStreamToArrayBufferCode, readableStreamToArrayBuffer, ASCIILiteral(), s_readableStreamReadableStreamToArrayBufferCodeLength) \ - macro(readableStreamReadableStreamToJSONCode, readableStreamToJSON, ASCIILiteral(), s_readableStreamReadableStreamToJSONCodeLength) \ - macro(readableStreamReadableStreamToBlobCode, readableStreamToBlob, ASCIILiteral(), s_readableStreamReadableStreamToBlobCodeLength) \ - 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) \ - macro(readableStreamValuesCode, values, ASCIILiteral(), s_readableStreamValuesCodeLength) \ - macro(readableStreamLazyAsyncIteratorCode, lazyAsyncIterator, ASCIILiteral(), s_readableStreamLazyAsyncIteratorCodeLength) \ - -#define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_FUNCTION_NAME(macro) \ - macro(cancel) \ - macro(consumeReadableStream) \ - macro(createEmptyReadableStream) \ - macro(createNativeReadableStream) \ - macro(getReader) \ - macro(initializeReadableStream) \ - macro(lazyAsyncIterator) \ - macro(locked) \ - macro(pipeThrough) \ - macro(pipeTo) \ - macro(readableStreamToArray) \ - macro(readableStreamToArrayBuffer) \ - macro(readableStreamToBlob) \ - macro(readableStreamToJSON) \ - macro(readableStreamToText) \ - macro(tee) \ - macro(values) \ - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/ReadableStreamDefaultControllerBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamDefaultControllerBuiltins.cpp deleted file mode 100644 index 8719e4cc1..000000000 --- a/src/bun.js/builtins/cpp/ReadableStreamDefaultControllerBuiltins.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamDefaultControllerCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamDefaultControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/ReadableStreamDefaultControllerBuiltins.h b/src/bun.js/builtins/cpp/ReadableStreamDefaultControllerBuiltins.h deleted file mode 100644 index 3925f5fb9..000000000 --- a/src/bun.js/builtins/cpp/ReadableStreamDefaultControllerBuiltins.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamDefaultControllerEnqueueCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamDefaultControllerErrorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamDefaultControllerCloseCodeImplementationVisibility; -extern const char* const s_readableStreamDefaultControllerDesiredSizeCode; -extern const int s_readableStreamDefaultControllerDesiredSizeCodeLength; -extern const JSC::ConstructAbility s_readableStreamDefaultControllerDesiredSizeCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamDefaultControllerDesiredSizeCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamDefaultControllerDesiredSizeCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/ReadableStreamDefaultReaderBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamDefaultReaderBuiltins.cpp deleted file mode 100644 index 2e8388a4f..000000000 --- a/src/bun.js/builtins/cpp/ReadableStreamDefaultReaderBuiltins.cpp +++ /dev/null @@ -1,300 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamDefaultReaderCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamDefaultReaderReadManyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamDefaultReaderReadManyCodeLength = 4743; -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" \ - " var queue = @getByIdDirectPrivate(controller, \"queue\");\n" \ - " \n" \ - " if (!queue) {\n" \ - " //\n" \ - " //\n" \ - " return controller.@pull(\n" \ - " controller\n" \ - " ).@then(\n" \ - " function({done, value}) {\n" \ - " return (\n" \ - " done ? \n" \ - " { done: true, value: [], size: 0 } : \n" \ - " { value: [value], size: 1, done: false }\n" \ - " );\n" \ - " }\n" \ - " );\n" \ - " }\n" \ - "\n" \ - " const content = queue.content;\n" \ - " var size = queue.size;\n" \ - " var values = content.toArray(false);\n" \ - " \n" \ - " var length = values.length;\n" \ - "\n" \ - " if (length > 0) {\n" \ - " var outValues = @newArrayWithSize(length);\n" \ - " if (@isReadableByteStreamController(controller)) {\n" \ - "\n" \ - " {\n" \ - " const buf = values[0];\n" \ - " if (!(@ArrayBuffer.@isView(buf) || buf instanceof @ArrayBuffer)) {\n" \ - " @putByValDirect(outValues, 0, new @Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength));\n" \ - " } else {\n" \ - " @putByValDirect(outValues, 0, buf);\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " for (var i = 1; i < length; i++) {\n" \ - " const buf = values[i];\n" \ - " if (!(@ArrayBuffer.@isView(buf) || buf instanceof @ArrayBuffer)) {\n" \ - " @putByValDirect(outValues, i, new @Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength));\n" \ - " } else {\n" \ - " @putByValDirect(outValues, i, buf);\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " } else {\n" \ - " @putByValDirect(outValues, 0, values[0].value);\n" \ - " for (var i = 1; i < length; i++) {\n" \ - " @putByValDirect(outValues, i, values[i].value);\n" \ - " }\n" \ - " }\n" \ - " \n" \ - " @resetQueue(@getByIdDirectPrivate(controller, \"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" \ - " return {value: outValues, 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 length = value.length;\n" \ - "\n" \ - " if (@isReadableByteStreamController(controller)) {\n" \ - " for (var i = 0; i < length; i++) {\n" \ - " const buf = value[i];\n" \ - " if (!(@ArrayBuffer.@isView(buf) || buf instanceof @ArrayBuffer)) {\n" \ - " const {buffer, byteOffset, byteLength} = buf;\n" \ - " @putByValDirect(value, i, new @Uint8Array(buffer, byteOffset, byteLength));\n" \ - " }\n" \ - " }\n" \ - " } else {\n" \ - " for (var i = 1; i < length; i++) {\n" \ - " @putByValDirect(value, i, value[i].value);\n" \ - " }\n" \ - " }\n" \ - " \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 JSC::ImplementationVisibility s_readableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamDefaultReaderReleaseLockCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_readableStreamDefaultReaderClosedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/ReadableStreamDefaultReaderBuiltins.h b/src/bun.js/builtins/cpp/ReadableStreamDefaultReaderBuiltins.h deleted file mode 100644 index cd061220a..000000000 --- a/src/bun.js/builtins/cpp/ReadableStreamDefaultReaderBuiltins.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_readableStreamDefaultReaderInitializeReadableStreamDefaultReaderCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamDefaultReaderCancelCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamDefaultReaderReadManyCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamDefaultReaderReadCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamDefaultReaderReleaseLockCodeImplementationVisibility; -extern const char* const s_readableStreamDefaultReaderClosedCode; -extern const int s_readableStreamDefaultReaderClosedCodeLength; -extern const JSC::ConstructAbility s_readableStreamDefaultReaderClosedCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamDefaultReaderClosedCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamDefaultReaderClosedCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp b/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp deleted file mode 100644 index b7d388218..000000000 --- a/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.cpp +++ /dev/null @@ -1,2683 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeLength = 788; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamReaderGenericInitializeCode = - "(function (reader, stream) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " @putByIdDirectPrivate(reader, \"ownerReadableStream\", stream);\n" \ - " @putByIdDirectPrivate(stream, \"reader\", reader);\n" \ - " if (@getByIdDirectPrivate(stream, \"state\") === @streamReadable)\n" \ - " @putByIdDirectPrivate(\n" \ - " reader,\n" \ - " \"closedPromiseCapability\",\n" \ - " @newPromiseCapability(@Promise)\n" \ - " );\n" \ - " else if (@getByIdDirectPrivate(stream, \"state\") === @streamClosed)\n" \ - " @putByIdDirectPrivate(reader, \"closedPromiseCapability\", {\n" \ - " @promise: @Promise.@resolve(),\n" \ - " });\n" \ - " else {\n" \ - " @assert(@getByIdDirectPrivate(stream, \"state\") === @streamErrored);\n" \ - " @putByIdDirectPrivate(reader, \"closedPromiseCapability\", {\n" \ - " @promise: @newHandledRejectedPromise(\n" \ - " @getByIdDirectPrivate(stream, \"storedError\")\n" \ - " ),\n" \ - " });\n" \ - " }\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeLength = 873; -static const JSC::Intrinsic s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCode = - "(function (\n" \ - " stream,\n" \ - " underlyingSource,\n" \ - " size,\n" \ - " 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" \ - " @putByIdDirectPrivate(this, \"controlledReadableStream\", stream);\n" \ - " @putByIdDirectPrivate(this, \"underlyingSource\", underlyingSource);\n" \ - " @putByIdDirectPrivate(this, \"queue\", @newQueue());\n" \ - " @putByIdDirectPrivate(this, \"started\", -1);\n" \ - " @putByIdDirectPrivate(this, \"closeRequested\", false);\n" \ - " @putByIdDirectPrivate(this, \"pullAgain\", false);\n" \ - " @putByIdDirectPrivate(this, \"pulling\", false);\n" \ - " @putByIdDirectPrivate(\n" \ - " this,\n" \ - " \"strategy\",\n" \ - " @validateAndNormalizeQueuingStrategy(size, highWaterMark)\n" \ - " );\n" \ - "\n" \ - " return this;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeLength = 305; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerErrorCode = - "(function (controller, error) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \ - " if (@getByIdDirectPrivate(stream, \"state\") !== @streamReadable) return;\n" \ - " @putByIdDirectPrivate(controller, \"queue\", @newQueue());\n" \ - "\n" \ - " @readableStreamError(stream, error);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamPipeToCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamPipeToCodeLength = 739; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamPipeToCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamPipeToCode = - "(function (stream, sink) {\n" \ - " \"use strict\";\n" \ - " @assert(@isReadableStream(stream));\n" \ - "\n" \ - " const reader = new @ReadableStreamDefaultReader(stream);\n" \ - "\n" \ - " @getByIdDirectPrivate(reader, \"closedPromiseCapability\").@promise.@then(\n" \ - " () => {},\n" \ - " (e) => {\n" \ - " sink.error(e);\n" \ - " }\n" \ - " );\n" \ - "\n" \ - " function doPipe() {\n" \ - " @readableStreamDefaultReaderRead(reader).@then(\n" \ - " 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" \ - " },\n" \ - " function (e) {\n" \ - " sink.error(e);\n" \ - " }\n" \ - " );\n" \ - " }\n" \ - " doPipe();\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeLength = 190; -static const JSC::Intrinsic s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsAcquireReadableStreamDefaultReaderCode = - "(function (stream) {\n" \ - " \"use strict\";\n" \ - " var start = @getByIdDirectPrivate(stream, \"start\");\n" \ - " if (start) {\n" \ - " start.@call(stream);\n" \ - " }\n" \ - "\n" \ - " return new @ReadableStreamDefaultReader(stream);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeLength = 975; -static const JSC::Intrinsic s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = - "(function (\n" \ - " stream,\n" \ - " underlyingSource,\n" \ - " size,\n" \ - " highWaterMark,\n" \ - " startMethod,\n" \ - " pullMethod,\n" \ - " cancelMethod\n" \ - ") {\n" \ - " \"use strict\";\n" \ - "\n" \ - " const controller = new @ReadableStreamDefaultController(\n" \ - " stream,\n" \ - " underlyingSource,\n" \ - " size,\n" \ - " highWaterMark,\n" \ - " @isReadableStream\n" \ - " );\n" \ - "\n" \ - " const pullAlgorithm = () =>\n" \ - " @promiseInvokeOrNoopMethod(underlyingSource, pullMethod, [controller]);\n" \ - " const cancelAlgorithm = (reason) =>\n" \ - " @promiseInvokeOrNoopMethod(underlyingSource, cancelMethod, [reason]);\n" \ - "\n" \ - " @putByIdDirectPrivate(controller, \"pullAlgorithm\", pullAlgorithm);\n" \ - " @putByIdDirectPrivate(controller, \"cancelAlgorithm\", cancelAlgorithm);\n" \ - " @putByIdDirectPrivate(\n" \ - " controller,\n" \ - " \"pull\",\n" \ - " @readableStreamDefaultControllerPull\n" \ - " );\n" \ - " @putByIdDirectPrivate(\n" \ - " controller,\n" \ - " \"cancel\",\n" \ - " @readableStreamDefaultControllerCancel\n" \ - " );\n" \ - " @putByIdDirectPrivate(stream, \"readableStreamController\", controller);\n" \ - "\n" \ - " @readableStreamDefaultControllerStart(controller);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControllerCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength = 1243; -static const JSC::Intrinsic s_readableStreamInternalsCreateReadableStreamControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = - "(function (stream, underlyingSource, strategy) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " const type = underlyingSource.type;\n" \ - " const typeString = @toString(type);\n" \ - "\n" \ - " if (typeString === \"bytes\") {\n" \ - " //\n" \ - " //\n" \ - "\n" \ - " if (strategy.highWaterMark === @undefined) strategy.highWaterMark = 0;\n" \ - " if (strategy.size !== @undefined)\n" \ - " @throwRangeError(\n" \ - " \"Strategy for a ReadableByteStreamController cannot have a size\"\n" \ - " );\n" \ - "\n" \ - " @putByIdDirectPrivate(\n" \ - " stream,\n" \ - " \"readableStreamController\",\n" \ - " new @ReadableByteStreamController(\n" \ - " stream,\n" \ - " underlyingSource,\n" \ - " strategy.highWaterMark,\n" \ - " @isReadableStream\n" \ - " )\n" \ - " );\n" \ - " } else if (typeString === \"direct\") {\n" \ - " var highWaterMark = strategy?.highWaterMark;\n" \ - " @initializeArrayBufferStream.@call(\n" \ - " stream,\n" \ - " underlyingSource,\n" \ - " highWaterMark\n" \ - " );\n" \ - " } else if (type === @undefined) {\n" \ - " if (strategy.highWaterMark === @undefined) strategy.highWaterMark = 1;\n" \ - "\n" \ - " @setupReadableStreamDefaultController(\n" \ - " stream,\n" \ - " underlyingSource,\n" \ - " strategy.size,\n" \ - " strategy.highWaterMark,\n" \ - " underlyingSource.start,\n" \ - " underlyingSource.pull,\n" \ - " underlyingSource.cancel\n" \ - " );\n" \ - " } else @throwRangeError(\"Invalid type for underlying source\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamDefaultControllerStartCodeLength = 762; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerStartCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerStartCode = - "(function (controller) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " if (@getByIdDirectPrivate(controller, \"started\") !== -1) return;\n" \ - "\n" \ - " const underlyingSource = @getByIdDirectPrivate(\n" \ - " controller,\n" \ - " \"underlyingSource\"\n" \ - " );\n" \ - " const startMethod = underlyingSource.start;\n" \ - " @putByIdDirectPrivate(controller, \"started\", 0);\n" \ - "\n" \ - " @promiseInvokeOrNoopMethodNoCatch(underlyingSource, startMethod, [\n" \ - " controller,\n" \ - " ]).@then(\n" \ - " () => {\n" \ - " @putByIdDirectPrivate(controller, \"started\", 1);\n" \ - " @assert(!@getByIdDirectPrivate(controller, \"pulling\"));\n" \ - " @assert(!@getByIdDirectPrivate(controller, \"pullAgain\"));\n" \ - " @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \ - " },\n" \ - " (error) => {\n" \ - " @readableStreamDefaultControllerError(controller, error);\n" \ - " }\n" \ - " );\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeLength = 3229; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = - "(function (\n" \ - " source,\n" \ - " destination,\n" \ - " preventClose,\n" \ - " preventAbort,\n" \ - " preventCancel,\n" \ - " signal\n" \ - ") {\n" \ - " \"use strict\";\n" \ - "\n" \ - " const isDirectStream = !!@getByIdDirectPrivate(source, \"start\");\n" \ - "\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(\n" \ - " \"Piping to a readable bytestream is not supported\"\n" \ - " );\n" \ - "\n" \ - " let pipeState = {\n" \ - " source: source,\n" \ - " destination: destination,\n" \ - " preventAbort: preventAbort,\n" \ - " preventCancel: preventCancel,\n" \ - " preventClose: preventClose,\n" \ - " signal: signal,\n" \ - " };\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 = (reason) => {\n" \ - " if (pipeState.finalized) return;\n" \ - "\n" \ - " @pipeToShutdownWithAction(\n" \ - " pipeState,\n" \ - " () => {\n" \ - " const shouldAbortDestination =\n" \ - " !pipeState.preventAbort &&\n" \ - " @getByIdDirectPrivate(pipeState.destination, \"state\") ===\n" \ - " \"writable\";\n" \ - " const promiseDestination = shouldAbortDestination\n" \ - " ? @writableStreamAbort(pipeState.destination, reason)\n" \ - " : @Promise.@resolve();\n" \ - "\n" \ - " const shouldAbortSource =\n" \ - " !pipeState.preventCancel &&\n" \ - " @getByIdDirectPrivate(pipeState.source, \"state\") ===\n" \ - " @streamReadable;\n" \ - " const promiseSource = shouldAbortSource\n" \ - " ? @readableStreamCancel(pipeState.source, reason)\n" \ - " : @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(\n" \ - " handleResolvedPromise,\n" \ - " handleRejectedPromise\n" \ - " );\n" \ - " promiseSource.@then(handleResolvedPromise, handleRejectedPromise);\n" \ - " return promiseCapability.@promise;\n" \ - " },\n" \ - " reason\n" \ - " );\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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToLoopCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsPipeToLoopCodeLength = 180; -static const JSC::Intrinsic s_readableStreamInternalsPipeToLoopCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToLoopCode = - "(function (pipeState) {\n" \ - " \"use strict\";\n" \ - " if (pipeState.shuttingDown) return;\n" \ - "\n" \ - " @pipeToDoReadWrite(pipeState).@then((result) => {\n" \ - " if (result) @pipeToLoop(pipeState);\n" \ - " });\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsPipeToDoReadWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsPipeToDoReadWriteCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsPipeToDoReadWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsPipeToDoReadWriteCodeLength = 1296; -static const JSC::Intrinsic s_readableStreamInternalsPipeToDoReadWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToDoReadWriteCode = - "(function (pipeState) {\n" \ - " \"use strict\";\n" \ - " @assert(!pipeState.shuttingDown);\n" \ - "\n" \ - " pipeState.pendingReadPromiseCapability = @newPromiseCapability(@Promise);\n" \ - " @getByIdDirectPrivate(pipeState.writer, \"readyPromise\").@promise.@then(\n" \ - " () => {\n" \ - " if (pipeState.shuttingDown) {\n" \ - " pipeState.pendingReadPromiseCapability.@resolve.@call(\n" \ - " @undefined,\n" \ - " false\n" \ - " );\n" \ - " return;\n" \ - " }\n" \ - "\n" \ - " @readableStreamDefaultReaderRead(pipeState.reader).@then(\n" \ - " (result) => {\n" \ - " const canWrite =\n" \ - " !result.done &&\n" \ - " @getByIdDirectPrivate(pipeState.writer, \"stream\") !== @undefined;\n" \ - " pipeState.pendingReadPromiseCapability.@resolve.@call(\n" \ - " @undefined,\n" \ - " canWrite\n" \ - " );\n" \ - " if (!canWrite) return;\n" \ - "\n" \ - " pipeState.pendingWritePromise = @writableStreamDefaultWriterWrite(\n" \ - " pipeState.writer,\n" \ - " result.value\n" \ - " );\n" \ - " },\n" \ - " (e) => {\n" \ - " pipeState.pendingReadPromiseCapability.@resolve.@call(\n" \ - " @undefined,\n" \ - " false\n" \ - " );\n" \ - " }\n" \ - " );\n" \ - " },\n" \ - " (e) => {\n" \ - " pipeState.pendingReadPromiseCapability.@resolve.@call(\n" \ - " @undefined,\n" \ - " false\n" \ - " );\n" \ - " }\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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeLength = 687; -static const JSC::Intrinsic s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode = - "(function (pipeState) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " const action = () => {\n" \ - " pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);\n" \ - " const error = @getByIdDirectPrivate(pipeState.source, \"storedError\");\n" \ - " if (!pipeState.preventAbort) {\n" \ - " @pipeToShutdownWithAction(\n" \ - " pipeState,\n" \ - " () => @writableStreamAbort(pipeState.destination, error),\n" \ - " error\n" \ - " );\n" \ - " return;\n" \ - " }\n" \ - " @pipeToShutdown(pipeState, error);\n" \ - " };\n" \ - "\n" \ - " if (@getByIdDirectPrivate(pipeState.source, \"state\") === @streamErrored) {\n" \ - " action();\n" \ - " return;\n" \ - " }\n" \ - "\n" \ - " @getByIdDirectPrivate(\n" \ - " pipeState.reader,\n" \ - " \"closedPromiseCapability\"\n" \ - " ).@promise.@then(@undefined, action);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeLength = 598; -static const JSC::Intrinsic s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode = - "(function (pipeState) {\n" \ - " \"use strict\";\n" \ - " const action = () => {\n" \ - " const error = @getByIdDirectPrivate(pipeState.destination, \"storedError\");\n" \ - " if (!pipeState.preventCancel) {\n" \ - " @pipeToShutdownWithAction(\n" \ - " pipeState,\n" \ - " () => @readableStreamCancel(pipeState.source, error),\n" \ - " error\n" \ - " );\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(\n" \ - " @undefined,\n" \ - " action\n" \ - " );\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeLength = 673; -static const JSC::Intrinsic s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCode = - "(function (pipeState) {\n" \ - " \"use strict\";\n" \ - " const action = () => {\n" \ - " pipeState.pendingReadPromiseCapability.@resolve.@call(@undefined, false);\n" \ - " const error = @getByIdDirectPrivate(pipeState.source, \"storedError\");\n" \ - " if (!pipeState.preventClose) {\n" \ - " @pipeToShutdownWithAction(pipeState, () =>\n" \ - " @writableStreamDefaultWriterCloseWithErrorPropagation(pipeState.writer)\n" \ - " );\n" \ - " return;\n" \ - " }\n" \ - " @pipeToShutdown(pipeState);\n" \ - " };\n" \ - " if (@getByIdDirectPrivate(pipeState.source, \"state\") === @streamClosed) {\n" \ - " action();\n" \ - " return;\n" \ - " }\n" \ - " @getByIdDirectPrivate(\n" \ - " pipeState.reader,\n" \ - " \"closedPromiseCapability\"\n" \ - " ).@promise.@then(action, @undefined);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeLength = 492; -static const JSC::Intrinsic s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCode = - "(function (pipeState) {\n" \ - " \"use strict\";\n" \ - " if (\n" \ - " !@writableStreamCloseQueuedOrInFlight(pipeState.destination) &&\n" \ - " @getByIdDirectPrivate(pipeState.destination, \"state\") !== \"closed\"\n" \ - " )\n" \ - " return;\n" \ - "\n" \ - " //\n" \ - "\n" \ - " const error = @makeTypeError(\"closing is propagated backward\");\n" \ - " if (!pipeState.preventCancel) {\n" \ - " @pipeToShutdownWithAction(\n" \ - " pipeState,\n" \ - " () => @readableStreamCancel(pipeState.source, error),\n" \ - " error\n" \ - " );\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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownWithActionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsPipeToShutdownWithActionCodeLength = 850; -static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownWithActionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = - "(function (pipeState, action) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " if (pipeState.shuttingDown) 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" \ - " () => {\n" \ - " if (hasError) @pipeToFinalize(pipeState, error);\n" \ - " else @pipeToFinalize(pipeState);\n" \ - " },\n" \ - " (e) => {\n" \ - " @pipeToFinalize(pipeState, e);\n" \ - " }\n" \ - " );\n" \ - " };\n" \ - "\n" \ - " if (\n" \ - " @getByIdDirectPrivate(pipeState.destination, \"state\") === \"writable\" &&\n" \ - " !@writableStreamCloseQueuedOrInFlight(pipeState.destination)\n" \ - " ) {\n" \ - " pipeState.pendingReadPromiseCapability.@promise.@then(\n" \ - " () => {\n" \ - " pipeState.pendingWritePromise.@then(finalize, finalize);\n" \ - " },\n" \ - " (e) => @pipeToFinalize(pipeState, e)\n" \ - " );\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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsPipeToShutdownCodeLength = 692; -static const JSC::Intrinsic s_readableStreamInternalsPipeToShutdownCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToShutdownCode = - "(function (pipeState) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " if (pipeState.shuttingDown) return;\n" \ - "\n" \ - " pipeState.shuttingDown = true;\n" \ - "\n" \ - " const hasError = arguments.length > 1;\n" \ - " const error = arguments[1];\n" \ - " const finalize = () => {\n" \ - " if (hasError) @pipeToFinalize(pipeState, error);\n" \ - " else @pipeToFinalize(pipeState);\n" \ - " };\n" \ - "\n" \ - " if (\n" \ - " @getByIdDirectPrivate(pipeState.destination, \"state\") === \"writable\" &&\n" \ - " !@writableStreamCloseQueuedOrInFlight(pipeState.destination)\n" \ - " ) {\n" \ - " pipeState.pendingReadPromiseCapability.@promise.@then(\n" \ - " () => {\n" \ - " pipeState.pendingWritePromise.@then(finalize, finalize);\n" \ - " },\n" \ - " (e) => @pipeToFinalize(pipeState, e)\n" \ - " );\n" \ - " return;\n" \ - " }\n" \ - " finalize();\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsPipeToFinalizeCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsPipeToFinalizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsPipeToFinalizeCodeLength = 349; -static const JSC::Intrinsic s_readableStreamInternalsPipeToFinalizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsPipeToFinalizeCode = - "(function (pipeState) {\n" \ - " \"use strict\";\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 pipeState.promiseCapability.@resolve.@call();\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamTeeCodeLength = 1839; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeCode = - "(function (stream, shouldClone) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " @assert(@isReadableStream(stream));\n" \ - " @assert(typeof shouldClone === \"boolean\");\n" \ - "\n" \ - " var start_ = @getByIdDirectPrivate(stream, \"start\");\n" \ - " if (start_) {\n" \ - " @putByIdDirectPrivate(stream, \"start\", @undefined);\n" \ - " start_();\n" \ - " }\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(\n" \ - " teeState,\n" \ - " reader,\n" \ - " shouldClone\n" \ - " );\n" \ - "\n" \ - " const branch1Source = {};\n" \ - " @putByIdDirectPrivate(branch1Source, \"pull\", pullFunction);\n" \ - " @putByIdDirectPrivate(\n" \ - " branch1Source,\n" \ - " \"cancel\",\n" \ - " @readableStreamTeeBranch1CancelFunction(teeState, stream)\n" \ - " );\n" \ - "\n" \ - " const branch2Source = {};\n" \ - " @putByIdDirectPrivate(branch2Source, \"pull\", pullFunction);\n" \ - " @putByIdDirectPrivate(\n" \ - " branch2Source,\n" \ - " \"cancel\",\n" \ - " @readableStreamTeeBranch2CancelFunction(teeState, stream)\n" \ - " );\n" \ - "\n" \ - " const branch1 = new @ReadableStream(branch1Source);\n" \ - " const branch2 = new @ReadableStream(branch2Source);\n" \ - "\n" \ - " @getByIdDirectPrivate(reader, \"closedPromiseCapability\").@promise.@then(\n" \ - " @undefined,\n" \ - " function (e) {\n" \ - " if (teeState.closedOrErrored) return;\n" \ - " @readableStreamDefaultControllerError(\n" \ - " branch1.@readableStreamController,\n" \ - " e\n" \ - " );\n" \ - " @readableStreamDefaultControllerError(\n" \ - " branch2.@readableStreamController,\n" \ - " e\n" \ - " );\n" \ - " teeState.closedOrErrored = true;\n" \ - " if (!teeState.canceled1 || !teeState.canceled2)\n" \ - " teeState.cancelPromiseCapability.@resolve.@call();\n" \ - " }\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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeePullFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamTeePullFunctionCodeLength = 1336; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeePullFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeePullFunctionCode = - "(function (teeState, reader, shouldClone) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " return function () {\n" \ - " @Promise.prototype.@then.@call(\n" \ - " @readableStreamDefaultReaderRead(reader),\n" \ - " function (result) {\n" \ - " @assert(@isObject(result));\n" \ - " @assert(typeof result.done === \"boolean\");\n" \ - " if (result.done && !teeState.closedOrErrored) {\n" \ - " if (!teeState.canceled1)\n" \ - " @readableStreamDefaultControllerClose(\n" \ - " teeState.branch1.@readableStreamController\n" \ - " );\n" \ - " if (!teeState.canceled2)\n" \ - " @readableStreamDefaultControllerClose(\n" \ - " teeState.branch2.@readableStreamController\n" \ - " );\n" \ - " teeState.closedOrErrored = true;\n" \ - " if (!teeState.canceled1 || !teeState.canceled2)\n" \ - " teeState.cancelPromiseCapability.@resolve.@call();\n" \ - " }\n" \ - " if (teeState.closedOrErrored) return;\n" \ - " if (!teeState.canceled1)\n" \ - " @readableStreamDefaultControllerEnqueue(\n" \ - " teeState.branch1.@readableStreamController,\n" \ - " result.value\n" \ - " );\n" \ - " if (!teeState.canceled2)\n" \ - " @readableStreamDefaultControllerEnqueue(\n" \ - " teeState.branch2.@readableStreamController,\n" \ - " shouldClone\n" \ - " ? @structuredCloneForStream(result.value)\n" \ - " : result.value\n" \ - " );\n" \ - " }\n" \ - " );\n" \ - " };\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeLength = 442; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode = - "(function (teeState, stream) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " return function (r) {\n" \ - " teeState.canceled1 = true;\n" \ - " teeState.reason1 = r;\n" \ - " if (teeState.canceled2) {\n" \ - " @readableStreamCancel(stream, [\n" \ - " teeState.reason1,\n" \ - " teeState.reason2,\n" \ - " ]).@then(\n" \ - " teeState.cancelPromiseCapability.@resolve,\n" \ - " teeState.cancelPromiseCapability.@reject\n" \ - " );\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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeLength = 442; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCode = - "(function (teeState, stream) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " return function (r) {\n" \ - " teeState.canceled2 = true;\n" \ - " teeState.reason2 = r;\n" \ - " if (teeState.canceled1) {\n" \ - " @readableStreamCancel(stream, [\n" \ - " teeState.reason1,\n" \ - " teeState.reason2,\n" \ - " ]).@then(\n" \ - " teeState.cancelPromiseCapability.@resolve,\n" \ - " teeState.cancelPromiseCapability.@reject\n" \ - " );\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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsIsReadableStreamCodeLength = 174; -static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsIsReadableStreamCode = - "(function (stream) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " return (\n" \ - " @isObject(stream) &&\n" \ - " @getByIdDirectPrivate(stream, \"readableStreamController\") !== @undefined\n" \ - " );\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamDefaultReaderCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamDefaultReaderCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsIsReadableStreamDefaultReaderCodeLength = 135; -static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamDefaultReaderCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsIsReadableStreamDefaultReaderCode = - "(function (reader) {\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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsIsReadableStreamDefaultControllerCodeLength = 170; -static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsIsReadableStreamDefaultControllerCode = - "(function (controller) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " return (\n" \ - " @isObject(controller) &&\n" \ - " !!@getByIdDirectPrivate(controller, \"underlyingSource\")\n" \ - " );\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadDirectStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadDirectStreamCodeLength = 1583; -static const JSC::Intrinsic s_readableStreamInternalsReadDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadDirectStreamCode = - "(function (stream, sink, underlyingSource) {\n" \ - " \"use strict\";\n" \ - " \n" \ - " @putByIdDirectPrivate(stream, \"underlyingSource\", @undefined);\n" \ - " @putByIdDirectPrivate(stream, \"start\", @undefined);\n" \ - "\n" \ - " function close(stream, reason) {\n" \ - " if (reason && underlyingSource?.cancel) {\n" \ - " try {\n" \ - " var prom = underlyingSource.cancel(reason);\n" \ - " @markPromiseAsHandled(prom);\n" \ - " } catch (e) {\n" \ - " }\n" \ - "\n" \ - " underlyingSource = @undefined;\n" \ - " }\n" \ - "\n" \ - " if (stream) {\n" \ - " @putByIdDirectPrivate(stream, \"readableStreamController\", @undefined);\n" \ - " @putByIdDirectPrivate(stream, \"reader\", @undefined);\n" \ - " if (reason) {\n" \ - " @putByIdDirectPrivate(stream, \"state\", @streamErrored);\n" \ - " @putByIdDirectPrivate(stream, \"storedError\", reason);\n" \ - " } else {\n" \ - " @putByIdDirectPrivate(stream, \"state\", @streamClosed);\n" \ - " }\n" \ - " stream = @undefined;\n" \ - " }\n" \ - " }\n" \ - "\n" \ - "\n" \ - "\n" \ - "\n" \ - "\n" \ - " if (!underlyingSource.pull) {\n" \ - " close();\n" \ - " return;\n" \ - " }\n" \ - "\n" \ - " if (!@isCallable(underlyingSource.pull)) {\n" \ - " close();\n" \ - " @throwTypeError(\"pull is not a function\");\n" \ - " return;\n" \ - " }\n" \ - "\n" \ - " @putByIdDirectPrivate(stream, \"readableStreamController\", sink);\n" \ - " const highWaterMark = @getByIdDirectPrivate(stream, \"highWaterMark\");\n" \ - "\n" \ - " sink.start({\n" \ - " highWaterMark: !highWaterMark || highWaterMark < 64 ? 64 : highWaterMark,\n" \ - " });\n" \ - "\n" \ - " @startDirectStream.@call(sink, stream, underlyingSource.pull, close);\n" \ - " @putByIdDirectPrivate(stream, \"reader\", {});\n" \ - "\n" \ - " var maybePromise = underlyingSource.pull(sink);\n" \ - " sink = @undefined;\n" \ - " if (maybePromise && @isPromise(maybePromise)) {\n" \ - " return maybePromise.@then(() => {});\n" \ - " }\n" \ - "\n" \ - "\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsAssignToStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsAssignToStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsAssignToStreamCodeLength = 438; -static const JSC::Intrinsic s_readableStreamInternalsAssignToStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsAssignToStreamCode = - "(function (stream, sink) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " //\n" \ - " var underlyingSource = @getByIdDirectPrivate(stream, \"underlyingSource\");\n" \ - "\n" \ - " //\n" \ - " if (underlyingSource) {\n" \ - " try {\n" \ - " return @readDirectStream(stream, sink, underlyingSource);\n" \ - " } catch(e) {\n" \ - " throw e;\n" \ - " } finally {\n" \ - " underlyingSource = @undefined;\n" \ - " stream = @undefined;\n" \ - " sink = @undefined;\n" \ - " }\n" \ - " \n" \ - "\n" \ - " }\n" \ - "\n" \ - " return @readStreamIntoSink(stream, sink, true);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadStreamIntoSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadStreamIntoSinkCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadStreamIntoSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadStreamIntoSinkCodeLength = 2869; -static const JSC::Intrinsic s_readableStreamInternalsReadStreamIntoSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadStreamIntoSinkCode = - "(async function (stream, sink, isNative) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var didClose = false;\n" \ - " var didThrow = false;\n" \ - " try {\n" \ - " var reader = stream.getReader();\n" \ - " var many = reader.readMany();\n" \ - " if (many && @isPromise(many)) {\n" \ - " many = await many;\n" \ - " }\n" \ - " if (many.done) {\n" \ - " didClose = true;\n" \ - " return sink.end();\n" \ - " }\n" \ - " var wroteCount = many.value.length;\n" \ - " const highWaterMark = @getByIdDirectPrivate(stream, \"highWaterMark\");\n" \ - " if (isNative) @startDirectStream.@call(sink, stream, @undefined, () => !didThrow && @markPromiseAsHandled(stream.cancel()));\n" \ - "\n" \ - " sink.start({ highWaterMark: highWaterMark || 0 });\n" \ - " \n" \ - "\n" \ - " for (\n" \ - " var i = 0, values = many.value, length = many.value.length;\n" \ - " i < length;\n" \ - " i++\n" \ - " ) {\n" \ - " sink.write(values[i]);\n" \ - " }\n" \ - "\n" \ - " var streamState = @getByIdDirectPrivate(stream, \"state\");\n" \ - " if (streamState === @streamClosed) {\n" \ - " didClose = true;\n" \ - " return sink.end();\n" \ - " }\n" \ - "\n" \ - " while (true) {\n" \ - " var { value, done } = await reader.read();\n" \ - " if (done) {\n" \ - " didClose = true;\n" \ - " return sink.end();\n" \ - " }\n" \ - "\n" \ - " sink.write(value);\n" \ - " }\n" \ - " } catch (e) {\n" \ - " didThrow = true;\n" \ - "\n" \ - "\n" \ - " try {\n" \ - " reader = @undefined;\n" \ - " const prom = stream.cancel(e);\n" \ - " @markPromiseAsHandled(prom);\n" \ - " } catch (j) {}\n" \ - "\n" \ - " if (sink && !didClose) {\n" \ - " didClose = true;\n" \ - " try {\n" \ - " sink.close(e);\n" \ - " } catch (j) {\n" \ - " throw new globalThis.AggregateError([e, j]);\n" \ - " }\n" \ - " }\n" \ - "\n" \ - "\n" \ - " throw e;\n" \ - " } finally {\n" \ - " if (reader) {\n" \ - " try {\n" \ - " reader.releaseLock();\n" \ - " } catch (e) {}\n" \ - " reader = @undefined;\n" \ - " }\n" \ - " sink = @undefined;\n" \ - " var streamState = @getByIdDirectPrivate(stream, \"state\");\n" \ - " if (stream) {\n" \ - "\n" \ - " //\n" \ - " //\n" \ - " var readableStreamController = @getByIdDirectPrivate(\n" \ - " stream,\n" \ - " \"readableStreamController\"\n" \ - " );\n" \ - " if (readableStreamController) {\n" \ - " if (\n" \ - " @getByIdDirectPrivate(readableStreamController, \"underlyingSource\")\n" \ - " )\n" \ - " @putByIdDirectPrivate(\n" \ - " readableStreamController,\n" \ - " \"underlyingSource\",\n" \ - " @undefined\n" \ - " );\n" \ - " if (\n" \ - " @getByIdDirectPrivate(\n" \ - " readableStreamController,\n" \ - " \"controlledReadableStream\"\n" \ - " )\n" \ - " )\n" \ - " @putByIdDirectPrivate(\n" \ - " readableStreamController,\n" \ - " \"controlledReadableStream\",\n" \ - " @undefined\n" \ - " );\n" \ - "\n" \ - " @putByIdDirectPrivate(stream, \"readableStreamController\", null);\n" \ - " if (@getByIdDirectPrivate(stream, \"underlyingSource\"))\n" \ - " @putByIdDirectPrivate(stream, \"underlyingSource\", @undefined);\n" \ - " readableStreamController = @undefined;\n" \ - " }\n" \ - "\n" \ - " if (!didThrow && streamState !== @streamClosed && streamState !== @streamErrored) {\n" \ - " @readableStreamClose(stream);\n" \ - " }\n" \ - " stream = @undefined;\n" \ - "\n" \ - " \n" \ - " }\n" \ - " }\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsHandleDirectStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsHandleDirectStreamErrorCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsHandleDirectStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsHandleDirectStreamErrorCodeLength = 774; -static const JSC::Intrinsic s_readableStreamInternalsHandleDirectStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsHandleDirectStreamErrorCode = - "(function (e) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var controller = this;\n" \ - " var sink = controller.@sink;\n" \ - " if (sink) {\n" \ - " @putByIdDirectPrivate(controller, \"sink\", @undefined);\n" \ - " try {\n" \ - " sink.close(e);\n" \ - " } catch (f) {}\n" \ - " }\n" \ - "\n" \ - " this.error =\n" \ - " this.flush =\n" \ - " this.write =\n" \ - " this.close =\n" \ - " this.end =\n" \ - " @onReadableStreamDirectControllerClosed;\n" \ - "\n" \ - " if (typeof this.@underlyingSource.close === \"function\") {\n" \ - " try {\n" \ - " this.@underlyingSource.close.@call(this.@underlyingSource, e);\n" \ - " } catch (e) {}\n" \ - " }\n" \ - "\n" \ - " try {\n" \ - " var pend = controller._pendingRead;\n" \ - " if (pend) {\n" \ - " controller._pendingRead = @undefined;\n" \ - " @rejectPromise(pend, e);\n" \ - " }\n" \ - " } catch (f) {}\n" \ - " var stream = controller.@controlledReadableStream;\n" \ - " if (stream) @readableStreamError(stream, e);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsHandleDirectStreamErrorRejectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsHandleDirectStreamErrorRejectCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsHandleDirectStreamErrorRejectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsHandleDirectStreamErrorRejectCodeLength = 92; -static const JSC::Intrinsic s_readableStreamInternalsHandleDirectStreamErrorRejectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsHandleDirectStreamErrorRejectCode = - "(function (e) {\n" \ - " @handleDirectStreamError.@call(this, e);\n" \ - " return @Promise.@reject(e);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsOnPullDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsOnPullDirectStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsOnPullDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsOnPullDirectStreamCodeLength = 1503; -static const JSC::Intrinsic s_readableStreamInternalsOnPullDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnPullDirectStreamCode = - "(function (controller) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var stream = controller.@controlledReadableStream;\n" \ - " if (!stream || @getByIdDirectPrivate(stream, \"state\") !== @streamReadable)\n" \ - " return;\n" \ - "\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " if (controller._deferClose === -1) {\n" \ - " return;\n" \ - " }\n" \ - "\n" \ - " controller._deferClose = -1;\n" \ - " controller._deferFlush = -1;\n" \ - " var deferClose;\n" \ - " var deferFlush;\n" \ - "\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - " try {\n" \ - " var result = controller.@underlyingSource.pull(controller);\n" \ - "\n" \ - " if (result && @isPromise(result)) {\n" \ - " if (controller._handleError === @undefined) {\n" \ - " controller._handleError =\n" \ - " @handleDirectStreamErrorReject.bind(controller);\n" \ - " }\n" \ - "\n" \ - " @Promise.prototype.catch.@call(result, controller._handleError);\n" \ - " }\n" \ - " } catch (e) {\n" \ - " return @handleDirectStreamErrorReject.@call(controller, e);\n" \ - " } finally {\n" \ - " deferClose = controller._deferClose;\n" \ - " deferFlush = controller._deferFlush;\n" \ - " controller._deferFlush = controller._deferClose = 0;\n" \ - " }\n" \ - "\n" \ - " var promiseToReturn;\n" \ - "\n" \ - " if (controller._pendingRead === @undefined) {\n" \ - " controller._pendingRead = promiseToReturn = @newPromise();\n" \ - " } else {\n" \ - " promiseToReturn = @readableStreamAddReadRequest(stream);\n" \ - " }\n" \ - "\n" \ - " //\n" \ - " //\n" \ - " if (deferClose === 1) {\n" \ - " var reason = controller._deferCloseReason;\n" \ - " controller._deferCloseReason = @undefined;\n" \ - " @onCloseDirectStream.@call(controller, reason);\n" \ - " return promiseToReturn;\n" \ - " }\n" \ - "\n" \ - " //\n" \ - " if (deferFlush === 1) {\n" \ - " @onFlushDirectStream.@call(controller);\n" \ - " }\n" \ - "\n" \ - " return promiseToReturn;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsNoopDoneFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsNoopDoneFunctionCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsNoopDoneFunctionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsNoopDoneFunctionCodeLength = 81; -static const JSC::Intrinsic s_readableStreamInternalsNoopDoneFunctionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsNoopDoneFunctionCode = - "(function () {\n" \ - " return @Promise.@resolve({ value: @undefined, done: true });\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeLength = 107; -static const JSC::Intrinsic s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnReadableStreamDirectControllerClosedCode = - "(function (reason) {\n" \ - " \"use strict\";\n" \ - " @throwTypeError(\"ReadableStreamDirectController is now closed\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsOnCloseDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsOnCloseDirectStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsOnCloseDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsOnCloseDirectStreamCodeLength = 2190; -static const JSC::Intrinsic s_readableStreamInternalsOnCloseDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnCloseDirectStreamCode = - "(function (reason) {\n" \ - " \"use strict\";\n" \ - " var stream = this.@controlledReadableStream;\n" \ - " if (!stream || @getByIdDirectPrivate(stream, \"state\") !== @streamReadable)\n" \ - " return;\n" \ - "\n" \ - " if (this._deferClose !== 0) {\n" \ - " this._deferClose = 1;\n" \ - " this._deferCloseReason = reason;\n" \ - " return;\n" \ - " }\n" \ - "\n" \ - " @putByIdDirectPrivate(stream, \"state\", @streamClosing);\n" \ - " if (typeof this.@underlyingSource.close === \"function\") {\n" \ - " try {\n" \ - " this.@underlyingSource.close.@call(this.@underlyingSource, reason);\n" \ - " } catch (e) {}\n" \ - " }\n" \ - "\n" \ - " var flushed;\n" \ - " try {\n" \ - " flushed = this.@sink.end();\n" \ - " @putByIdDirectPrivate(this, \"sink\", @undefined);\n" \ - " } catch (e) {\n" \ - " if (this._pendingRead) {\n" \ - " var read = this._pendingRead;\n" \ - " this._pendingRead = @undefined;\n" \ - " @rejectPromise(read, e);\n" \ - " }\n" \ - " @readableStreamError(stream, e);\n" \ - " return;\n" \ - " }\n" \ - "\n" \ - " this.error =\n" \ - " this.flush =\n" \ - " this.write =\n" \ - " this.close =\n" \ - " this.end =\n" \ - " @onReadableStreamDirectControllerClosed;\n" \ - "\n" \ - " var reader = @getByIdDirectPrivate(stream, \"reader\");\n" \ - "\n" \ - " if (reader && @isReadableStreamDefaultReader(reader)) {\n" \ - " var _pendingRead = this._pendingRead;\n" \ - " if (_pendingRead && @isPromise(_pendingRead) && flushed?.byteLength) {\n" \ - " this._pendingRead = @undefined;\n" \ - " @fulfillPromise(_pendingRead, { value: flushed, done: false });\n" \ - " @readableStreamClose(stream);\n" \ - " return;\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " if (flushed?.byteLength) {\n" \ - " var requests = @getByIdDirectPrivate(reader, \"readRequests\");\n" \ - " if (requests?.isNotEmpty()) {\n" \ - " @readableStreamFulfillReadRequest(stream, flushed, false);\n" \ - " @readableStreamClose(stream);\n" \ - " return;\n" \ - " }\n" \ - "\n" \ - " @putByIdDirectPrivate(stream, \"state\", @streamReadable);\n" \ - " this.@pull = () => {\n" \ - " var thisResult = @createFulfilledPromise({\n" \ - " value: flushed,\n" \ - " done: false,\n" \ - " });\n" \ - " flushed = @undefined;\n" \ - " @readableStreamClose(stream);\n" \ - " stream = @undefined;\n" \ - " return thisResult;\n" \ - " };\n" \ - " } else if (this._pendingRead) {\n" \ - " var read = this._pendingRead;\n" \ - " this._pendingRead = @undefined;\n" \ - " @putByIdDirectPrivate(this, \"pull\", @noopDoneFunction);\n" \ - " @fulfillPromise(read, { value: @undefined, done: true });\n" \ - " }\n" \ - "\n" \ - " @readableStreamClose(stream);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsOnFlushDirectStreamCodeLength = 929; -static const JSC::Intrinsic s_readableStreamInternalsOnFlushDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnFlushDirectStreamCode = - "(function () {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var stream = this.@controlledReadableStream;\n" \ - " var reader = @getByIdDirectPrivate(stream, \"reader\");\n" \ - " if (!reader || !@isReadableStreamDefaultReader(reader)) {\n" \ - " return;\n" \ - " }\n" \ - "\n" \ - " var _pendingRead = this._pendingRead;\n" \ - " this._pendingRead = @undefined;\n" \ - " if (_pendingRead && @isPromise(_pendingRead)) {\n" \ - " var flushed = this.@sink.flush();\n" \ - " if (flushed?.byteLength) {\n" \ - " this._pendingRead = @getByIdDirectPrivate(\n" \ - " stream,\n" \ - " \"readRequests\"\n" \ - " )?.shift();\n" \ - " @fulfillPromise(_pendingRead, { value: flushed, done: false });\n" \ - " } else {\n" \ - " this._pendingRead = _pendingRead;\n" \ - " }\n" \ - " } else if (@getByIdDirectPrivate(stream, \"readRequests\")?.isNotEmpty()) {\n" \ - " var flushed = this.@sink.flush();\n" \ - " if (flushed?.byteLength) {\n" \ - " @readableStreamFulfillReadRequest(stream, flushed, false);\n" \ - " }\n" \ - " } else if (this._deferFlush === -1) {\n" \ - " this._deferFlush = 1;\n" \ - " }\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsCreateTextStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsCreateTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsCreateTextStreamCodeLength = 2373; -static const JSC::Intrinsic s_readableStreamInternalsCreateTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsCreateTextStreamCode = - "(function (highWaterMark) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var sink;\n" \ - " var array = [];\n" \ - " var hasString = false;\n" \ - " var hasBuffer = false;\n" \ - " var rope = \"\";\n" \ - " var estimatedLength = @toLength(0);\n" \ - " var capability = @newPromiseCapability(@Promise);\n" \ - " var calledDone = false;\n" \ - "\n" \ - " sink = {\n" \ - " start() {},\n" \ - " write(chunk) {\n" \ - " if (typeof chunk === \"string\") {\n" \ - " var chunkLength = @toLength(chunk.length);\n" \ - " if (chunkLength > 0) {\n" \ - " rope += chunk;\n" \ - " hasString = true;\n" \ - " //\n" \ - " estimatedLength += chunkLength;\n" \ - " }\n" \ - "\n" \ - " return chunkLength;\n" \ - " }\n" \ - "\n" \ - " if (\n" \ - " !chunk ||\n" \ - " !(@ArrayBuffer.@isView(chunk) || chunk instanceof @ArrayBuffer)\n" \ - " ) {\n" \ - " @throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");\n" \ - " }\n" \ - "\n" \ - " const byteLength = @toLength(chunk.byteLength);\n" \ - " if (byteLength > 0) {\n" \ - " hasBuffer = true;\n" \ - " if (rope.length > 0) {\n" \ - " @arrayPush(array, rope, chunk);\n" \ - " rope = \"\";\n" \ - " } else {\n" \ - " @arrayPush(array, chunk);\n" \ - " }\n" \ - " }\n" \ - " estimatedLength += byteLength;\n" \ - " return byteLength;\n" \ - " },\n" \ - "\n" \ - " flush() {\n" \ - " return 0;\n" \ - " },\n" \ - "\n" \ - " end() {\n" \ - " if (calledDone) {\n" \ - " return \"\";\n" \ - " }\n" \ - " return sink.fulfill();\n" \ - " },\n" \ - "\n" \ - " fulfill() {\n" \ - " calledDone = true;\n" \ - " const result = sink.finishInternal();\n" \ - "\n" \ - " @fulfillPromise(capability.@promise, result);\n" \ - " return result;\n" \ - " },\n" \ - "\n" \ - " finishInternal() {\n" \ - " if (!hasString && !hasBuffer) {\n" \ - " return \"\";\n" \ - " }\n" \ - "\n" \ - " if (hasString && !hasBuffer) {\n" \ - " return rope;\n" \ - " }\n" \ - "\n" \ - " if (hasBuffer && !hasString) {\n" \ - " return new globalThis.TextDecoder().decode(\n" \ - " @Bun.concatArrayBuffers(array)\n" \ - " );\n" \ - " }\n" \ - "\n" \ - " //\n" \ - "\n" \ - " var arrayBufferSink = new @Bun.ArrayBufferSink();\n" \ - " arrayBufferSink.start({\n" \ - " highWaterMark: estimatedLength,\n" \ - " asUint8Array: true,\n" \ - " });\n" \ - " for (let item of array) {\n" \ - " arrayBufferSink.write(item);\n" \ - " }\n" \ - " array.length = 0;\n" \ - " if (rope.length > 0) {\n" \ - " arrayBufferSink.write(rope);\n" \ - " rope = \"\";\n" \ - " }\n" \ - "\n" \ - " //\n" \ - " return new globalThis.TextDecoder().decode(arrayBufferSink.end());\n" \ - " },\n" \ - "\n" \ - " close() {\n" \ - " try {\n" \ - " if (!calledDone) {\n" \ - " calledDone = true;\n" \ - " sink.fulfill();\n" \ - " }\n" \ - " } catch (e) {}\n" \ - " },\n" \ - " };\n" \ - "\n" \ - " return [sink, capability];\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsInitializeTextStreamCodeLength = 822; -static const JSC::Intrinsic s_readableStreamInternalsInitializeTextStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeTextStreamCode = - "(function (underlyingSource, highWaterMark) {\n" \ - " \"use strict\";\n" \ - " var [sink, closingPromise] = @createTextStream(highWaterMark);\n" \ - "\n" \ - " var controller = {\n" \ - " @underlyingSource: underlyingSource,\n" \ - " @pull: @onPullDirectStream,\n" \ - " @controlledReadableStream: this,\n" \ - " @sink: sink,\n" \ - " close: @onCloseDirectStream,\n" \ - " write: sink.write,\n" \ - " error: @handleDirectStreamError,\n" \ - " end: @onCloseDirectStream,\n" \ - " @close: @onCloseDirectStream,\n" \ - " flush: @onFlushDirectStream,\n" \ - " _pendingRead: @undefined,\n" \ - " _deferClose: 0,\n" \ - " _deferFlush: 0,\n" \ - " _deferCloseReason: @undefined,\n" \ - " _handleError: @undefined,\n" \ - " };\n" \ - "\n" \ - " @putByIdDirectPrivate(this, \"readableStreamController\", controller);\n" \ - " @putByIdDirectPrivate(this, \"underlyingSource\", @undefined);\n" \ - " @putByIdDirectPrivate(this, \"start\", @undefined);\n" \ - " return closingPromise;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsInitializeArrayStreamCodeLength = 1330; -static const JSC::Intrinsic s_readableStreamInternalsInitializeArrayStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeArrayStreamCode = - "(function (underlyingSource, highWaterMark) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var array = [];\n" \ - " var closingPromise = @newPromiseCapability(@Promise);\n" \ - " var calledDone = false;\n" \ - "\n" \ - " function fulfill() {\n" \ - " calledDone = true;\n" \ - " closingPromise.@resolve.@call(@undefined, array);\n" \ - " return array;\n" \ - " }\n" \ - "\n" \ - " var sink = {\n" \ - " start() {},\n" \ - " write(chunk) {\n" \ - " @arrayPush(array, chunk);\n" \ - " return chunk.byteLength || chunk.length;\n" \ - " },\n" \ - "\n" \ - " flush() {\n" \ - " return 0;\n" \ - " },\n" \ - "\n" \ - " end() {\n" \ - " if (calledDone) {\n" \ - " return [];\n" \ - " }\n" \ - " return fulfill();\n" \ - " },\n" \ - "\n" \ - " close() {\n" \ - " if (!calledDone) {\n" \ - " fulfill();\n" \ - " }\n" \ - " },\n" \ - " };\n" \ - "\n" \ - " var controller = {\n" \ - " @underlyingSource: underlyingSource,\n" \ - " @pull: @onPullDirectStream,\n" \ - " @controlledReadableStream: this,\n" \ - " @sink: sink,\n" \ - " close: @onCloseDirectStream,\n" \ - " write: sink.write,\n" \ - " error: @handleDirectStreamError,\n" \ - " end: @onCloseDirectStream,\n" \ - " @close: @onCloseDirectStream,\n" \ - " flush: @onFlushDirectStream,\n" \ - " _pendingRead: @undefined,\n" \ - " _deferClose: 0,\n" \ - " _deferFlush: 0,\n" \ - " _deferCloseReason: @undefined,\n" \ - " _handleError: @undefined,\n" \ - " };\n" \ - "\n" \ - " @putByIdDirectPrivate(this, \"readableStreamController\", controller);\n" \ - " @putByIdDirectPrivate(this, \"underlyingSource\", @undefined);\n" \ - " @putByIdDirectPrivate(this, \"start\", @undefined);\n" \ - " return closingPromise;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayBufferStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsInitializeArrayBufferStreamCodeLength = 995; -static const JSC::Intrinsic s_readableStreamInternalsInitializeArrayBufferStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode = - "(function (underlyingSource, highWaterMark) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " //\n" \ - " //\n" \ - " //\n" \ - "\n" \ - " var opts =\n" \ - " highWaterMark && typeof highWaterMark === \"number\"\n" \ - " ? { highWaterMark, stream: true, asUint8Array: true }\n" \ - " : { stream: true, asUint8Array: true };\n" \ - " var sink = new @Bun.ArrayBufferSink();\n" \ - " sink.start(opts);\n" \ - "\n" \ - " var controller = {\n" \ - " @underlyingSource: underlyingSource,\n" \ - " @pull: @onPullDirectStream,\n" \ - " @controlledReadableStream: this,\n" \ - " @sink: sink,\n" \ - " close: @onCloseDirectStream,\n" \ - " write: sink.write.bind(sink),\n" \ - " error: @handleDirectStreamError,\n" \ - " end: @onCloseDirectStream,\n" \ - " @close: @onCloseDirectStream,\n" \ - " flush: @onFlushDirectStream,\n" \ - " _pendingRead: @undefined,\n" \ - " _deferClose: 0,\n" \ - " _deferFlush: 0,\n" \ - " _deferCloseReason: @undefined,\n" \ - " _handleError: @undefined,\n" \ - " };\n" \ - "\n" \ - " @putByIdDirectPrivate(this, \"readableStreamController\", controller);\n" \ - " @putByIdDirectPrivate(this, \"underlyingSource\", @undefined);\n" \ - " @putByIdDirectPrivate(this, \"start\", @undefined);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamErrorCodeLength = 1212; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamErrorCode = - "(function (stream, error) {\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) 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(\n" \ - " @undefined,\n" \ - " error\n" \ - " );\n" \ - " const promise = @getByIdDirectPrivate(\n" \ - " reader,\n" \ - " \"closedPromiseCapability\"\n" \ - " ).@promise;\n" \ - " @markPromiseAsHandled(promise);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeLength = 700; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCode = - "(function (controller) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \ - "\n" \ - " if (!@readableStreamDefaultControllerCanCloseOrEnqueue(controller))\n" \ - " return false;\n" \ - " if (!(@getByIdDirectPrivate(controller, \"started\") === 1)) return false;\n" \ - " if (\n" \ - " (!@isReadableStreamLocked(stream) ||\n" \ - " !@getByIdDirectPrivate(\n" \ - " @getByIdDirectPrivate(stream, \"reader\"),\n" \ - " \"readRequests\"\n" \ - " )?.isNotEmpty()) &&\n" \ - " @readableStreamDefaultControllerGetDesiredSize(controller) <= 0\n" \ - " )\n" \ - " return false;\n" \ - " const desiredSize =\n" \ - " @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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeLength = 1277; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCode = - "(function (controller) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " //\n" \ - " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \ - "\n" \ - " if (!@readableStreamDefaultControllerCanCloseOrEnqueue(controller)) return;\n" \ - " if (!(@getByIdDirectPrivate(controller, \"started\") === 1)) return;\n" \ - " if (\n" \ - " (!@isReadableStreamLocked(stream) ||\n" \ - " !@getByIdDirectPrivate(\n" \ - " @getByIdDirectPrivate(stream, \"reader\"),\n" \ - " \"readRequests\"\n" \ - " )?.isNotEmpty()) &&\n" \ - " @readableStreamDefaultControllerGetDesiredSize(controller) <= 0\n" \ - " )\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\")\n" \ - " .@call(@undefined)\n" \ - " .@then(\n" \ - " function () {\n" \ - " @putByIdDirectPrivate(controller, \"pulling\", false);\n" \ - " if (@getByIdDirectPrivate(controller, \"pullAgain\")) {\n" \ - " @putByIdDirectPrivate(controller, \"pullAgain\", false);\n" \ - "\n" \ - " @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \ - " }\n" \ - " },\n" \ - " function (error) {\n" \ - " @readableStreamDefaultControllerError(controller, error);\n" \ - " }\n" \ - " );\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamLockedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsIsReadableStreamLockedCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamLockedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsIsReadableStreamLockedCodeLength = 131; -static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamLockedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsIsReadableStreamLockedCode = - "(function (stream) {\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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeLength = 403; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = - "(function (controller) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \ - " const state = @getByIdDirectPrivate(stream, \"state\");\n" \ - "\n" \ - " if (state === @streamErrored) return null;\n" \ - " if (state === @streamClosed) return 0;\n" \ - "\n" \ - " return (\n" \ - " @getByIdDirectPrivate(controller, \"strategy\").highWaterMark -\n" \ - " @getByIdDirectPrivate(controller, \"queue\").size\n" \ - " );\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericCancelCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamReaderGenericCancelCodeLength = 189; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = - "(function (reader, reason) {\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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamCancelCodeLength = 736; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCancelCode = - "(function (stream, reason) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " @putByIdDirectPrivate(stream, \"disturbed\", true);\n" \ - " const state = @getByIdDirectPrivate(stream, \"state\");\n" \ - " if (state === @streamClosed) return @Promise.@resolve();\n" \ - " if (state === @streamErrored)\n" \ - " return @Promise.@reject(@getByIdDirectPrivate(stream, \"storedError\"));\n" \ - " @readableStreamClose(stream);\n" \ - "\n" \ - " var controller = @getByIdDirectPrivate(stream, \"readableStreamController\");\n" \ - " var cancel = controller.@cancel;\n" \ - " if (cancel) {\n" \ - " return cancel(controller, reason).@then(function () {});\n" \ - " }\n" \ - "\n" \ - " var close = controller.close;\n" \ - " if (close) {\n" \ - " return @Promise.@resolve(controller.close(reason));\n" \ - " }\n" \ - "\n" \ - " @throwTypeError(\"ReadableStreamController has no cancel or close method\");\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeLength = 213; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerCancelCode = - "(function (controller, reason) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " @putByIdDirectPrivate(controller, \"queue\", @newQueue());\n" \ - " return @getByIdDirectPrivate(controller, \"cancelAlgorithm\").@call(\n" \ - " @undefined,\n" \ - " reason\n" \ - " );\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerPullCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamDefaultControllerPullCodeLength = 751; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerPullCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerPullCode = - "(function (controller) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var queue = @getByIdDirectPrivate(controller, \"queue\");\n" \ - " if (queue.content.isNotEmpty()) {\n" \ - " const chunk = @dequeueValue(queue);\n" \ - " if (\n" \ - " @getByIdDirectPrivate(controller, \"closeRequested\") &&\n" \ - " queue.content.isEmpty()\n" \ - " )\n" \ - " @readableStreamClose(\n" \ - " @getByIdDirectPrivate(controller, \"controlledReadableStream\")\n" \ - " );\n" \ - " else @readableStreamDefaultControllerCallPullIfNeeded(controller);\n" \ - "\n" \ - " return @createFulfilledPromise({ value: chunk, done: false });\n" \ - " }\n" \ - " const pendingPromise = @readableStreamAddReadRequest(\n" \ - " @getByIdDirectPrivate(controller, \"controlledReadableStream\")\n" \ - " );\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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeLength = 351; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerCloseCode = - "(function (controller) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " @assert(@readableStreamDefaultControllerCanCloseOrEnqueue(controller));\n" \ - " @putByIdDirectPrivate(controller, \"closeRequested\", true);\n" \ - " if (@getByIdDirectPrivate(controller, \"queue\")?.content?.isEmpty())\n" \ - " @readableStreamClose(\n" \ - " @getByIdDirectPrivate(controller, \"controlledReadableStream\")\n" \ - " );\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCloseCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamCloseCodeLength = 883; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamCloseCode = - "(function (stream) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " @assert(@getByIdDirectPrivate(stream, \"state\") === @streamReadable);\n" \ - " @putByIdDirectPrivate(stream, \"state\", @streamClosed);\n" \ - " if (!@getByIdDirectPrivate(stream, \"reader\")) return;\n" \ - "\n" \ - " if (\n" \ - " @isReadableStreamDefaultReader(@getByIdDirectPrivate(stream, \"reader\"))\n" \ - " ) {\n" \ - " const requests = @getByIdDirectPrivate(\n" \ - " @getByIdDirectPrivate(stream, \"reader\"),\n" \ - " \"readRequests\"\n" \ - " );\n" \ - " if (requests.isNotEmpty()) {\n" \ - " @putByIdDirectPrivate(\n" \ - " @getByIdDirectPrivate(stream, \"reader\"),\n" \ - " \"readRequests\",\n" \ - " @createFIFO()\n" \ - " );\n" \ - "\n" \ - " for (var request = requests.shift(); request; request = requests.shift())\n" \ - " @fulfillPromise(request, { value: @undefined, done: true });\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " @getByIdDirectPrivate(\n" \ - " @getByIdDirectPrivate(stream, \"reader\"),\n" \ - " \"closedPromiseCapability\"\n" \ - " ).@resolve.@call();\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadRequestCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamFulfillReadRequestCodeLength = 237; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamFulfillReadRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = - "(function (stream, chunk, done) {\n" \ - " \"use strict\";\n" \ - " const readRequest = @getByIdDirectPrivate(\n" \ - " @getByIdDirectPrivate(stream, \"reader\"),\n" \ - " \"readRequests\"\n" \ - " ).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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeLength = 986; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = - "(function (controller, chunk) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " const stream = @getByIdDirectPrivate(controller, \"controlledReadableStream\");\n" \ - " //\n" \ - " @assert(@readableStreamDefaultControllerCanCloseOrEnqueue(controller));\n" \ - "\n" \ - " if (\n" \ - " @isReadableStreamLocked(stream) &&\n" \ - " @getByIdDirectPrivate(\n" \ - " @getByIdDirectPrivate(stream, \"reader\"),\n" \ - " \"readRequests\"\n" \ - " )?.isNotEmpty()\n" \ - " ) {\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(\n" \ - " @getByIdDirectPrivate(controller, \"queue\"),\n" \ - " chunk,\n" \ - " 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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamDefaultReaderReadCodeLength = 631; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultReaderReadCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = - "(function (reader) {\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(\n" \ - " @getByIdDirectPrivate(stream, \"readableStreamController\")\n" \ - " );\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamAddReadRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamAddReadRequestCodeLength = 377; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamAddReadRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamAddReadRequestCode = - "(function (stream) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " @assert(\n" \ - " @isReadableStreamDefaultReader(@getByIdDirectPrivate(stream, \"reader\"))\n" \ - " );\n" \ - " @assert(@getByIdDirectPrivate(stream, \"state\") == @streamReadable);\n" \ - "\n" \ - " const readRequest = @newPromise();\n" \ - "\n" \ - " @getByIdDirectPrivate(\n" \ - " @getByIdDirectPrivate(stream, \"reader\"),\n" \ - " \"readRequests\"\n" \ - " ).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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamDisturbedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsIsReadableStreamDisturbedCodeLength = 132; -static const JSC::Intrinsic s_readableStreamInternalsIsReadableStreamDisturbedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsIsReadableStreamDisturbedCode = - "(function (stream) {\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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeLength = 1083; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamReaderGenericReleaseCode = - "(function (reader) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " @assert(!!@getByIdDirectPrivate(reader, \"ownerReadableStream\"));\n" \ - " @assert(\n" \ - " @getByIdDirectPrivate(\n" \ - " @getByIdDirectPrivate(reader, \"ownerReadableStream\"),\n" \ - " \"reader\"\n" \ - " ) === reader\n" \ - " );\n" \ - "\n" \ - " if (\n" \ - " @getByIdDirectPrivate(\n" \ - " @getByIdDirectPrivate(reader, \"ownerReadableStream\"),\n" \ - " \"state\"\n" \ - " ) === @streamReadable\n" \ - " )\n" \ - " @getByIdDirectPrivate(reader, \"closedPromiseCapability\").@reject.@call(\n" \ - " @undefined,\n" \ - " @makeTypeError(\n" \ - " \"releasing lock of reader whose stream is still in readable state\"\n" \ - " )\n" \ - " );\n" \ - " else\n" \ - " @putByIdDirectPrivate(reader, \"closedPromiseCapability\", {\n" \ - " @promise: @newHandledRejectedPromise(\n" \ - " @makeTypeError(\"reader released lock\")\n" \ - " ),\n" \ - " });\n" \ - "\n" \ - " const promise = @getByIdDirectPrivate(\n" \ - " reader,\n" \ - " \"closedPromiseCapability\"\n" \ - " ).@promise;\n" \ - " @markPromiseAsHandled(promise);\n" \ - " @putByIdDirectPrivate(\n" \ - " @getByIdDirectPrivate(reader, \"ownerReadableStream\"),\n" \ - " \"reader\",\n" \ - " @undefined\n" \ - " );\n" \ - " @putByIdDirectPrivate(reader, \"ownerReadableStream\", @undefined);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeLength = 257; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCode = - "(function (controller) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " return (\n" \ - " !@getByIdDirectPrivate(controller, \"closeRequested\") &&\n" \ - " @getByIdDirectPrivate(\n" \ - " @getByIdDirectPrivate(controller, \"controlledReadableStream\"),\n" \ - " \"state\"\n" \ - " ) === @streamReadable\n" \ - " );\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsLazyLoadStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsLazyLoadStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsLazyLoadStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsLazyLoadStreamCodeLength = 3983; -static const JSC::Intrinsic s_readableStreamInternalsLazyLoadStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsLazyLoadStreamCode = - "(function (stream, autoAllocateChunkSize) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var nativeType = @getByIdDirectPrivate(stream, \"bunNativeType\");\n" \ - " var nativePtr = @getByIdDirectPrivate(stream, \"bunNativePtr\");\n" \ - " var Prototype = @lazyStreamPrototypeMap.@get(nativeType);\n" \ - " if (Prototype === @undefined) {\n" \ - " var [pull, start, cancel, setClose, deinit, setRefOrUnref, drain] = @lazyLoad(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" \ - " function callClose(controller) {\n" \ - " try {\n" \ - " controller.close();\n" \ - " } catch(e) {\n" \ - " globalThis.reportError(e);\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " handleResult = function handleResult(result, controller, view) {\n" \ - " \"use strict\";\n" \ - " if (result && @isPromise(result)) {\n" \ - " return result.then(\n" \ - " handleNativeReadableStreamPromiseResult.bind({\n" \ - " c: controller,\n" \ - " v: view,\n" \ - " }),\n" \ - " (err) => controller.error(err)\n" \ - " );\n" \ - " } else if (typeof result === 'number') {\n" \ - " if (view && view.byteLength === result && view.buffer === controller.byobRequest?.view?.buffer) {\n" \ - " controller.byobRequest.respondWithNewView(view);\n" \ - " } else {\n" \ - " controller.byobRequest.respond(result);\n" \ - " }\n" \ - " } else if (result.constructor === @Uint8Array) {\n" \ - " controller.enqueue(result);\n" \ - " }\n" \ - "\n" \ - " if (closer[0] || result === false) {\n" \ - " @enqueueJob(callClose, controller);\n" \ - " closer[0] = false;\n" \ - " }\n" \ - " };\n" \ - "\n" \ - " function createResult(tag, controller, view, closer) {\n" \ - " closer[0] = false;\n" \ - "\n" \ - " var result;\n" \ - " try {\n" \ - " result = pull(tag, view, closer);\n" \ - " } catch (err) {\n" \ - " return controller.error(err);\n" \ - " }\n" \ - "\n" \ - " return handleResult(result, controller, view);\n" \ - " }\n" \ - "\n" \ - " const registry = deinit ? new FinalizationRegistry(deinit) : null;\n" \ - " Prototype = class NativeReadableStreamSource {\n" \ - " constructor(tag, autoAllocateChunkSize, drainValue) {\n" \ - " this.#tag = tag;\n" \ - " this.#cancellationToken = {};\n" \ - " this.pull = this.#pull.bind(this);\n" \ - " this.cancel = this.#cancel.bind(this);\n" \ - " this.autoAllocateChunkSize = autoAllocateChunkSize;\n" \ - "\n" \ - " if (drainValue !== @undefined) {\n" \ - " this.start = (controller) => {\n" \ - " controller.enqueue(drainValue);\n" \ - " };\n" \ - " }\n" \ - "\n" \ - " if (registry) {\n" \ - " registry.register(this, tag, this.#cancellationToken);\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " #cancellationToken;\n" \ - " pull;\n" \ - " cancel;\n" \ - " start;\n" \ - "\n" \ - " #tag;\n" \ - " type = \"bytes\";\n" \ - " autoAllocateChunkSize = 0;\n" \ - " \n" \ - " static startSync = start;\n" \ - " \n" \ - " \n" \ - " #pull(controller) {\n" \ - " var tag = this.#tag;\n" \ - "\n" \ - " if (!tag) {\n" \ - " controller.close();\n" \ - " return;\n" \ - " }\n" \ - "\n" \ - " createResult(tag, controller, controller.byobRequest.view, closer);\n" \ - " }\n" \ - "\n" \ - " #cancel(reason) {\n" \ - " var tag = this.#tag;\n" \ - "\n" \ - " registry && registry.unregister(this.#cancellationToken);\n" \ - " setRefOrUnref && setRefOrUnref(tag, false);\n" \ - " cancel(tag, reason);\n" \ - " }\n" \ - " static deinit = deinit;\n" \ - " static drain = drain;\n" \ - " };\n" \ - " @lazyStreamPrototypeMap.@set(nativeType, Prototype);\n" \ - " }\n" \ - "\n" \ - " const chunkSize = Prototype.startSync(nativePtr, autoAllocateChunkSize);\n" \ - " var drainValue;\n" \ - " const {drain: drainFn, deinit: deinitFn} = Prototype;\n" \ - " if (drainFn) {\n" \ - " drainValue = drainFn(nativePtr);\n" \ - " }\n" \ - "\n" \ - " //\n" \ - " if (chunkSize === 0) {\n" \ - " deinit && nativePtr && @enqueueJob(deinit, nativePtr);\n" \ - "\n" \ - " if ((drainValue?.byteLength ?? 0) > 0) {\n" \ - " return {\n" \ - " start(controller) {\n" \ - " controller.enqueue(drainValue);\n" \ - " controller.close();\n" \ - " },\n" \ - " type: \"bytes\",\n" \ - " };\n" \ - " }\n" \ - "\n" \ - " return {\n" \ - " start(controller) {\n" \ - " controller.close();\n" \ - " },\n" \ - " type: \"bytes\",\n" \ - " };\n" \ - " }\n" \ - "\n" \ - " return new Prototype(nativePtr, chunkSize, drainValue);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength = 578; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoArrayCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = - "(function (stream) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var reader = stream.getReader();\n" \ - " var manyResult = reader.readMany();\n" \ - "\n" \ - " async function processManyResult(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" \ - " break;\n" \ - " }\n" \ - " chunks = chunks.concat(thisResult.value);\n" \ - " }\n" \ - "\n" \ - " return chunks;\n" \ - " }\n" \ - "\n" \ - " if (manyResult && @isPromise(manyResult)) {\n" \ - " return manyResult.@then(processManyResult);\n" \ - " }\n" \ - "\n" \ - " return processManyResult(manyResult);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoTextCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoTextCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamIntoTextCodeLength = 333; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamIntoTextCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamIntoTextCode = - "(function (stream) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " const [textStream, closer] = @createTextStream(\n" \ - " @getByIdDirectPrivate(stream, \"highWaterMark\")\n" \ - " );\n" \ - " const prom = @readStreamIntoSink(stream, textStream, false);\n" \ - " if (prom && @isPromise(prom)) {\n" \ - " return @Promise.@resolve(prom).@then(closer.@promise);\n" \ - " }\n" \ - " return closer.@promise;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeLength = 1533; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = - "(function (stream, underlyingSource) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var sink = new @Bun.ArrayBufferSink();\n" \ - " @putByIdDirectPrivate(stream, \"underlyingSource\", @undefined);\n" \ - " var highWaterMark = @getByIdDirectPrivate(stream, \"highWaterMark\");\n" \ - " sink.start(highWaterMark ? { highWaterMark } : {});\n" \ - " var capability = @newPromiseCapability(@Promise);\n" \ - " var ended = false;\n" \ - " var pull = underlyingSource.pull;\n" \ - " var close = underlyingSource.close;\n" \ - "\n" \ - " var controller = {\n" \ - " start() {},\n" \ - " close(reason) {\n" \ - " if (!ended) {\n" \ - " ended = true;\n" \ - " if (close) {\n" \ - " close();\n" \ - " }\n" \ - "\n" \ - " @fulfillPromise(capability.@promise, sink.end());\n" \ - " }\n" \ - " },\n" \ - " end() {\n" \ - " if (!ended) {\n" \ - " ended = true;\n" \ - " if (close) {\n" \ - " close();\n" \ - " }\n" \ - " @fulfillPromise(capability.@promise, sink.end());\n" \ - " }\n" \ - " },\n" \ - " flush() {\n" \ - " return 0;\n" \ - " },\n" \ - " write: sink.write.bind(sink),\n" \ - " };\n" \ - "\n" \ - " var didError = false;\n" \ - " try {\n" \ - " const firstPull = pull(controller);\n" \ - " if (firstPull && @isObject(firstPull) && @isPromise(firstPull)) {\n" \ - " return (async function (controller, promise, pull) {\n" \ - " while (!ended) {\n" \ - " await pull(controller);\n" \ - " }\n" \ - " return await promise;\n" \ - " })(controller, promise, pull);\n" \ - " }\n" \ - "\n" \ - " return capability.@promise;\n" \ - " } catch (e) {\n" \ - " didError = true;\n" \ - " @readableStreamError(stream, e);\n" \ - " return @Promise.@reject(e);\n" \ - " } finally {\n" \ - " if (!didError && stream) @readableStreamClose(stream);\n" \ - " controller = close = sink = pull = stream = @undefined;\n" \ - " }\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength = 496; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToTextDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = - "(async function (stream, underlyingSource) {\n" \ - " \"use strict\";\n" \ - " const capability = @initializeTextStream.@call(\n" \ - " stream,\n" \ - " underlyingSource,\n" \ - " @undefined\n" \ - " );\n" \ - " var reader = stream.getReader();\n" \ - "\n" \ - " while (@getByIdDirectPrivate(stream, \"state\") === @streamReadable) {\n" \ - " var thisResult = await reader.read();\n" \ - " if (thisResult.done) {\n" \ - " break;\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " try {\n" \ - " reader.releaseLock();\n" \ - " } catch (e) {}\n" \ - " reader = @undefined;\n" \ - " stream = @undefined;\n" \ - "\n" \ - " return capability.@promise;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 667; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = - "(async function (stream, underlyingSource) {\n" \ - " const capability = @initializeArrayStream.@call(\n" \ - " stream,\n" \ - " underlyingSource,\n" \ - " @undefined\n" \ - " );\n" \ - " underlyingSource = @undefined;\n" \ - " var reader = stream.getReader();\n" \ - " try {\n" \ - " while (@getByIdDirectPrivate(stream, \"state\") === @streamReadable) {\n" \ - " var thisResult = await reader.read();\n" \ - " if (thisResult.done) {\n" \ - " break;\n" \ - " }\n" \ - " }\n" \ - "\n" \ - " try {\n" \ - " reader.releaseLock();\n" \ - " } catch (e) {}\n" \ - " reader = @undefined;\n" \ - "\n" \ - " return @Promise.@resolve(capability.@promise);\n" \ - " } catch (e) {\n" \ - " throw e;\n" \ - " } finally {\n" \ - " stream = @undefined;\n" \ - " reader = @undefined;\n" \ - " }\n" \ - "\n" \ - " return capability.@promise;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength = 1478; -static const JSC::Intrinsic s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = - "(function (prototype) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " var asyncIterator = globalThis.Symbol.asyncIterator;\n" \ - "\n" \ - " var ReadableStreamAsyncIterator = async function* ReadableStreamAsyncIterator(stream, preventCancel) {\n" \ - " var reader = stream.getReader();\n" \ - " var deferredError;\n" \ - " try {\n" \ - " while (true) {\n" \ - " var done, value;\n" \ - " const firstResult = reader.readMany();\n" \ - " if (@isPromise(firstResult)) {\n" \ - " ({done, value} = await firstResult);\n" \ - " } else {\n" \ - " ({done, value} = firstResult);\n" \ - " }\n" \ - "\n" \ - " if (done) {\n" \ - " return;\n" \ - " }\n" \ - " yield* value;\n" \ - " }\n" \ - " } catch(e) {\n" \ - " deferredError = e;\n" \ - " } finally {\n" \ - " reader.releaseLock();\n" \ - "\n" \ - " if (!preventCancel) {\n" \ - " stream.cancel(deferredError);\n" \ - " }\n" \ - "\n" \ - " if (deferredError) {\n" \ - " throw deferredError;\n" \ - " }\n" \ - " }\n" \ - " };\n" \ - " var createAsyncIterator = function asyncIterator() {\n" \ - " return ReadableStreamAsyncIterator(this, false);\n" \ - " };\n" \ - " var createValues = function values({preventCancel = false} = {preventCancel: false}) {\n" \ - " return ReadableStreamAsyncIterator(this, preventCancel);\n" \ - " };\n" \ - " @Object.@defineProperty(prototype, asyncIterator, { value: createAsyncIterator });\n" \ - " @Object.@defineProperty(prototype, \"values\", { value: createValues });\n" \ - " return prototype;\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/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.h b/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.h deleted file mode 100644 index d34758e0b..000000000 --- a/src/bun.js/builtins/cpp/ReadableStreamInternalsBuiltins.h +++ /dev/null @@ -1,732 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamPipeToCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsCreateReadableStreamControllerCode; -extern const int s_readableStreamInternalsCreateReadableStreamControllerCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControllerCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsCreateReadableStreamControllerCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerStartCode; -extern const int s_readableStreamInternalsReadableStreamDefaultControllerStartCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToLoopCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToDoReadWriteCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToClosingMustBePropagatedBackwardCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownWithActionCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToShutdownCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsPipeToFinalizeCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeePullFunctionCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamDefaultReaderCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamDefaultControllerCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsReadDirectStreamCode; -extern const int s_readableStreamInternalsReadDirectStreamCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsReadDirectStreamCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsReadDirectStreamCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsReadDirectStreamCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsAssignToStreamCode; -extern const int s_readableStreamInternalsAssignToStreamCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsAssignToStreamCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsAssignToStreamCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsReadStreamIntoSinkCode; -extern const int s_readableStreamInternalsReadStreamIntoSinkCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsReadStreamIntoSinkCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsReadStreamIntoSinkCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsReadStreamIntoSinkCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsHandleDirectStreamErrorCode; -extern const int s_readableStreamInternalsHandleDirectStreamErrorCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsHandleDirectStreamErrorCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsHandleDirectStreamErrorCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsHandleDirectStreamErrorCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsHandleDirectStreamErrorRejectCode; -extern const int s_readableStreamInternalsHandleDirectStreamErrorRejectCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsHandleDirectStreamErrorRejectCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsHandleDirectStreamErrorRejectCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsHandleDirectStreamErrorRejectCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsOnPullDirectStreamCode; -extern const int s_readableStreamInternalsOnPullDirectStreamCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsOnPullDirectStreamCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsOnPullDirectStreamCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsOnPullDirectStreamCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsNoopDoneFunctionCode; -extern const int s_readableStreamInternalsNoopDoneFunctionCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsNoopDoneFunctionCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsNoopDoneFunctionCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsNoopDoneFunctionCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsOnReadableStreamDirectControllerClosedCode; -extern const int s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsOnCloseDirectStreamCode; -extern const int s_readableStreamInternalsOnCloseDirectStreamCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsOnCloseDirectStreamCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsOnCloseDirectStreamCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsOnCloseDirectStreamCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsOnFlushDirectStreamCode; -extern const int s_readableStreamInternalsOnFlushDirectStreamCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsOnFlushDirectStreamCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsCreateTextStreamCode; -extern const int s_readableStreamInternalsCreateTextStreamCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsCreateTextStreamCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsCreateTextStreamCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsInitializeTextStreamCode; -extern const int s_readableStreamInternalsInitializeTextStreamCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsInitializeTextStreamCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsInitializeArrayStreamCode; -extern const int s_readableStreamInternalsInitializeArrayStreamCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayStreamCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayStreamCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode; -extern const int s_readableStreamInternalsInitializeArrayBufferStreamCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsInitializeArrayBufferStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamErrorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCallPullIfNeededCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamLockedCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericCancelCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCancelCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerPullCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCloseCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamCloseCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamFulfillReadRequestCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamAddReadRequestCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsIsReadableStreamDisturbedCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamReaderGenericReleaseCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCode; -extern const int s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefaultControllerCanCloseOrEnqueueCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsLazyLoadStreamCode; -extern const int s_readableStreamInternalsLazyLoadStreamCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsLazyLoadStreamCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsLazyLoadStreamCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsLazyLoadStreamCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsReadableStreamIntoArrayCode; -extern const int s_readableStreamInternalsReadableStreamIntoArrayCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoArrayCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsReadableStreamIntoTextCode; -extern const int s_readableStreamInternalsReadableStreamIntoTextCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoTextCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamIntoTextCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode; -extern const int s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsReadableStreamToTextDirectCode; -extern const int s_readableStreamInternalsReadableStreamToTextDirectCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToTextDirectCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode; -extern const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility; -extern const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode; -extern const int s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength; -extern const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility; -extern const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructorKind; -extern const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeImplementationVisibility; - -#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_DATA(macro) \ - macro(readableStreamReaderGenericInitialize, readableStreamInternalsReadableStreamReaderGenericInitialize, 2) \ - macro(privateInitializeReadableStreamDefaultController, readableStreamInternalsPrivateInitializeReadableStreamDefaultController, 4) \ - macro(readableStreamDefaultControllerError, readableStreamInternalsReadableStreamDefaultControllerError, 2) \ - macro(readableStreamPipeTo, readableStreamInternalsReadableStreamPipeTo, 2) \ - macro(acquireReadableStreamDefaultReader, readableStreamInternalsAcquireReadableStreamDefaultReader, 1) \ - macro(setupReadableStreamDefaultController, readableStreamInternalsSetupReadableStreamDefaultController, 7) \ - macro(createReadableStreamController, readableStreamInternalsCreateReadableStreamController, 3) \ - macro(readableStreamDefaultControllerStart, readableStreamInternalsReadableStreamDefaultControllerStart, 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(readDirectStream, readableStreamInternalsReadDirectStream, 3) \ - macro(assignToStream, readableStreamInternalsAssignToStream, 2) \ - macro(readStreamIntoSink, readableStreamInternalsReadStreamIntoSink, 3) \ - macro(handleDirectStreamError, readableStreamInternalsHandleDirectStreamError, 1) \ - macro(handleDirectStreamErrorReject, readableStreamInternalsHandleDirectStreamErrorReject, 1) \ - macro(onPullDirectStream, readableStreamInternalsOnPullDirectStream, 1) \ - macro(noopDoneFunction, readableStreamInternalsNoopDoneFunction, 0) \ - macro(onReadableStreamDirectControllerClosed, readableStreamInternalsOnReadableStreamDirectControllerClosed, 1) \ - macro(onCloseDirectStream, readableStreamInternalsOnCloseDirectStream, 1) \ - macro(onFlushDirectStream, readableStreamInternalsOnFlushDirectStream, 0) \ - macro(createTextStream, readableStreamInternalsCreateTextStream, 1) \ - macro(initializeTextStream, readableStreamInternalsInitializeTextStream, 2) \ - macro(initializeArrayStream, readableStreamInternalsInitializeArrayStream, 2) \ - macro(initializeArrayBufferStream, readableStreamInternalsInitializeArrayBufferStream, 2) \ - 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) \ - macro(lazyLoadStream, readableStreamInternalsLazyLoadStream, 2) \ - macro(readableStreamIntoArray, readableStreamInternalsReadableStreamIntoArray, 1) \ - macro(readableStreamIntoText, readableStreamInternalsReadableStreamIntoText, 1) \ - macro(readableStreamToArrayBufferDirect, readableStreamInternalsReadableStreamToArrayBufferDirect, 2) \ - macro(readableStreamToTextDirect, readableStreamInternalsReadableStreamToTextDirect, 2) \ - macro(readableStreamToArrayDirect, readableStreamInternalsReadableStreamToArrayDirect, 2) \ - macro(readableStreamDefineLazyIterators, readableStreamInternalsReadableStreamDefineLazyIterators, 1) \ - -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMREADERGENERICINITIALIZE 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_PRIVATEINITIALIZEREADABLESTREAMDEFAULTCONTROLLER 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERERROR 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMPIPETO 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ACQUIREREADABLESTREAMDEFAULTREADER 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_SETUPREADABLESTREAMDEFAULTCONTROLLER 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_CREATEREADABLESTREAMCONTROLLER 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFAULTCONTROLLERSTART 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_READDIRECTSTREAM 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ASSIGNTOSTREAM 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READSTREAMINTOSINK 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_HANDLEDIRECTSTREAMERROR 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_HANDLEDIRECTSTREAMERRORREJECT 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ONPULLDIRECTSTREAM 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_NOOPDONEFUNCTION 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ONREADABLESTREAMDIRECTCONTROLLERCLOSED 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ONCLOSEDIRECTSTREAM 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_ONFLUSHDIRECTSTREAM 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_CREATETEXTSTREAM 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_INITIALIZETEXTSTREAM 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_INITIALIZEARRAYSTREAM 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_INITIALIZEARRAYBUFFERSTREAM 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_BUILTIN_READABLESTREAMINTERNALS_LAZYLOADSTREAM 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMINTOARRAY 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMINTOTEXT 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTOARRAYBUFFERDIRECT 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTOTEXTDIRECT 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMTOARRAYDIRECT 1 -#define WEBCORE_BUILTIN_READABLESTREAMINTERNALS_READABLESTREAMDEFINELAZYITERATORS 1 - -#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_CODE(macro) \ - macro(readableStreamInternalsReadableStreamReaderGenericInitializeCode, readableStreamReaderGenericInitialize, ASCIILiteral(), s_readableStreamInternalsReadableStreamReaderGenericInitializeCodeLength) \ - macro(readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCode, privateInitializeReadableStreamDefaultController, ASCIILiteral(), s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeLength) \ - macro(readableStreamInternalsReadableStreamDefaultControllerErrorCode, readableStreamDefaultControllerError, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeLength) \ - macro(readableStreamInternalsReadableStreamPipeToCode, readableStreamPipeTo, ASCIILiteral(), s_readableStreamInternalsReadableStreamPipeToCodeLength) \ - macro(readableStreamInternalsAcquireReadableStreamDefaultReaderCode, acquireReadableStreamDefaultReader, ASCIILiteral(), s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeLength) \ - macro(readableStreamInternalsSetupReadableStreamDefaultControllerCode, setupReadableStreamDefaultController, ASCIILiteral(), s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeLength) \ - macro(readableStreamInternalsCreateReadableStreamControllerCode, createReadableStreamController, ASCIILiteral(), s_readableStreamInternalsCreateReadableStreamControllerCodeLength) \ - macro(readableStreamInternalsReadableStreamDefaultControllerStartCode, readableStreamDefaultControllerStart, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefaultControllerStartCodeLength) \ - 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(readableStreamInternalsReadDirectStreamCode, readDirectStream, ASCIILiteral(), s_readableStreamInternalsReadDirectStreamCodeLength) \ - macro(readableStreamInternalsAssignToStreamCode, assignToStream, ASCIILiteral(), s_readableStreamInternalsAssignToStreamCodeLength) \ - macro(readableStreamInternalsReadStreamIntoSinkCode, readStreamIntoSink, ASCIILiteral(), s_readableStreamInternalsReadStreamIntoSinkCodeLength) \ - macro(readableStreamInternalsHandleDirectStreamErrorCode, handleDirectStreamError, ASCIILiteral(), s_readableStreamInternalsHandleDirectStreamErrorCodeLength) \ - macro(readableStreamInternalsHandleDirectStreamErrorRejectCode, handleDirectStreamErrorReject, ASCIILiteral(), s_readableStreamInternalsHandleDirectStreamErrorRejectCodeLength) \ - macro(readableStreamInternalsOnPullDirectStreamCode, onPullDirectStream, ASCIILiteral(), s_readableStreamInternalsOnPullDirectStreamCodeLength) \ - macro(readableStreamInternalsNoopDoneFunctionCode, noopDoneFunction, ASCIILiteral(), s_readableStreamInternalsNoopDoneFunctionCodeLength) \ - macro(readableStreamInternalsOnReadableStreamDirectControllerClosedCode, onReadableStreamDirectControllerClosed, ASCIILiteral(), s_readableStreamInternalsOnReadableStreamDirectControllerClosedCodeLength) \ - macro(readableStreamInternalsOnCloseDirectStreamCode, onCloseDirectStream, ASCIILiteral(), s_readableStreamInternalsOnCloseDirectStreamCodeLength) \ - macro(readableStreamInternalsOnFlushDirectStreamCode, onFlushDirectStream, ASCIILiteral(), s_readableStreamInternalsOnFlushDirectStreamCodeLength) \ - macro(readableStreamInternalsCreateTextStreamCode, createTextStream, ASCIILiteral(), s_readableStreamInternalsCreateTextStreamCodeLength) \ - macro(readableStreamInternalsInitializeTextStreamCode, initializeTextStream, ASCIILiteral(), s_readableStreamInternalsInitializeTextStreamCodeLength) \ - macro(readableStreamInternalsInitializeArrayStreamCode, initializeArrayStream, ASCIILiteral(), s_readableStreamInternalsInitializeArrayStreamCodeLength) \ - macro(readableStreamInternalsInitializeArrayBufferStreamCode, initializeArrayBufferStream, ASCIILiteral(), s_readableStreamInternalsInitializeArrayBufferStreamCodeLength) \ - 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) \ - macro(readableStreamInternalsLazyLoadStreamCode, lazyLoadStream, ASCIILiteral(), s_readableStreamInternalsLazyLoadStreamCodeLength) \ - macro(readableStreamInternalsReadableStreamIntoArrayCode, readableStreamIntoArray, ASCIILiteral(), s_readableStreamInternalsReadableStreamIntoArrayCodeLength) \ - macro(readableStreamInternalsReadableStreamIntoTextCode, readableStreamIntoText, ASCIILiteral(), s_readableStreamInternalsReadableStreamIntoTextCodeLength) \ - macro(readableStreamInternalsReadableStreamToArrayBufferDirectCode, readableStreamToArrayBufferDirect, ASCIILiteral(), s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeLength) \ - macro(readableStreamInternalsReadableStreamToTextDirectCode, readableStreamToTextDirect, ASCIILiteral(), s_readableStreamInternalsReadableStreamToTextDirectCodeLength) \ - macro(readableStreamInternalsReadableStreamToArrayDirectCode, readableStreamToArrayDirect, ASCIILiteral(), s_readableStreamInternalsReadableStreamToArrayDirectCodeLength) \ - macro(readableStreamInternalsReadableStreamDefineLazyIteratorsCode, readableStreamDefineLazyIterators, ASCIILiteral(), s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeLength) \ - -#define WEBCORE_FOREACH_READABLESTREAMINTERNALS_BUILTIN_FUNCTION_NAME(macro) \ - macro(acquireReadableStreamDefaultReader) \ - macro(assignToStream) \ - macro(createReadableStreamController) \ - macro(createTextStream) \ - macro(handleDirectStreamError) \ - macro(handleDirectStreamErrorReject) \ - macro(initializeArrayBufferStream) \ - macro(initializeArrayStream) \ - macro(initializeTextStream) \ - macro(isReadableStream) \ - macro(isReadableStreamDefaultController) \ - macro(isReadableStreamDefaultReader) \ - macro(isReadableStreamDisturbed) \ - macro(isReadableStreamLocked) \ - macro(lazyLoadStream) \ - macro(noopDoneFunction) \ - macro(onCloseDirectStream) \ - macro(onFlushDirectStream) \ - macro(onPullDirectStream) \ - macro(onReadableStreamDirectControllerClosed) \ - macro(pipeToClosingMustBePropagatedBackward) \ - macro(pipeToClosingMustBePropagatedForward) \ - macro(pipeToDoReadWrite) \ - macro(pipeToErrorsMustBePropagatedBackward) \ - macro(pipeToErrorsMustBePropagatedForward) \ - macro(pipeToFinalize) \ - macro(pipeToLoop) \ - macro(pipeToShutdown) \ - macro(pipeToShutdownWithAction) \ - macro(privateInitializeReadableStreamDefaultController) \ - macro(readDirectStream) \ - macro(readStreamIntoSink) \ - 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(readableStreamDefaultControllerStart) \ - macro(readableStreamDefaultReaderRead) \ - macro(readableStreamDefineLazyIterators) \ - macro(readableStreamError) \ - macro(readableStreamFulfillReadRequest) \ - macro(readableStreamIntoArray) \ - macro(readableStreamIntoText) \ - macro(readableStreamPipeTo) \ - macro(readableStreamPipeToWritableStream) \ - macro(readableStreamReaderGenericCancel) \ - macro(readableStreamReaderGenericInitialize) \ - macro(readableStreamReaderGenericRelease) \ - macro(readableStreamTee) \ - macro(readableStreamTeeBranch1CancelFunction) \ - macro(readableStreamTeeBranch2CancelFunction) \ - macro(readableStreamTeePullFunction) \ - macro(readableStreamToArrayBufferDirect) \ - macro(readableStreamToArrayDirect) \ - macro(readableStreamToTextDirect) \ - 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##ImplementationVisibility, 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/bun.js/builtins/cpp/StreamInternalsBuiltins.cpp b/src/bun.js/builtins/cpp/StreamInternalsBuiltins.cpp deleted file mode 100644 index 7f84dd40e..000000000 --- a/src/bun.js/builtins/cpp/StreamInternalsBuiltins.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_streamInternalsMarkPromiseAsHandledCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_streamInternalsMarkPromiseAsHandledCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_streamInternalsMarkPromiseAsHandledCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsShieldingPromiseResolveCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopNoCatchCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopMethodCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsValidateAndNormalizeQueuingStrategyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsCreateFIFOCodeImplementationVisibility = JSC::ImplementationVisibility::Private; -const int s_streamInternalsCreateFIFOCodeLength = 2863; -static const JSC::Intrinsic s_streamInternalsCreateFIFOCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsCreateFIFOCode = - "(function () {\n" \ - " \"use strict\";\n" \ - " var slice = @Array.prototype.slice;\n" \ - "\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" \ - " _head;\n" \ - " _tail;\n" \ - " _capacityMask;\n" \ - " _list;\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: head, _tail, _list, _capacityMask } = this;\n" \ - " if (head === _tail) return @undefined;\n" \ - " var item = _list[head];\n" \ - " @putByValDirect(_list, head, @undefined);\n" \ - " head = this._head = (head + 1) & _capacityMask;\n" \ - " if (head < 2 && _tail > 10000 && _tail <= _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 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 JSC::ImplementationVisibility s_streamInternalsNewQueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsDequeueValueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsEnqueueValueWithSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsPeekQueueValueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_streamInternalsPeekQueueValueCodeLength = 81; -static const JSC::Intrinsic s_streamInternalsPeekQueueValueCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsPeekQueueValueCode = - "(function (queue)\n" \ - "{\n" \ - " \"use strict\";\n" \ - " return queue.content.peek()?.value;\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_streamInternalsResetQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_streamInternalsResetQueueCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_streamInternalsResetQueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsExtractSizeAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_streamInternalsExtractSizeAlgorithmCodeLength = 294; -static const JSC::Intrinsic s_streamInternalsExtractSizeAlgorithmCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsExtractSizeAlgorithmCode = - "(function (strategy)\n" \ - "{\n" \ - " const sizeAlgorithm = strategy.size;\n" \ - "\n" \ - " if (sizeAlgorithm === @undefined)\n" \ - " return () => 1;\n" \ - "\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 JSC::ImplementationVisibility s_streamInternalsExtractHighWaterMarkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_streamInternalsExtractHighWaterMarkCodeLength = 322; -static const JSC::Intrinsic s_streamInternalsExtractHighWaterMarkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsExtractHighWaterMarkCode = - "(function (strategy, defaultHWM)\n" \ - "{\n" \ - " const highWaterMark = strategy.highWaterMark;\n" \ - "\n" \ - " if (highWaterMark === @undefined)\n" \ - " return defaultHWM;\n" \ - "\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 JSC::ImplementationVisibility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsCreateFulfilledPromiseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_streamInternalsToDictionaryCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/StreamInternalsBuiltins.h b/src/bun.js/builtins/cpp/StreamInternalsBuiltins.h deleted file mode 100644 index b068e244c..000000000 --- a/src/bun.js/builtins/cpp/StreamInternalsBuiltins.h +++ /dev/null @@ -1,327 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_streamInternalsMarkPromiseAsHandledCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsShieldingPromiseResolveCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopNoCatchCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopMethodCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrNoopCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsValidateAndNormalizeQueuingStrategyCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsCreateFIFOCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsNewQueueCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsDequeueValueCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsEnqueueValueWithSizeCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsPeekQueueValueCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsResetQueueCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsExtractSizeAlgorithmCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsExtractHighWaterMarkCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_streamInternalsCreateFulfilledPromiseCodeImplementationVisibility; -extern const char* const s_streamInternalsToDictionaryCode; -extern const int s_streamInternalsToDictionaryCodeLength; -extern const JSC::ConstructAbility s_streamInternalsToDictionaryCodeConstructAbility; -extern const JSC::ConstructorKind s_streamInternalsToDictionaryCodeConstructorKind; -extern const JSC::ImplementationVisibility s_streamInternalsToDictionaryCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/TransformStreamBuiltins.cpp b/src/bun.js/builtins/cpp/TransformStreamBuiltins.cpp deleted file mode 100644 index 7552cc5b0..000000000 --- a/src/bun.js/builtins/cpp/TransformStreamBuiltins.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_transformStreamInitializeTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_transformStreamInitializeTransformStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_transformStreamInitializeTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamReadableCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamWritableCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/TransformStreamBuiltins.h b/src/bun.js/builtins/cpp/TransformStreamBuiltins.h deleted file mode 100644 index 68b36206a..000000000 --- a/src/bun.js/builtins/cpp/TransformStreamBuiltins.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_transformStreamInitializeTransformStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamReadableCodeImplementationVisibility; -extern const char* const s_transformStreamWritableCode; -extern const int s_transformStreamWritableCodeLength; -extern const JSC::ConstructAbility s_transformStreamWritableCodeConstructAbility; -extern const JSC::ConstructorKind s_transformStreamWritableCodeConstructorKind; -extern const JSC::ImplementationVisibility s_transformStreamWritableCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/TransformStreamDefaultControllerBuiltins.cpp b/src/bun.js/builtins/cpp/TransformStreamDefaultControllerBuiltins.cpp deleted file mode 100644 index 696d11c80..000000000 --- a/src/bun.js/builtins/cpp/TransformStreamDefaultControllerBuiltins.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamDefaultControllerDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamDefaultControllerTerminateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/TransformStreamDefaultControllerBuiltins.h b/src/bun.js/builtins/cpp/TransformStreamDefaultControllerBuiltins.h deleted file mode 100644 index b0b75cda8..000000000 --- a/src/bun.js/builtins/cpp/TransformStreamDefaultControllerBuiltins.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_transformStreamDefaultControllerInitializeTransformStreamDefaultControllerCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamDefaultControllerDesiredSizeCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamDefaultControllerEnqueueCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamDefaultControllerErrorCodeImplementationVisibility; -extern const char* const s_transformStreamDefaultControllerTerminateCode; -extern const int s_transformStreamDefaultControllerTerminateCodeLength; -extern const JSC::ConstructAbility s_transformStreamDefaultControllerTerminateCodeConstructAbility; -extern const JSC::ConstructorKind s_transformStreamDefaultControllerTerminateCodeConstructorKind; -extern const JSC::ImplementationVisibility s_transformStreamDefaultControllerTerminateCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/TransformStreamInternalsBuiltins.cpp b/src/bun.js/builtins/cpp/TransformStreamInternalsBuiltins.cpp deleted file mode 100644 index 329eb52ea..000000000 --- a/src/bun.js/builtins/cpp/TransformStreamInternalsBuiltins.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_transformStreamInternalsIsTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_transformStreamInternalsIsTransformStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_transformStreamInternalsIsTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsIsTransformStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsCreateTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsInitializeTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamSetBackpressureCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/TransformStreamInternalsBuiltins.h b/src/bun.js/builtins/cpp/TransformStreamInternalsBuiltins.h deleted file mode 100644 index b362896c9..000000000 --- a/src/bun.js/builtins/cpp/TransformStreamInternalsBuiltins.h +++ /dev/null @@ -1,318 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_transformStreamInternalsIsTransformStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsIsTransformStreamDefaultControllerCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsCreateTransformStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsInitializeTransformStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamErrorWritableAndUnblockWriteCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamSetBackpressureCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCodeImplementationVisibility; -extern const char* const s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCode; -extern const int s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeLength; -extern const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility; -extern const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructorKind; -extern const JSC::ImplementationVisibility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h b/src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h deleted file mode 100644 index fde4bb97e..000000000 --- a/src/bun.js/builtins/cpp/WebCoreJSBuiltinInternals.h +++ /dev/null @@ -1,76 +0,0 @@ -// clang-format off -namespace Zig { class GlobalObject; } -#include "root.h" - -/* - * 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) 2023 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 "ReadableByteStreamInternalsBuiltins.h" -#include "ReadableStreamInternalsBuiltins.h" -#include "StreamInternalsBuiltins.h" -#include "TransformStreamInternalsBuiltins.h" -#include "WritableStreamInternalsBuiltins.h" -#include <JavaScriptCore/VM.h> -#include <JavaScriptCore/WeakInlines.h> - -namespace WebCore { - -using JSDOMGlobalObject = Zig::GlobalObject; - -class JSBuiltinInternalFunctions { -public: - explicit JSBuiltinInternalFunctions(JSC::VM&); - - 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/bun.js/builtins/cpp/WebCoreJSBuiltins.h b/src/bun.js/builtins/cpp/WebCoreJSBuiltins.h deleted file mode 100644 index 63a375248..000000000 --- a/src/bun.js/builtins/cpp/WebCoreJSBuiltins.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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) 2023 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 "BundlerPluginBuiltins.h" -#include "ByteLengthQueuingStrategyBuiltins.h" -#include "ConsoleObjectBuiltins.h" -#include "CountQueuingStrategyBuiltins.h" -#include "ImportMetaObjectBuiltins.h" -#include "JSBufferConstructorBuiltins.h" -#include "JSBufferPrototypeBuiltins.h" -#include "ProcessObjectInternalsBuiltins.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 { - -class JSBuiltinFunctions { -public: - explicit JSBuiltinFunctions(JSC::VM& vm) - : m_vm(vm) - , m_bundlerPluginBuiltins(m_vm) - , m_byteLengthQueuingStrategyBuiltins(m_vm) - , m_consoleObjectBuiltins(m_vm) - , m_countQueuingStrategyBuiltins(m_vm) - , m_importMetaObjectBuiltins(m_vm) - , m_jsBufferConstructorBuiltins(m_vm) - , m_jsBufferPrototypeBuiltins(m_vm) - , m_processObjectInternalsBuiltins(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(); - } - - BundlerPluginBuiltinsWrapper& bundlerPluginBuiltins() { return m_bundlerPluginBuiltins; } - ByteLengthQueuingStrategyBuiltinsWrapper& byteLengthQueuingStrategyBuiltins() { return m_byteLengthQueuingStrategyBuiltins; } - ConsoleObjectBuiltinsWrapper& consoleObjectBuiltins() { return m_consoleObjectBuiltins; } - CountQueuingStrategyBuiltinsWrapper& countQueuingStrategyBuiltins() { return m_countQueuingStrategyBuiltins; } - ImportMetaObjectBuiltinsWrapper& importMetaObjectBuiltins() { return m_importMetaObjectBuiltins; } - JSBufferConstructorBuiltinsWrapper& jsBufferConstructorBuiltins() { return m_jsBufferConstructorBuiltins; } - JSBufferPrototypeBuiltinsWrapper& jsBufferPrototypeBuiltins() { return m_jsBufferPrototypeBuiltins; } - ProcessObjectInternalsBuiltinsWrapper& processObjectInternalsBuiltins() { return m_processObjectInternalsBuiltins; } - 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; - BundlerPluginBuiltinsWrapper m_bundlerPluginBuiltins; - ByteLengthQueuingStrategyBuiltinsWrapper m_byteLengthQueuingStrategyBuiltins; - ConsoleObjectBuiltinsWrapper m_consoleObjectBuiltins; - CountQueuingStrategyBuiltinsWrapper m_countQueuingStrategyBuiltins; - ImportMetaObjectBuiltinsWrapper m_importMetaObjectBuiltins; - JSBufferConstructorBuiltinsWrapper m_jsBufferConstructorBuiltins; - JSBufferPrototypeBuiltinsWrapper m_jsBufferPrototypeBuiltins; - ProcessObjectInternalsBuiltinsWrapper m_processObjectInternalsBuiltins; - 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/bun.js/builtins/cpp/WritableStreamDefaultControllerBuiltins.cpp b/src/bun.js/builtins/cpp/WritableStreamDefaultControllerBuiltins.cpp deleted file mode 100644 index 9da322b83..000000000 --- a/src/bun.js/builtins/cpp/WritableStreamDefaultControllerBuiltins.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/WritableStreamDefaultControllerBuiltins.h b/src/bun.js/builtins/cpp/WritableStreamDefaultControllerBuiltins.h deleted file mode 100644 index ca7d33d66..000000000 --- a/src/bun.js/builtins/cpp/WritableStreamDefaultControllerBuiltins.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_writableStreamDefaultControllerInitializeWritableStreamDefaultControllerCodeImplementationVisibility; -extern const char* const s_writableStreamDefaultControllerErrorCode; -extern const int s_writableStreamDefaultControllerErrorCodeLength; -extern const JSC::ConstructAbility s_writableStreamDefaultControllerErrorCodeConstructAbility; -extern const JSC::ConstructorKind s_writableStreamDefaultControllerErrorCodeConstructorKind; -extern const JSC::ImplementationVisibility s_writableStreamDefaultControllerErrorCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/WritableStreamDefaultWriterBuiltins.cpp b/src/bun.js/builtins/cpp/WritableStreamDefaultWriterBuiltins.cpp deleted file mode 100644 index fc00693ca..000000000 --- a/src/bun.js/builtins/cpp/WritableStreamDefaultWriterBuiltins.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterClosedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterReadyCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterAbortCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterReleaseLockCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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/bun.js/builtins/cpp/WritableStreamDefaultWriterBuiltins.h b/src/bun.js/builtins/cpp/WritableStreamDefaultWriterBuiltins.h deleted file mode 100644 index fe0a6ef34..000000000 --- a/src/bun.js/builtins/cpp/WritableStreamDefaultWriterBuiltins.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_writableStreamDefaultWriterInitializeWritableStreamDefaultWriterCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterClosedCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterDesiredSizeCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterReadyCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterAbortCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterCloseCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamDefaultWriterReleaseLockCodeImplementationVisibility; -extern const char* const s_writableStreamDefaultWriterWriteCode; -extern const int s_writableStreamDefaultWriterWriteCodeLength; -extern const JSC::ConstructAbility s_writableStreamDefaultWriterWriteCodeConstructAbility; -extern const JSC::ConstructorKind s_writableStreamDefaultWriterWriteCodeConstructorKind; -extern const JSC::ImplementationVisibility s_writableStreamDefaultWriterWriteCodeImplementationVisibility; - -#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##ImplementationVisibility, 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/bun.js/builtins/cpp/WritableStreamInternalsBuiltins.cpp b/src/bun.js/builtins/cpp/WritableStreamInternalsBuiltins.cpp deleted file mode 100644 index 6b2111f4b..000000000 --- a/src/bun.js/builtins/cpp/WritableStreamInternalsBuiltins.cpp +++ /dev/null @@ -1,1232 +0,0 @@ -/* - * 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) 2023 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/IdentifierInlines.h> -#include <JavaScriptCore/ImplementationVisibility.h> -#include <JavaScriptCore/Intrinsic.h> -#include <JavaScriptCore/JSObjectInlines.h> -#include <JavaScriptCore/VM.h> - -namespace WebCore { - -const JSC::ConstructAbility s_writableStreamInternalsIsWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_writableStreamInternalsIsWritableStreamCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_writableStreamInternalsIsWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamInternalsIsWritableStreamDefaultWriterCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamInternalsCreateWritableStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamInternalsInitializeWritableStreamSlotsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsInitializeWritableStreamSlotsCodeLength = 762; -static const JSC::Intrinsic s_writableStreamInternalsInitializeWritableStreamSlotsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsInitializeWritableStreamSlotsCode = - "(function (stream, underlyingSink)\n" \ - "{ \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseForBindingsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamCloseForBindingsCodeLength = 434; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamCloseForBindingsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamCloseForBindingsCode = - "(function (stream)\n" \ - "{ \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAbortForBindingsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamAbortForBindingsCodeLength = 266; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAbortForBindingsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamAbortForBindingsCode = - "(function (stream, reason)\n" \ - "{ \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsIsWritableStreamLockedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsIsWritableStreamLockedCodeLength = 108; -static const JSC::Intrinsic s_writableStreamInternalsIsWritableStreamLockedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsIsWritableStreamLockedCode = - "(function (stream)\n" \ - "{ \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeLength = 1538; -static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultWriterCode = - "(function (writer, stream)\n" \ - "{ \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAbortCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamAbortCodeLength = 928; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAbortCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamAbortCode = - "(function (stream, reason)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamCloseCodeLength = 904; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamCloseCode = - "(function (stream)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAddWriteRequestCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamAddWriteRequestCodeLength = 391; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamAddWriteRequestCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamAddWriteRequestCode = - "(function (stream)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeLength = 188; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCode = - "(function (stream)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDealWithRejectionCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDealWithRejectionCodeLength = 294; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDealWithRejectionCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode = - "(function (stream, error)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishErroringCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamFinishErroringCodeLength = 1575; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishErroringCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishErroringCode = - "(function (stream)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeLength = 1111; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = - "(function (stream)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeLength = 753; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCode = - "(function (stream, error)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeLength = 296; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteCode = - "(function (stream)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeLength = 491; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCode = - "(function (stream, error)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeLength = 196; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCode = - "(function (stream)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeLength = 377; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCode = - "(function (stream)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeLength = 363; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode = - "(function (stream)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeLength = 809; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCode = - "(function (stream)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamStartErroringCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamStartErroringCodeLength = 752; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamStartErroringCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamStartErroringCode = - "(function (stream, reason)\n" \ - "{\n" \ - " \"use strict\";\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\") === 1)\n" \ - " @writableStreamFinishErroring(stream);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_writableStreamInternalsWritableStreamUpdateBackpressureCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamUpdateBackpressureCodeLength = 621; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamUpdateBackpressureCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamUpdateBackpressureCode = - "(function (stream, backpressure)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeLength = 195; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode = - "(function (writer, reason)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeLength = 179; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode = - "(function (writer)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeLength = 533; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode = - "(function (writer)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeLength = 625; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode = - "(function (writer, error)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeLength = 613; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = - "(function (writer, error)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeLength = 424; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = - "(function (writer)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeLength = 568; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterReleaseCode = - "(function (writer)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeLength = 1266; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = - "(function (writer, chunk)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeLength = 1142; -static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode = - "(function (stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm)\n" \ - "{\n" \ - " \"use strict\";\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\", -1);\n" \ - " @putByIdDirectPrivate(controller, \"startAlgorithm\", startAlgorithm);\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" \ - " @writableStreamDefaultControllerStart(controller);\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength = 982; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerStartCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = - "(function (controller) {\n" \ - " \"use strict\";\n" \ - "\n" \ - " if (@getByIdDirectPrivate(controller, \"started\") !== -1)\n" \ - " return;\n" \ - "\n" \ - " @putByIdDirectPrivate(controller, \"started\", 0);\n" \ - "\n" \ - " const startAlgorithm = @getByIdDirectPrivate(controller, \"startAlgorithm\");\n" \ - " @putByIdDirectPrivate(controller, \"startAlgorithm\", @undefined);\n" \ - " const stream = @getByIdDirectPrivate(controller, \"stream\");\n" \ - " return @Promise.@resolve(startAlgorithm.@call()).@then(() => {\n" \ - " const state = @getByIdDirectPrivate(stream, \"state\");\n" \ - " @assert(state === \"writable\" || state === \"erroring\");\n" \ - " @putByIdDirectPrivate(controller, \"started\", 1);\n" \ - " @writableStreamDefaultControllerAdvanceQueueIfNeeded(controller);\n" \ - " }, (error) => {\n" \ - " const state = @getByIdDirectPrivate(stream, \"state\");\n" \ - " @assert(state === \"writable\" || state === \"erroring\");\n" \ - " @putByIdDirectPrivate(controller, \"started\", 1);\n" \ - " @writableStreamDealWithRejection(stream, error);\n" \ - " });\n" \ - "})\n" \ -; - -const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 1394; -static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = - "(function (stream, underlyingSink, underlyingSinkDict, highWaterMark, sizeAlgorithm)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeLength = 884; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCode = - "(function (controller)\n" \ - "{\n" \ - " \"use strict\";\n" \ - " const stream = @getByIdDirectPrivate(controller, \"stream\");\n" \ - "\n" \ - " if (@getByIdDirectPrivate(controller, \"started\") !== 1)\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" \ - " const queue = @getByIdDirectPrivate(controller, \"queue\");\n" \ - "\n" \ - " if (queue.content?.isEmpty() ?? false)\n" \ - " return;\n" \ - "\n" \ - " const value = @peekQueueValue(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 JSC::ImplementationVisibility s_writableStreamInternalsIsCloseSentinelCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeLength = 329; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCode = - "(function (controller)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeLength = 208; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerCloseCode = - "(function (controller)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeLength = 336; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = - "(function (controller, error)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeLength = 246; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCode = - "(function (controller, error)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeLength = 159; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCode = - "(function (controller)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeLength = 275; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCode = - "(function (controller, chunk)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeLength = 157; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCode = - "(function (controller)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeLength = 646; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCode = - "(function (controller)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeLength = 1165; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode = - "(function (controller, chunk)\n" \ - "{\n" \ - " \"use strict\";\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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeLength = 725; -static const JSC::Intrinsic s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode = - "(function (controller, chunk, chunkSize)\n" \ - "{\n" \ - " \"use strict\";\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/bun.js/builtins/cpp/WritableStreamInternalsBuiltins.h b/src/bun.js/builtins/cpp/WritableStreamInternalsBuiltins.h deleted file mode 100644 index bc114276b..000000000 --- a/src/bun.js/builtins/cpp/WritableStreamInternalsBuiltins.h +++ /dev/null @@ -1,597 +0,0 @@ -/* - * 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) 2023 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 JSC::ImplementationVisibility s_writableStreamInternalsIsWritableStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsIsWritableStreamDefaultWriterCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsAcquireWritableStreamDefaultWriterCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsCreateWritableStreamCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsInitializeWritableStreamSlotsCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseForBindingsCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAbortForBindingsCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsIsWritableStreamLockedCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultWriterCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAbortCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamAddWriteRequestCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamCloseQueuedOrInFlightCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDealWithRejectionCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishErroringCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamFinishInFlightWriteWithErrorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamHasOperationMarkedInFlightCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamMarkCloseRequestInFlightCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamStartErroringCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamUpdateBackpressureCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterAbortCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultWriterWriteCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeImplementationVisibility; -extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode; -extern const int s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength; -extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility; -extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructorKind; -extern const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsIsCloseSentinelCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerClearAlgorithmsCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerCloseCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetBackpressureCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetChunkSizeCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerGetDesiredSizeCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerProcessCloseCodeImplementationVisibility; -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 JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCodeImplementationVisibility; -extern const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode; -extern const int s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeLength; -extern const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructAbility; -extern const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructorKind; -extern const JSC::ImplementationVisibility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeImplementationVisibility; - -#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(writableStreamDefaultControllerStart, writableStreamInternalsWritableStreamDefaultControllerStart, 1) \ - 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_WRITABLESTREAMDEFAULTCONTROLLERSTART 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(writableStreamInternalsWritableStreamDefaultControllerStartCode, writableStreamDefaultControllerStart, ASCIILiteral(), s_writableStreamInternalsWritableStreamDefaultControllerStartCodeLength) \ - 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(writableStreamDefaultControllerStart) \ - 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##ImplementationVisibility, 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/bun.js/builtins/js/BundlerPlugin.js b/src/bun.js/builtins/js/BundlerPlugin.js deleted file mode 100644 index 344f570d0..000000000 --- a/src/bun.js/builtins/js/BundlerPlugin.js +++ /dev/null @@ -1,467 +0,0 @@ -/* - * Copyright (C) 2023 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. ``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. - */ - -// This API expects 4 functions: -// - onLoadAsync -// - onResolveAsync -// - addError -// - addFilter -// -// It should be generic enough to reuse for Bun.plugin() eventually, too. - -function runOnResolvePlugins( - specifier, - inputNamespace, - importer, - internalID, - kindId -) { - "use strict"; - - // Must be kept in sync with ImportRecord.label - const kind = [ - "entry-point", - "import-statement", - "require-call", - "dynamic-import", - "require-resolve", - "import-rule", - "url-token", - "internal", - ][kindId]; - - var promiseResult = (async (inputPath, inputNamespace, importer, kind) => { - var {onResolve, onLoad} = this; - var results = onResolve.@get(inputNamespace); - if (!results) { - this.onResolveAsync(internalID, null, null, null); - return null; - } - - for (let [filter, callback] of results) { - if (filter.test(inputPath)) { - var result = callback({ - path: inputPath, - importer, - namespace: inputNamespace, - // resolveDir - kind, - // pluginData - }); - - while ( - result && - @isPromise(result) && - (@getPromiseInternalField(result, @promiseFieldFlags) & - @promiseStateMask) === - @promiseStateFulfilled - ) { - result = @getPromiseInternalField( - result, - @promiseFieldReactionsOrResult - ); - } - - if (result && @isPromise(result)) { - result = await result; - } - - if (!result || !@isObject(result)) { - continue; - } - - - var { - path, - namespace: userNamespace = inputNamespace, - external, - } = result; - if ( - !(typeof path === "string") || - !(typeof userNamespace === "string") - ) { - @throwTypeError( - "onResolve plugins must return an object with a string 'path' and string 'loader' field" - ); - } - - if (!path) { - continue; - } - - if (!userNamespace) { - userNamespace = inputNamespace; - } - if (typeof external !== "boolean" && !@isUndefinedOrNull(external)) { - @throwTypeError( - 'onResolve plugins "external" field must be boolean or unspecified' - ); - } - - - if (!external) { - if (userNamespace === "file") { - // TODO: Windows - - if (path[0] !== "/" || path.includes("..")) { - @throwTypeError( - 'onResolve plugin "path" must be absolute when the namespace is "file"' - ); - } - } - if (userNamespace === "dataurl") { - if (!path.startsWith("data:")) { - @throwTypeError( - 'onResolve plugin "path" must start with "data:" when the namespace is "dataurl"' - ); - } - } - - if (userNamespace && userNamespace !== "file" && (!onLoad || !onLoad.@has(userNamespace))) { - @throwTypeError( - `Expected onLoad plugin for namespace ${@jsonStringify(userNamespace, " ")} to exist` - ); - } - - } - this.onResolveAsync(internalID, path, userNamespace, external); - return null; - } - } - - this.onResolveAsync(internalID, null, null, null); - return null; - })(specifier, inputNamespace, importer, kind); - - while ( - promiseResult && - @isPromise(promiseResult) && - (@getPromiseInternalField(promiseResult, @promiseFieldFlags) & - @promiseStateMask) === - @promiseStateFulfilled - ) { - promiseResult = @getPromiseInternalField( - promiseResult, - @promiseFieldReactionsOrResult - ); - } - - if (promiseResult && @isPromise(promiseResult)) { - promiseResult.then( - () => {}, - (e) => { - this.addError(internalID, e, 0); - } - ); - } -} - -function runSetupFunction(setup, config) { - "use strict"; - var onLoadPlugins = new Map(), - onResolvePlugins = new Map(); - - function validate(filterObject, callback, map) { - if (!filterObject || !@isObject(filterObject)) { - @throwTypeError('Expected an object with "filter" RegExp'); - } - - if (!callback || !@isCallable(callback)) { - @throwTypeError("callback must be a function"); - } - - var { filter, namespace = "file" } = filterObject; - - if (!filter) { - @throwTypeError('Expected an object with "filter" RegExp'); - } - - if (!@isRegExpObject(filter)) { - @throwTypeError("filter must be a RegExp"); - } - - if (namespace && !(typeof namespace === "string")) { - @throwTypeError("namespace must be a string"); - } - - if ((namespace?.length ?? 0) === 0) { - namespace = "file"; - } - - if (!/^([/@a-zA-Z0-9_\\-]+)$/.test(namespace)) { - @throwTypeError("namespace can only contain @a-zA-Z0-9_\\-"); - } - - var callbacks = map.@get(namespace); - - if (!callbacks) { - map.@set(namespace, [[filter, callback]]); - } else { - @arrayPush(callbacks, [filter, callback]); - } - } - - function onLoad(filterObject, callback) { - validate(filterObject, callback, onLoadPlugins); - } - - function onResolve(filterObject, callback) { - validate(filterObject, callback, onResolvePlugins); - } - - function onStart(callback) { - // builtin generator thinks the // in the link is a comment and removes it - @throwTypeError("On-start callbacks are not implemented yet. See https:/\/github.com/oven-sh/bun/issues/2771"); - } - - function onEnd(callback) { - @throwTypeError("On-end callbacks are not implemented yet. See https:/\/github.com/oven-sh/bun/issues/2771"); - } - - function onDispose(callback) { - @throwTypeError("On-dispose callbacks are not implemented yet. See https:/\/github.com/oven-sh/bun/issues/2771"); - } - - function resolve(callback) { - @throwTypeError("build.resolve() is not implemented yet. See https:/\/github.com/oven-sh/bun/issues/2771"); - } - - const processSetupResult = () => { - var anyOnLoad = false, - anyOnResolve = false; - - for (var [namespace, callbacks] of onLoadPlugins.entries()) { - for (var [filter] of callbacks) { - this.addFilter(filter, namespace, 1); - anyOnLoad = true; - } - } - - for (var [namespace, callbacks] of onResolvePlugins.entries()) { - for (var [filter] of callbacks) { - this.addFilter(filter, namespace, 0); - anyOnResolve = true; - } - } - - if (anyOnResolve) { - var onResolveObject = this.onResolve; - if (!onResolveObject) { - this.onResolve = onResolvePlugins; - } else { - for (var [namespace, callbacks] of onResolvePlugins.entries()) { - var existing = onResolveObject.@get(namespace); - - if (!existing) { - onResolveObject.@set(namespace, callbacks); - } else { - onResolveObject.@set(namespace, existing.concat(callbacks)); - } - } - } - } - - if (anyOnLoad) { - var onLoadObject = this.onLoad; - if (!onLoadObject) { - this.onLoad = onLoadPlugins; - } else { - for (var [namespace, callbacks] of onLoadPlugins.entries()) { - var existing = onLoadObject.@get(namespace); - - if (!existing) { - onLoadObject.@set(namespace, callbacks); - } else { - onLoadObject.@set(namespace, existing.concat(callbacks)); - } - } - } - } - - return anyOnLoad || anyOnResolve; - }; - - var setupResult = setup({ - config, - onDispose, - onEnd, - onLoad, - onResolve, - onStart, - resolve, - // esbuild's options argument is different, we provide some interop - initialOptions: { - ...config, - bundle: true, - entryPoints: config.entrypoints ?? config.entryPoints ?? [], - minify: typeof config.minify === 'boolean' ? config.minify : false, - minifyIdentifiers: config.minify === true || config.minify?.identifiers, - minifyWhitespace: config.minify === true || config.minify?.whitespace, - minifySyntax: config.minify === true || config.minify?.syntax, - outbase: config.root, - platform: config.target === 'bun' ? 'node' : config.target, - root: undefined, - }, - esbuild: {}, - }); - - if (setupResult && @isPromise(setupResult)) { - if ( - @getPromiseInternalField(setupResult, @promiseFieldFlags) & - @promiseStateFulfilled - ) { - setupResult = @getPromiseInternalField( - setupResult, - @promiseFieldReactionsOrResult - ); - } else { - return setupResult.@then(processSetupResult); - } - } - - return processSetupResult(); -} - -function runOnLoadPlugins(internalID, path, namespace, defaultLoaderId) { - "use strict"; - - const LOADERS_MAP = { - jsx: 0, - js: 1, - ts: 2, - tsx: 3, - css: 4, - file: 5, - json: 6, - toml: 7, - wasm: 8, - napi: 9, - base64: 10, - dataurl: 11, - text: 12, - }; - const loaderName = [ - "jsx", - "js", - "ts", - "tsx", - "css", - "file", - "json", - "toml", - "wasm", - "napi", - "base64", - "dataurl", - "text", - ][defaultLoaderId]; - - var promiseResult = (async (internalID, path, namespace, defaultLoader) => { - var results = this.onLoad.@get(namespace); - if (!results) { - this.onLoadAsync(internalID, null, null, null); - return null; - } - - for (let [filter, callback] of results) { - if (filter.test(path)) { - var result = callback({ - path, - namespace, - // suffix - // pluginData - loader: defaultLoader, - }); - - while ( - result && - @isPromise(result) && - (@getPromiseInternalField(result, @promiseFieldFlags) & - @promiseStateMask) === - @promiseStateFulfilled - ) { - result = @getPromiseInternalField( - result, - @promiseFieldReactionsOrResult - ); - } - - if (result && @isPromise(result)) { - result = await result; - } - - if (!result || !@isObject(result)) { - continue; - } - - var { contents, loader = defaultLoader } = result; - if (!(typeof contents === "string") && !@isTypedArrayView(contents)) { - @throwTypeError( - 'onLoad plugins must return an object with "contents" as a string or Uint8Array' - ); - } - - if (!(typeof loader === "string")) { - @throwTypeError( - 'onLoad plugins must return an object with "loader" as a string' - ); - } - - const chosenLoader = LOADERS_MAP[loader]; - if (chosenLoader === @undefined) { - @throwTypeError(`Loader ${@jsonStringify(loader, " ")} is not supported.`); - } - - this.onLoadAsync(internalID, contents, chosenLoader); - return null; - } - } - - this.onLoadAsync(internalID, null, null); - return null; - })(internalID, path, namespace, loaderName); - - while ( - promiseResult && - @isPromise(promiseResult) && - (@getPromiseInternalField(promiseResult, @promiseFieldFlags) & - @promiseStateMask) === - @promiseStateFulfilled - ) { - promiseResult = @getPromiseInternalField( - promiseResult, - @promiseFieldReactionsOrResult - ); - } - - if (promiseResult && @isPromise(promiseResult)) { - promiseResult.then( - () => {}, - (e) => { - this.addError(internalID, e, 1); - } - ); - } -} diff --git a/src/bun.js/builtins/js/ConsoleObject.js b/src/bun.js/builtins/js/ConsoleObject.js deleted file mode 100644 index d51ed08ef..000000000 --- a/src/bun.js/builtins/js/ConsoleObject.js +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2023 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. ``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. - */ - -@overriddenName="[Symbol.asyncIterator]" -function asyncIterator() { - "use strict"; - - const Iterator = async function* ConsoleAsyncIterator() { - "use strict"; - - const stream = @Bun.stdin.stream(); - var reader = stream.getReader(); - - // TODO: use builtin - var decoder = new globalThis.TextDecoder("utf-8", { fatal: false }); - var deferredError; - var indexOf = @Bun.indexOfLine; - - try { - while (true) { - var done, value; - var pendingChunk; - const firstResult = reader.readMany(); - if (@isPromise(firstResult)) { - ({done, value} = await firstResult); - } else { - ({done, value} = firstResult); - } - - if (done) { - if (pendingChunk) { - yield decoder.decode(pendingChunk); - } - return; - } - - var actualChunk; - // we assume it was given line-by-line - for (const chunk of value) { - actualChunk = chunk; - if (pendingChunk) { - actualChunk = Buffer.concat([pendingChunk, chunk]); - pendingChunk = null; - } - - var last = 0; - // TODO: "\r", 0x4048, 0x4049, 0x404A, 0x404B, 0x404C, 0x404D, 0x404E, 0x404F - var i = indexOf(actualChunk, last); - while (i !== -1) { - yield decoder.decode(actualChunk.subarray(last, i)); - last = i + 1; - i = indexOf(actualChunk, last); - } - - pendingChunk = actualChunk.subarray(last); - } - } - } catch(e) { - deferredError = e; - } finally { - reader.releaseLock(); - - if (deferredError) { - throw deferredError; - } - } - }; - - const symbol = globalThis.Symbol.asyncIterator; - this[symbol] = Iterator; - return Iterator(); -} - -function write(input) { - "use strict"; - - var writer = @getByIdDirectPrivate(this, "writer"); - if (!writer) { - var length = @toLength(input?.length ?? 0); - writer = @Bun.stdout.writer({highWaterMark: length > 65536 ? length : 65536}); - @putByIdDirectPrivate(this, "writer", writer); - } - - var wrote = writer.write(input); - - const count = @argumentCount(); - for (var i = 1; i < count; i++) { - wrote += writer.write(@argument(i)); - } - - writer.flush(true); - return wrote; -}
\ No newline at end of file diff --git a/src/bun.js/builtins/js/ImportMetaObject.js b/src/bun.js/builtins/js/ImportMetaObject.js deleted file mode 100644 index e2a9a42d8..000000000 --- a/src/bun.js/builtins/js/ImportMetaObject.js +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright 2023 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. ``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 loadCJS2ESM(resolvedSpecifier) { - "use strict"; - - var loader = @Loader; - var queue = @createFIFO(); - var key = resolvedSpecifier; - while (key) { - // we need to explicitly check because state could be @ModuleFetch - // it will throw this error if we do not: - // @throwTypeError("Requested module is already fetched."); - var entry = loader.registry.@get(key); - - if (!entry || !entry.state || entry.state <= @ModuleFetch) { - @fulfillModuleSync(key); - entry = loader.registry.@get(key); - } - - - // entry.fetch is a Promise<SourceCode> - // SourceCode is not a string, it's a JSC::SourceCode object - // this pulls it out of the promise without delaying by a tick - // the promise is already fullfilled by @fullfillModuleSync - var sourceCodeObject = @getPromiseInternalField( - entry.fetch, - @promiseFieldReactionsOrResult - ); - // parseModule() returns a Promise, but the value is already fulfilled - // so we just pull it out of the promise here once again - // But, this time we do it a little more carefully because this is a JSC function call and not bun source code - var moduleRecordPromise = loader.parseModule(key, sourceCodeObject); - var module = entry.module; - if (!module && moduleRecordPromise && @isPromise(moduleRecordPromise)) { - var reactionsOrResult = @getPromiseInternalField( - moduleRecordPromise, - @promiseFieldReactionsOrResult - ); - var flags = @getPromiseInternalField( - moduleRecordPromise, - @promiseFieldFlags - ); - var state = flags & @promiseStateMask; - // this branch should never happen, but just to be safe - if ( - state === @promiseStatePending || - (reactionsOrResult && @isPromise(reactionsOrResult)) - ) { - @throwTypeError(`require() async module \"${key}\" is unsupported`); - } else if (state === @promiseStateRejected) { - // this branch happens if there is a syntax error and somehow bun didn't catch it - // "throw" is unsupported here, so we use "throwTypeError" (TODO: use SyntaxError but preserve the specifier) - @throwTypeError( - `${ - reactionsOrResult?.message ?? "An error occurred" - } while parsing module \"${key}\"` - ); - } - entry.module = module = reactionsOrResult; - } else if (moduleRecordPromise && !module) { - entry.module = module = moduleRecordPromise; - } - - // This is very similar to "requestInstantiate" in ModuleLoader.js in JavaScriptCore. - @setStateToMax(entry, @ModuleLink); - var dependenciesMap = module.dependenciesMap; - var requestedModules = loader.requestedModules(module); - var dependencies = @newArrayWithSize(requestedModules.length); - for (var i = 0, length = requestedModules.length; i < length; ++i) { - var depName = requestedModules[i]; - // optimization: if it starts with a slash then it's an absolute path - // we don't need to run the resolver a 2nd time - var depKey = - depName[0] === "/" - ? depName - : loader.resolve(depName, key, @undefined); - var depEntry = loader.ensureRegistered(depKey); - if (depEntry.state < @ModuleLink) { - queue.push(depKey); - } - - @putByValDirect(dependencies, i, depEntry); - dependenciesMap.@set(depName, depEntry); - } - - entry.dependencies = dependencies; - // All dependencies resolved, set instantiate and satisfy field directly. - entry.instantiate = @Promise.resolve(entry) - entry.satisfy = @Promise.resolve(entry); - key = queue.shift(); - while (key && (loader.registry.@get(key)?.state ?? @ModuleFetch) >= @ModuleLink) { - key = queue.shift(); - } - - } - - var linkAndEvaluateResult = loader.linkAndEvaluateModule( - resolvedSpecifier, - @undefined - ); - if (linkAndEvaluateResult && @isPromise(linkAndEvaluateResult)) { - // if you use top-level await, or any dependencies use top-level await, then we throw here - // this means the module will still actually load eventually, but that's okay. - @throwTypeError( - `require() async module \"${resolvedSpecifier}\" is unsupported` - ); - } - - return loader.registry.@get(resolvedSpecifier); - -} - - -function requireESM(resolved) { - "use strict"; - var entry = @Loader.registry.@get(resolved); - - if (!entry || !entry.evaluated) { - entry = @loadCJS2ESM(resolved); - } - - if (!entry || !entry.evaluated || !entry.module) { - @throwTypeError(`require() failed to evaluate module \"${resolved}\". This is an internal consistentency error.`); - } - var exports = @Loader.getModuleNamespaceObject(entry.module); - var commonJS = exports.default; - var cjs = commonJS?.[@commonJSSymbol]; - if (cjs === 0) { - return commonJS; - } else if (cjs && @isCallable(commonJS)) { - return commonJS(); - } - - return exports; -} - -function internalRequire(resolved) { - "use strict"; - - var cached = @requireMap.@get(resolved); - const last5 = resolved.substring(resolved.length - 5); - if (cached) { - if (last5 === ".node") { - return cached.exports; - } - - return cached; - } - - // TODO: remove this hardcoding - if (last5 === ".json") { - var fs = (globalThis[Symbol.for("_fs")] ||= @Bun.fs()); - var exports = JSON.parse(fs.readFileSync(resolved, "utf8")); - @requireMap.@set(resolved, exports); - return exports; - } else if (last5 === ".node") { - var module = { exports: {} }; - process.dlopen(module, resolved); - @requireMap.@set(resolved, module); - return module.exports; - } else if (last5 === ".toml") { - var fs = (globalThis[Symbol.for("_fs")] ||= @Bun.fs()); - var exports = @Bun.TOML.parse(fs.readFileSync(resolved, "utf8")); - @requireMap.@set(resolved, exports); - return exports; - } else { - var exports = @requireESM(resolved); - @requireMap.@set(resolved, exports); - return exports; - } -} - -function require(name) { - const from = this?.path ?? arguments.callee.path; - - if (typeof name !== "string") { - @throwTypeError("require(name) must be a string"); - } - - return @internalRequire(@resolveSync(name, from)); -} - -@getter -function main() { - return this.path === @Bun.main; -} diff --git a/src/bun.js/builtins/js/JSBufferConstructor.js b/src/bun.js/builtins/js/JSBufferConstructor.js deleted file mode 100644 index f5389385e..000000000 --- a/src/bun.js/builtins/js/JSBufferConstructor.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2023 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. ``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. - */ - -// ^ that comment is required or the builtins generator will have a fit. - -function from(items) { - "use strict"; - - if (@isUndefinedOrNull(items)) { - @throwTypeError( - "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.", - ); - } - - - // TODO: figure out why private symbol not found - if ( - typeof items === "string" || - (typeof items === "object" && - (@isTypedArrayView(items) || - items instanceof ArrayBuffer || - items instanceof SharedArrayBuffer || - items instanceof @String)) - ) { - switch (@argumentCount()) { - case 1: { - return new @Buffer(items); - } - case 2: { - return new @Buffer(items, @argument(1)); - } - default: { - return new @Buffer(items, @argument(1), @argument(2)); - } - } - } - - var arrayLike = @toObject( - items, - "The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.", - ); - - if (!@isJSArray(arrayLike)) { - const toPrimitive = @tryGetByIdWithWellKnownSymbol(items, "toPrimitive"); - - if (toPrimitive) { - const primitive = toPrimitive.@call(items, "string"); - - if (typeof primitive === "string") { - switch (@argumentCount()) { - case 1: { - return new @Buffer(primitive); - } - case 2: { - return new @Buffer(primitive, @argument(1)); - } - default: { - return new @Buffer(primitive, @argument(1), @argument(2)); - } - } - } - } - - if (!("length" in arrayLike) || @isCallable(arrayLike)) { - @throwTypeError( - "The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.", - ); - } - } - - // Don't pass the second argument because Node's Buffer.from doesn't accept - // a function and Uint8Array.from requires it if it exists - // That means we cannot use @tailCallFowrardArguments here, sadly - return new @Buffer(@Uint8Array.from(arrayLike).buffer); -} diff --git a/src/bun.js/builtins/js/JSBufferPrototype.js b/src/bun.js/builtins/js/JSBufferPrototype.js deleted file mode 100644 index 1ae6fb0d6..000000000 --- a/src/bun.js/builtins/js/JSBufferPrototype.js +++ /dev/null @@ -1,580 +0,0 @@ -/* - * Copyright 2023 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. ``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. - */ - - -// ^ that comment is required or the builtins generator will have a fit. - -// The fastest way as of April 2022 is to use DataView. -// DataView has intrinsics that cause inlining - -function setBigUint64(offset, value, le) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value, le); -} -function readInt8(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt8(offset); -} -function readUInt8(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint8(offset); -} -function readInt16LE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt16(offset, true); -} -function readInt16BE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt16(offset, false); -} -function readUInt16LE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint16(offset, true); -} -function readUInt16BE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint16(offset, false); -} -function readInt32LE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt32(offset, true); -} -function readInt32BE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt32(offset, false); -} -function readUInt32LE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint32(offset, true); -} -function readUInt32BE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint32(offset, false); -} - -function readIntLE(offset, byteLength) { - "use strict"; - const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength); - switch (byteLength) { - case 1: { - return view.getInt8(offset); - } - case 2: { - return view.getInt16(offset, true); - } - case 3: { - const val = view.getUint16(offset, true) + view.getUint8(offset + 2) * 2 ** 16; - return val | (val & 2 ** 23) * 0x1fe; - } - case 4: { - return view.getInt32(offset, true); - } - case 5: { - const last = view.getUint8(offset + 4); - return (last | (last & 2 ** 7) * 0x1fffffe) * 2 ** 32 + view.getUint32(offset, true); - } - case 6: { - const last = view.getUint16(offset + 4, true); - return (last | (last & 2 ** 15) * 0x1fffe) * 2 ** 32 + view.getUint32(offset, true); - } - } - @throwRangeError("byteLength must be >= 1 and <= 6"); -} -function readIntBE(offset, byteLength) { - "use strict"; - const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength); - switch (byteLength) { - case 1: { - return view.getInt8(offset); - } - case 2: { - return view.getInt16(offset, false); - } - case 3: { - const val = view.getUint16(offset + 1, false) + view.getUint8(offset) * 2 ** 16; - return val | (val & 2 ** 23) * 0x1fe; - } - case 4: { - return view.getInt32(offset, false); - } - case 5: { - const last = view.getUint8(offset); - return (last | (last & 2 ** 7) * 0x1fffffe) * 2 ** 32 + view.getUint32(offset + 1, false); - } - case 6: { - const last = view.getUint16(offset, false); - return (last | (last & 2 ** 15) * 0x1fffe) * 2 ** 32 + view.getUint32(offset + 2, false); - } - } - @throwRangeError("byteLength must be >= 1 and <= 6"); -} -function readUIntLE(offset, byteLength) { - "use strict"; - const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength); - switch (byteLength) { - case 1: { - return view.getUint8(offset); - } - case 2: { - return view.getUint16(offset, true); - } - case 3: { - return view.getUint16(offset, true) + view.getUint8(offset + 2) * 2 ** 16; - } - case 4: { - return view.getUint32(offset, true); - } - case 5: { - return view.getUint8(offset + 4) * 2 ** 32 + view.getUint32(offset, true); - } - case 6: { - return view.getUint16(offset + 4, true) * 2 ** 32 + view.getUint32(offset, true); - } - } - @throwRangeError("byteLength must be >= 1 and <= 6"); -} - -function inspect(recurseTimes, ctx) { - "use strict"; - - return @Bun.inspect(this); -} - -function readUIntBE(offset, byteLength) { - "use strict"; - const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength); - switch (byteLength) { - case 1: { - return view.getUint8(offset); - } - case 2: { - return view.getUint16(offset, false); - } - case 3: { - return view.getUint16(offset + 1, false) + view.getUint8(offset) * 2 ** 16; - } - case 4: { - return view.getUint32(offset, false); - } - case 5: { - const last = view.getUint8(offset); - return (last | (last & 2 ** 7) * 0x1fffffe) * 2 ** 32 + view.getUint32(offset + 1, false); - } - case 6: { - const last = view.getUint16(offset, false); - return (last | (last & 2 ** 15) * 0x1fffe) * 2 ** 32 + view.getUint32(offset + 2, false); - } - } - @throwRangeError("byteLength must be >= 1 and <= 6"); -} - -function readFloatLE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat32(offset, true); -} -function readFloatBE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat32(offset, false); -} -function readDoubleLE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat64(offset, true); -} -function readDoubleBE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat64(offset, false); -} -function readBigInt64LE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigInt64(offset, true); -} -function readBigInt64BE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigInt64(offset, false); -} -function readBigUInt64LE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigUint64(offset, true); -} -function readBigUInt64BE(offset) { - "use strict"; - return (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigUint64(offset, false); -} - -function writeInt8(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt8(offset, value); - return offset + 1; -} -function writeUInt8(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint8(offset, value); - return offset + 1; -} -function writeInt16LE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt16(offset, value, true); - return offset + 2; -} -function writeInt16BE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt16(offset, value, false); - return offset + 2; -} -function writeUInt16LE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint16(offset, value, true); - return offset + 2; -} -function writeUInt16BE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint16(offset, value, false); - return offset + 2; -} -function writeInt32LE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt32(offset, value, true); - return offset + 4; -} -function writeInt32BE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt32(offset, value, false); - return offset + 4; -} -function writeUInt32LE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint32(offset, value, true); - return offset + 4; -} -function writeUInt32BE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint32(offset, value, false); - return offset + 4; -} - -function writeIntLE(value, offset, byteLength) { - "use strict"; - const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength); - switch (byteLength) { - case 1: { - view.setInt8(offset, value); - break; - } - case 2: { - view.setInt16(offset, value, true); - break; - } - case 3: { - view.setUint16(offset, value & 0xFFFF, true); - view.setInt8(offset + 2, Math.floor(value * 2 ** -16)); - break; - } - case 4: { - view.setInt32(offset, value, true); - break; - } - case 5: { - view.setUint32(offset, value | 0, true); - view.setInt8(offset + 4, Math.floor(value * 2 ** -32)); - break; - } - case 6: { - view.setUint32(offset, value | 0, true); - view.setInt16(offset + 4, Math.floor(value * 2 ** -32), true); - break; - } - default: { - @throwRangeError("byteLength must be >= 1 and <= 6"); - } - } - return offset + byteLength; -} -function writeIntBE(value, offset, byteLength) { - "use strict"; - const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength); - switch (byteLength) { - case 1: { - view.setInt8(offset, value); - break; - } - case 2: { - view.setInt16(offset, value, false); - break; - } - case 3: { - view.setUint16(offset + 1, value & 0xFFFF, false); - view.setInt8(offset, Math.floor(value * 2 ** -16)); - break; - } - case 4: { - view.setInt32(offset, value, false); - break; - } - case 5: { - view.setUint32(offset + 1, value | 0, false); - view.setInt8(offset, Math.floor(value * 2 ** -32)); - break; - } - case 6: { - view.setUint32(offset + 2, value | 0, false); - view.setInt16(offset, Math.floor(value * 2 ** -32), false); - break; - } - default: { - @throwRangeError("byteLength must be >= 1 and <= 6"); - } - } - return offset + byteLength; -} -function writeUIntLE(value, offset, byteLength) { - "use strict"; - const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength); - switch (byteLength) { - case 1: { - view.setUint8(offset, value); - break; - } - case 2: { - view.setUint16(offset, value, true); - break; - } - case 3: { - view.setUint16(offset, value & 0xFFFF, true); - view.setUint8(offset + 2, Math.floor(value * 2 ** -16)); - break; - } - case 4: { - view.setUint32(offset, value, true); - break; - } - case 5: { - view.setUint32(offset, value | 0, true); - view.setUint8(offset + 4, Math.floor(value * 2 ** -32)); - break; - } - case 6: { - view.setUint32(offset, value | 0, true); - view.setUint16(offset + 4, Math.floor(value * 2 ** -32), true); - break; - } - default: { - @throwRangeError("byteLength must be >= 1 and <= 6"); - } - } - return offset + byteLength; -} -function writeUIntBE(value, offset, byteLength) { - "use strict"; - const view = this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength); - switch (byteLength) { - case 1: { - view.setUint8(offset, value); - break; - } - case 2: { - view.setUint16(offset, value, false); - break; - } - case 3: { - view.setUint16(offset + 1, value & 0xFFFF, false); - view.setUint8(offset, Math.floor(value * 2 ** -16)); - break; - } - case 4: { - view.setUint32(offset, value, false); - break; - } - case 5: { - view.setUint32(offset + 1, value | 0, false); - view.setUint8(offset, Math.floor(value * 2 ** -32)); - break; - } - case 6: { - view.setUint32(offset + 2, value | 0, false); - view.setUint16(offset, Math.floor(value * 2 ** -32), false); - break; - } - default: { - @throwRangeError("byteLength must be >= 1 and <= 6"); - } - } - return offset + byteLength; -} - -function writeFloatLE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat32(offset, value, true); - return offset + 4; -} - -function writeFloatBE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat32(offset, value, false); - return offset + 4; -} - -function writeDoubleLE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat64(offset, value, true); - return offset + 8; -} - -function writeDoubleBE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat64(offset, value, false); - return offset + 8; -} - -function writeBigInt64LE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigInt64(offset, value, true); - return offset + 8; -} - -function writeBigInt64BE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigInt64(offset, value, false); - return offset + 8; -} - -function writeBigUInt64LE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value, true); - return offset + 8; -} - -function writeBigUInt64BE(value, offset) { - "use strict"; - (this.@dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value, false); - return offset + 8; -} - -function utf8Write(text, offset, length) { - "use strict"; - return this.write(text, offset, length, "utf8"); -} -function ucs2Write(text, offset, length) { - "use strict"; - return this.write(text, offset, length, "ucs2"); -} -function utf16leWrite(text, offset, length) { - "use strict"; - return this.write(text, offset, length, "utf16le"); -} -function latin1Write(text, offset, length) { - "use strict"; - return this.write(text, offset, length, "latin1"); -} -function asciiWrite(text, offset, length) { - "use strict"; - return this.write(text, offset, length, "ascii"); -} -function base64Write(text, offset, length) { - "use strict"; - return this.write(text, offset, length, "base64"); -} -function base64urlWrite(text, offset, length) { - "use strict"; - return this.write(text, offset, length, "base64url"); -} -function hexWrite(text, offset, length) { - "use strict"; - return this.write(text, offset, length, "hex"); -} - -function utf8Slice(offset, length) { - "use strict"; - return this.toString(offset, length, "utf8"); -} -function ucs2Slice(offset, length) { - "use strict"; - return this.toString(offset, length, "ucs2"); -} -function utf16leSlice(offset, length) { - "use strict"; - return this.toString(offset, length, "utf16le"); -} -function latin1Slice(offset, length) { - "use strict"; - return this.toString(offset, length, "latin1"); -} -function asciiSlice(offset, length) { - "use strict"; - return this.toString(offset, length, "ascii"); -} -function base64Slice(offset, length) { - "use strict"; - return this.toString(offset, length, "base64"); -} -function base64urlSlice(offset, length) { - "use strict"; - return this.toString(offset, length, "base64url"); -} -function hexSlice(offset, length) { - "use strict"; - return this.toString(offset, length, "hex"); -} - -function toJSON() { - "use strict"; - const type = "Buffer"; - const data = @Array.from(this); - return { type, data }; -} - -function slice(start, end) { - "use strict"; - var { buffer, byteOffset, byteLength } = this; - - function adjustOffset(offset, length) { - // Use Math.trunc() to convert offset to an integer value that can be larger - // than an Int32. Hence, don't use offset | 0 or similar techniques. - offset = @trunc(offset); - if (offset === 0 || @isNaN(offset)) { - return 0; - } else if (offset < 0) { - offset += length; - return offset > 0 ? offset : 0; - } else { - return offset < length ? offset : length; - } - } - - var start_ = adjustOffset(start, byteLength); - var end_ = end !== @undefined ? adjustOffset(end, byteLength) : byteLength; - return new Buffer(buffer, byteOffset + start_, end_ > start_ ? (end_ - start_) : 0); -} - -@getter -function parent() { - "use strict"; - return @isObject(this) && this instanceof @Buffer ? this.buffer : @undefined; -} - -@getter -function offset() { - "use strict"; - return @isObject(this) && this instanceof @Buffer ? this.byteOffset : @undefined; -} diff --git a/src/bun.js/builtins/js/ReadableByteStreamController.js b/src/bun.js/builtins/js/ReadableByteStreamController.js deleted file mode 100644 index 0b47d730c..000000000 --- a/src/bun.js/builtins/js/ReadableByteStreamController.js +++ /dev/null @@ -1,117 +0,0 @@ -/* - * 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/bun.js/builtins/js/ReadableByteStreamInternals.js b/src/bun.js/builtins/js/ReadableByteStreamInternals.js deleted file mode 100644 index 01da62e1a..000000000 --- a/src/bun.js/builtins/js/ReadableByteStreamInternals.js +++ /dev/null @@ -1,712 +0,0 @@ -/* - * 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", 0); - @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; - @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(controller, "underlyingByteSource"), "start", [controller]).@then(() => { - @putByIdDirectPrivate(controller, "started", 1); - @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 readableStreamByteStreamControllerStart(controller) { - "use strict"; - @putByIdDirectPrivate(controller, "start", @undefined); - -} - - -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").content?.isNotEmpty()) { - 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") > 0)) - 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/bun.js/builtins/js/ReadableStream.js b/src/bun.js/builtins/js/ReadableStream.js deleted file mode 100644 index 1449c836d..000000000 --- a/src/bun.js/builtins/js/ReadableStream.js +++ /dev/null @@ -1,459 +0,0 @@ -/* - * 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 = { @bunNativeType: 0, @bunNativePtr: 0, @lazy: false }; - 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); - @putByIdDirectPrivate(this, "bunNativeType", @getByIdDirectPrivate(underlyingSource, "bunNativeType") ?? 0); - @putByIdDirectPrivate(this, "bunNativePtr", @getByIdDirectPrivate(underlyingSource, "bunNativePtr") ?? 0); - - const isDirect = underlyingSource.type === "direct"; - // direct streams are always lazy - const isUnderlyingSourceLazy = !!underlyingSource.@lazy; - const isLazy = isDirect || isUnderlyingSourceLazy; - - // // 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 && !isLazy) { - const size = @getByIdDirectPrivate(strategy, "size"); - const highWaterMark = @getByIdDirectPrivate(strategy, "highWaterMark"); - @putByIdDirectPrivate(this, "highWaterMark", highWaterMark); - @putByIdDirectPrivate(this, "underlyingSource", @undefined); - @setupReadableStreamDefaultController(this, underlyingSource, size, highWaterMark !== @undefined ? highWaterMark : 1, @getByIdDirectPrivate(underlyingSource, "start"), @getByIdDirectPrivate(underlyingSource, "pull"), @getByIdDirectPrivate(underlyingSource, "cancel")); - - return this; - } - if (isDirect) { - @putByIdDirectPrivate(this, "underlyingSource", underlyingSource); - @putByIdDirectPrivate(this, "highWaterMark", @getByIdDirectPrivate(strategy, "highWaterMark")); - @putByIdDirectPrivate(this, "start", () => @createReadableStreamController(this, underlyingSource, strategy)); - } else if (isLazy) { - const autoAllocateChunkSize = underlyingSource.autoAllocateChunkSize; - @putByIdDirectPrivate(this, "highWaterMark", @undefined); - @putByIdDirectPrivate(this, "underlyingSource", @undefined); - @putByIdDirectPrivate(this, "highWaterMark", autoAllocateChunkSize || @getByIdDirectPrivate(strategy, "highWaterMark")); - - - @putByIdDirectPrivate(this, "start", () => { - const instance = @lazyLoadStream(this, autoAllocateChunkSize); - if (instance) { - @createReadableStreamController(this, instance, strategy); - } - }); - } else { - @putByIdDirectPrivate(this, "underlyingSource", @undefined); - @putByIdDirectPrivate(this, "highWaterMark", @getByIdDirectPrivate(strategy, "highWaterMark")); - @putByIdDirectPrivate(this, "start", @undefined); - @createReadableStreamController(this, underlyingSource, strategy); - } - - - return this; -} - - -@linkTimeConstant -function readableStreamToArray(stream) { - "use strict"; - - // this is a direct stream - var underlyingSource = @getByIdDirectPrivate(stream, "underlyingSource"); - if (underlyingSource !== @undefined) { - return @readableStreamToArrayDirect(stream, underlyingSource); - } - - return @readableStreamIntoArray(stream); -} - -@linkTimeConstant -function readableStreamToText(stream) { - "use strict"; - - // this is a direct stream - var underlyingSource = @getByIdDirectPrivate(stream, "underlyingSource"); - if (underlyingSource !== @undefined) { - return @readableStreamToTextDirect(stream, underlyingSource); - } - - return @readableStreamIntoText(stream); -} - -@linkTimeConstant -function readableStreamToArrayBuffer(stream) { - "use strict"; - - // this is a direct stream - var underlyingSource = @getByIdDirectPrivate(stream, "underlyingSource"); - - if (underlyingSource !== @undefined) { - return @readableStreamToArrayBufferDirect(stream, underlyingSource); - } - - return @Bun.readableStreamToArray(stream).@then(@Bun.concatArrayBuffers); -} - -@linkTimeConstant -function readableStreamToJSON(stream) { - "use strict"; - - return @Bun.readableStreamToText(stream).@then(globalThis.JSON.parse); -} - -@linkTimeConstant -function readableStreamToBlob(stream) { - "use strict"; - return @Promise.resolve(@Bun.readableStreamToArray(stream)).@then(array => new Blob(array)); -} - -@linkTimeConstant -function consumeReadableStream(nativePtr, nativeType, inputStream) { - "use strict"; - const symbol = globalThis.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[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); -} - -@linkTimeConstant -function createEmptyReadableStream() { - "use strict"; - - var stream = new @ReadableStream({ - pull() {}, - }); - @readableStreamClose(stream); - return stream; -} - -@linkTimeConstant -function createNativeReadableStream(nativePtr, nativeType, autoAllocateChunkSize) { - "use strict"; - return new @ReadableStream({ - @lazy: true, - @bunNativeType: nativeType, - @bunNativePtr: nativePtr, - autoAllocateChunkSize: autoAllocateChunkSize, - }); -} - -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) { - var start_ = @getByIdDirectPrivate(this, "start"); - if (start_) { - @putByIdDirectPrivate(this, "start", @undefined); - start_(); - } - - 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"; - if (!@isReadableStream(this)) - return @Promise.@reject(@makeThisTypeError("ReadableStream", "pipeTo")); - - if (@isReadableStreamLocked(this)) - return @Promise.@reject(@makeTypeError("ReadableStream is locked")); - - // 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 = @argument(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 (@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); -} - -function values(options) { - "use strict"; - var prototype = @ReadableStream.prototype; - @readableStreamDefineLazyIterators(prototype); - return prototype.values.@call(this, options); -} - -@linkTimeConstant -function lazyAsyncIterator() { - "use strict"; - var prototype = @ReadableStream.prototype; - @readableStreamDefineLazyIterators(prototype); - return prototype[globalThis.Symbol.asyncIterator].@call(this); -}
\ No newline at end of file diff --git a/src/bun.js/builtins/js/ReadableStreamBYOBReader.js b/src/bun.js/builtins/js/ReadableStreamBYOBReader.js deleted file mode 100644 index 16e4ebce5..000000000 --- a/src/bun.js/builtins/js/ReadableStreamBYOBReader.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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/bun.js/builtins/js/ReadableStreamBYOBRequest.js b/src/bun.js/builtins/js/ReadableStreamBYOBRequest.js deleted file mode 100644 index d97667165..000000000 --- a/src/bun.js/builtins/js/ReadableStreamBYOBRequest.js +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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/bun.js/builtins/js/ReadableStreamDefaultController.js b/src/bun.js/builtins/js/ReadableStreamDefaultController.js deleted file mode 100644 index 07fc65cb1..000000000 --- a/src/bun.js/builtins/js/ReadableStreamDefaultController.js +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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/bun.js/builtins/js/ReadableStreamDefaultReader.js b/src/bun.js/builtins/js/ReadableStreamDefaultReader.js deleted file mode 100644 index 77da965ed..000000000 --- a/src/bun.js/builtins/js/ReadableStreamDefaultReader.js +++ /dev/null @@ -1,224 +0,0 @@ -/* - * 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"); - var queue = @getByIdDirectPrivate(controller, "queue"); - - if (!queue) { - // This is a ReadableStream direct controller implemented in JS - // It hasn't been started yet. - return controller.@pull( - controller - ).@then( - function({done, value}) { - return ( - done ? - { done: true, value: [], size: 0 } : - { value: [value], size: 1, done: false } - ); - } - ); - } - - const content = queue.content; - var size = queue.size; - var values = content.toArray(false); - - var length = values.length; - - if (length > 0) { - var outValues = @newArrayWithSize(length); - if (@isReadableByteStreamController(controller)) { - - { - const buf = values[0]; - if (!(@ArrayBuffer.@isView(buf) || buf instanceof @ArrayBuffer)) { - @putByValDirect(outValues, 0, new @Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength)); - } else { - @putByValDirect(outValues, 0, buf); - } - } - - for (var i = 1; i < length; i++) { - const buf = values[i]; - if (!(@ArrayBuffer.@isView(buf) || buf instanceof @ArrayBuffer)) { - @putByValDirect(outValues, i, new @Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength)); - } else { - @putByValDirect(outValues, i, buf); - } - } - - } else { - @putByValDirect(outValues, 0, values[0].value); - for (var i = 1; i < length; i++) { - @putByValDirect(outValues, i, values[i].value); - } - } - - @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: outValues, 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 length = value.length; - - if (@isReadableByteStreamController(controller)) { - for (var i = 0; i < length; i++) { - const buf = value[i]; - if (!(@ArrayBuffer.@isView(buf) || buf instanceof @ArrayBuffer)) { - const {buffer, byteOffset, byteLength} = buf; - @putByValDirect(value, i, new @Uint8Array(buffer, byteOffset, byteLength)); - } - } - } else { - for (var i = 1; i < length; i++) { - @putByValDirect(value, i, value[i].value); - } - } - - 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/bun.js/builtins/js/ReadableStreamInternals.js b/src/bun.js/builtins/js/ReadableStreamInternals.js deleted file mode 100644 index ca7a1c355..000000000 --- a/src/bun.js/builtins/js/ReadableStreamInternals.js +++ /dev/null @@ -1,2209 +0,0 @@ -/* - * 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", -1); - @putByIdDirectPrivate(this, "closeRequested", false); - @putByIdDirectPrivate(this, "pullAgain", false); - @putByIdDirectPrivate(this, "pulling", false); - @putByIdDirectPrivate( - this, - "strategy", - @validateAndNormalizeQueuingStrategy(size, highWaterMark) - ); - - return this; -} - -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) { - "use strict"; - var start = @getByIdDirectPrivate(stream, "start"); - if (start) { - start.@call(stream); - } - - return new @ReadableStreamDefaultReader(stream); -} - -// 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 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); - - @readableStreamDefaultControllerStart(controller); -} - -function createReadableStreamController(stream, underlyingSource, strategy) { - "use strict"; - - 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" - ); - - @putByIdDirectPrivate( - stream, - "readableStreamController", - new @ReadableByteStreamController( - stream, - underlyingSource, - strategy.highWaterMark, - @isReadableStream - ) - ); - } else if (typeString === "direct") { - var highWaterMark = strategy?.highWaterMark; - @initializeArrayBufferStream.@call( - stream, - underlyingSource, - highWaterMark - ); - } else if (type === @undefined) { - if (strategy.highWaterMark === @undefined) strategy.highWaterMark = 1; - - @setupReadableStreamDefaultController( - stream, - underlyingSource, - strategy.size, - strategy.highWaterMark, - underlyingSource.start, - underlyingSource.pull, - underlyingSource.cancel - ); - } else @throwRangeError("Invalid type for underlying source"); -} - -function readableStreamDefaultControllerStart(controller) { - "use strict"; - - if (@getByIdDirectPrivate(controller, "started") !== -1) return; - - const underlyingSource = @getByIdDirectPrivate( - controller, - "underlyingSource" - ); - const startMethod = underlyingSource.start; - @putByIdDirectPrivate(controller, "started", 0); - - @promiseInvokeOrNoopMethodNoCatch(underlyingSource, startMethod, [ - controller, - ]).@then( - () => { - @putByIdDirectPrivate(controller, "started", 1); - @assert(!@getByIdDirectPrivate(controller, "pulling")); - @assert(!@getByIdDirectPrivate(controller, "pullAgain")); - @readableStreamDefaultControllerCallPullIfNeeded(controller); - }, - (error) => { - @readableStreamDefaultControllerError(controller, error); - } - ); -} - -// 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 -) { - "use strict"; - - const isDirectStream = !!@getByIdDirectPrivate(source, "start"); - - - @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 = (reason) => { - if (pipeState.finalized) return; - - @pipeToShutdownWithAction( - pipeState, - () => { - const shouldAbortDestination = - !pipeState.preventAbort && - @getByIdDirectPrivate(pipeState.destination, "state") === - "writable"; - const promiseDestination = shouldAbortDestination - ? @writableStreamAbort(pipeState.destination, reason) - : @Promise.@resolve(); - - const shouldAbortSource = - !pipeState.preventCancel && - @getByIdDirectPrivate(pipeState.source, "state") === - @streamReadable; - const promiseSource = shouldAbortSource - ? @readableStreamCancel(pipeState.source, reason) - : @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; - }, - reason - ); - }; - 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) { - "use strict"; - if (pipeState.shuttingDown) return; - - @pipeToDoReadWrite(pipeState).@then((result) => { - if (result) @pipeToLoop(pipeState); - }); -} - -function pipeToDoReadWrite(pipeState) { - "use strict"; - @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) { - "use strict"; - - 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) { - "use strict"; - 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) { - "use strict"; - 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) { - "use strict"; - 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) { - "use strict"; - - 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) { - "use strict"; - - 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) { - "use strict"; - - @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"); - - var start_ = @getByIdDirectPrivate(stream, "start"); - if (start_) { - @putByIdDirectPrivate(stream, "start", @undefined); - start_(); - } - - 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 readDirectStream(stream, sink, underlyingSource) { - "use strict"; - - @putByIdDirectPrivate(stream, "underlyingSource", @undefined); - @putByIdDirectPrivate(stream, "start", @undefined); - - function close(stream, reason) { - if (reason && underlyingSource?.cancel) { - try { - var prom = underlyingSource.cancel(reason); - @markPromiseAsHandled(prom); - } catch (e) { - } - - underlyingSource = @undefined; - } - - if (stream) { - @putByIdDirectPrivate(stream, "readableStreamController", @undefined); - @putByIdDirectPrivate(stream, "reader", @undefined); - if (reason) { - @putByIdDirectPrivate(stream, "state", @streamErrored); - @putByIdDirectPrivate(stream, "storedError", reason); - } else { - @putByIdDirectPrivate(stream, "state", @streamClosed); - } - stream = @undefined; - } - } - - - - - - if (!underlyingSource.pull) { - close(); - return; - } - - if (!@isCallable(underlyingSource.pull)) { - close(); - @throwTypeError("pull is not a function"); - return; - } - - @putByIdDirectPrivate(stream, "readableStreamController", sink); - const highWaterMark = @getByIdDirectPrivate(stream, "highWaterMark"); - - sink.start({ - highWaterMark: !highWaterMark || highWaterMark < 64 ? 64 : highWaterMark, - }); - - @startDirectStream.@call(sink, stream, underlyingSource.pull, close); - @putByIdDirectPrivate(stream, "reader", {}); - - var maybePromise = underlyingSource.pull(sink); - sink = @undefined; - if (maybePromise && @isPromise(maybePromise)) { - return maybePromise.@then(() => {}); - } - - -} - -@linkTimeConstant; -function assignToStream(stream, sink) { - "use strict"; - - // The stream is either a direct stream or a "default" JS stream - var underlyingSource = @getByIdDirectPrivate(stream, "underlyingSource"); - - // we know it's a direct stream when @underlyingSource is set - if (underlyingSource) { - try { - return @readDirectStream(stream, sink, underlyingSource); - } catch(e) { - throw e; - } finally { - underlyingSource = @undefined; - stream = @undefined; - sink = @undefined; - } - - - } - - return @readStreamIntoSink(stream, sink, true); -} - -async function readStreamIntoSink(stream, sink, isNative) { - "use strict"; - - var didClose = false; - var didThrow = false; - try { - var reader = stream.getReader(); - var many = reader.readMany(); - if (many && @isPromise(many)) { - many = await many; - } - if (many.done) { - didClose = true; - return sink.end(); - } - var wroteCount = many.value.length; - const highWaterMark = @getByIdDirectPrivate(stream, "highWaterMark"); - if (isNative) @startDirectStream.@call(sink, stream, @undefined, () => !didThrow && @markPromiseAsHandled(stream.cancel())); - - sink.start({ highWaterMark: highWaterMark || 0 }); - - - for ( - var i = 0, values = many.value, length = many.value.length; - i < length; - i++ - ) { - sink.write(values[i]); - } - - var streamState = @getByIdDirectPrivate(stream, "state"); - if (streamState === @streamClosed) { - didClose = true; - return sink.end(); - } - - while (true) { - var { value, done } = await reader.read(); - if (done) { - didClose = true; - return sink.end(); - } - - sink.write(value); - } - } catch (e) { - didThrow = true; - - - try { - reader = @undefined; - const prom = stream.cancel(e); - @markPromiseAsHandled(prom); - } catch (j) {} - - if (sink && !didClose) { - didClose = true; - try { - sink.close(e); - } catch (j) { - throw new globalThis.AggregateError([e, j]); - } - } - - - throw e; - } finally { - if (reader) { - try { - reader.releaseLock(); - } catch (e) {} - reader = @undefined; - } - sink = @undefined; - var streamState = @getByIdDirectPrivate(stream, "state"); - if (stream) { - - // make it easy for this to be GC'd - // but don't do property transitions - var readableStreamController = @getByIdDirectPrivate( - stream, - "readableStreamController" - ); - if (readableStreamController) { - if ( - @getByIdDirectPrivate(readableStreamController, "underlyingSource") - ) - @putByIdDirectPrivate( - readableStreamController, - "underlyingSource", - @undefined - ); - if ( - @getByIdDirectPrivate( - readableStreamController, - "controlledReadableStream" - ) - ) - @putByIdDirectPrivate( - readableStreamController, - "controlledReadableStream", - @undefined - ); - - @putByIdDirectPrivate(stream, "readableStreamController", null); - if (@getByIdDirectPrivate(stream, "underlyingSource")) - @putByIdDirectPrivate(stream, "underlyingSource", @undefined); - readableStreamController = @undefined; - } - - if (!didThrow && streamState !== @streamClosed && streamState !== @streamErrored) { - @readableStreamClose(stream); - } - stream = @undefined; - - - } - } -} - -function handleDirectStreamError(e) { - "use strict"; - - var controller = this; - var sink = controller.@sink; - if (sink) { - @putByIdDirectPrivate(controller, "sink", @undefined); - try { - sink.close(e); - } catch (f) {} - } - - this.error = - this.flush = - this.write = - this.close = - this.end = - @onReadableStreamDirectControllerClosed; - - if (typeof this.@underlyingSource.close === "function") { - try { - this.@underlyingSource.close.@call(this.@underlyingSource, e); - } catch (e) {} - } - - try { - var pend = controller._pendingRead; - if (pend) { - controller._pendingRead = @undefined; - @rejectPromise(pend, e); - } - } catch (f) {} - var stream = controller.@controlledReadableStream; - if (stream) @readableStreamError(stream, e); -} - -function handleDirectStreamErrorReject(e) { - @handleDirectStreamError.@call(this, e); - return @Promise.@reject(e); -} - -function onPullDirectStream(controller) { - "use strict"; - - var stream = controller.@controlledReadableStream; - if (!stream || @getByIdDirectPrivate(stream, "state") !== @streamReadable) - return; - - // pull is in progress - // this is a recursive call - // ignore it - if (controller._deferClose === -1) { - return; - } - - controller._deferClose = -1; - controller._deferFlush = -1; - var deferClose; - var deferFlush; - - // Direct streams allow @pull to be called multiple times, unlike the spec. - // Backpressure is handled by the destination, not by the underlying source. - // In this case, we rely on the heuristic that repeatedly draining in the same tick - // is bad for performance - // this code is only run when consuming a direct stream from JS - // without the HTTP server or anything else - try { - var result = controller.@underlyingSource.pull(controller); - - if (result && @isPromise(result)) { - if (controller._handleError === @undefined) { - controller._handleError = - @handleDirectStreamErrorReject.bind(controller); - } - - @Promise.prototype.catch.@call(result, controller._handleError); - } - } catch (e) { - return @handleDirectStreamErrorReject.@call(controller, e); - } finally { - deferClose = controller._deferClose; - deferFlush = controller._deferFlush; - controller._deferFlush = controller._deferClose = 0; - } - - var promiseToReturn; - - if (controller._pendingRead === @undefined) { - controller._pendingRead = promiseToReturn = @newPromise(); - } else { - promiseToReturn = @readableStreamAddReadRequest(stream); - } - - // they called close during @pull() - // we delay that - if (deferClose === 1) { - var reason = controller._deferCloseReason; - controller._deferCloseReason = @undefined; - @onCloseDirectStream.@call(controller, reason); - return promiseToReturn; - } - - // not done, but they called flush() - if (deferFlush === 1) { - @onFlushDirectStream.@call(controller); - } - - return promiseToReturn; -} - -function noopDoneFunction() { - return @Promise.@resolve({ value: @undefined, done: true }); -} - -function onReadableStreamDirectControllerClosed(reason) { - "use strict"; - @throwTypeError("ReadableStreamDirectController is now closed"); -} - -function onCloseDirectStream(reason) { - "use strict"; - var stream = this.@controlledReadableStream; - if (!stream || @getByIdDirectPrivate(stream, "state") !== @streamReadable) - return; - - if (this._deferClose !== 0) { - this._deferClose = 1; - this._deferCloseReason = reason; - return; - } - - @putByIdDirectPrivate(stream, "state", @streamClosing); - if (typeof this.@underlyingSource.close === "function") { - try { - this.@underlyingSource.close.@call(this.@underlyingSource, reason); - } catch (e) {} - } - - var flushed; - try { - flushed = this.@sink.end(); - @putByIdDirectPrivate(this, "sink", @undefined); - } catch (e) { - if (this._pendingRead) { - var read = this._pendingRead; - this._pendingRead = @undefined; - @rejectPromise(read, e); - } - @readableStreamError(stream, e); - return; - } - - this.error = - this.flush = - this.write = - this.close = - this.end = - @onReadableStreamDirectControllerClosed; - - var reader = @getByIdDirectPrivate(stream, "reader"); - - if (reader && @isReadableStreamDefaultReader(reader)) { - var _pendingRead = this._pendingRead; - if (_pendingRead && @isPromise(_pendingRead) && flushed?.byteLength) { - this._pendingRead = @undefined; - @fulfillPromise(_pendingRead, { value: flushed, done: false }); - @readableStreamClose(stream); - return; - } - } - - if (flushed?.byteLength) { - var requests = @getByIdDirectPrivate(reader, "readRequests"); - if (requests?.isNotEmpty()) { - @readableStreamFulfillReadRequest(stream, flushed, false); - @readableStreamClose(stream); - return; - } - - @putByIdDirectPrivate(stream, "state", @streamReadable); - this.@pull = () => { - var thisResult = @createFulfilledPromise({ - value: flushed, - done: false, - }); - flushed = @undefined; - @readableStreamClose(stream); - stream = @undefined; - return thisResult; - }; - } else if (this._pendingRead) { - var read = this._pendingRead; - this._pendingRead = @undefined; - @putByIdDirectPrivate(this, "pull", @noopDoneFunction); - @fulfillPromise(read, { value: @undefined, done: true }); - } - - @readableStreamClose(stream); -} - -function onFlushDirectStream() { - "use strict"; - - var stream = this.@controlledReadableStream; - var reader = @getByIdDirectPrivate(stream, "reader"); - if (!reader || !@isReadableStreamDefaultReader(reader)) { - return; - } - - var _pendingRead = this._pendingRead; - this._pendingRead = @undefined; - if (_pendingRead && @isPromise(_pendingRead)) { - var flushed = this.@sink.flush(); - if (flushed?.byteLength) { - this._pendingRead = @getByIdDirectPrivate( - stream, - "readRequests" - )?.shift(); - @fulfillPromise(_pendingRead, { value: flushed, done: false }); - } else { - this._pendingRead = _pendingRead; - } - } else if (@getByIdDirectPrivate(stream, "readRequests")?.isNotEmpty()) { - var flushed = this.@sink.flush(); - if (flushed?.byteLength) { - @readableStreamFulfillReadRequest(stream, flushed, false); - } - } else if (this._deferFlush === -1) { - this._deferFlush = 1; - } -} - -function createTextStream(highWaterMark) { - "use strict"; - - var sink; - var array = []; - var hasString = false; - var hasBuffer = false; - var rope = ""; - var estimatedLength = @toLength(0); - var capability = @newPromiseCapability(@Promise); - var calledDone = false; - - sink = { - start() {}, - write(chunk) { - if (typeof chunk === "string") { - var chunkLength = @toLength(chunk.length); - if (chunkLength > 0) { - rope += chunk; - hasString = true; - // TODO: utf16 byte length - estimatedLength += chunkLength; - } - - return chunkLength; - } - - if ( - !chunk || - !(@ArrayBuffer.@isView(chunk) || chunk instanceof @ArrayBuffer) - ) { - @throwTypeError("Expected text, ArrayBuffer or ArrayBufferView"); - } - - const byteLength = @toLength(chunk.byteLength); - if (byteLength > 0) { - hasBuffer = true; - if (rope.length > 0) { - @arrayPush(array, rope, chunk); - rope = ""; - } else { - @arrayPush(array, chunk); - } - } - estimatedLength += byteLength; - return byteLength; - }, - - flush() { - return 0; - }, - - end() { - if (calledDone) { - return ""; - } - return sink.fulfill(); - }, - - fulfill() { - calledDone = true; - const result = sink.finishInternal(); - - @fulfillPromise(capability.@promise, result); - return result; - }, - - finishInternal() { - if (!hasString && !hasBuffer) { - return ""; - } - - if (hasString && !hasBuffer) { - return rope; - } - - if (hasBuffer && !hasString) { - return new globalThis.TextDecoder().decode( - @Bun.concatArrayBuffers(array) - ); - } - - // worst case: mixed content - - var arrayBufferSink = new @Bun.ArrayBufferSink(); - arrayBufferSink.start({ - highWaterMark: estimatedLength, - asUint8Array: true, - }); - for (let item of array) { - arrayBufferSink.write(item); - } - array.length = 0; - if (rope.length > 0) { - arrayBufferSink.write(rope); - rope = ""; - } - - // TODO: use builtin - return new globalThis.TextDecoder().decode(arrayBufferSink.end()); - }, - - close() { - try { - if (!calledDone) { - calledDone = true; - sink.fulfill(); - } - } catch (e) {} - }, - }; - - return [sink, capability]; -} - -function initializeTextStream(underlyingSource, highWaterMark) { - "use strict"; - var [sink, closingPromise] = @createTextStream(highWaterMark); - - var controller = { - @underlyingSource: underlyingSource, - @pull: @onPullDirectStream, - @controlledReadableStream: this, - @sink: sink, - close: @onCloseDirectStream, - write: sink.write, - error: @handleDirectStreamError, - end: @onCloseDirectStream, - @close: @onCloseDirectStream, - flush: @onFlushDirectStream, - _pendingRead: @undefined, - _deferClose: 0, - _deferFlush: 0, - _deferCloseReason: @undefined, - _handleError: @undefined, - }; - - @putByIdDirectPrivate(this, "readableStreamController", controller); - @putByIdDirectPrivate(this, "underlyingSource", @undefined); - @putByIdDirectPrivate(this, "start", @undefined); - return closingPromise; -} - -function initializeArrayStream(underlyingSource, highWaterMark) { - "use strict"; - - var array = []; - var closingPromise = @newPromiseCapability(@Promise); - var calledDone = false; - - function fulfill() { - calledDone = true; - closingPromise.@resolve.@call(@undefined, array); - return array; - } - - var sink = { - start() {}, - write(chunk) { - @arrayPush(array, chunk); - return chunk.byteLength || chunk.length; - }, - - flush() { - return 0; - }, - - end() { - if (calledDone) { - return []; - } - return fulfill(); - }, - - close() { - if (!calledDone) { - fulfill(); - } - }, - }; - - var controller = { - @underlyingSource: underlyingSource, - @pull: @onPullDirectStream, - @controlledReadableStream: this, - @sink: sink, - close: @onCloseDirectStream, - write: sink.write, - error: @handleDirectStreamError, - end: @onCloseDirectStream, - @close: @onCloseDirectStream, - flush: @onFlushDirectStream, - _pendingRead: @undefined, - _deferClose: 0, - _deferFlush: 0, - _deferCloseReason: @undefined, - _handleError: @undefined, - }; - - @putByIdDirectPrivate(this, "readableStreamController", controller); - @putByIdDirectPrivate(this, "underlyingSource", @undefined); - @putByIdDirectPrivate(this, "start", @undefined); - return closingPromise; -} - -function initializeArrayBufferStream(underlyingSource, highWaterMark) { - "use strict"; - - // This is the fallback implementation for direct streams - // When we don't know what the destination type is - // We assume it is a Uint8Array. - - var opts = - highWaterMark && typeof highWaterMark === "number" - ? { highWaterMark, stream: true, asUint8Array: true } - : { stream: true, asUint8Array: true }; - var sink = new @Bun.ArrayBufferSink(); - sink.start(opts); - - var controller = { - @underlyingSource: underlyingSource, - @pull: @onPullDirectStream, - @controlledReadableStream: this, - @sink: sink, - close: @onCloseDirectStream, - write: sink.write.bind(sink), - error: @handleDirectStreamError, - end: @onCloseDirectStream, - @close: @onCloseDirectStream, - flush: @onFlushDirectStream, - _pendingRead: @undefined, - _deferClose: 0, - _deferFlush: 0, - _deferCloseReason: @undefined, - _handleError: @undefined, - }; - - @putByIdDirectPrivate(this, "readableStreamController", controller); - @putByIdDirectPrivate(this, "underlyingSource", @undefined); - @putByIdDirectPrivate(this, "start", @undefined); -} - -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) { - "use strict"; - - const stream = @getByIdDirectPrivate(controller, "controlledReadableStream"); - - if (!@readableStreamDefaultControllerCanCloseOrEnqueue(controller)) - return false; - if (!(@getByIdDirectPrivate(controller, "started") === 1)) 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") === 1)) 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); - - var controller = @getByIdDirectPrivate(stream, "readableStreamController"); - var cancel = controller.@cancel; - if (cancel) { - return cancel(controller, reason).@then(function () {}); - } - - var close = controller.close; - if (close) { - return @Promise.@resolve(controller.close(reason)); - } - - @throwTypeError("ReadableStreamController has no cancel or close method"); -} - -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 - ); -} - -function lazyLoadStream(stream, autoAllocateChunkSize) { - "use strict"; - - var nativeType = @getByIdDirectPrivate(stream, "bunNativeType"); - var nativePtr = @getByIdDirectPrivate(stream, "bunNativePtr"); - var Prototype = @lazyStreamPrototypeMap.@get(nativeType); - if (Prototype === @undefined) { - var [pull, start, cancel, setClose, deinit, setRefOrUnref, drain] = @lazyLoad(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); - } - - function callClose(controller) { - try { - controller.close(); - } catch(e) { - globalThis.reportError(e); - } - } - - 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 (typeof result === 'number') { - if (view && view.byteLength === result && view.buffer === controller.byobRequest?.view?.buffer) { - controller.byobRequest.respondWithNewView(view); - } else { - controller.byobRequest.respond(result); - } - } else if (result.constructor === @Uint8Array) { - controller.enqueue(result); - } - - if (closer[0] || result === false) { - @enqueueJob(callClose, controller); - closer[0] = false; - } - }; - - function createResult(tag, controller, view, closer) { - closer[0] = false; - - var result; - try { - result = pull(tag, view, closer); - } catch (err) { - return controller.error(err); - } - - return handleResult(result, controller, view); - } - - const registry = deinit ? new FinalizationRegistry(deinit) : null; - Prototype = class NativeReadableStreamSource { - constructor(tag, autoAllocateChunkSize, drainValue) { - this.#tag = tag; - this.#cancellationToken = {}; - this.pull = this.#pull.bind(this); - this.cancel = this.#cancel.bind(this); - this.autoAllocateChunkSize = autoAllocateChunkSize; - - if (drainValue !== @undefined) { - this.start = (controller) => { - controller.enqueue(drainValue); - }; - } - - if (registry) { - registry.register(this, tag, this.#cancellationToken); - } - } - - #cancellationToken; - pull; - cancel; - start; - - #tag; - type = "bytes"; - autoAllocateChunkSize = 0; - - static startSync = start; - - - #pull(controller) { - var tag = this.#tag; - - if (!tag) { - controller.close(); - return; - } - - createResult(tag, controller, controller.byobRequest.view, closer); - } - - #cancel(reason) { - var tag = this.#tag; - - registry && registry.unregister(this.#cancellationToken); - setRefOrUnref && setRefOrUnref(tag, false); - cancel(tag, reason); - } - static deinit = deinit; - static drain = drain; - }; - @lazyStreamPrototypeMap.@set(nativeType, Prototype); - } - - const chunkSize = Prototype.startSync(nativePtr, autoAllocateChunkSize); - var drainValue; - const {drain: drainFn, deinit: deinitFn} = Prototype; - if (drainFn) { - drainValue = drainFn(nativePtr); - } - - // empty file, no need for native back-and-forth on this - if (chunkSize === 0) { - deinit && nativePtr && @enqueueJob(deinit, nativePtr); - - if ((drainValue?.byteLength ?? 0) > 0) { - return { - start(controller) { - controller.enqueue(drainValue); - controller.close(); - }, - type: "bytes", - }; - } - - return { - start(controller) { - controller.close(); - }, - type: "bytes", - }; - } - - return new Prototype(nativePtr, chunkSize, drainValue); -} - -function readableStreamIntoArray(stream) { - "use strict"; - - var reader = stream.getReader(); - var manyResult = reader.readMany(); - - async function processManyResult(result) { - if (result.done) { - return []; - } - - var chunks = result.value || []; - - while (true) { - var thisResult = await reader.read(); - if (thisResult.done) { - break; - } - chunks = chunks.concat(thisResult.value); - } - - return chunks; - } - - if (manyResult && @isPromise(manyResult)) { - return manyResult.@then(processManyResult); - } - - return processManyResult(manyResult); -} - -function readableStreamIntoText(stream) { - "use strict"; - - const [textStream, closer] = @createTextStream( - @getByIdDirectPrivate(stream, "highWaterMark") - ); - const prom = @readStreamIntoSink(stream, textStream, false); - if (prom && @isPromise(prom)) { - return @Promise.@resolve(prom).@then(closer.@promise); - } - return closer.@promise; -} - -function readableStreamToArrayBufferDirect(stream, underlyingSource) { - "use strict"; - - var sink = new @Bun.ArrayBufferSink(); - @putByIdDirectPrivate(stream, "underlyingSource", @undefined); - var highWaterMark = @getByIdDirectPrivate(stream, "highWaterMark"); - sink.start(highWaterMark ? { highWaterMark } : {}); - var capability = @newPromiseCapability(@Promise); - var ended = false; - var pull = underlyingSource.pull; - var close = underlyingSource.close; - - var controller = { - start() {}, - close(reason) { - if (!ended) { - ended = true; - if (close) { - close(); - } - - @fulfillPromise(capability.@promise, sink.end()); - } - }, - end() { - if (!ended) { - ended = true; - if (close) { - close(); - } - @fulfillPromise(capability.@promise, sink.end()); - } - }, - flush() { - return 0; - }, - write: sink.write.bind(sink), - }; - - var didError = false; - try { - const firstPull = pull(controller); - if (firstPull && @isObject(firstPull) && @isPromise(firstPull)) { - return (async function (controller, promise, pull) { - while (!ended) { - await pull(controller); - } - return await promise; - })(controller, promise, pull); - } - - return capability.@promise; - } catch (e) { - didError = true; - @readableStreamError(stream, e); - return @Promise.@reject(e); - } finally { - if (!didError && stream) @readableStreamClose(stream); - controller = close = sink = pull = stream = @undefined; - } -} - -async function readableStreamToTextDirect(stream, underlyingSource) { - "use strict"; - const capability = @initializeTextStream.@call( - stream, - underlyingSource, - @undefined - ); - var reader = stream.getReader(); - - while (@getByIdDirectPrivate(stream, "state") === @streamReadable) { - var thisResult = await reader.read(); - if (thisResult.done) { - break; - } - } - - try { - reader.releaseLock(); - } catch (e) {} - reader = @undefined; - stream = @undefined; - - return capability.@promise; -} - -async function readableStreamToArrayDirect(stream, underlyingSource) { - const capability = @initializeArrayStream.@call( - stream, - underlyingSource, - @undefined - ); - underlyingSource = @undefined; - var reader = stream.getReader(); - try { - while (@getByIdDirectPrivate(stream, "state") === @streamReadable) { - var thisResult = await reader.read(); - if (thisResult.done) { - break; - } - } - - try { - reader.releaseLock(); - } catch (e) {} - reader = @undefined; - - return @Promise.@resolve(capability.@promise); - } catch (e) { - throw e; - } finally { - stream = @undefined; - reader = @undefined; - } - - return capability.@promise; -} - - -function readableStreamDefineLazyIterators(prototype) { - "use strict"; - - var asyncIterator = globalThis.Symbol.asyncIterator; - - var ReadableStreamAsyncIterator = async function* ReadableStreamAsyncIterator(stream, preventCancel) { - var reader = stream.getReader(); - var deferredError; - try { - while (true) { - var done, value; - const firstResult = reader.readMany(); - if (@isPromise(firstResult)) { - ({done, value} = await firstResult); - } else { - ({done, value} = firstResult); - } - - if (done) { - return; - } - yield* value; - } - } catch(e) { - deferredError = e; - } finally { - reader.releaseLock(); - - if (!preventCancel) { - stream.cancel(deferredError); - } - - if (deferredError) { - throw deferredError; - } - } - }; - var createAsyncIterator = function asyncIterator() { - return ReadableStreamAsyncIterator(this, false); - }; - var createValues = function values({preventCancel = false} = {preventCancel: false}) { - return ReadableStreamAsyncIterator(this, preventCancel); - }; - @Object.@defineProperty(prototype, asyncIterator, { value: createAsyncIterator }); - @Object.@defineProperty(prototype, "values", { value: createValues }); - return prototype; -}
\ No newline at end of file diff --git a/src/bun.js/builtins/js/StreamInternals.js b/src/bun.js/builtins/js/StreamInternals.js deleted file mode 100644 index 0f08b7901..000000000 --- a/src/bun.js/builtins/js/StreamInternals.js +++ /dev/null @@ -1,325 +0,0 @@ -/* - * 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 }; -} - -@linkTimeConstant -function createFIFO() { - "use strict"; - var slice = @Array.prototype.slice; - - class Denqueue { - constructor() { - this._head = 0; - this._tail = 0; - // this._capacity = 0; - this._capacityMask = 0x3; - this._list = @newArrayWithSize(4); - } - - _head; - _tail; - _capacityMask; - _list; - - 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: head, _tail, _list, _capacityMask } = this; - if (head === _tail) return @undefined; - var item = _list[head]; - @putByValDirect(_list, head, @undefined); - head = this._head = (head + 1) & _capacityMask; - if (head < 2 && _tail > 10000 && _tail <= _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 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"; - return queue.content.peek()?.value; -} - -function resetQueue(queue) -{ - "use strict"; - - @assert("content" in queue); - @assert("size" in queue); - queue.content.clear(); - queue.size = 0; -} - -function extractSizeAlgorithm(strategy) -{ - const sizeAlgorithm = strategy.size; - - if (sizeAlgorithm === @undefined) - return () => 1; - - if (typeof sizeAlgorithm !== "function") - @throwTypeError("strategy.size must be a function"); - - return (chunk) => { return sizeAlgorithm(chunk); }; -} - -function extractHighWaterMark(strategy, defaultHWM) -{ - const highWaterMark = strategy.highWaterMark; - - if (highWaterMark === @undefined) - return defaultHWM; - - 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/bun.js/builtins/js/TransformStream.js b/src/bun.js/builtins/js/TransformStream.js deleted file mode 100644 index 8d82d87d8..000000000 --- a/src/bun.js/builtins/js/TransformStream.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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/bun.js/builtins/js/TransformStreamInternals.js b/src/bun.js/builtins/js/TransformStreamInternals.js deleted file mode 100644 index 4263e3991..000000000 --- a/src/bun.js/builtins/js/TransformStreamInternals.js +++ /dev/null @@ -1,350 +0,0 @@ -/* - * 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/bun.js/builtins/js/WritableStreamDefaultWriter.js b/src/bun.js/builtins/js/WritableStreamDefaultWriter.js deleted file mode 100644 index 69a953fc3..000000000 --- a/src/bun.js/builtins/js/WritableStreamDefaultWriter.js +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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/bun.js/builtins/js/WritableStreamInternals.js b/src/bun.js/builtins/js/WritableStreamInternals.js deleted file mode 100644 index 58c4ee87c..000000000 --- a/src/bun.js/builtins/js/WritableStreamInternals.js +++ /dev/null @@ -1,858 +0,0 @@ -/* - * 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) -{ "use strict"; - - @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) -{ "use strict"; - - 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) -{ "use strict"; - - 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) -{ "use strict"; - - return @getByIdDirectPrivate(stream, "writer") !== @undefined; -} - -function setUpWritableStreamDefaultWriter(writer, stream) -{ "use strict"; - - 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) -{ - "use strict"; - 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) -{ - "use strict"; - - 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) -{ - "use strict"; - - @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) -{ - "use strict"; - - return @getByIdDirectPrivate(stream, "closeRequest") !== @undefined || @getByIdDirectPrivate(stream, "inFlightCloseRequest") !== @undefined; -} - -function writableStreamDealWithRejection(stream, error) -{ - "use strict"; - - const state = @getByIdDirectPrivate(stream, "state"); - if (state === "writable") { - @writableStreamStartErroring(stream, error); - return; - } - - @assert(state === "erroring"); - @writableStreamFinishErroring(stream); -} - -function writableStreamFinishErroring(stream) -{ - "use strict"; - - @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) -{ - "use strict"; - - 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) -{ - "use strict"; - - 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) -{ - "use strict"; - - const inFlightWriteRequest = @getByIdDirectPrivate(stream, "inFlightWriteRequest"); - @assert(inFlightWriteRequest !== @undefined); - inFlightWriteRequest.@resolve.@call(); - - @putByIdDirectPrivate(stream, "inFlightWriteRequest", @undefined); -} - -function writableStreamFinishInFlightWriteWithError(stream, error) -{ - "use strict"; - - 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) -{ - "use strict"; - - return @getByIdDirectPrivate(stream, "inFlightWriteRequest") !== @undefined || @getByIdDirectPrivate(stream, "inFlightCloseRequest") !== @undefined; -} - -function writableStreamMarkCloseRequestInFlight(stream) -{ - "use strict"; - - const closeRequest = @getByIdDirectPrivate(stream, "closeRequest"); - @assert(@getByIdDirectPrivate(stream, "inFlightCloseRequest") === @undefined); - @assert(closeRequest !== @undefined); - - @putByIdDirectPrivate(stream, "inFlightCloseRequest", closeRequest); - @putByIdDirectPrivate(stream, "closeRequest", @undefined); -} - -function writableStreamMarkFirstWriteRequestInFlight(stream) -{ - "use strict"; - - const writeRequests = @getByIdDirectPrivate(stream, "writeRequests"); - @assert(@getByIdDirectPrivate(stream, "inFlightWriteRequest") === @undefined); - @assert(writeRequests.isNotEmpty()); - - const writeRequest = writeRequests.shift(); - @putByIdDirectPrivate(stream, "inFlightWriteRequest", writeRequest); -} - -function writableStreamRejectCloseAndClosedPromiseIfNeeded(stream) -{ - "use strict"; - - @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) -{ - "use strict"; - - @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") === 1) - @writableStreamFinishErroring(stream); -} - -function writableStreamUpdateBackpressure(stream, backpressure) -{ - "use strict"; - @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) -{ - "use strict"; - const stream = @getByIdDirectPrivate(writer, "stream"); - @assert(stream !== @undefined); - return @writableStreamAbort(stream, reason); -} - -function writableStreamDefaultWriterClose(writer) -{ - "use strict"; - const stream = @getByIdDirectPrivate(writer, "stream"); - @assert(stream !== @undefined); - return @writableStreamClose(stream); -} - -function writableStreamDefaultWriterCloseWithErrorPropagation(writer) -{ - "use strict"; - 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) -{ - "use strict"; - 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) -{ - "use strict"; - 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) -{ - "use strict"; - 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) -{ - "use strict"; - - 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) -{ - "use strict"; - - 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) -{ - "use strict"; - - @assert(@isWritableStream(stream)); - @assert(@getByIdDirectPrivate(stream, "controller") === @undefined); - - @putByIdDirectPrivate(controller, "stream", stream); - @putByIdDirectPrivate(stream, "controller", controller); - - @resetQueue(@getByIdDirectPrivate(controller, "queue")); - - @putByIdDirectPrivate(controller, "started", -1); - @putByIdDirectPrivate(controller, "startAlgorithm", startAlgorithm); - @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); - - @writableStreamDefaultControllerStart(controller); -} - -function writableStreamDefaultControllerStart(controller) { - "use strict"; - - if (@getByIdDirectPrivate(controller, "started") !== -1) - return; - - @putByIdDirectPrivate(controller, "started", 0); - - const startAlgorithm = @getByIdDirectPrivate(controller, "startAlgorithm"); - @putByIdDirectPrivate(controller, "startAlgorithm", @undefined); - const stream = @getByIdDirectPrivate(controller, "stream"); - return @Promise.@resolve(startAlgorithm.@call()).@then(() => { - const state = @getByIdDirectPrivate(stream, "state"); - @assert(state === "writable" || state === "erroring"); - @putByIdDirectPrivate(controller, "started", 1); - @writableStreamDefaultControllerAdvanceQueueIfNeeded(controller); - }, (error) => { - const state = @getByIdDirectPrivate(stream, "state"); - @assert(state === "writable" || state === "erroring"); - @putByIdDirectPrivate(controller, "started", 1); - @writableStreamDealWithRejection(stream, error); - }); -} - -function setUpWritableStreamDefaultControllerFromUnderlyingSink(stream, underlyingSink, underlyingSinkDict, highWaterMark, sizeAlgorithm) -{ - "use strict"; - 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) -{ - "use strict"; - const stream = @getByIdDirectPrivate(controller, "stream"); - - if (@getByIdDirectPrivate(controller, "started") !== 1) - 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; - } - - const queue = @getByIdDirectPrivate(controller, "queue"); - - if (queue.content?.isEmpty() ?? false) - return; - - const value = @peekQueueValue(queue); - if (value === @isCloseSentinel) - @writableStreamDefaultControllerProcessClose(controller); - else - @writableStreamDefaultControllerProcessWrite(controller, value); -} - -function isCloseSentinel() -{ -} - -function writableStreamDefaultControllerClearAlgorithms(controller) -{ - "use strict"; - @putByIdDirectPrivate(controller, "writeAlgorithm", @undefined); - @putByIdDirectPrivate(controller, "closeAlgorithm", @undefined); - @putByIdDirectPrivate(controller, "abortAlgorithm", @undefined); - @putByIdDirectPrivate(controller, "strategySizeAlgorithm", @undefined); -} - -function writableStreamDefaultControllerClose(controller) -{ - "use strict"; - @enqueueValueWithSize(@getByIdDirectPrivate(controller, "queue"), @isCloseSentinel, 0); - @writableStreamDefaultControllerAdvanceQueueIfNeeded(controller); -} - -function writableStreamDefaultControllerError(controller, error) -{ - "use strict"; - const stream = @getByIdDirectPrivate(controller, "stream"); - @assert(stream !== @undefined); - @assert(@getByIdDirectPrivate(stream, "state") === "writable"); - - @writableStreamDefaultControllerClearAlgorithms(controller); - @writableStreamStartErroring(stream, error); -} - -function writableStreamDefaultControllerErrorIfNeeded(controller, error) -{ - "use strict"; - const stream = @getByIdDirectPrivate(controller, "stream"); - if (@getByIdDirectPrivate(stream, "state") === "writable") - @writableStreamDefaultControllerError(controller, error); -} - -function writableStreamDefaultControllerGetBackpressure(controller) -{ - "use strict"; - const desiredSize = @writableStreamDefaultControllerGetDesiredSize(controller); - return desiredSize <= 0; -} - -function writableStreamDefaultControllerGetChunkSize(controller, chunk) -{ - "use strict"; - try { - return @getByIdDirectPrivate(controller, "strategySizeAlgorithm").@call(@undefined, chunk); - } catch (e) { - @writableStreamDefaultControllerErrorIfNeeded(controller, e); - return 1; - } -} - -function writableStreamDefaultControllerGetDesiredSize(controller) -{ - "use strict"; - return @getByIdDirectPrivate(controller, "strategyHWM") - @getByIdDirectPrivate(controller, "queue").size; -} - -function writableStreamDefaultControllerProcessClose(controller) -{ - "use strict"; - 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) -{ - "use strict"; - 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) -{ - "use strict"; - 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/bun.js/builtins/ts/BundlerPlugin.ts b/src/bun.js/builtins/ts/BundlerPlugin.ts new file mode 100644 index 000000000..831a6614e --- /dev/null +++ b/src/bun.js/builtins/ts/BundlerPlugin.ts @@ -0,0 +1,370 @@ +import type { + AnyFunction, + BuildConfig, + BunPlugin, + OnLoadCallback, + OnLoadResult, + OnLoadResultObject, + OnLoadResultSourceCode, + OnResolveCallback, + PluginBuilder, + PluginConstraints, +} from "bun"; + +// This API expects 4 functions: +// It should be generic enough to reuse for Bun.plugin() eventually, too. +interface BundlerPlugin { + onLoad: Map<string, [RegExp, OnLoadCallback][]>; + onResolve: Map<string, [RegExp, OnResolveCallback][]>; + onLoadAsync( + internalID, + sourceCode: string | Uint8Array | ArrayBuffer | DataView | null, + loaderKey: number | null, + ): void; + onResolveAsync(internalID, a, b, c): void; + addError(internalID, error, number): void; + addFilter(filter, namespace, number): void; +} + +// Extra types +type Setup = BunPlugin["setup"]; +type MinifyObj = Exclude<BuildConfig["minify"], boolean>; +interface BuildConfigExt extends BuildConfig { + // we support esbuild-style entryPoints + entryPoints?: string[]; + // plugins is guaranteed to not be null + plugins: BunPlugin[]; +} +interface PluginBuilderExt extends PluginBuilder { + // these functions aren't implemented yet, so we dont publicly expose them + resolve: AnyFunction; + onStart: AnyFunction; + onEnd: AnyFunction; + onDispose: AnyFunction; + // we partially support initialOptions. it's read-only and a subset of + // all options mapped to their esbuild names + initialOptions: any; + // we set this to an empty object + esbuild: any; +} + +export function runSetupFunction(this: BundlerPlugin, setup: Setup, config: BuildConfigExt) { + var onLoadPlugins = new Map<string, [RegExp, AnyFunction][]>(); + var onResolvePlugins = new Map<string, [RegExp, AnyFunction][]>(); + + function validate(filterObject: PluginConstraints, callback, map) { + if (!filterObject || !$isObject(filterObject)) { + throw new TypeError('Expected an object with "filter" RegExp'); + } + + if (!callback || !$isCallable(callback)) { + throw new TypeError("callback must be a function"); + } + + var { filter, namespace = "file" } = filterObject; + + if (!filter) { + throw new TypeError('Expected an object with "filter" RegExp'); + } + + if (!$isRegExpObject(filter)) { + throw new TypeError("filter must be a RegExp"); + } + + if (namespace && !(typeof namespace === "string")) { + throw new TypeError("namespace must be a string"); + } + + if ((namespace?.length ?? 0) === 0) { + namespace = "file"; + } + + if (!/^([/$a-zA-Z0-9_\\-]+)$/.test(namespace)) { + throw new TypeError("namespace can only contain $a-zA-Z0-9_\\-"); + } + + var callbacks = map.$get(namespace); + + if (!callbacks) { + map.$set(namespace, [[filter, callback]]); + } else { + $arrayPush(callbacks, [filter, callback]); + } + } + + function onLoad(filterObject, callback) { + validate(filterObject, callback, onLoadPlugins); + } + + function onResolve(filterObject, callback) { + validate(filterObject, callback, onResolvePlugins); + } + + const processSetupResult = () => { + var anyOnLoad = false, + anyOnResolve = false; + + for (var [namespace, callbacks] of onLoadPlugins.entries()) { + for (var [filter] of callbacks) { + this.addFilter(filter, namespace, 1); + anyOnLoad = true; + } + } + + for (var [namespace, callbacks] of onResolvePlugins.entries()) { + for (var [filter] of callbacks) { + this.addFilter(filter, namespace, 0); + anyOnResolve = true; + } + } + + if (anyOnResolve) { + var onResolveObject = this.onResolve; + if (!onResolveObject) { + this.onResolve = onResolvePlugins; + } else { + for (var [namespace, callbacks] of onResolvePlugins.entries()) { + var existing = onResolveObject.$get(namespace) as [RegExp, AnyFunction][]; + + if (!existing) { + onResolveObject.$set(namespace, callbacks); + } else { + onResolveObject.$set(namespace, existing.concat(callbacks)); + } + } + } + } + + if (anyOnLoad) { + var onLoadObject = this.onLoad; + if (!onLoadObject) { + this.onLoad = onLoadPlugins; + } else { + for (var [namespace, callbacks] of onLoadPlugins.entries()) { + var existing = onLoadObject.$get(namespace) as [RegExp, AnyFunction][]; + + if (!existing) { + onLoadObject.$set(namespace, callbacks); + } else { + onLoadObject.$set(namespace, existing.concat(callbacks)); + } + } + } + } + + return anyOnLoad || anyOnResolve; + }; + + var setupResult = setup({ + config: config, + onDispose: notImplementedIssueFn(2771, "On-dispose callbacks"), + onEnd: notImplementedIssueFn(2771, "On-end callbacks"), + onLoad, + onResolve, + onStart: notImplementedIssueFn(2771, "On-start callbacks"), + resolve: notImplementedIssueFn(2771, "build.resolve()"), + // esbuild's options argument is different, we provide some interop + initialOptions: { + ...config, + bundle: true, + entryPoints: config.entrypoints ?? config.entryPoints ?? [], + minify: typeof config.minify === "boolean" ? config.minify : false, + minifyIdentifiers: config.minify === true || (config.minify as MinifyObj)?.identifiers, + minifyWhitespace: config.minify === true || (config.minify as MinifyObj)?.whitespace, + minifySyntax: config.minify === true || (config.minify as MinifyObj)?.syntax, + outbase: config.root, + platform: config.target === "bun" ? "node" : config.target, + }, + esbuild: {}, + } satisfies PluginBuilderExt as PluginBuilder); + + if (setupResult && $isPromise(setupResult)) { + if ($getPromiseInternalField(setupResult, $promiseFieldFlags) & $promiseStateFulfilled) { + setupResult = $getPromiseInternalField(setupResult, $promiseFieldReactionsOrResult); + } else { + return setupResult.$then(processSetupResult); + } + } + + return processSetupResult(); +} + +export function runOnResolvePlugins(this: BundlerPlugin, specifier, inputNamespace, importer, internalID, kindId) { + // Must be kept in sync with ImportRecord.label + const kind = $ImportKindIdToLabel[kindId]; + + var promiseResult: any = (async (inputPath, inputNamespace, importer, kind) => { + var { onResolve, onLoad } = this; + var results = onResolve.$get(inputNamespace); + if (!results) { + this.onResolveAsync(internalID, null, null, null); + return null; + } + + for (let [filter, callback] of results) { + if (filter.test(inputPath)) { + var result = callback({ + path: inputPath, + importer, + namespace: inputNamespace, + // resolveDir + kind, + // pluginData + }); + + while ( + result && + $isPromise(result) && + ($getPromiseInternalField(result, $promiseFieldFlags) & $promiseStateMask) === $promiseStateFulfilled + ) { + result = $getPromiseInternalField(result, $promiseFieldReactionsOrResult); + } + + if (result && $isPromise(result)) { + result = await result; + } + + if (!result || !$isObject(result)) { + continue; + } + + var { path, namespace: userNamespace = inputNamespace, external } = result; + if (!(typeof path === "string") || !(typeof userNamespace === "string")) { + throw new TypeError("onResolve plugins must return an object with a string 'path' and string 'loader' field"); + } + + if (!path) { + continue; + } + + if (!userNamespace) { + userNamespace = inputNamespace; + } + if (typeof external !== "boolean" && !$isUndefinedOrNull(external)) { + throw new TypeError('onResolve plugins "external" field must be boolean or unspecified'); + } + + if (!external) { + if (userNamespace === "file") { + if (process.platform !== "win32") { + if (path[0] !== "/" || path.includes("..")) { + throw new TypeError('onResolve plugin "path" must be absolute when the namespace is "file"'); + } + } else { + // TODO: Windows + } + } + if (userNamespace === "dataurl") { + if (!path.startsWith("data:")) { + throw new TypeError('onResolve plugin "path" must start with "data:" when the namespace is "dataurl"'); + } + } + + if (userNamespace && userNamespace !== "file" && (!onLoad || !onLoad.$has(userNamespace))) { + throw new TypeError(`Expected onLoad plugin for namespace ${userNamespace} to exist`); + } + } + this.onResolveAsync(internalID, path, userNamespace, external); + return null; + } + } + + this.onResolveAsync(internalID, null, null, null); + return null; + })(specifier, inputNamespace, importer, kind); + + while ( + promiseResult && + $isPromise(promiseResult) && + ($getPromiseInternalField(promiseResult, $promiseFieldFlags) & $promiseStateMask) === $promiseStateFulfilled + ) { + promiseResult = $getPromiseInternalField(promiseResult, $promiseFieldReactionsOrResult); + } + + if (promiseResult && $isPromise(promiseResult)) { + promiseResult.then( + () => {}, + e => { + this.addError(internalID, e, 0); + }, + ); + } +} + +export function runOnLoadPlugins(this: BundlerPlugin, internalID, path, namespace, defaultLoaderId) { + const LOADERS_MAP = $LoaderLabelToId; + const loaderName = $LoaderIdToLabel[defaultLoaderId]; + + var promiseResult = (async (internalID, path, namespace, defaultLoader) => { + var results = this.onLoad.$get(namespace); + if (!results) { + this.onLoadAsync(internalID, null, null); + return null; + } + + for (let [filter, callback] of results) { + if (filter.test(path)) { + var result = callback({ + path, + namespace, + // suffix + // pluginData + loader: defaultLoader, + }); + + while ( + result && + $isPromise(result) && + ($getPromiseInternalField(result, $promiseFieldFlags) & $promiseStateMask) === $promiseStateFulfilled + ) { + result = $getPromiseInternalField(result, $promiseFieldReactionsOrResult); + } + + if (result && $isPromise(result)) { + result = await result; + } + + if (!result || !$isObject(result)) { + continue; + } + + var { contents, loader = defaultLoader } = result as OnLoadResultSourceCode & OnLoadResultObject; + if (!(typeof contents === "string") && !$isTypedArrayView(contents)) { + throw new TypeError('onLoad plugins must return an object with "contents" as a string or Uint8Array'); + } + + if (!(typeof loader === "string")) { + throw new TypeError('onLoad plugins must return an object with "loader" as a string'); + } + + const chosenLoader = LOADERS_MAP[loader]; + if (chosenLoader === undefined) { + throw new TypeError(`Loader ${loader} is not supported.`); + } + + this.onLoadAsync(internalID, contents, chosenLoader); + return null; + } + } + + this.onLoadAsync(internalID, null, null); + return null; + })(internalID, path, namespace, loaderName); + + while ( + promiseResult && + $isPromise(promiseResult) && + ($getPromiseInternalField(promiseResult, $promiseFieldFlags) & $promiseStateMask) === $promiseStateFulfilled + ) { + promiseResult = $getPromiseInternalField(promiseResult, $promiseFieldReactionsOrResult); + } + + if (promiseResult && $isPromise(promiseResult)) { + promiseResult.then( + () => {}, + e => { + this.addError(internalID, e, 1); + }, + ); + } +} diff --git a/src/bun.js/builtins/js/ByteLengthQueuingStrategy.js b/src/bun.js/builtins/ts/ByteLengthQueuingStrategy.ts index e8f5b1cfc..fc3f3d998 100644 --- a/src/bun.js/builtins/js/ByteLengthQueuingStrategy.js +++ b/src/bun.js/builtins/ts/ByteLengthQueuingStrategy.ts @@ -24,28 +24,19 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@getter -function highWaterMark() -{ - "use strict"; +$getter; +export function highWaterMark(this: any) { + const highWaterMark = $getByIdDirectPrivate(this, "highWaterMark"); + if (highWaterMark === undefined) + throw new TypeError("ByteLengthQueuingStrategy.highWaterMark getter called on incompatible |this| value."); - const highWaterMark = @getByIdDirectPrivate(this, "highWaterMark"); - if (highWaterMark === @undefined) - @throwTypeError("ByteLengthQueuingStrategy.highWaterMark getter called on incompatible |this| value."); - - return highWaterMark; + return highWaterMark; } -function size(chunk) -{ - "use strict"; - - return chunk.byteLength; +export function size(chunk) { + return chunk.byteLength; } -function initializeByteLengthQueuingStrategy(parameters) -{ - "use strict"; - - @putByIdDirectPrivate(this, "highWaterMark", @extractHighWaterMarkFromQueuingStrategyInit(parameters)); +export function initializeByteLengthQueuingStrategy(this: any, parameters: any) { + $putByIdDirectPrivate(this, "highWaterMark", $extractHighWaterMarkFromQueuingStrategyInit(parameters)); } diff --git a/src/bun.js/builtins/ts/ConsoleObject.ts b/src/bun.js/builtins/ts/ConsoleObject.ts new file mode 100644 index 000000000..45746459a --- /dev/null +++ b/src/bun.js/builtins/ts/ConsoleObject.ts @@ -0,0 +1,84 @@ +$overriddenName = "[Symbol.asyncIterator]"; +export function asyncIterator(this: Console) { + const Iterator = async function* ConsoleAsyncIterator() { + const stream = Bun.stdin.stream(); + var reader = stream.getReader(); + + // TODO: use builtin + var decoder = new (globalThis as any).TextDecoder("utf-8", { fatal: false }) as TextDecoder; + var deferredError; + var indexOf = Bun.indexOfLine; + + try { + while (true) { + var done, value; + var pendingChunk; + const firstResult = reader.readMany(); + if ($isPromise(firstResult)) { + ({ done, value } = await firstResult); + } else { + ({ done, value } = firstResult); + } + + if (done) { + if (pendingChunk) { + yield decoder.decode(pendingChunk); + } + return; + } + + var actualChunk; + // we assume it was given line-by-line + for (const chunk of value) { + actualChunk = chunk; + if (pendingChunk) { + actualChunk = Buffer.concat([pendingChunk, chunk]); + pendingChunk = null; + } + + var last = 0; + // TODO: "\r", 0x4048, 0x4049, 0x404A, 0x404B, 0x404C, 0x404D, 0x404E, 0x404F + var i = indexOf(actualChunk, last); + while (i !== -1) { + yield decoder.decode(actualChunk.subarray(last, i)); + last = i + 1; + i = indexOf(actualChunk, last); + } + + pendingChunk = actualChunk.subarray(last); + } + } + } catch (e) { + deferredError = e; + } finally { + reader.releaseLock(); + + if (deferredError) { + throw deferredError; + } + } + }; + + const symbol = globalThis.Symbol.asyncIterator; + this[symbol] = Iterator; + return Iterator(); +} + +export function write(this: Console, input) { + var writer = $getByIdDirectPrivate(this, "writer"); + if (!writer) { + var length = $toLength(input?.length ?? 0); + writer = Bun.stdout.writer({ highWaterMark: length > 65536 ? length : 65536 }); + $putByIdDirectPrivate(this, "writer", writer); + } + + var wrote = writer.write(input); + + const count = $argumentCount(); + for (var i = 1; i < count; i++) { + wrote += writer.write($argument(i)); + } + + writer.flush(true); + return wrote; +} diff --git a/src/bun.js/builtins/js/CountQueuingStrategy.js b/src/bun.js/builtins/ts/CountQueuingStrategy.ts index 3cd9cffc2..a72dca1ca 100644 --- a/src/bun.js/builtins/js/CountQueuingStrategy.js +++ b/src/bun.js/builtins/ts/CountQueuingStrategy.ts @@ -23,28 +23,20 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -@getter -function highWaterMark() -{ - "use strict"; +$getter; +export function highWaterMark(this: any) { + const highWaterMark = $getByIdDirectPrivate(this, "highWaterMark"); - const highWaterMark = @getByIdDirectPrivate(this, "highWaterMark"); - if (highWaterMark === @undefined) - @throwTypeError("CountQueuingStrategy.highWaterMark getter called on incompatible |this| value."); + if (highWaterMark === undefined) + throw new TypeError("CountQueuingStrategy.highWaterMark getter called on incompatible |this| value."); - return highWaterMark; + return highWaterMark; } -function size() -{ - "use strict"; - - return 1; +export function size() { + return 1; } -function initializeCountQueuingStrategy(parameters) -{ - "use strict"; - - @putByIdDirectPrivate(this, "highWaterMark", @extractHighWaterMarkFromQueuingStrategyInit(parameters)); +export function initializeCountQueuingStrategy(this: any, parameters: any) { + $putByIdDirectPrivate(this, "highWaterMark", $extractHighWaterMarkFromQueuingStrategyInit(parameters)); } diff --git a/src/bun.js/builtins/ts/ImportMetaObject.ts b/src/bun.js/builtins/ts/ImportMetaObject.ts new file mode 100644 index 000000000..6c66075c6 --- /dev/null +++ b/src/bun.js/builtins/ts/ImportMetaObject.ts @@ -0,0 +1,152 @@ +type ImportMetaObject = Partial<ImportMeta>; + +export function loadCJS2ESM(this: ImportMetaObject, resolvedSpecifier: string) { + var loader = Loader; + var queue = $createFIFO(); + var key = resolvedSpecifier; + while (key) { + // we need to explicitly check because state could be $ModuleFetch + // it will throw this error if we do not: + // $throwTypeError("Requested module is already fetched."); + var entry = loader.registry.$get(key); + + if (!entry || !entry.state || entry.state <= $ModuleFetch) { + $fulfillModuleSync(key); + entry = loader.registry.$get(key)!; + } + + // entry.fetch is a Promise<SourceCode> + // SourceCode is not a string, it's a JSC::SourceCode object + // this pulls it out of the promise without delaying by a tick + // the promise is already fullfilled by $fullfillModuleSync + var sourceCodeObject = $getPromiseInternalField(entry.fetch, $promiseFieldReactionsOrResult); + // parseModule() returns a Promise, but the value is already fulfilled + // so we just pull it out of the promise here once again + // But, this time we do it a little more carefully because this is a JSC function call and not bun source code + var moduleRecordPromise = loader.parseModule(key, sourceCodeObject); + var module = entry.module; + if (!module && moduleRecordPromise && $isPromise(moduleRecordPromise)) { + var reactionsOrResult = $getPromiseInternalField(moduleRecordPromise, $promiseFieldReactionsOrResult); + var flags = $getPromiseInternalField(moduleRecordPromise, $promiseFieldFlags); + var state = flags & $promiseStateMask; + // this branch should never happen, but just to be safe + if (state === $promiseStatePending || (reactionsOrResult && $isPromise(reactionsOrResult))) { + throw new TypeError(`require() async module "${key}" is unsupported`); + } else if (state === $promiseStateRejected) { + // TODO: use SyntaxError but preserve the specifier + throw new TypeError(`${reactionsOrResult?.message ?? "An error occurred"} while parsing module \"${key}\"`); + } + entry.module = module = reactionsOrResult; + } else if (moduleRecordPromise && !module) { + entry.module = module = moduleRecordPromise as LoaderModule; + } + + // This is very similar to "requestInstantiate" in ModuleLoader.js in JavaScriptCore. + $setStateToMax(entry, $ModuleLink); + var dependenciesMap = module.dependenciesMap; + var requestedModules = loader.requestedModules(module); + var dependencies = $newArrayWithSize<string>(requestedModules.length); + for (var i = 0, length = requestedModules.length; i < length; ++i) { + var depName = requestedModules[i]; + // optimization: if it starts with a slash then it's an absolute path + // we don't need to run the resolver a 2nd time + var depKey = depName[0] === "/" ? depName : loader.resolve(depName, key); + var depEntry = loader.ensureRegistered(depKey); + if (depEntry.state < $ModuleLink) { + queue.push(depKey); + } + + $putByValDirect(dependencies, i, depEntry); + dependenciesMap.$set(depName, depEntry); + } + + entry.dependencies = dependencies; + // All dependencies resolved, set instantiate and satisfy field directly. + entry.instantiate = Promise.resolve(entry); + entry.satisfy = Promise.resolve(entry); + key = queue.shift(); + while (key && (loader.registry.$get(key)?.state ?? $ModuleFetch) >= $ModuleLink) { + key = queue.shift(); + } + } + + var linkAndEvaluateResult = loader.linkAndEvaluateModule(resolvedSpecifier, undefined); + if (linkAndEvaluateResult && $isPromise(linkAndEvaluateResult)) { + // if you use top-level await, or any dependencies use top-level await, then we throw here + // this means the module will still actually load eventually, but that's okay. + throw new TypeError(`require() async module \"${resolvedSpecifier}\" is unsupported`); + } + + return loader.registry.$get(resolvedSpecifier); +} + +export function requireESM(this: ImportMetaObject, resolved) { + var entry = Loader.registry.$get(resolved); + + if (!entry || !entry.evaluated) { + entry = $loadCJS2ESM(resolved); + } + + if (!entry || !entry.evaluated || !entry.module) { + throw new TypeError(`require() failed to evaluate module "${resolved}". This is an internal consistentency error.`); + } + var exports = Loader.getModuleNamespaceObject(entry.module); + var commonJS = exports.default; + var cjs = commonJS?.[$commonJSSymbol]; + if (cjs === 0) { + return commonJS; + } else if (cjs && $isCallable(commonJS)) { + return commonJS(); + } + + return exports; +} + +export function internalRequire(this: ImportMetaObject, resolved) { + var cached = $requireMap.$get(resolved); + const last5 = resolved.substring(resolved.length - 5); + if (cached) { + if (last5 === ".node") { + return cached.exports; + } + return cached; + } + + // TODO: remove this hardcoding + if (last5 === ".json") { + var fs = (globalThis[Symbol.for("_fs")] ||= Bun.fs()); + var exports = JSON.parse(fs.readFileSync(resolved, "utf8")); + $requireMap.$set(resolved, exports); + return exports; + } else if (last5 === ".node") { + var module = { exports: {} }; + process.dlopen(module, resolved); + $requireMap.$set(resolved, module); + return module.exports; + } else if (last5 === ".toml") { + var fs = (globalThis[Symbol.for("_fs")] ||= Bun.fs()); + var exports = Bun.TOML.parse(fs.readFileSync(resolved, "utf8")); + $requireMap.$set(resolved, exports); + return exports; + } else { + var exports = $requireESM(resolved); + $requireMap.$set(resolved, exports); + return exports; + } +} + +$sloppy; +export function require(this: ImportMetaObject, name) { + var from = this?.path ?? arguments.callee.path; + + if (typeof name !== "string") { + throw new TypeError("require(name) must be a string"); + } + + return $internalRequire($resolveSync(name, from)); +} + +$getter; +export function main(this: ImportMetaObject) { + return this.path === Bun.main; +} diff --git a/src/bun.js/builtins/ts/JSBufferConstructor.ts b/src/bun.js/builtins/ts/JSBufferConstructor.ts new file mode 100644 index 000000000..debc62d51 --- /dev/null +++ b/src/bun.js/builtins/ts/JSBufferConstructor.ts @@ -0,0 +1,67 @@ +export function from(items) { + if ($isUndefinedOrNull(items)) { + throw new TypeError( + "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.", + ); + } + + // TODO: figure out why private symbol not found + if ( + typeof items === "string" || + (typeof items === "object" && + ($isTypedArrayView(items) || + items instanceof ArrayBuffer || + items instanceof SharedArrayBuffer || + items instanceof String)) + ) { + switch ($argumentCount()) { + case 1: { + return new $Buffer(items); + } + case 2: { + return new $Buffer(items, $argument(1)); + } + default: { + return new $Buffer(items, $argument(1), $argument(2)); + } + } + } + + var arrayLike = $toObject( + items, + "The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.", + ) as ArrayLike<any>; + + if (!$isJSArray(arrayLike)) { + const toPrimitive = $tryGetByIdWithWellKnownSymbol(items, "toPrimitive"); + + if (toPrimitive) { + const primitive = toPrimitive.$call(items, "string"); + + if (typeof primitive === "string") { + switch ($argumentCount()) { + case 1: { + return new $Buffer(primitive); + } + case 2: { + return new $Buffer(primitive, $argument(1)); + } + default: { + return new $Buffer(primitive, $argument(1), $argument(2)); + } + } + } + } + + if (!("length" in arrayLike) || $isCallable(arrayLike)) { + throw new TypeError( + "The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.", + ); + } + } + + // Don't pass the second argument because Node's Buffer.from doesn't accept + // a function and Uint8Array.from requires it if it exists + // That means we cannot use $tailCallFowrardArguments here, sadly + return new $Buffer(Uint8Array.from(arrayLike).buffer); +} diff --git a/src/bun.js/builtins/ts/JSBufferPrototype.ts b/src/bun.js/builtins/ts/JSBufferPrototype.ts new file mode 100644 index 000000000..97b25b9b2 --- /dev/null +++ b/src/bun.js/builtins/ts/JSBufferPrototype.ts @@ -0,0 +1,495 @@ +// The fastest way as of April 2022 is to use DataView. +// DataView has intrinsics that cause inlining + +interface BufferExt extends Buffer { + $dataView?: DataView; + + toString(encoding?: BufferEncoding, start?: number, end?: number): string; + toString(offset: number, length: number, encoding?: BufferEncoding): string; +} + +export function setBigUint64(this: BufferExt, offset, value, le) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64( + offset, + value, + le, + ); +} +export function readInt8(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt8(offset); +} +export function readUInt8(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint8(offset); +} +export function readInt16LE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt16(offset, true); +} +export function readInt16BE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt16(offset, false); +} +export function readUInt16LE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint16(offset, true); +} +export function readUInt16BE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint16(offset, false); +} +export function readInt32LE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt32(offset, true); +} +export function readInt32BE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getInt32(offset, false); +} +export function readUInt32LE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint32(offset, true); +} +export function readUInt32BE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getUint32(offset, false); +} + +export function readIntLE(this: BufferExt, offset, byteLength) { + const view = (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)); + switch (byteLength) { + case 1: { + return view.getInt8(offset); + } + case 2: { + return view.getInt16(offset, true); + } + case 3: { + const val = view.getUint16(offset, true) + view.getUint8(offset + 2) * 2 ** 16; + return val | ((val & (2 ** 23)) * 0x1fe); + } + case 4: { + return view.getInt32(offset, true); + } + case 5: { + const last = view.getUint8(offset + 4); + return (last | ((last & (2 ** 7)) * 0x1fffffe)) * 2 ** 32 + view.getUint32(offset, true); + } + case 6: { + const last = view.getUint16(offset + 4, true); + return (last | ((last & (2 ** 15)) * 0x1fffe)) * 2 ** 32 + view.getUint32(offset, true); + } + } + throw new RangeError("byteLength must be >= 1 and <= 6"); +} +export function readIntBE(this: BufferExt, offset, byteLength) { + const view = (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)); + switch (byteLength) { + case 1: { + return view.getInt8(offset); + } + case 2: { + return view.getInt16(offset, false); + } + case 3: { + const val = view.getUint16(offset + 1, false) + view.getUint8(offset) * 2 ** 16; + return val | ((val & (2 ** 23)) * 0x1fe); + } + case 4: { + return view.getInt32(offset, false); + } + case 5: { + const last = view.getUint8(offset); + return (last | ((last & (2 ** 7)) * 0x1fffffe)) * 2 ** 32 + view.getUint32(offset + 1, false); + } + case 6: { + const last = view.getUint16(offset, false); + return (last | ((last & (2 ** 15)) * 0x1fffe)) * 2 ** 32 + view.getUint32(offset + 2, false); + } + } + throw new RangeError("byteLength must be >= 1 and <= 6"); +} +export function readUIntLE(this: BufferExt, offset, byteLength) { + const view = (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)); + switch (byteLength) { + case 1: { + return view.getUint8(offset); + } + case 2: { + return view.getUint16(offset, true); + } + case 3: { + return view.getUint16(offset, true) + view.getUint8(offset + 2) * 2 ** 16; + } + case 4: { + return view.getUint32(offset, true); + } + case 5: { + return view.getUint8(offset + 4) * 2 ** 32 + view.getUint32(offset, true); + } + case 6: { + return view.getUint16(offset + 4, true) * 2 ** 32 + view.getUint32(offset, true); + } + } + throw new RangeError("byteLength must be >= 1 and <= 6"); +} +export function readUIntBE(this: BufferExt, offset, byteLength) { + const view = (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)); + switch (byteLength) { + case 1: { + return view.getUint8(offset); + } + case 2: { + return view.getUint16(offset, false); + } + case 3: { + return view.getUint16(offset + 1, false) + view.getUint8(offset) * 2 ** 16; + } + case 4: { + return view.getUint32(offset, false); + } + case 5: { + const last = view.getUint8(offset); + return (last | ((last & (2 ** 7)) * 0x1fffffe)) * 2 ** 32 + view.getUint32(offset + 1, false); + } + case 6: { + const last = view.getUint16(offset, false); + return (last | ((last & (2 ** 15)) * 0x1fffe)) * 2 ** 32 + view.getUint32(offset + 2, false); + } + } + throw new RangeError("byteLength must be >= 1 and <= 6"); +} + +export function readFloatLE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat32(offset, true); +} +export function readFloatBE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat32(offset, false); +} +export function readDoubleLE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat64(offset, true); +} +export function readDoubleBE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getFloat64(offset, false); +} +export function readBigInt64LE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigInt64(offset, true); +} +export function readBigInt64BE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigInt64(offset, false); +} +export function readBigUInt64LE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigUint64(offset, true); +} +export function readBigUInt64BE(this: BufferExt, offset) { + return (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).getBigUint64(offset, false); +} + +export function writeInt8(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt8(offset, value); + return offset + 1; +} +export function writeUInt8(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint8(offset, value); + return offset + 1; +} +export function writeInt16LE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt16(offset, value, true); + return offset + 2; +} +export function writeInt16BE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt16(offset, value, false); + return offset + 2; +} +export function writeUInt16LE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint16(offset, value, true); + return offset + 2; +} +export function writeUInt16BE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint16(offset, value, false); + return offset + 2; +} +export function writeInt32LE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt32(offset, value, true); + return offset + 4; +} +export function writeInt32BE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setInt32(offset, value, false); + return offset + 4; +} +export function writeUInt32LE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint32(offset, value, true); + return offset + 4; +} +export function writeUInt32BE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setUint32(offset, value, false); + return offset + 4; +} + +export function writeIntLE(this: BufferExt, value, offset, byteLength) { + const view = (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)); + switch (byteLength) { + case 1: { + view.setInt8(offset, value); + break; + } + case 2: { + view.setInt16(offset, value, true); + break; + } + case 3: { + view.setUint16(offset, value & 0xffff, true); + view.setInt8(offset + 2, Math.floor(value * 2 ** -16)); + break; + } + case 4: { + view.setInt32(offset, value, true); + break; + } + case 5: { + view.setUint32(offset, value | 0, true); + view.setInt8(offset + 4, Math.floor(value * 2 ** -32)); + break; + } + case 6: { + view.setUint32(offset, value | 0, true); + view.setInt16(offset + 4, Math.floor(value * 2 ** -32), true); + break; + } + default: { + throw new RangeError("byteLength must be >= 1 and <= 6"); + } + } + return offset + byteLength; +} +export function writeIntBE(this: BufferExt, value, offset, byteLength) { + const view = (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)); + switch (byteLength) { + case 1: { + view.setInt8(offset, value); + break; + } + case 2: { + view.setInt16(offset, value, false); + break; + } + case 3: { + view.setUint16(offset + 1, value & 0xffff, false); + view.setInt8(offset, Math.floor(value * 2 ** -16)); + break; + } + case 4: { + view.setInt32(offset, value, false); + break; + } + case 5: { + view.setUint32(offset + 1, value | 0, false); + view.setInt8(offset, Math.floor(value * 2 ** -32)); + break; + } + case 6: { + view.setUint32(offset + 2, value | 0, false); + view.setInt16(offset, Math.floor(value * 2 ** -32), false); + break; + } + default: { + throw new RangeError("byteLength must be >= 1 and <= 6"); + } + } + return offset + byteLength; +} +export function writeUIntLE(this: BufferExt, value, offset, byteLength) { + const view = (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)); + switch (byteLength) { + case 1: { + view.setUint8(offset, value); + break; + } + case 2: { + view.setUint16(offset, value, true); + break; + } + case 3: { + view.setUint16(offset, value & 0xffff, true); + view.setUint8(offset + 2, Math.floor(value * 2 ** -16)); + break; + } + case 4: { + view.setUint32(offset, value, true); + break; + } + case 5: { + view.setUint32(offset, value | 0, true); + view.setUint8(offset + 4, Math.floor(value * 2 ** -32)); + break; + } + case 6: { + view.setUint32(offset, value | 0, true); + view.setUint16(offset + 4, Math.floor(value * 2 ** -32), true); + break; + } + default: { + throw new RangeError("byteLength must be >= 1 and <= 6"); + } + } + return offset + byteLength; +} +export function writeUIntBE(this: BufferExt, value, offset, byteLength) { + const view = (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)); + switch (byteLength) { + case 1: { + view.setUint8(offset, value); + break; + } + case 2: { + view.setUint16(offset, value, false); + break; + } + case 3: { + view.setUint16(offset + 1, value & 0xffff, false); + view.setUint8(offset, Math.floor(value * 2 ** -16)); + break; + } + case 4: { + view.setUint32(offset, value, false); + break; + } + case 5: { + view.setUint32(offset + 1, value | 0, false); + view.setUint8(offset, Math.floor(value * 2 ** -32)); + break; + } + case 6: { + view.setUint32(offset + 2, value | 0, false); + view.setUint16(offset, Math.floor(value * 2 ** -32), false); + break; + } + default: { + throw new RangeError("byteLength must be >= 1 and <= 6"); + } + } + return offset + byteLength; +} + +export function writeFloatLE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat32(offset, value, true); + return offset + 4; +} + +export function writeFloatBE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat32(offset, value, false); + return offset + 4; +} + +export function writeDoubleLE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat64(offset, value, true); + return offset + 8; +} + +export function writeDoubleBE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setFloat64(offset, value, false); + return offset + 8; +} + +export function writeBigInt64LE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigInt64(offset, value, true); + return offset + 8; +} + +export function writeBigInt64BE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigInt64(offset, value, false); + return offset + 8; +} + +export function writeBigUInt64LE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value, true); + return offset + 8; +} + +export function writeBigUInt64BE(this: BufferExt, value, offset) { + (this.$dataView ||= new DataView(this.buffer, this.byteOffset, this.byteLength)).setBigUint64(offset, value, false); + return offset + 8; +} + +export function utf8Write(this: BufferExt, text, offset, length) { + return this.write(text, offset, length, "utf8"); +} +export function ucs2Write(this: BufferExt, text, offset, length) { + return this.write(text, offset, length, "ucs2"); +} +export function utf16leWrite(this: BufferExt, text, offset, length) { + return this.write(text, offset, length, "utf16le"); +} +export function latin1Write(this: BufferExt, text, offset, length) { + return this.write(text, offset, length, "latin1"); +} +export function asciiWrite(this: BufferExt, text, offset, length) { + return this.write(text, offset, length, "ascii"); +} +export function base64Write(this: BufferExt, text, offset, length) { + return this.write(text, offset, length, "base64"); +} +export function base64urlWrite(this: BufferExt, text, offset, length) { + return this.write(text, offset, length, "base64url"); +} +export function hexWrite(this: BufferExt, text, offset, length) { + return this.write(text, offset, length, "hex"); +} + +export function utf8Slice(this: BufferExt, offset, length) { + return this.toString(offset, length, "utf8"); +} +export function ucs2Slice(this: BufferExt, offset, length) { + return this.toString(offset, length, "ucs2"); +} +export function utf16leSlice(this: BufferExt, offset, length) { + return this.toString(offset, length, "utf16le"); +} +export function latin1Slice(this: BufferExt, offset, length) { + return this.toString(offset, length, "latin1"); +} +export function asciiSlice(this: BufferExt, offset, length) { + return this.toString(offset, length, "ascii"); +} +export function base64Slice(this: BufferExt, offset, length) { + return this.toString(offset, length, "base64"); +} +export function base64urlSlice(this: BufferExt, offset, length) { + return this.toString(offset, length, "base64url"); +} +export function hexSlice(this: BufferExt, offset, length) { + return this.toString(offset, length, "hex"); +} + +export function toJSON(this: BufferExt) { + const type = "Buffer"; + const data = Array.from(this); + return { type, data }; +} + +export function slice(this: BufferExt, start, end) { + var { buffer, byteOffset, byteLength } = this; + + function adjustOffset(offset, length) { + // Use Math.trunc() to convert offset to an integer value that can be larger + // than an Int32. Hence, don't use offset | 0 or similar techniques. + offset = $trunc(offset); + if (offset === 0 || isNaN(offset)) { + return 0; + } else if (offset < 0) { + offset += length; + return offset > 0 ? offset : 0; + } else { + return offset < length ? offset : length; + } + } + + var start_ = adjustOffset(start, byteLength); + var end_ = end !== undefined ? adjustOffset(end, byteLength) : byteLength; + return new $Buffer(buffer, byteOffset + start_, end_ > start_ ? end_ - start_ : 0); +} + +$getter; +export function parent(this: BufferExt) { + return $isObject(this) && this instanceof $Buffer ? this.buffer : undefined; +} + +$getter; +export function offset(this: BufferExt) { + return $isObject(this) && this instanceof $Buffer ? this.byteOffset : undefined; +} + +export function inspect(this: BufferExt, recurseTimes, ctx) { + return Bun.inspect(this); +} diff --git a/src/bun.js/builtins/js/ProcessObjectInternals.js b/src/bun.js/builtins/ts/ProcessObjectInternals.ts index 82df97f63..8b24e68ba 100644 --- a/src/bun.js/builtins/js/ProcessObjectInternals.js +++ b/src/bun.js/builtins/ts/ProcessObjectInternals.ts @@ -23,12 +23,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - -function binding(bindingName) { - "use strict"; - bindingName !== "constants" && - @throwTypeError( - 'process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.' +export function binding(bindingName) { + if (bindingName !== "constants") + throw new TypeError( + "process.binding() is not supported in Bun. If that breaks something, please file an issue and include a reproducible code sample.", ); var cache = globalThis.Symbol.for("process.bindings.constants"); @@ -37,24 +35,21 @@ function binding(bindingName) { // TODO: make this less hacky. // This calls require("node:fs").constants // except, outside an ESM module. - const {constants: fs} = globalThis[globalThis.Symbol.for("Bun.lazy")]( - "createImportMeta", - "node:process" - ).require( - "node:fs" - ) + const { constants: fs } = globalThis[globalThis.Symbol.for("Bun.lazy")]("createImportMeta", "node:process").require( + "node:fs", + ); constants = { fs, zlib: {}, crypto: {}, - os: @Bun._Os().constants, + os: Bun._Os().constants, }; globalThis[cache] = constants; } return constants; } -function getStdioWriteStream(fd_, rawRequire) { +export function getStdioWriteStream(fd_, rawRequire) { var module = { path: "node:process", require: rawRequire }; var require = path => module.require(path); @@ -103,6 +98,8 @@ function getStdioWriteStream(fd_, rawRequire) { _destroy(err, callback) { if (!err && this.#onClose !== null) { var AbortError = class AbortError extends Error { + code: string; + name: string; constructor(message = "The operation was aborted", options = void 0) { if (options !== void 0 && typeof options !== "object") { throw new Error(`Invalid AbortError options:\n\n${JSON.stringify(options, null, 2)}`); @@ -369,7 +366,7 @@ function getStdioWriteStream(fd_, rawRequire) { return this.#write1(chunk); } - #performCallback(cb, err) { + #performCallback(cb, err?: any) { if (err) { this.emit("error", err); } @@ -475,7 +472,7 @@ function getStdioWriteStream(fd_, rawRequire) { return new FastStdioWriteStream(fd_); } -function getStdinStream(fd_, rawRequire, Bun) { +export function getStdinStream(fd_, rawRequire, Bun) { var module = { path: "node:process", require: rawRequire }; var require = path => module.require(path); @@ -508,7 +505,7 @@ function getStdinStream(fd_, rawRequire, Bun) { super({ readable: true, writable: true }); } - #onFinished(err) { + #onFinished(err?) { const cb = this.#onClose; this.#onClose = null; @@ -545,6 +542,7 @@ function getStdinStream(fd_, rawRequire, Bun) { } setRawMode(mode) {} + on(name, callback) { // Streams don't generally required to present any data when only // `readable` events are present, i.e. `readableFlowing === false` diff --git a/src/bun.js/builtins/ts/ReadableByteStreamController.ts b/src/bun.js/builtins/ts/ReadableByteStreamController.ts new file mode 100644 index 000000000..888f241bc --- /dev/null +++ b/src/bun.js/builtins/ts/ReadableByteStreamController.ts @@ -0,0 +1,93 @@ +/* + * 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. + */ + +export function initializeReadableByteStreamController(this, stream, underlyingByteSource, highWaterMark) { + if (arguments.length !== 4 && arguments[3] !== $isReadableStream) + throw new TypeError("ReadableByteStreamController constructor should not be called directly"); + + return $privateInitializeReadableByteStreamController.$call(this, stream, underlyingByteSource, highWaterMark); +} + +export function enqueue(this, chunk) { + if (!$isReadableByteStreamController(this)) throw $makeThisTypeError("ReadableByteStreamController", "enqueue"); + + if ($getByIdDirectPrivate(this, "closeRequested")) + throw new TypeError("ReadableByteStreamController is requested to close"); + + if ($getByIdDirectPrivate($getByIdDirectPrivate(this, "controlledReadableStream"), "state") !== $streamReadable) + throw new TypeError("ReadableStream is not readable"); + + if (!$isObject(chunk) || !ArrayBuffer.$isView(chunk)) throw new TypeError("Provided chunk is not a TypedArray"); + + return $readableByteStreamControllerEnqueue(this, chunk); +} + +export function error(this, error) { + if (!$isReadableByteStreamController(this)) throw $makeThisTypeError("ReadableByteStreamController", "error"); + + if ($getByIdDirectPrivate($getByIdDirectPrivate(this, "controlledReadableStream"), "state") !== $streamReadable) + throw new TypeError("ReadableStream is not readable"); + + $readableByteStreamControllerError(this, error); +} + +export function close(this) { + if (!$isReadableByteStreamController(this)) throw $makeThisTypeError("ReadableByteStreamController", "close"); + + if ($getByIdDirectPrivate(this, "closeRequested")) throw new TypeError("Close has already been requested"); + + if ($getByIdDirectPrivate($getByIdDirectPrivate(this, "controlledReadableStream"), "state") !== $streamReadable) + throw new TypeError("ReadableStream is not readable"); + + $readableByteStreamControllerClose(this); +} + +$getter; +export function byobRequest(this) { + 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; +export function desiredSize(this) { + if (!$isReadableByteStreamController(this)) throw $makeGetterTypeError("ReadableByteStreamController", "desiredSize"); + + return $readableByteStreamControllerGetDesiredSize(this); +} diff --git a/src/bun.js/builtins/ts/ReadableByteStreamInternals.ts b/src/bun.js/builtins/ts/ReadableByteStreamInternals.ts new file mode 100644 index 000000000..f44c385b4 --- /dev/null +++ b/src/bun.js/builtins/ts/ReadableByteStreamInternals.ts @@ -0,0 +1,656 @@ +/* + * 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 + +export function privateInitializeReadableByteStreamController(this, stream, underlyingByteSource, highWaterMark) { + if (!$isReadableStream(stream)) throw new TypeError("ReadableByteStreamController needs a ReadableStream"); + + // readableStreamController is initialized with null value. + if ($getByIdDirectPrivate(stream, "readableStreamController") !== null) + throw new TypeError("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", 0); + $putByIdDirectPrivate(this, "closeRequested", false); + + let hwm = $toNumber(highWaterMark); + if (isNaN(hwm) || hwm < 0) throw new RangeError("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) + throw new RangeError("autoAllocateChunkSize value is negative or equal to positive or negative infinity"); + } + $putByIdDirectPrivate(this, "autoAllocateChunkSize", autoAllocateChunkSize); + $putByIdDirectPrivate(this, "pendingPullIntos", $createFIFO()); + + const controller = this; + $promiseInvokeOrNoopNoCatch($getByIdDirectPrivate(controller, "underlyingByteSource"), "start", [controller]).$then( + () => { + $putByIdDirectPrivate(controller, "started", 1); + $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; +} + +export function readableStreamByteStreamControllerStart(this, controller) { + $putByIdDirectPrivate(controller, "start", undefined); +} + +export function privateInitializeReadableStreamBYOBRequest(this, controller, view) { + $putByIdDirectPrivate(this, "associatedReadableByteStreamController", controller); + $putByIdDirectPrivate(this, "view", view); +} + +export function isReadableByteStreamController(controller) { + // Same test mechanism as in isReadableStreamDefaultController (ReadableStreamInternals.js). + // See corresponding function for explanations. + return $isObject(controller) && !!$getByIdDirectPrivate(controller, "underlyingByteSource"); +} + +export function isReadableStreamBYOBRequest(byobRequest) { + // Same test mechanism as in isReadableStreamDefaultController (ReadableStreamInternals.js). + // See corresponding function for explanations. + return $isObject(byobRequest) && !!$getByIdDirectPrivate(byobRequest, "associatedReadableByteStreamController"); +} + +export function isReadableStreamBYOBReader(reader) { + // 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"); +} + +export function readableByteStreamControllerCancel(controller, reason) { + 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]); +} + +export function readableByteStreamControllerError(controller, e) { + $assert( + $getByIdDirectPrivate($getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === $streamReadable, + ); + $readableByteStreamControllerClearPendingPullIntos(controller); + $putByIdDirectPrivate(controller, "queue", $newQueue()); + $readableStreamError($getByIdDirectPrivate(controller, "controlledReadableStream"), e); +} + +export function readableByteStreamControllerClose(controller) { + $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")); +} + +export function readableByteStreamControllerClearPendingPullIntos(controller) { + $readableByteStreamControllerInvalidateBYOBRequest(controller); + var existing = $getByIdDirectPrivate(controller, "pendingPullIntos"); + if (existing !== undefined) { + existing.clear(); + } else { + $putByIdDirectPrivate(controller, "pendingPullIntos", $createFIFO()); + } +} + +export function readableByteStreamControllerGetDesiredSize(controller) { + 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; +} + +export function readableStreamHasBYOBReader(stream) { + const reader = $getByIdDirectPrivate(stream, "reader"); + return reader !== undefined && $isReadableStreamBYOBReader(reader); +} + +export function readableStreamHasDefaultReader(stream) { + const reader = $getByIdDirectPrivate(stream, "reader"); + return reader !== undefined && $isReadableStreamDefaultReader(reader); +} + +export function readableByteStreamControllerHandleQueueDrain(controller) { + $assert( + $getByIdDirectPrivate($getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === $streamReadable, + ); + if (!$getByIdDirectPrivate(controller, "queue").size && $getByIdDirectPrivate(controller, "closeRequested")) + $readableStreamClose($getByIdDirectPrivate(controller, "controlledReadableStream")); + else $readableByteStreamControllerCallPullIfNeeded(controller); +} + +export function readableByteStreamControllerPull(controller) { + const stream = $getByIdDirectPrivate(controller, "controlledReadableStream"); + $assert($readableStreamHasDefaultReader(stream)); + if ($getByIdDirectPrivate(controller, "queue").content?.isNotEmpty()) { + 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; +} + +export function readableByteStreamControllerShouldCallPull(controller) { + const stream = $getByIdDirectPrivate(controller, "controlledReadableStream"); + + if ($getByIdDirectPrivate(stream, "state") !== $streamReadable) return false; + if ($getByIdDirectPrivate(controller, "closeRequested")) return false; + if (!($getByIdDirectPrivate(controller, "started") > 0)) 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; +} + +export function readableByteStreamControllerCallPullIfNeeded(controller) { + 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); + }, + ); +} + +export function transferBufferToCurrentRealm(buffer) { + // 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; +} + +export function readableStreamReaderKind(reader) { + if (!!$getByIdDirectPrivate(reader, "readRequests")) return $getByIdDirectPrivate(reader, "bunNativePtr") ? 3 : 1; + + if (!!$getByIdDirectPrivate(reader, "readIntoRequests")) return 2; + + return 0; +} + +export function readableByteStreamControllerEnqueue(controller, chunk) { + 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. +export function readableByteStreamControllerEnqueueChunk(controller, buffer, byteOffset, byteLength) { + $getByIdDirectPrivate(controller, "queue").content.push({ + buffer: buffer, + byteOffset: byteOffset, + byteLength: byteLength, + }); + $getByIdDirectPrivate(controller, "queue").size += byteLength; +} + +export function readableByteStreamControllerRespondWithNewView(controller, view) { + $assert($getByIdDirectPrivate(controller, "pendingPullIntos").isNotEmpty()); + + let firstDescriptor = $getByIdDirectPrivate(controller, "pendingPullIntos").peek(); + + if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) + throw new RangeError("Invalid value for view.byteOffset"); + + if (firstDescriptor.byteLength !== view.byteLength) throw new RangeError("Invalid value for view.byteLength"); + + firstDescriptor.buffer = view.buffer; + $readableByteStreamControllerRespondInternal(controller, view.byteLength); +} + +export function readableByteStreamControllerRespond(controller, bytesWritten) { + bytesWritten = $toNumber(bytesWritten); + + if (isNaN(bytesWritten) || bytesWritten === Infinity || bytesWritten < 0) + throw new RangeError("bytesWritten has an incorrect value"); + + $assert($getByIdDirectPrivate(controller, "pendingPullIntos").isNotEmpty()); + + $readableByteStreamControllerRespondInternal(controller, bytesWritten); +} + +export function readableByteStreamControllerRespondInternal(controller, bytesWritten) { + let firstDescriptor = $getByIdDirectPrivate(controller, "pendingPullIntos").peek(); + let stream = $getByIdDirectPrivate(controller, "controlledReadableStream"); + + if ($getByIdDirectPrivate(stream, "state") === $streamClosed) { + if (bytesWritten !== 0) throw new TypeError("bytesWritten is different from 0 even though stream is closed"); + $readableByteStreamControllerRespondInClosedState(controller, firstDescriptor); + } else { + $assert($getByIdDirectPrivate(stream, "state") === $streamReadable); + $readableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor); + } +} + +export function readableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) { + if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) + throw new RangeError("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); +} + +export function readableByteStreamControllerRespondInClosedState(controller, firstDescriptor) { + 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). +export function readableByteStreamControllerProcessPullDescriptors(controller) { + $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). +export function readableByteStreamControllerFillDescriptorFromQueue(controller, pullIntoDescriptor) { + 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). +export function readableByteStreamControllerShiftPendingDescriptor(controller) { + let descriptor = $getByIdDirectPrivate(controller, "pendingPullIntos").shift(); + $readableByteStreamControllerInvalidateBYOBRequest(controller); + return descriptor; +} + +export function readableByteStreamControllerInvalidateBYOBRequest(controller) { + 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). +export function readableByteStreamControllerCommitDescriptor(stream, pullIntoDescriptor) { + $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). +export function readableByteStreamControllerConvertDescriptor(pullIntoDescriptor) { + $assert(pullIntoDescriptor.bytesFilled <= pullIntoDescriptor.byteLength); + $assert(pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize === 0); + + return new pullIntoDescriptor.ctor( + pullIntoDescriptor.buffer, + pullIntoDescriptor.byteOffset, + pullIntoDescriptor.bytesFilled / pullIntoDescriptor.elementSize, + ); +} + +export function readableStreamFulfillReadIntoRequest(stream, chunk, done) { + const readIntoRequest = $getByIdDirectPrivate($getByIdDirectPrivate(stream, "reader"), "readIntoRequests").shift(); + $fulfillPromise(readIntoRequest, { value: chunk, done: done }); +} + +export function readableStreamBYOBReaderRead(reader, view) { + 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); +} + +export function readableByteStreamControllerPullInto(controller, view) { + 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; +} + +export function readableStreamAddReadIntoRequest(stream) { + $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/bun.js/builtins/ts/ReadableStream.ts b/src/bun.js/builtins/ts/ReadableStream.ts new file mode 100644 index 000000000..22453403d --- /dev/null +++ b/src/bun.js/builtins/ts/ReadableStream.ts @@ -0,0 +1,416 @@ +/* + * 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. + */ + +export function initializeReadableStream(this: any, underlyingSource: UnderlyingSource, strategy: any) { + if (underlyingSource === undefined) + underlyingSource = { $bunNativeType: 0, $bunNativePtr: 0, $lazy: false } as UnderlyingSource; + if (strategy === undefined) strategy = {}; + + if (!$isObject(underlyingSource)) throw new TypeError("ReadableStream constructor takes an object as first argument"); + + if (strategy !== undefined && !$isObject(strategy)) + throw new TypeError("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); + $putByIdDirectPrivate(this, "bunNativeType", $getByIdDirectPrivate(underlyingSource, "bunNativeType") ?? 0); + $putByIdDirectPrivate(this, "bunNativePtr", $getByIdDirectPrivate(underlyingSource, "bunNativePtr") ?? 0); + + const isDirect = underlyingSource.type === "direct"; + // direct streams are always lazy + const isUnderlyingSourceLazy = !!underlyingSource.$lazy; + const isLazy = isDirect || isUnderlyingSourceLazy; + + // 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 && !isLazy) { + const size = $getByIdDirectPrivate(strategy, "size"); + const highWaterMark = $getByIdDirectPrivate(strategy, "highWaterMark"); + $putByIdDirectPrivate(this, "highWaterMark", highWaterMark); + $putByIdDirectPrivate(this, "underlyingSource", undefined); + $setupReadableStreamDefaultController( + this, + underlyingSource, + size, + highWaterMark !== undefined ? highWaterMark : 1, + $getByIdDirectPrivate(underlyingSource, "start"), + $getByIdDirectPrivate(underlyingSource, "pull"), + $getByIdDirectPrivate(underlyingSource, "cancel"), + ); + + return this; + } + if (isDirect) { + $putByIdDirectPrivate(this, "underlyingSource", underlyingSource); + $putByIdDirectPrivate(this, "highWaterMark", $getByIdDirectPrivate(strategy, "highWaterMark")); + $putByIdDirectPrivate(this, "start", () => $createReadableStreamController(this, underlyingSource, strategy)); + } else if (isLazy) { + const autoAllocateChunkSize = underlyingSource.autoAllocateChunkSize; + $putByIdDirectPrivate(this, "highWaterMark", undefined); + $putByIdDirectPrivate(this, "underlyingSource", undefined); + $putByIdDirectPrivate( + this, + "highWaterMark", + autoAllocateChunkSize || $getByIdDirectPrivate(strategy, "highWaterMark"), + ); + + $putByIdDirectPrivate(this, "start", () => { + const instance = $lazyLoadStream(this, autoAllocateChunkSize); + if (instance) { + $createReadableStreamController(this, instance, strategy); + } + }); + } else { + $putByIdDirectPrivate(this, "underlyingSource", undefined); + $putByIdDirectPrivate(this, "highWaterMark", $getByIdDirectPrivate(strategy, "highWaterMark")); + $putByIdDirectPrivate(this, "start", undefined); + $createReadableStreamController(this, underlyingSource, strategy); + } + + return this; +} + +$linkTimeConstant; +export function readableStreamToArray(stream) { + // this is a direct stream + var underlyingSource = $getByIdDirectPrivate(stream, "underlyingSource"); + if (underlyingSource !== undefined) { + return $readableStreamToArrayDirect(stream, underlyingSource); + } + + return $readableStreamIntoArray(stream); +} + +$linkTimeConstant; +export function readableStreamToText(stream) { + // this is a direct stream + var underlyingSource = $getByIdDirectPrivate(stream, "underlyingSource"); + if (underlyingSource !== undefined) { + return $readableStreamToTextDirect(stream, underlyingSource); + } + + return $readableStreamIntoText(stream); +} + +$linkTimeConstant; +export function readableStreamToArrayBuffer(stream) { + // this is a direct stream + var underlyingSource = $getByIdDirectPrivate(stream, "underlyingSource"); + + if (underlyingSource !== undefined) { + return $readableStreamToArrayBufferDirect(stream, underlyingSource); + } + + return (Bun.readableStreamToArray(stream) as Promise<any>).$then(Bun.concatArrayBuffers); +} + +$linkTimeConstant; +export function readableStreamToJSON(stream) { + return Bun.readableStreamToText(stream).$then(globalThis.JSON.parse); +} + +$linkTimeConstant; +export function readableStreamToBlob(stream) { + return Promise.resolve(Bun.readableStreamToArray(stream)).$then(array => new Blob(array)); +} + +$linkTimeConstant; +export function consumeReadableStream(nativePtr, nativeType, inputStream) { + const symbol = globalThis.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[globalThis.Symbol.for("Bun.lazy")](nativeType); + + Prototype = class NativeReadableStreamSink { + handleError: any; + handleClosed: any; + processResult: any; + + 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); + } + + _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)) { + throw new TypeError("Cannot start reading from a locked stream"); + } + + return new Prototype(inputStream.getReader(), nativePtr); +} + +$linkTimeConstant; +export function createEmptyReadableStream() { + var stream = new ReadableStream({ + pull() {}, + } as any); + $readableStreamClose(stream); + return stream; +} + +$linkTimeConstant; +export function createNativeReadableStream(nativePtr, nativeType, autoAllocateChunkSize) { + return new ReadableStream({ + $lazy: true, + $bunNativeType: nativeType, + $bunNativePtr: nativePtr, + autoAllocateChunkSize: autoAllocateChunkSize, + }); +} + +export function cancel(this, reason) { + if (!$isReadableStream(this)) return Promise.$reject($makeThisTypeError("ReadableStream", "cancel")); + + if ($isReadableStreamLocked(this)) return Promise.$reject($makeTypeError("ReadableStream is locked")); + + return $readableStreamCancel(this, reason); +} + +export function getReader(this, options) { + if (!$isReadableStream(this)) throw $makeThisTypeError("ReadableStream", "getReader"); + + const mode = $toDictionary(options, {}, "ReadableStream.getReader takes an object as first argument").mode; + if (mode === undefined) { + var start_ = $getByIdDirectPrivate(this, "start"); + if (start_) { + $putByIdDirectPrivate(this, "start", undefined); + start_(); + } + + return new ReadableStreamDefaultReader(this); + } + // String conversion is required by spec, hence double equals. + if (mode == "byob") { + return new ReadableStreamBYOBReader(this); + } + + throw new TypeError("Invalid mode is specified"); +} + +export function pipeThrough(this, streams, options) { + 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; +} + +export function pipeTo(this, destination) { + if (!$isReadableStream(this)) return Promise.$reject($makeThisTypeError("ReadableStream", "pipeTo")); + + if ($isReadableStreamLocked(this)) return Promise.$reject($makeTypeError("ReadableStream is locked")); + + // 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 = $argument(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(new TypeError("options.signal must be AbortSignal")); + } + + const internalDestination = $getInternalWritableStream(destination); + if (!$isWritableStream(internalDestination)) + return Promise.$reject(new TypeError("ReadableStream pipeTo requires a WritableStream")); + + if ($isWritableStreamLocked(internalDestination)) return Promise.$reject(new TypeError("WritableStream is locked")); + + return $readableStreamPipeToWritableStream( + this, + internalDestination, + preventClose, + preventAbort, + preventCancel, + signal, + ); +} + +export function tee(this) { + if (!$isReadableStream(this)) throw $makeThisTypeError("ReadableStream", "tee"); + + return $readableStreamTee(this, false); +} + +$getter; +export function locked(this) { + if (!$isReadableStream(this)) throw $makeGetterTypeError("ReadableStream", "locked"); + + return $isReadableStreamLocked(this); +} + +export function values(this, options) { + var prototype = ReadableStream.prototype; + $readableStreamDefineLazyIterators(prototype); + return prototype.values.$call(this, options); +} + +$linkTimeConstant; +export function lazyAsyncIterator(this) { + var prototype = ReadableStream.prototype; + $readableStreamDefineLazyIterators(prototype); + return prototype[globalThis.Symbol.asyncIterator].$call(this); +} diff --git a/src/bun.js/builtins/ts/ReadableStreamBYOBReader.ts b/src/bun.js/builtins/ts/ReadableStreamBYOBReader.ts new file mode 100644 index 000000000..5ebfddb19 --- /dev/null +++ b/src/bun.js/builtins/ts/ReadableStreamBYOBReader.ts @@ -0,0 +1,80 @@ +/* + * 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. + */ + +export function initializeReadableStreamBYOBReader(this, stream) { + if (!$isReadableStream(stream)) throw new TypeError("ReadableStreamBYOBReader needs a ReadableStream"); + if (!$isReadableByteStreamController($getByIdDirectPrivate(stream, "readableStreamController"))) + throw new TypeError("ReadableStreamBYOBReader needs a ReadableByteStreamController"); + if ($isReadableStreamLocked(stream)) throw new TypeError("ReadableStream is locked"); + + $readableStreamReaderGenericInitialize(this, stream); + $putByIdDirectPrivate(this, "readIntoRequests", $createFIFO()); + + return this; +} + +export function cancel(this, reason) { + 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); +} + +export function read(this, view: DataView) { + 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); +} + +export function releaseLock(this) { + if (!$isReadableStreamBYOBReader(this)) throw $makeThisTypeError("ReadableStreamBYOBReader", "releaseLock"); + + if (!$getByIdDirectPrivate(this, "ownerReadableStream")) return; + + if ($getByIdDirectPrivate(this, "readIntoRequests")?.isNotEmpty()) + throw new TypeError("There are still pending read requests, cannot release the lock"); + + $readableStreamReaderGenericRelease(this); +} + +$getter; +export function closed(this) { + if (!$isReadableStreamBYOBReader(this)) + return Promise.$reject($makeGetterTypeError("ReadableStreamBYOBReader", "closed")); + + return $getByIdDirectPrivate(this, "closedPromiseCapability").$promise; +} diff --git a/src/bun.js/builtins/ts/ReadableStreamBYOBRequest.ts b/src/bun.js/builtins/ts/ReadableStreamBYOBRequest.ts new file mode 100644 index 000000000..1354f9349 --- /dev/null +++ b/src/bun.js/builtins/ts/ReadableStreamBYOBRequest.ts @@ -0,0 +1,66 @@ +/* + * 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. + */ + +export function initializeReadableStreamBYOBRequest(this, controller, view) { + if (arguments.length !== 3 && arguments[2] !== $isReadableStream) + throw new TypeError("ReadableStreamBYOBRequest constructor should not be called directly"); + + return $privateInitializeReadableStreamBYOBRequest.$call(this, controller, view); +} + +export function respond(this, bytesWritten) { + if (!$isReadableStreamBYOBRequest(this)) throw $makeThisTypeError("ReadableStreamBYOBRequest", "respond"); + + if ($getByIdDirectPrivate(this, "associatedReadableByteStreamController") === undefined) + throw new TypeError("ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined"); + + return $readableByteStreamControllerRespond( + $getByIdDirectPrivate(this, "associatedReadableByteStreamController"), + bytesWritten, + ); +} + +export function respondWithNewView(this, view) { + if (!$isReadableStreamBYOBRequest(this)) throw $makeThisTypeError("ReadableStreamBYOBRequest", "respond"); + + if ($getByIdDirectPrivate(this, "associatedReadableByteStreamController") === undefined) + throw new TypeError("ReadableStreamBYOBRequest.associatedReadableByteStreamController is undefined"); + + if (!$isObject(view)) throw new TypeError("Provided view is not an object"); + + if (!ArrayBuffer.$isView(view)) throw new TypeError("Provided view is not an ArrayBufferView"); + + return $readableByteStreamControllerRespondWithNewView( + $getByIdDirectPrivate(this, "associatedReadableByteStreamController"), + view, + ); +} + +$getter; +export function view(this) { + if (!$isReadableStreamBYOBRequest(this)) throw $makeGetterTypeError("ReadableStreamBYOBRequest", "view"); + + return $getByIdDirectPrivate(this, "view"); +} diff --git a/src/bun.js/builtins/ts/ReadableStreamDefaultController.ts b/src/bun.js/builtins/ts/ReadableStreamDefaultController.ts new file mode 100644 index 000000000..912cd1acb --- /dev/null +++ b/src/bun.js/builtins/ts/ReadableStreamDefaultController.ts @@ -0,0 +1,63 @@ +/* + * 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. + */ + +export function initializeReadableStreamDefaultController(this, stream, underlyingSource, size, highWaterMark) { + if (arguments.length !== 5 && arguments[4] !== $isReadableStream) + throw new TypeError("ReadableStreamDefaultController constructor should not be called directly"); + + return $privateInitializeReadableStreamDefaultController.$call(this, stream, underlyingSource, size, highWaterMark); +} + +export function enqueue(this, chunk) { + if (!$isReadableStreamDefaultController(this)) throw $makeThisTypeError("ReadableStreamDefaultController", "enqueue"); + + if (!$readableStreamDefaultControllerCanCloseOrEnqueue(this)) + throw new TypeError("ReadableStreamDefaultController is not in a state where chunk can be enqueued"); + + return $readableStreamDefaultControllerEnqueue(this, chunk); +} + +export function error(this, err) { + if (!$isReadableStreamDefaultController(this)) throw $makeThisTypeError("ReadableStreamDefaultController", "error"); + + $readableStreamDefaultControllerError(this, err); +} + +export function close(this) { + if (!$isReadableStreamDefaultController(this)) throw $makeThisTypeError("ReadableStreamDefaultController", "close"); + + if (!$readableStreamDefaultControllerCanCloseOrEnqueue(this)) + throw new TypeError("ReadableStreamDefaultController is not in a state where it can be closed"); + + $readableStreamDefaultControllerClose(this); +} + +$getter; +export function desiredSize(this) { + if (!$isReadableStreamDefaultController(this)) + throw $makeGetterTypeError("ReadableStreamDefaultController", "desiredSize"); + + return $readableStreamDefaultControllerGetDesiredSize(this); +} diff --git a/src/bun.js/builtins/ts/ReadableStreamDefaultReader.ts b/src/bun.js/builtins/ts/ReadableStreamDefaultReader.ts new file mode 100644 index 000000000..ecd553ed5 --- /dev/null +++ b/src/bun.js/builtins/ts/ReadableStreamDefaultReader.ts @@ -0,0 +1,185 @@ +/* + * 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. + */ + +export function initializeReadableStreamDefaultReader(this, stream) { + if (!$isReadableStream(stream)) throw new TypeError("ReadableStreamDefaultReader needs a ReadableStream"); + if ($isReadableStreamLocked(stream)) throw new TypeError("ReadableStream is locked"); + + $readableStreamReaderGenericInitialize(this, stream); + $putByIdDirectPrivate(this, "readRequests", $createFIFO()); + + return this; +} + +export function cancel(this, reason) { + if (!$isReadableStreamDefaultReader(this)) + return Promise.$reject($makeThisTypeError("ReadableStreamDefaultReader", "cancel")); + + if (!$getByIdDirectPrivate(this, "ownerReadableStream")) + return Promise.$reject(new TypeError("cancel() called on a reader owned by no readable stream")); + + return $readableStreamReaderGenericCancel(this, reason); +} + +export function readMany(this) { + if (!$isReadableStreamDefaultReader(this)) + throw new TypeError("ReadableStreamDefaultReader.readMany() should not be called directly"); + + const stream = $getByIdDirectPrivate(this, "ownerReadableStream"); + if (!stream) throw new TypeError("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"); + var queue = $getByIdDirectPrivate(controller, "queue"); + + if (!queue) { + // This is a ReadableStream direct controller implemented in JS + // It hasn't been started yet. + return controller.$pull(controller).$then(function ({ done, value }) { + return done ? { done: true, value: [], size: 0 } : { value: [value], size: 1, done: false }; + }); + } + + const content = queue.content; + var size = queue.size; + var values = content.toArray(false); + + var length = values.length; + + if (length > 0) { + var outValues = $newArrayWithSize(length); + if ($isReadableByteStreamController(controller)) { + { + const buf = values[0]; + if (!(ArrayBuffer.$isView(buf) || buf instanceof ArrayBuffer)) { + $putByValDirect(outValues, 0, new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength)); + } else { + $putByValDirect(outValues, 0, buf); + } + } + + for (var i = 1; i < length; i++) { + const buf = values[i]; + if (!(ArrayBuffer.$isView(buf) || buf instanceof ArrayBuffer)) { + $putByValDirect(outValues, i, new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength)); + } else { + $putByValDirect(outValues, i, buf); + } + } + } else { + $putByValDirect(outValues, 0, values[0].value); + for (var i = 1; i < length; i++) { + $putByValDirect(outValues, i, values[i].value); + } + } + + $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: outValues, 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 length = value.length; + + if ($isReadableByteStreamController(controller)) { + for (var i = 0; i < length; i++) { + const buf = value[i]; + if (!(ArrayBuffer.$isView(buf) || buf instanceof ArrayBuffer)) { + const { buffer, byteOffset, byteLength } = buf; + $putByValDirect(value, i, new Uint8Array(buffer, byteOffset, byteLength)); + } + } + } else { + for (var i = 1; i < length; i++) { + $putByValDirect(value, i, value[i].value); + } + } + + 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); +} + +export function read(this) { + if (!$isReadableStreamDefaultReader(this)) + return Promise.$reject($makeThisTypeError("ReadableStreamDefaultReader", "read")); + if (!$getByIdDirectPrivate(this, "ownerReadableStream")) + return Promise.$reject(new TypeError("read() called on a reader owned by no readable stream")); + + return $readableStreamDefaultReaderRead(this); +} + +export function releaseLock(this) { + if (!$isReadableStreamDefaultReader(this)) throw $makeThisTypeError("ReadableStreamDefaultReader", "releaseLock"); + + if (!$getByIdDirectPrivate(this, "ownerReadableStream")) return; + + if ($getByIdDirectPrivate(this, "readRequests")?.isNotEmpty()) + throw new TypeError("There are still pending read requests, cannot release the lock"); + + $readableStreamReaderGenericRelease(this); +} + +$getter; +export function closed(this) { + if (!$isReadableStreamDefaultReader(this)) + return Promise.$reject($makeGetterTypeError("ReadableStreamDefaultReader", "closed")); + + return $getByIdDirectPrivate(this, "closedPromiseCapability").$promise; +} diff --git a/src/bun.js/builtins/ts/ReadableStreamInternals.ts b/src/bun.js/builtins/ts/ReadableStreamInternals.ts new file mode 100644 index 000000000..c0867445f --- /dev/null +++ b/src/bun.js/builtins/ts/ReadableStreamInternals.ts @@ -0,0 +1,1801 @@ +/* + * 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 + +export function readableStreamReaderGenericInitialize(reader, stream) { + $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")), + }); + } +} + +export function privateInitializeReadableStreamDefaultController(this, stream, underlyingSource, size, highWaterMark) { + if (!$isReadableStream(stream)) throw new TypeError("ReadableStreamDefaultController needs a ReadableStream"); + + // readableStreamController is initialized with null value. + if ($getByIdDirectPrivate(stream, "readableStreamController") !== null) + throw new TypeError("ReadableStream already has a controller"); + + $putByIdDirectPrivate(this, "controlledReadableStream", stream); + $putByIdDirectPrivate(this, "underlyingSource", underlyingSource); + $putByIdDirectPrivate(this, "queue", $newQueue()); + $putByIdDirectPrivate(this, "started", -1); + $putByIdDirectPrivate(this, "closeRequested", false); + $putByIdDirectPrivate(this, "pullAgain", false); + $putByIdDirectPrivate(this, "pulling", false); + $putByIdDirectPrivate(this, "strategy", $validateAndNormalizeQueuingStrategy(size, highWaterMark)); + + return this; +} + +export function readableStreamDefaultControllerError(controller, error) { + const stream = $getByIdDirectPrivate(controller, "controlledReadableStream"); + if ($getByIdDirectPrivate(stream, "state") !== $streamReadable) return; + $putByIdDirectPrivate(controller, "queue", $newQueue()); + + $readableStreamError(stream, error); +} + +export function readableStreamPipeTo(stream, sink) { + $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(); +} + +export function acquireReadableStreamDefaultReader(stream) { + var start = $getByIdDirectPrivate(stream, "start"); + if (start) { + start.$call(stream); + } + + return new ReadableStreamDefaultReader(stream); +} + +// https://streams.spec.whatwg.org/#set-up-readable-stream-default-controller, starting from step 6. +// The other part is implemented in privateInitializeReadableStreamDefaultController. +export function setupReadableStreamDefaultController( + stream, + underlyingSource, + size, + highWaterMark, + startMethod, + pullMethod, + cancelMethod, +) { + const controller = new ReadableStreamDefaultController( + stream, + underlyingSource, + size, + highWaterMark, + $isReadableStream, + ); + + 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); + + $readableStreamDefaultControllerStart(controller); +} + +export function createReadableStreamController(stream, underlyingSource, strategy) { + 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"); + + $putByIdDirectPrivate( + stream, + "readableStreamController", + new ReadableByteStreamController(stream, underlyingSource, strategy.highWaterMark, $isReadableStream), + ); + } else if (typeString === "direct") { + var highWaterMark = strategy?.highWaterMark; + $initializeArrayBufferStream.$call(stream, underlyingSource, highWaterMark); + } else if (type === undefined) { + if (strategy.highWaterMark === undefined) strategy.highWaterMark = 1; + + $setupReadableStreamDefaultController( + stream, + underlyingSource, + strategy.size, + strategy.highWaterMark, + underlyingSource.start, + underlyingSource.pull, + underlyingSource.cancel, + ); + } else throw new RangeError("Invalid type for underlying source"); +} + +export function readableStreamDefaultControllerStart(controller) { + if ($getByIdDirectPrivate(controller, "started") !== -1) return; + + const underlyingSource = $getByIdDirectPrivate(controller, "underlyingSource"); + const startMethod = underlyingSource.start; + $putByIdDirectPrivate(controller, "started", 0); + + $promiseInvokeOrNoopMethodNoCatch(underlyingSource, startMethod, [controller]).$then( + () => { + $putByIdDirectPrivate(controller, "started", 1); + $assert(!$getByIdDirectPrivate(controller, "pulling")); + $assert(!$getByIdDirectPrivate(controller, "pullAgain")); + $readableStreamDefaultControllerCallPullIfNeeded(controller); + }, + error => { + $readableStreamDefaultControllerError(controller, error); + }, + ); +} + +// FIXME: Replace readableStreamPipeTo by below function. +// This method implements the latest https://streams.spec.whatwg.org/#readable-stream-pipe-to. +export function readableStreamPipeToWritableStream( + source, + destination, + preventClose, + preventAbort, + preventCancel, + signal, +) { + // const isDirectStream = !!$getByIdDirectPrivate(source, "start"); + + $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: any = { + 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 = reason => { + if (pipeState.finalized) return; + + $pipeToShutdownWithAction( + pipeState, + () => { + const shouldAbortDestination = + !pipeState.preventAbort && $getByIdDirectPrivate(pipeState.destination, "state") === "writable"; + const promiseDestination = shouldAbortDestination + ? $writableStreamAbort(pipeState.destination, reason) + : Promise.$resolve(); + + const shouldAbortSource = + !pipeState.preventCancel && $getByIdDirectPrivate(pipeState.source, "state") === $streamReadable; + const promiseSource = shouldAbortSource + ? $readableStreamCancel(pipeState.source, reason) + : 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; + }, + reason, + ); + }; + if ($whenSignalAborted(signal, algorithm)) return pipeState.promiseCapability.$promise; + } + + $pipeToErrorsMustBePropagatedForward(pipeState); + $pipeToErrorsMustBePropagatedBackward(pipeState); + $pipeToClosingMustBePropagatedForward(pipeState); + $pipeToClosingMustBePropagatedBackward(pipeState); + + $pipeToLoop(pipeState); + + return pipeState.promiseCapability.$promise; +} + +export function pipeToLoop(pipeState) { + if (pipeState.shuttingDown) return; + + $pipeToDoReadWrite(pipeState).$then(result => { + if (result) $pipeToLoop(pipeState); + }); +} + +export 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; +} + +export 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); +} + +export 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); +} + +export 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); +} + +export function pipeToClosingMustBePropagatedBackward(pipeState) { + if ( + !$writableStreamCloseQueuedOrInFlight(pipeState.destination) && + $getByIdDirectPrivate(pipeState.destination, "state") !== "closed" + ) + return; + + // $assert no chunks have been read/written + + const error = new TypeError("closing is propagated backward"); + if (!pipeState.preventCancel) { + $pipeToShutdownWithAction(pipeState, () => $readableStreamCancel(pipeState.source, error), error); + return; + } + $pipeToShutdown(pipeState, error); +} + +export 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(); +} + +export 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(); +} + +export 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(); +} + +export function readableStreamTee(stream, shouldClone) { + $assert($isReadableStream(stream)); + $assert(typeof shouldClone === "boolean"); + + var start_ = $getByIdDirectPrivate(stream, "start"); + if (start_) { + $putByIdDirectPrivate(stream, "start", undefined); + start_(); + } + + 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]; +} + +export function readableStreamTeePullFunction(teeState, reader, shouldClone) { + 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, + ); + }); + }; +} + +export function readableStreamTeeBranch1CancelFunction(teeState, stream) { + 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; + }; +} + +export function readableStreamTeeBranch2CancelFunction(teeState, stream) { + 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; + }; +} + +export function isReadableStream(stream) { + // 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; +} + +export function isReadableStreamDefaultReader(reader) { + // 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"); +} + +export function isReadableStreamDefaultController(controller) { + // 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"); +} + +export function readDirectStream(stream, sink, underlyingSource) { + $putByIdDirectPrivate(stream, "underlyingSource", undefined); + $putByIdDirectPrivate(stream, "start", undefined); + + function close(stream, reason) { + if (reason && underlyingSource?.cancel) { + try { + var prom = underlyingSource.cancel(reason); + $markPromiseAsHandled(prom); + } catch (e) {} + + underlyingSource = undefined; + } + + if (stream) { + $putByIdDirectPrivate(stream, "readableStreamController", undefined); + $putByIdDirectPrivate(stream, "reader", undefined); + if (reason) { + $putByIdDirectPrivate(stream, "state", $streamErrored); + $putByIdDirectPrivate(stream, "storedError", reason); + } else { + $putByIdDirectPrivate(stream, "state", $streamClosed); + } + stream = undefined; + } + } + + if (!underlyingSource.pull) { + close(); + return; + } + + if (!$isCallable(underlyingSource.pull)) { + close(); + $throwTypeError("pull is not a function"); + return; + } + + $putByIdDirectPrivate(stream, "readableStreamController", sink); + const highWaterMark = $getByIdDirectPrivate(stream, "highWaterMark"); + + sink.start({ + highWaterMark: !highWaterMark || highWaterMark < 64 ? 64 : highWaterMark, + }); + + $startDirectStream.$call(sink, stream, underlyingSource.pull, close); + $putByIdDirectPrivate(stream, "reader", {}); + + var maybePromise = underlyingSource.pull(sink); + sink = undefined; + if (maybePromise && $isPromise(maybePromise)) { + return maybePromise.$then(() => {}); + } +} + +$linkTimeConstant; +export function assignToStream(stream, sink) { + // The stream is either a direct stream or a "default" JS stream + var underlyingSource = $getByIdDirectPrivate(stream, "underlyingSource"); + + // we know it's a direct stream when $underlyingSource is set + if (underlyingSource) { + try { + return $readDirectStream(stream, sink, underlyingSource); + } catch (e) { + throw e; + } finally { + underlyingSource = undefined; + stream = undefined; + sink = undefined; + } + } + + return $readStreamIntoSink(stream, sink, true); +} + +export async function readStreamIntoSink(stream, sink, isNative) { + var didClose = false; + var didThrow = false; + try { + var reader = stream.getReader(); + var many = reader.readMany(); + if (many && $isPromise(many)) { + many = await many; + } + if (many.done) { + didClose = true; + return sink.end(); + } + var wroteCount = many.value.length; + const highWaterMark = $getByIdDirectPrivate(stream, "highWaterMark"); + if (isNative) + $startDirectStream.$call(sink, stream, undefined, () => !didThrow && $markPromiseAsHandled(stream.cancel())); + + sink.start({ highWaterMark: highWaterMark || 0 }); + + for (var i = 0, values = many.value, length = many.value.length; i < length; i++) { + sink.write(values[i]); + } + + var streamState = $getByIdDirectPrivate(stream, "state"); + if (streamState === $streamClosed) { + didClose = true; + return sink.end(); + } + + while (true) { + var { value, done } = await reader.read(); + if (done) { + didClose = true; + return sink.end(); + } + + sink.write(value); + } + } catch (e) { + didThrow = true; + + try { + reader = undefined; + const prom = stream.cancel(e); + $markPromiseAsHandled(prom); + } catch (j) {} + + if (sink && !didClose) { + didClose = true; + try { + sink.close(e); + } catch (j) { + throw new globalThis.AggregateError([e, j]); + } + } + + throw e; + } finally { + if (reader) { + try { + reader.releaseLock(); + } catch (e) {} + reader = undefined; + } + sink = undefined; + var streamState = $getByIdDirectPrivate(stream, "state"); + if (stream) { + // make it easy for this to be GC'd + // but don't do property transitions + var readableStreamController = $getByIdDirectPrivate(stream, "readableStreamController"); + if (readableStreamController) { + if ($getByIdDirectPrivate(readableStreamController, "underlyingSource")) + $putByIdDirectPrivate(readableStreamController, "underlyingSource", undefined); + if ($getByIdDirectPrivate(readableStreamController, "controlledReadableStream")) + $putByIdDirectPrivate(readableStreamController, "controlledReadableStream", undefined); + + $putByIdDirectPrivate(stream, "readableStreamController", null); + if ($getByIdDirectPrivate(stream, "underlyingSource")) + $putByIdDirectPrivate(stream, "underlyingSource", undefined); + readableStreamController = undefined; + } + + if (!didThrow && streamState !== $streamClosed && streamState !== $streamErrored) { + $readableStreamClose(stream); + } + stream = undefined; + } + } +} + +export function handleDirectStreamError(e) { + var controller = this; + var sink = controller.$sink; + if (sink) { + $putByIdDirectPrivate(controller, "sink", undefined); + try { + sink.close(e); + } catch (f) {} + } + + this.error = this.flush = this.write = this.close = this.end = $onReadableStreamDirectControllerClosed; + + if (typeof this.$underlyingSource.close === "function") { + try { + this.$underlyingSource.close.$call(this.$underlyingSource, e); + } catch (e) {} + } + + try { + var pend = controller._pendingRead; + if (pend) { + controller._pendingRead = undefined; + $rejectPromise(pend, e); + } + } catch (f) {} + var stream = controller.$controlledReadableStream; + if (stream) $readableStreamError(stream, e); +} + +export function handleDirectStreamErrorReject(e) { + $handleDirectStreamError.$call(this, e); + return Promise.$reject(e); +} + +export function onPullDirectStream(controller) { + var stream = controller.$controlledReadableStream; + if (!stream || $getByIdDirectPrivate(stream, "state") !== $streamReadable) return; + + // pull is in progress + // this is a recursive call + // ignore it + if (controller._deferClose === -1) { + return; + } + + controller._deferClose = -1; + controller._deferFlush = -1; + var deferClose; + var deferFlush; + + // Direct streams allow $pull to be called multiple times, unlike the spec. + // Backpressure is handled by the destination, not by the underlying source. + // In this case, we rely on the heuristic that repeatedly draining in the same tick + // is bad for performance + // this code is only run when consuming a direct stream from JS + // without the HTTP server or anything else + try { + var result = controller.$underlyingSource.pull(controller); + + if (result && $isPromise(result)) { + if (controller._handleError === undefined) { + controller._handleError = $handleDirectStreamErrorReject.bind(controller); + } + + Promise.prototype.catch.$call(result, controller._handleError); + } + } catch (e) { + return $handleDirectStreamErrorReject.$call(controller, e); + } finally { + deferClose = controller._deferClose; + deferFlush = controller._deferFlush; + controller._deferFlush = controller._deferClose = 0; + } + + var promiseToReturn; + + if (controller._pendingRead === undefined) { + controller._pendingRead = promiseToReturn = $newPromise(); + } else { + promiseToReturn = $readableStreamAddReadRequest(stream); + } + + // they called close during $pull() + // we delay that + if (deferClose === 1) { + var reason = controller._deferCloseReason; + controller._deferCloseReason = undefined; + $onCloseDirectStream.$call(controller, reason); + return promiseToReturn; + } + + // not done, but they called flush() + if (deferFlush === 1) { + $onFlushDirectStream.$call(controller); + } + + return promiseToReturn; +} + +export function noopDoneFunction() { + return Promise.$resolve({ value: undefined, done: true }); +} + +export function onReadableStreamDirectControllerClosed(reason) { + $throwTypeError("ReadableStreamDirectController is now closed"); +} + +export function onCloseDirectStream(reason) { + var stream = this.$controlledReadableStream; + if (!stream || $getByIdDirectPrivate(stream, "state") !== $streamReadable) return; + + if (this._deferClose !== 0) { + this._deferClose = 1; + this._deferCloseReason = reason; + return; + } + + $putByIdDirectPrivate(stream, "state", $streamClosing); + if (typeof this.$underlyingSource.close === "function") { + try { + this.$underlyingSource.close.$call(this.$underlyingSource, reason); + } catch (e) {} + } + + var flushed; + try { + flushed = this.$sink.end(); + $putByIdDirectPrivate(this, "sink", undefined); + } catch (e) { + if (this._pendingRead) { + var read = this._pendingRead; + this._pendingRead = undefined; + $rejectPromise(read, e); + } + $readableStreamError(stream, e); + return; + } + + this.error = this.flush = this.write = this.close = this.end = $onReadableStreamDirectControllerClosed; + + var reader = $getByIdDirectPrivate(stream, "reader"); + + if (reader && $isReadableStreamDefaultReader(reader)) { + var _pendingRead = this._pendingRead; + if (_pendingRead && $isPromise(_pendingRead) && flushed?.byteLength) { + this._pendingRead = undefined; + $fulfillPromise(_pendingRead, { value: flushed, done: false }); + $readableStreamClose(stream); + return; + } + } + + if (flushed?.byteLength) { + var requests = $getByIdDirectPrivate(reader, "readRequests"); + if (requests?.isNotEmpty()) { + $readableStreamFulfillReadRequest(stream, flushed, false); + $readableStreamClose(stream); + return; + } + + $putByIdDirectPrivate(stream, "state", $streamReadable); + this.$pull = () => { + var thisResult = $createFulfilledPromise({ + value: flushed, + done: false, + }); + flushed = undefined; + $readableStreamClose(stream); + stream = undefined; + return thisResult; + }; + } else if (this._pendingRead) { + var read = this._pendingRead; + this._pendingRead = undefined; + $putByIdDirectPrivate(this, "pull", $noopDoneFunction); + $fulfillPromise(read, { value: undefined, done: true }); + } + + $readableStreamClose(stream); +} + +export function onFlushDirectStream() { + var stream = this.$controlledReadableStream; + var reader = $getByIdDirectPrivate(stream, "reader"); + if (!reader || !$isReadableStreamDefaultReader(reader)) { + return; + } + + var _pendingRead = this._pendingRead; + this._pendingRead = undefined; + if (_pendingRead && $isPromise(_pendingRead)) { + var flushed = this.$sink.flush(); + if (flushed?.byteLength) { + this._pendingRead = $getByIdDirectPrivate(stream, "readRequests")?.shift(); + $fulfillPromise(_pendingRead, { value: flushed, done: false }); + } else { + this._pendingRead = _pendingRead; + } + } else if ($getByIdDirectPrivate(stream, "readRequests")?.isNotEmpty()) { + var flushed = this.$sink.flush(); + if (flushed?.byteLength) { + $readableStreamFulfillReadRequest(stream, flushed, false); + } + } else if (this._deferFlush === -1) { + this._deferFlush = 1; + } +} + +export function createTextStream(highWaterMark) { + var sink; + var array = []; + var hasString = false; + var hasBuffer = false; + var rope = ""; + var estimatedLength = $toLength(0); + var capability = $newPromiseCapability(Promise); + var calledDone = false; + + sink = { + start() {}, + write(chunk) { + if (typeof chunk === "string") { + var chunkLength = $toLength(chunk.length); + if (chunkLength > 0) { + rope += chunk; + hasString = true; + // TODO: utf16 byte length + estimatedLength += chunkLength; + } + + return chunkLength; + } + + if (!chunk || !($ArrayBuffer.$isView(chunk) || chunk instanceof $ArrayBuffer)) { + $throwTypeError("Expected text, ArrayBuffer or ArrayBufferView"); + } + + const byteLength = $toLength(chunk.byteLength); + if (byteLength > 0) { + hasBuffer = true; + if (rope.length > 0) { + $arrayPush(array, rope, chunk); + rope = ""; + } else { + $arrayPush(array, chunk); + } + } + estimatedLength += byteLength; + return byteLength; + }, + + flush() { + return 0; + }, + + end() { + if (calledDone) { + return ""; + } + return sink.fulfill(); + }, + + fulfill() { + calledDone = true; + const result = sink.finishInternal(); + + $fulfillPromise(capability.$promise, result); + return result; + }, + + finishInternal() { + if (!hasString && !hasBuffer) { + return ""; + } + + if (hasString && !hasBuffer) { + return rope; + } + + if (hasBuffer && !hasString) { + return new globalThis.TextDecoder().decode($Bun.concatArrayBuffers(array)); + } + + // worst case: mixed content + + var arrayBufferSink = new $Bun.ArrayBufferSink(); + arrayBufferSink.start({ + highWaterMark: estimatedLength, + asUint8Array: true, + }); + for (let item of array) { + arrayBufferSink.write(item); + } + array.length = 0; + if (rope.length > 0) { + arrayBufferSink.write(rope); + rope = ""; + } + + // TODO: use builtin + return new globalThis.TextDecoder().decode(arrayBufferSink.end()); + }, + + close() { + try { + if (!calledDone) { + calledDone = true; + sink.fulfill(); + } + } catch (e) {} + }, + }; + + return [sink, capability]; +} + +export function initializeTextStream(underlyingSource, highWaterMark) { + var [sink, closingPromise] = $createTextStream(highWaterMark); + + var controller = { + $underlyingSource: underlyingSource, + $pull: $onPullDirectStream, + $controlledReadableStream: this, + $sink: sink, + close: $onCloseDirectStream, + write: sink.write, + error: $handleDirectStreamError, + end: $onCloseDirectStream, + $close: $onCloseDirectStream, + flush: $onFlushDirectStream, + _pendingRead: undefined, + _deferClose: 0, + _deferFlush: 0, + _deferCloseReason: undefined, + _handleError: undefined, + }; + + $putByIdDirectPrivate(this, "readableStreamController", controller); + $putByIdDirectPrivate(this, "underlyingSource", undefined); + $putByIdDirectPrivate(this, "start", undefined); + return closingPromise; +} + +export function initializeArrayStream(underlyingSource, highWaterMark) { + var array = []; + var closingPromise = $newPromiseCapability(Promise); + var calledDone = false; + + function fulfill() { + calledDone = true; + closingPromise.$resolve.$call(undefined, array); + return array; + } + + var sink = { + start() {}, + write(chunk) { + $arrayPush(array, chunk); + return chunk.byteLength || chunk.length; + }, + + flush() { + return 0; + }, + + end() { + if (calledDone) { + return []; + } + return fulfill(); + }, + + close() { + if (!calledDone) { + fulfill(); + } + }, + }; + + var controller = { + $underlyingSource: underlyingSource, + $pull: $onPullDirectStream, + $controlledReadableStream: this, + $sink: sink, + close: $onCloseDirectStream, + write: sink.write, + error: $handleDirectStreamError, + end: $onCloseDirectStream, + $close: $onCloseDirectStream, + flush: $onFlushDirectStream, + _pendingRead: undefined, + _deferClose: 0, + _deferFlush: 0, + _deferCloseReason: undefined, + _handleError: undefined, + }; + + $putByIdDirectPrivate(this, "readableStreamController", controller); + $putByIdDirectPrivate(this, "underlyingSource", undefined); + $putByIdDirectPrivate(this, "start", undefined); + return closingPromise; +} + +export function initializeArrayBufferStream(underlyingSource, highWaterMark) { + // This is the fallback implementation for direct streams + // When we don't know what the destination type is + // We assume it is a Uint8Array. + + var opts = + highWaterMark && typeof highWaterMark === "number" + ? { highWaterMark, stream: true, asUint8Array: true } + : { stream: true, asUint8Array: true }; + var sink = new $Bun.ArrayBufferSink(); + sink.start(opts); + + var controller = { + $underlyingSource: underlyingSource, + $pull: $onPullDirectStream, + $controlledReadableStream: this, + $sink: sink, + close: $onCloseDirectStream, + write: sink.write.bind(sink), + error: $handleDirectStreamError, + end: $onCloseDirectStream, + $close: $onCloseDirectStream, + flush: $onFlushDirectStream, + _pendingRead: undefined, + _deferClose: 0, + _deferFlush: 0, + _deferCloseReason: undefined, + _handleError: undefined, + }; + + $putByIdDirectPrivate(this, "readableStreamController", controller); + $putByIdDirectPrivate(this, "underlyingSource", undefined); + $putByIdDirectPrivate(this, "start", undefined); +} + +export function readableStreamError(stream, error) { + $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); +} + +export function readableStreamDefaultControllerShouldCallPull(controller) { + const stream = $getByIdDirectPrivate(controller, "controlledReadableStream"); + + if (!$readableStreamDefaultControllerCanCloseOrEnqueue(controller)) return false; + if (!($getByIdDirectPrivate(controller, "started") === 1)) 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; +} + +export function readableStreamDefaultControllerCallPullIfNeeded(controller) { + // FIXME: use $readableStreamDefaultControllerShouldCallPull + const stream = $getByIdDirectPrivate(controller, "controlledReadableStream"); + + if (!$readableStreamDefaultControllerCanCloseOrEnqueue(controller)) return; + if (!($getByIdDirectPrivate(controller, "started") === 1)) 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); + }, + ); +} + +export function isReadableStreamLocked(stream) { + $assert($isReadableStream(stream)); + return !!$getByIdDirectPrivate(stream, "reader"); +} + +export function readableStreamDefaultControllerGetDesiredSize(controller) { + 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; +} + +export function readableStreamReaderGenericCancel(reader, reason) { + const stream = $getByIdDirectPrivate(reader, "ownerReadableStream"); + $assert(!!stream); + return $readableStreamCancel(stream, reason); +} + +export function readableStreamCancel(stream, reason) { + $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); + + var controller = $getByIdDirectPrivate(stream, "readableStreamController"); + var cancel = controller.$cancel; + if (cancel) { + return cancel(controller, reason).$then(function () {}); + } + + var close = controller.close; + if (close) { + return Promise.$resolve(controller.close(reason)); + } + + $throwTypeError("ReadableStreamController has no cancel or close method"); +} + +export function readableStreamDefaultControllerCancel(controller, reason) { + $putByIdDirectPrivate(controller, "queue", $newQueue()); + return $getByIdDirectPrivate(controller, "cancelAlgorithm").$call(undefined, reason); +} + +export function readableStreamDefaultControllerPull(controller) { + 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; +} + +export function readableStreamDefaultControllerClose(controller) { + $assert($readableStreamDefaultControllerCanCloseOrEnqueue(controller)); + $putByIdDirectPrivate(controller, "closeRequested", true); + if ($getByIdDirectPrivate(controller, "queue")?.content?.isEmpty()) + $readableStreamClose($getByIdDirectPrivate(controller, "controlledReadableStream")); +} + +export function readableStreamClose(stream) { + $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(); +} + +export function readableStreamFulfillReadRequest(stream, chunk, done) { + const readRequest = $getByIdDirectPrivate($getByIdDirectPrivate(stream, "reader"), "readRequests").shift(); + $fulfillPromise(readRequest, { value: chunk, done: done }); +} + +export function readableStreamDefaultControllerEnqueue(controller, chunk) { + 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); +} + +export function readableStreamDefaultReaderRead(reader) { + 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"), + ); +} + +export function readableStreamAddReadRequest(stream) { + $assert($isReadableStreamDefaultReader($getByIdDirectPrivate(stream, "reader"))); + $assert($getByIdDirectPrivate(stream, "state") == $streamReadable); + + const readRequest = $newPromise(); + + $getByIdDirectPrivate($getByIdDirectPrivate(stream, "reader"), "readRequests").push(readRequest); + + return readRequest; +} + +export function isReadableStreamDisturbed(stream) { + $assert($isReadableStream(stream)); + return $getByIdDirectPrivate(stream, "disturbed"); +} + +export function readableStreamReaderGenericRelease(reader) { + $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); +} + +export function readableStreamDefaultControllerCanCloseOrEnqueue(controller) { + return ( + !$getByIdDirectPrivate(controller, "closeRequested") && + $getByIdDirectPrivate($getByIdDirectPrivate(controller, "controlledReadableStream"), "state") === $streamReadable + ); +} + +export function lazyLoadStream(stream, autoAllocateChunkSize) { + var nativeType = $getByIdDirectPrivate(stream, "bunNativeType"); + var nativePtr = $getByIdDirectPrivate(stream, "bunNativePtr"); + var Prototype = $lazyStreamPrototypeMap.$get(nativeType); + if (Prototype === undefined) { + var [pull, start, cancel, setClose, deinit, setRefOrUnref, drain] = $lazyLoad(nativeType); + var closer = [false]; + var handleResult; + function handleNativeReadableStreamPromiseResult(val) { + var { c, v } = this; + this.c = undefined; + this.v = undefined; + handleResult(val, c, v); + } + + function callClose(controller) { + try { + controller.close(); + } catch (e) { + globalThis.reportError(e); + } + } + + handleResult = function handleResult(result, controller, view) { + if (result && $isPromise(result)) { + return result.then( + handleNativeReadableStreamPromiseResult.bind({ + c: controller, + v: view, + }), + err => controller.error(err), + ); + } else if (typeof result === "number") { + if (view && view.byteLength === result && view.buffer === controller.byobRequest?.view?.buffer) { + controller.byobRequest.respondWithNewView(view); + } else { + controller.byobRequest.respond(result); + } + } else if (result.constructor === $Uint8Array) { + controller.enqueue(result); + } + + if (closer[0] || result === false) { + $enqueueJob(callClose, controller); + closer[0] = false; + } + }; + + function createResult(tag, controller, view, closer) { + closer[0] = false; + + var result; + try { + result = pull(tag, view, closer); + } catch (err) { + return controller.error(err); + } + + return handleResult(result, controller, view); + } + + const registry = deinit ? new FinalizationRegistry(deinit) : null; + Prototype = class NativeReadableStreamSource { + constructor(tag, autoAllocateChunkSize, drainValue) { + this.#tag = tag; + this.#cancellationToken = {}; + this.pull = this.#pull.bind(this); + this.cancel = this.#cancel.bind(this); + this.autoAllocateChunkSize = autoAllocateChunkSize; + + if (drainValue !== undefined) { + this.start = controller => { + controller.enqueue(drainValue); + }; + } + + if (registry) { + registry.register(this, tag, this.#cancellationToken); + } + } + + #cancellationToken; + pull; + cancel; + start; + + #tag; + type = "bytes"; + autoAllocateChunkSize = 0; + + static startSync = start; + + #pull(controller) { + var tag = this.#tag; + + if (!tag) { + controller.close(); + return; + } + + createResult(tag, controller, controller.byobRequest.view, closer); + } + + #cancel(reason) { + var tag = this.#tag; + + registry && registry.unregister(this.#cancellationToken); + setRefOrUnref && setRefOrUnref(tag, false); + cancel(tag, reason); + } + static deinit = deinit; + static drain = drain; + }; + $lazyStreamPrototypeMap.$set(nativeType, Prototype); + } + + const chunkSize = Prototype.startSync(nativePtr, autoAllocateChunkSize); + var drainValue; + const { drain: drainFn, deinit: deinitFn } = Prototype; + if (drainFn) { + drainValue = drainFn(nativePtr); + } + + // empty file, no need for native back-and-forth on this + if (chunkSize === 0) { + deinit && nativePtr && $enqueueJob(deinit, nativePtr); + + if ((drainValue?.byteLength ?? 0) > 0) { + return { + start(controller) { + controller.enqueue(drainValue); + controller.close(); + }, + type: "bytes", + }; + } + + return { + start(controller) { + controller.close(); + }, + type: "bytes", + }; + } + + return new Prototype(nativePtr, chunkSize, drainValue); +} + +export function readableStreamIntoArray(stream) { + var reader = stream.getReader(); + var manyResult = reader.readMany(); + + async function processManyResult(result) { + if (result.done) { + return []; + } + + var chunks = result.value || []; + + while (true) { + var thisResult = await reader.read(); + if (thisResult.done) { + break; + } + chunks = chunks.concat(thisResult.value); + } + + return chunks; + } + + if (manyResult && $isPromise(manyResult)) { + return manyResult.$then(processManyResult); + } + + return processManyResult(manyResult); +} + +export function readableStreamIntoText(stream) { + const [textStream, closer] = $createTextStream($getByIdDirectPrivate(stream, "highWaterMark")); + const prom = $readStreamIntoSink(stream, textStream, false); + if (prom && $isPromise(prom)) { + return Promise.$resolve(prom).$then(closer.$promise); + } + return closer.$promise; +} + +export function readableStreamToArrayBufferDirect(stream, underlyingSource) { + var sink = new $Bun.ArrayBufferSink(); + $putByIdDirectPrivate(stream, "underlyingSource", undefined); + var highWaterMark = $getByIdDirectPrivate(stream, "highWaterMark"); + sink.start(highWaterMark ? { highWaterMark } : {}); + var capability = $newPromiseCapability(Promise); + var ended = false; + var pull = underlyingSource.pull; + var close = underlyingSource.close; + + var controller = { + start() {}, + close(reason) { + if (!ended) { + ended = true; + if (close) { + close(); + } + + $fulfillPromise(capability.$promise, sink.end()); + } + }, + end() { + if (!ended) { + ended = true; + if (close) { + close(); + } + $fulfillPromise(capability.$promise, sink.end()); + } + }, + flush() { + return 0; + }, + write: sink.write.bind(sink), + }; + + var didError = false; + try { + const firstPull = pull(controller); + if (firstPull && $isObject(firstPull) && $isPromise(firstPull)) { + return (async function (controller, promise, pull) { + while (!ended) { + await pull(controller); + } + return await promise; + })(controller, promise, pull); + } + + return capability.$promise; + } catch (e) { + didError = true; + $readableStreamError(stream, e); + return Promise.$reject(e); + } finally { + if (!didError && stream) $readableStreamClose(stream); + controller = close = sink = pull = stream = undefined; + } +} + +export async function readableStreamToTextDirect(stream, underlyingSource) { + const capability = $initializeTextStream.$call(stream, underlyingSource, undefined); + var reader = stream.getReader(); + + while ($getByIdDirectPrivate(stream, "state") === $streamReadable) { + var thisResult = await reader.read(); + if (thisResult.done) { + break; + } + } + + try { + reader.releaseLock(); + } catch (e) {} + reader = undefined; + stream = undefined; + + return capability.$promise; +} + +export async function readableStreamToArrayDirect(stream, underlyingSource) { + const capability = $initializeArrayStream.$call(stream, underlyingSource, undefined); + underlyingSource = undefined; + var reader = stream.getReader(); + try { + while ($getByIdDirectPrivate(stream, "state") === $streamReadable) { + var thisResult = await reader.read(); + if (thisResult.done) { + break; + } + } + + try { + reader.releaseLock(); + } catch (e) {} + reader = undefined; + + return Promise.$resolve(capability.$promise); + } catch (e) { + throw e; + } finally { + stream = undefined; + reader = undefined; + } + + return capability.$promise; +} + +export function readableStreamDefineLazyIterators(prototype) { + var asyncIterator = globalThis.Symbol.asyncIterator; + + var ReadableStreamAsyncIterator = async function* ReadableStreamAsyncIterator(stream, preventCancel) { + var reader = stream.getReader(); + var deferredError; + try { + while (true) { + var done, value; + const firstResult = reader.readMany(); + if ($isPromise(firstResult)) { + ({ done, value } = await firstResult); + } else { + ({ done, value } = firstResult); + } + + if (done) { + return; + } + yield* value; + } + } catch (e) { + deferredError = e; + } finally { + reader.releaseLock(); + + if (!preventCancel) { + stream.cancel(deferredError); + } + + if (deferredError) { + throw deferredError; + } + } + }; + var createAsyncIterator = function asyncIterator() { + return ReadableStreamAsyncIterator(this, false); + }; + var createValues = function values({ preventCancel = false } = { preventCancel: false }) { + return ReadableStreamAsyncIterator(this, preventCancel); + }; + $Object.$defineProperty(prototype, asyncIterator, { value: createAsyncIterator }); + $Object.$defineProperty(prototype, "values", { value: createValues }); + return prototype; +} diff --git a/src/bun.js/builtins/ts/StreamInternals.ts b/src/bun.js/builtins/ts/StreamInternals.ts new file mode 100644 index 000000000..b42dc2f57 --- /dev/null +++ b/src/bun.js/builtins/ts/StreamInternals.ts @@ -0,0 +1,268 @@ +/* + * 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 + +export function markPromiseAsHandled(promise: Promise<unknown>) { + $assert($isPromise(promise)); + $putPromiseInternalField( + promise, + $promiseFieldFlags, + $getPromiseInternalField(promise, $promiseFieldFlags) | $promiseFlagsIsHandled, + ); +} + +export function shieldingPromiseResolve(result) { + const promise = Promise.$resolve(result); + if (promise.$then === undefined) promise.$then = Promise.prototype.$then; + return promise; +} + +export function promiseInvokeOrNoopMethodNoCatch(object, method, args) { + if (method === undefined) return Promise.$resolve(); + return $shieldingPromiseResolve(method.$apply(object, args)); +} + +export function promiseInvokeOrNoopNoCatch(object, key, args) { + return $promiseInvokeOrNoopMethodNoCatch(object, object[key], args); +} + +export function promiseInvokeOrNoopMethod(object, method, args) { + try { + return $promiseInvokeOrNoopMethodNoCatch(object, method, args); + } catch (error) { + return Promise.$reject(error); + } +} + +export function promiseInvokeOrNoop(object, key, args) { + try { + return $promiseInvokeOrNoopNoCatch(object, key, args); + } catch (error) { + return Promise.$reject(error); + } +} + +export function promiseInvokeOrFallbackOrNoop(object, key1, args1, key2, args2) { + 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); + } +} + +export function validateAndNormalizeQueuingStrategy(size, highWaterMark) { + if (size !== undefined && typeof size !== "function") throw new TypeError("size parameter must be a function"); + + const newHighWaterMark = $toNumber(highWaterMark); + + if (isNaN(newHighWaterMark) || newHighWaterMark < 0) + throw new RangeError("highWaterMark value is negative or not a number"); + + return { size: size, highWaterMark: newHighWaterMark }; +} + +$linkTimeConstant; +export function createFIFO() { + var slice = Array.prototype.slice; + + class Denqueue { + constructor() { + this._head = 0; + this._tail = 0; + // this._capacity = 0; + this._capacityMask = 0x3; + this._list = $newArrayWithSize(4); + } + + _head; + _tail; + _capacityMask; + _list; + + 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: head, _tail, _list, _capacityMask } = this; + if (head === _tail) return undefined; + var item = _list[head]; + $putByValDirect(_list, head, undefined); + head = this._head = (head + 1) & _capacityMask; + if (head < 2 && _tail > 10000 && _tail <= _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 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(); +} + +export function newQueue() { + return { content: $createFIFO(), size: 0 }; +} + +export function dequeueValue(queue) { + 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; +} + +export function enqueueValueWithSize(queue, value, size) { + size = $toNumber(size); + if (!isFinite(size) || size < 0) throw new RangeError("size has an incorrect value"); + + queue.content.push({ value, size }); + queue.size += size; +} + +export function peekQueueValue(queue) { + return queue.content.peek()?.value; +} + +export function resetQueue(queue) { + $assert("content" in queue); + $assert("size" in queue); + queue.content.clear(); + queue.size = 0; +} + +export function extractSizeAlgorithm(strategy) { + const sizeAlgorithm = strategy.size; + + if (sizeAlgorithm === undefined) return () => 1; + + if (typeof sizeAlgorithm !== "function") throw new TypeError("strategy.size must be a function"); + + return chunk => { + return sizeAlgorithm(chunk); + }; +} + +export function extractHighWaterMark(strategy, defaultHWM) { + const highWaterMark = strategy.highWaterMark; + + if (highWaterMark === undefined) return defaultHWM; + + if (isNaN(highWaterMark) || highWaterMark < 0) + throw new RangeError("highWaterMark value is negative or not a number"); + + return $toNumber(highWaterMark); +} + +export function extractHighWaterMarkFromQueuingStrategyInit(init: { highWaterMark?: number }) { + if (!$isObject(init)) throw new TypeError("QueuingStrategyInit argument must be an object."); + const { highWaterMark } = init; + if (highWaterMark === undefined) throw new TypeError("QueuingStrategyInit.highWaterMark member is required."); + + return $toNumber(highWaterMark); +} + +export function createFulfilledPromise(value) { + const promise = $newPromise(); + $fulfillPromise(promise, value); + return promise; +} + +export function toDictionary(value, defaultValue, errorMessage) { + if (value === undefined || value === null) return defaultValue; + if (!$isObject(value)) throw new TypeError(errorMessage); + return value; +} diff --git a/src/bun.js/builtins/ts/TransformStream.ts b/src/bun.js/builtins/ts/TransformStream.ts new file mode 100644 index 000000000..54467db39 --- /dev/null +++ b/src/bun.js/builtins/ts/TransformStream.ts @@ -0,0 +1,106 @@ +/* + * 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. + */ + +export function initializeTransformStream(this) { + 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) throw new RangeError("TransformStream transformer has a readableType"); + if ("writableType" in transformer) throw new RangeError("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; +export function readable() { + if (!$isTransformStream(this)) throw $makeThisTypeError("TransformStream", "readable"); + + return $getByIdDirectPrivate(this, "readable"); +} + +export function writable() { + if (!$isTransformStream(this)) throw $makeThisTypeError("TransformStream", "writable"); + + return $getByIdDirectPrivate(this, "writable"); +} diff --git a/src/bun.js/builtins/js/TransformStreamDefaultController.js b/src/bun.js/builtins/ts/TransformStreamDefaultController.ts index 5ed7d0dfa..1045498b8 100644 --- a/src/bun.js/builtins/js/TransformStreamDefaultController.js +++ b/src/bun.js/builtins/ts/TransformStreamDefaultController.ts @@ -23,54 +23,38 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -function initializeTransformStreamDefaultController() -{ - "use strict"; - - return this; +export function initializeTransformStreamDefaultController(this) { + return this; } -@getter -function desiredSize() -{ - "use strict"; - - if (!@isTransformStreamDefaultController(this)) - throw @makeThisTypeError("TransformStreamDefaultController", "enqueue"); +$getter; +export function desiredSize(this) { + if (!$isTransformStreamDefaultController(this)) + throw $makeThisTypeError("TransformStreamDefaultController", "enqueue"); - const stream = @getByIdDirectPrivate(this, "stream"); - const readable = @getByIdDirectPrivate(stream, "readable"); - const readableController = @getByIdDirectPrivate(readable, "readableStreamController"); + const stream = $getByIdDirectPrivate(this, "stream"); + const readable = $getByIdDirectPrivate(stream, "readable"); + const readableController = $getByIdDirectPrivate(readable, "readableStreamController"); - return @readableStreamDefaultControllerGetDesiredSize(readableController); + return $readableStreamDefaultControllerGetDesiredSize(readableController); } -function enqueue(chunk) -{ - "use strict"; - - if (!@isTransformStreamDefaultController(this)) - throw @makeThisTypeError("TransformStreamDefaultController", "enqueue"); +export function enqueue(this, chunk) { + if (!$isTransformStreamDefaultController(this)) + throw $makeThisTypeError("TransformStreamDefaultController", "enqueue"); - @transformStreamDefaultControllerEnqueue(this, chunk); + $transformStreamDefaultControllerEnqueue(this, chunk); } -function error(e) -{ - "use strict"; +export function error(this, e) { + if (!$isTransformStreamDefaultController(this)) throw $makeThisTypeError("TransformStreamDefaultController", "error"); - if (!@isTransformStreamDefaultController(this)) - throw @makeThisTypeError("TransformStreamDefaultController", "error"); - - @transformStreamDefaultControllerError(this, e); + $transformStreamDefaultControllerError(this, e); } -function terminate() -{ - "use strict"; - - if (!@isTransformStreamDefaultController(this)) - throw @makeThisTypeError("TransformStreamDefaultController", "terminate"); +export function terminate(this) { + if (!$isTransformStreamDefaultController(this)) + throw $makeThisTypeError("TransformStreamDefaultController", "terminate"); - @transformStreamDefaultControllerTerminate(this); + $transformStreamDefaultControllerTerminate(this); } diff --git a/src/bun.js/builtins/ts/TransformStreamInternals.ts b/src/bun.js/builtins/ts/TransformStreamInternals.ts new file mode 100644 index 000000000..9994d1282 --- /dev/null +++ b/src/bun.js/builtins/ts/TransformStreamInternals.ts @@ -0,0 +1,348 @@ +/* + * 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 + +export function isTransformStream(stream) { + return $isObject(stream) && !!$getByIdDirectPrivate(stream, "readable"); +} + +export function isTransformStreamDefaultController(controller) { + return $isObject(controller) && !!$getByIdDirectPrivate(controller, "transformAlgorithm"); +} + +export 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; +} + +export function initializeTransformStream( + stream, + startPromise, + writableHighWaterMark, + writableSizeAlgorithm, + readableHighWaterMark, + readableSizeAlgorithm, +) { + 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); +} + +export function transformStreamError(stream, e) { + const readable = $getByIdDirectPrivate(stream, "readable"); + const readableController = $getByIdDirectPrivate(readable, "readableStreamController"); + $readableStreamDefaultControllerError(readableController, e); + + $transformStreamErrorWritableAndUnblockWrite(stream, e); +} + +export function transformStreamErrorWritableAndUnblockWrite(stream, e) { + $transformStreamDefaultControllerClearAlgorithms($getByIdDirectPrivate(stream, "controller")); + + const writable = $getByIdDirectPrivate(stream, "internalWritable"); + $writableStreamDefaultControllerErrorIfNeeded($getByIdDirectPrivate(writable, "controller"), e); + + if ($getByIdDirectPrivate(stream, "backpressure")) $transformStreamSetBackpressure(stream, false); +} + +export function transformStreamSetBackpressure(stream, backpressure) { + $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); +} + +export function setUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm) { + $assert($isTransformStream(stream)); + $assert($getByIdDirectPrivate(stream, "controller") === undefined); + + $putByIdDirectPrivate(controller, "stream", stream); + $putByIdDirectPrivate(stream, "controller", controller); + $putByIdDirectPrivate(controller, "transformAlgorithm", transformAlgorithm); + $putByIdDirectPrivate(controller, "flushAlgorithm", flushAlgorithm); +} + +export function setUpTransformStreamDefaultControllerFromTransformer(stream, transformer, transformerDict) { + 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); +} + +export function transformStreamDefaultControllerClearAlgorithms(controller) { + // We set transformAlgorithm to true to allow GC but keep the isTransformStreamDefaultController check. + $putByIdDirectPrivate(controller, "transformAlgorithm", true); + $putByIdDirectPrivate(controller, "flushAlgorithm", undefined); +} + +export function transformStreamDefaultControllerEnqueue(controller, chunk) { + 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); + } +} + +export function transformStreamDefaultControllerError(controller, e) { + $transformStreamError($getByIdDirectPrivate(controller, "stream"), e); +} + +export function transformStreamDefaultControllerPerformTransform(controller, chunk) { + 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; +} + +export function transformStreamDefaultControllerTerminate(controller) { + 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); +} + +export function transformStreamDefaultSinkWriteAlgorithm(stream, chunk) { + 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); +} + +export function transformStreamDefaultSinkAbortAlgorithm(stream, reason) { + $transformStreamError(stream, reason); + return Promise.$resolve(); +} + +export function transformStreamDefaultSinkCloseAlgorithm(stream) { + 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; +} + +export function transformStreamDefaultSourcePullAlgorithm(stream) { + $assert($getByIdDirectPrivate(stream, "backpressure")); + $assert($getByIdDirectPrivate(stream, "backpressureChangePromise") !== undefined); + + $transformStreamSetBackpressure(stream, false); + + return $getByIdDirectPrivate(stream, "backpressureChangePromise").$promise; +} diff --git a/src/bun.js/builtins/js/WritableStreamDefaultController.js b/src/bun.js/builtins/ts/WritableStreamDefaultController.ts index 8c42212e0..1a3ddc290 100644 --- a/src/bun.js/builtins/js/WritableStreamDefaultController.js +++ b/src/bun.js/builtins/ts/WritableStreamDefaultController.ts @@ -23,34 +23,26 @@ * 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; +export function initializeWritableStreamDefaultController(this) { + $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"); +export function error(this, e) { + if ($getByIdDirectPrivate(this, "abortSteps") === undefined) + throw $makeThisTypeError("WritableStreamDefaultController", "error"); - const stream = @getByIdDirectPrivate(this, "stream"); - if (@getByIdDirectPrivate(stream, "state") !== "writable") - return; - @writableStreamDefaultControllerError(this, e); + const stream = $getByIdDirectPrivate(this, "stream"); + if ($getByIdDirectPrivate(stream, "state") !== "writable") return; + $writableStreamDefaultControllerError(this, e); } diff --git a/src/bun.js/builtins/ts/WritableStreamDefaultWriter.ts b/src/bun.js/builtins/ts/WritableStreamDefaultWriter.ts new file mode 100644 index 000000000..795b43892 --- /dev/null +++ b/src/bun.js/builtins/ts/WritableStreamDefaultWriter.ts @@ -0,0 +1,104 @@ +/* + * 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. + */ + +export function initializeWritableStreamDefaultWriter(stream) { + // 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; +export function closed() { + if (!$isWritableStreamDefaultWriter(this)) + return Promise.$reject($makeGetterTypeError("WritableStreamDefaultWriter", "closed")); + + return $getByIdDirectPrivate(this, "closedPromise").$promise; +} + +$getter; +export function desiredSize() { + if (!$isWritableStreamDefaultWriter(this)) throw $makeThisTypeError("WritableStreamDefaultWriter", "desiredSize"); + + if ($getByIdDirectPrivate(this, "stream") === undefined) $throwTypeError("WritableStreamDefaultWriter has no stream"); + + return $writableStreamDefaultWriterGetDesiredSize(this); +} + +$getter; +export function ready() { + if (!$isWritableStreamDefaultWriter(this)) + return Promise.$reject($makeThisTypeError("WritableStreamDefaultWriter", "ready")); + + return $getByIdDirectPrivate(this, "readyPromise").$promise; +} + +export function abort(reason) { + 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); +} + +export function close() { + 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); +} + +export function releaseLock() { + if (!$isWritableStreamDefaultWriter(this)) throw $makeThisTypeError("WritableStreamDefaultWriter", "releaseLock"); + + const stream = $getByIdDirectPrivate(this, "stream"); + if (stream === undefined) return; + + $assert($getByIdDirectPrivate(stream, "writer") !== undefined); + $writableStreamDefaultWriterRelease(this); +} + +export function write(chunk) { + 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/bun.js/builtins/ts/WritableStreamInternals.ts b/src/bun.js/builtins/ts/WritableStreamInternals.ts new file mode 100644 index 000000000..f436a285e --- /dev/null +++ b/src/bun.js/builtins/ts/WritableStreamInternals.ts @@ -0,0 +1,790 @@ +/* + * 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 + +export function isWritableStream(stream) { + return $isObject(stream) && !!$getByIdDirectPrivate(stream, "underlyingSink"); +} + +export function isWritableStreamDefaultWriter(writer) { + return $isObject(writer) && !!$getByIdDirectPrivate(writer, "closedPromise"); +} + +export function acquireWritableStreamDefaultWriter(stream) { + return new WritableStreamDefaultWriter(stream); +} + +// https://streams.spec.whatwg.org/#create-writable-stream +export 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); +} + +export function createInternalWritableStreamFromUnderlyingSink(underlyingSink, strategy) { + 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; +} + +export 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); +} + +export 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); +} + +export 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); +} + +export function isWritableStreamLocked(stream) { + return $getByIdDirectPrivate(stream, "writer") !== undefined; +} + +export 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); + } +} + +export 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; +} + +export 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; +} + +export 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; +} + +export function writableStreamCloseQueuedOrInFlight(stream) { + return ( + $getByIdDirectPrivate(stream, "closeRequest") !== undefined || + $getByIdDirectPrivate(stream, "inFlightCloseRequest") !== undefined + ); +} + +export function writableStreamDealWithRejection(stream, error) { + const state = $getByIdDirectPrivate(stream, "state"); + if (state === "writable") { + $writableStreamStartErroring(stream, error); + return; + } + + $assert(state === "erroring"); + $writableStreamFinishErroring(stream); +} + +export 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); + }, + ); +} + +export 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); +} + +export 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); +} + +export function writableStreamFinishInFlightWrite(stream) { + const inFlightWriteRequest = $getByIdDirectPrivate(stream, "inFlightWriteRequest"); + $assert(inFlightWriteRequest !== undefined); + inFlightWriteRequest.$resolve.$call(); + + $putByIdDirectPrivate(stream, "inFlightWriteRequest", undefined); +} + +export 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); +} + +export function writableStreamHasOperationMarkedInFlight(stream) { + return ( + $getByIdDirectPrivate(stream, "inFlightWriteRequest") !== undefined || + $getByIdDirectPrivate(stream, "inFlightCloseRequest") !== undefined + ); +} + +export function writableStreamMarkCloseRequestInFlight(stream) { + const closeRequest = $getByIdDirectPrivate(stream, "closeRequest"); + $assert($getByIdDirectPrivate(stream, "inFlightCloseRequest") === undefined); + $assert(closeRequest !== undefined); + + $putByIdDirectPrivate(stream, "inFlightCloseRequest", closeRequest); + $putByIdDirectPrivate(stream, "closeRequest", undefined); +} + +export function writableStreamMarkFirstWriteRequestInFlight(stream) { + const writeRequests = $getByIdDirectPrivate(stream, "writeRequests"); + $assert($getByIdDirectPrivate(stream, "inFlightWriteRequest") === undefined); + $assert(writeRequests.isNotEmpty()); + + const writeRequest = writeRequests.shift(); + $putByIdDirectPrivate(stream, "inFlightWriteRequest", writeRequest); +} + +export 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); + } +} + +export 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") === 1) + $writableStreamFinishErroring(stream); +} + +export 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); +} + +export function writableStreamDefaultWriterAbort(writer, reason) { + const stream = $getByIdDirectPrivate(writer, "stream"); + $assert(stream !== undefined); + return $writableStreamAbort(stream, reason); +} + +export function writableStreamDefaultWriterClose(writer) { + const stream = $getByIdDirectPrivate(writer, "stream"); + $assert(stream !== undefined); + return $writableStreamClose(stream); +} + +export 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); +} + +export 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); +} + +export 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); +} + +export 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")); +} + +export 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); +} + +export 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; +} + +export 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", -1); + $putByIdDirectPrivate(controller, "startAlgorithm", startAlgorithm); + $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); + + $writableStreamDefaultControllerStart(controller); +} + +export function writableStreamDefaultControllerStart(controller) { + if ($getByIdDirectPrivate(controller, "started") !== -1) return; + + $putByIdDirectPrivate(controller, "started", 0); + + const startAlgorithm = $getByIdDirectPrivate(controller, "startAlgorithm"); + $putByIdDirectPrivate(controller, "startAlgorithm", undefined); + const stream = $getByIdDirectPrivate(controller, "stream"); + return Promise.$resolve(startAlgorithm.$call()).$then( + () => { + const state = $getByIdDirectPrivate(stream, "state"); + $assert(state === "writable" || state === "erroring"); + $putByIdDirectPrivate(controller, "started", 1); + $writableStreamDefaultControllerAdvanceQueueIfNeeded(controller); + }, + error => { + const state = $getByIdDirectPrivate(stream, "state"); + $assert(state === "writable" || state === "erroring"); + $putByIdDirectPrivate(controller, "started", 1); + $writableStreamDealWithRejection(stream, error); + }, + ); +} + +export 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, + ); +} + +export function writableStreamDefaultControllerAdvanceQueueIfNeeded(controller) { + const stream = $getByIdDirectPrivate(controller, "stream"); + + if ($getByIdDirectPrivate(controller, "started") !== 1) 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; + } + + const queue = $getByIdDirectPrivate(controller, "queue"); + + if (queue.content?.isEmpty() ?? false) return; + + const value = $peekQueueValue(queue); + if (value === $isCloseSentinel) $writableStreamDefaultControllerProcessClose(controller); + else $writableStreamDefaultControllerProcessWrite(controller, value); +} + +export function isCloseSentinel() {} + +export function writableStreamDefaultControllerClearAlgorithms(controller) { + $putByIdDirectPrivate(controller, "writeAlgorithm", undefined); + $putByIdDirectPrivate(controller, "closeAlgorithm", undefined); + $putByIdDirectPrivate(controller, "abortAlgorithm", undefined); + $putByIdDirectPrivate(controller, "strategySizeAlgorithm", undefined); +} + +export function writableStreamDefaultControllerClose(controller) { + $enqueueValueWithSize($getByIdDirectPrivate(controller, "queue"), $isCloseSentinel, 0); + $writableStreamDefaultControllerAdvanceQueueIfNeeded(controller); +} + +export function writableStreamDefaultControllerError(controller, error) { + const stream = $getByIdDirectPrivate(controller, "stream"); + $assert(stream !== undefined); + $assert($getByIdDirectPrivate(stream, "state") === "writable"); + + $writableStreamDefaultControllerClearAlgorithms(controller); + $writableStreamStartErroring(stream, error); +} + +export function writableStreamDefaultControllerErrorIfNeeded(controller, error) { + const stream = $getByIdDirectPrivate(controller, "stream"); + if ($getByIdDirectPrivate(stream, "state") === "writable") $writableStreamDefaultControllerError(controller, error); +} + +export function writableStreamDefaultControllerGetBackpressure(controller) { + const desiredSize = $writableStreamDefaultControllerGetDesiredSize(controller); + return desiredSize <= 0; +} + +export function writableStreamDefaultControllerGetChunkSize(controller, chunk) { + try { + return $getByIdDirectPrivate(controller, "strategySizeAlgorithm").$call(undefined, chunk); + } catch (e) { + $writableStreamDefaultControllerErrorIfNeeded(controller, e); + return 1; + } +} + +export function writableStreamDefaultControllerGetDesiredSize(controller) { + return $getByIdDirectPrivate(controller, "strategyHWM") - $getByIdDirectPrivate(controller, "queue").size; +} + +export 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); + }, + ); +} + +export 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); + }, + ); +} + +export 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/bun.js/builtins/tsconfig.json b/src/bun.js/builtins/tsconfig.json new file mode 100644 index 000000000..612488c5f --- /dev/null +++ b/src/bun.js/builtins/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "noEmit": true + }, + "include": [".", "builtins.d.ts", "WebCoreJSBuiltins.d.ts", "../../../packages/bun-types/index.d.ts"] +} diff --git a/src/bun.js/scripts/generate-jssink.js b/src/bun.js/scripts/generate-jssink.js index 4c34d9222..715df1f82 100644 --- a/src/bun.js/scripts/generate-jssink.js +++ b/src/bun.js/scripts/generate-jssink.js @@ -252,8 +252,6 @@ async function implementation() { #include "JavaScriptCore/BuiltinNames.h" #include "JSBufferEncodingType.h" -#include "JSBufferPrototypeBuiltins.h" -#include "JSBufferConstructorBuiltins.h" #include "JavaScriptCore/JSBase.h" #if ENABLE(MEDIA_SOURCE) #include "BufferMediaSource.h" diff --git a/src/import_record.zig b/src/import_record.zig index dd34fe5d9..5c3072356 100644 --- a/src/import_record.zig +++ b/src/import_record.zig @@ -36,6 +36,9 @@ pub const ImportKind = enum(u8) { pub const Label = std.EnumArray(ImportKind, []const u8); pub const all_labels: Label = brk: { + // If these are changed, make sure to update + // - src/bun.js/builtins/builtins-codegen.ts + // - packages/bun-types/bun.d.ts var labels = Label.initFill(""); labels.set(ImportKind.entry_point, "entry-point"); labels.set(ImportKind.stmt, "import-statement"); diff --git a/test.ts b/test.ts new file mode 100644 index 000000000..2bc8c3f7d --- /dev/null +++ b/test.ts @@ -0,0 +1,2 @@ +console.log(1) + |