diff options
author | 2023-06-01 21:16:47 -0400 | |
---|---|---|
committer | 2023-06-01 18:16:47 -0700 | |
commit | 4df1d37ddc54242c339765f22fb90ba2e9e3a99a (patch) | |
tree | d63ede76463e7ecba78a4d4b31e5e8158193552f /src/bun.js/builtins | |
parent | 03ffd1c732aaaa30b5481f197221ce96da559e63 (diff) | |
download | bun-4df1d37ddc54242c339765f22fb90ba2e9e3a99a.tar.gz bun-4df1d37ddc54242c339765f22fb90ba2e9e3a99a.tar.zst bun-4df1d37ddc54242c339765f22fb90ba2e9e3a99a.zip |
Bundle and minify `.exports.js` files. (#3036)
* move all exports.js into src/js
* finalize the sort of this
* and it works
* add test.ts to gitignore
* okay
* convert some to ts just to show
* finish up
* fixup makefile
* minify syntax in dev
* finish rebase
* dont minify all modules
* merge
* finish rebase merge
* flaky test that hangs
Diffstat (limited to 'src/bun.js/builtins')
34 files changed, 0 insertions, 17514 deletions
diff --git a/src/bun.js/builtins/BunBuiltinNames.h b/src/bun.js/builtins/BunBuiltinNames.h deleted file mode 100644 index 640d122ca..000000000 --- a/src/bun.js/builtins/BunBuiltinNames.h +++ /dev/null @@ -1,267 +0,0 @@ -#pragma once - -#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) \ - macro(Bun) \ - macro(Loader) \ - macro(ReadableByteStreamController) \ - macro(ReadableStream) \ - macro(ReadableStreamBYOBReader) \ - macro(ReadableStreamBYOBRequest) \ - macro(ReadableStreamDefaultController) \ - macro(ReadableStreamDefaultReader) \ - macro(TransformStream) \ - macro(TransformStreamDefaultController) \ - macro(WritableStream) \ - macro(WritableStreamDefaultController) \ - macro(WritableStreamDefaultWriter) \ - macro(_events) \ - macro(abortAlgorithm) \ - macro(abortSteps) \ - macro(addEventListener) \ - macro(appendFromJS) \ - macro(argv) \ - macro(assignToStream) \ - macro(associatedReadableByteStreamController) \ - macro(autoAllocateChunkSize) \ - macro(backpressure) \ - macro(backpressureChangePromise) \ - macro(basename) \ - macro(body) \ - macro(bunNativePtr) \ - macro(bunNativeType) \ - macro(byobRequest) \ - macro(cancel) \ - macro(cancelAlgorithm) \ - macro(chdir) \ - macro(cloneArrayBuffer) \ - macro(close) \ - macro(closeAlgorithm) \ - macro(closeRequest) \ - macro(closeRequested) \ - macro(closed) \ - macro(closedPromise) \ - macro(closedPromiseCapability) \ - macro(code) \ - macro(commonJSSymbol) \ - macro(connect) \ - macro(consumeReadableStream) \ - macro(controlledReadableStream) \ - macro(controller) \ - macro(cork) \ - macro(createEmptyReadableStream) \ - macro(createFIFO) \ - macro(createNativeReadableStream) \ - macro(createReadableStream) \ - macro(createUninitializedArrayBuffer) \ - macro(createWritableStreamFromInternal) \ - macro(cwd) \ - macro(data) \ - macro(dataView) \ - macro(decode) \ - macro(delimiter) \ - macro(destroy) \ - macro(dir) \ - macro(direct) \ - macro(dirname) \ - macro(disturbed) \ - macro(document) \ - macro(encode) \ - macro(encoding) \ - macro(end) \ - macro(errno) \ - macro(errorSteps) \ - macro(execArgv) \ - macro(exports) \ - macro(extname) \ - macro(failureKind) \ - macro(fatal) \ - macro(fetch) \ - macro(fetchRequest) \ - macro(file) \ - macro(filePath) \ - macro(fillFromJS) \ - macro(filter) \ - macro(finishConsumingStream) \ - macro(flush) \ - macro(flushAlgorithm) \ - macro(format) \ - macro(fulfillModuleSync) \ - macro(get) \ - macro(getInternalWritableStream) \ - macro(handleEvent) \ - macro(hash) \ - macro(header) \ - macro(headers) \ - macro(highWaterMark) \ - macro(host) \ - macro(hostname) \ - macro(href) \ - macro(ignoreBOM) \ - macro(importer) \ - macro(inFlightCloseRequest) \ - macro(inFlightWriteRequest) \ - macro(initializeWith) \ - macro(internalRequire) \ - macro(internalStream) \ - macro(internalWritable) \ - macro(isAbortSignal) \ - macro(isAbsolute) \ - macro(isDisturbed) \ - macro(isPaused) \ - macro(isWindows) \ - macro(join) \ - macro(kind) \ - macro(lazy) \ - macro(lazyLoad) \ - macro(lazyStreamPrototypeMap) \ - macro(loadCJS2ESM) \ - macro(loadModule) \ - macro(localStreams) \ - macro(main) \ - macro(makeDOMException) \ - macro(makeGetterTypeError) \ - macro(makeThisTypeError) \ - macro(map) \ - macro(method) \ - macro(nextTick) \ - macro(normalize) \ - macro(on) \ - macro(once) \ - macro(options) \ - macro(origin) \ - macro(ownerReadableStream) \ - macro(parse) \ - macro(password) \ - macro(patch) \ - macro(path) \ - macro(pathname) \ - macro(pause) \ - macro(pendingAbortRequest) \ - macro(pendingPullIntos) \ - macro(pid) \ - macro(pipe) \ - macro(port) \ - macro(post) \ - macro(ppid) \ - macro(prependEventListener) \ - macro(process) \ - macro(protocol) \ - macro(pull) \ - macro(pullAgain) \ - macro(pullAlgorithm) \ - macro(pulling) \ - macro(put) \ - macro(queue) \ - macro(read) \ - macro(readIntoRequests) \ - macro(readRequests) \ - macro(readable) \ - macro(readableStreamController) \ - macro(readableStreamToArray) \ - macro(reader) \ - macro(readyPromise) \ - macro(readyPromiseCapability) \ - macro(redirect) \ - macro(relative) \ - macro(releaseLock) \ - macro(removeEventListener) \ - macro(require) \ - macro(requireESM) \ - macro(requireMap) \ - macro(resolve) \ - macro(resolveSync) \ - macro(resume) \ - macro(search) \ - macro(searchParams) \ - macro(self) \ - macro(sep) \ - macro(setBody) \ - macro(setStatus) \ - macro(setup) \ - macro(sink) \ - macro(size) \ - macro(start) \ - macro(startAlgorithm) \ - macro(startConsumingStream) \ - macro(startDirectStream) \ - macro(started) \ - macro(startedPromise) \ - macro(state) \ - macro(status) \ - macro(storedError) \ - macro(strategy) \ - macro(strategyHWM) \ - macro(strategySizeAlgorithm) \ - macro(stream) \ - macro(streamClosed) \ - macro(streamClosing) \ - macro(streamErrored) \ - macro(streamReadable) \ - macro(streamWaiting) \ - macro(streamWritable) \ - macro(structuredCloneForStream) \ - macro(syscall) \ - macro(textDecoderStreamDecoder) \ - macro(textDecoderStreamTransform) \ - macro(textEncoderStreamEncoder) \ - macro(textEncoderStreamTransform) \ - macro(toNamespacedPath) \ - macro(trace) \ - macro(transformAlgorithm) \ - macro(uncork) \ - macro(underlyingByteSource) \ - macro(underlyingSink) \ - macro(underlyingSource) \ - macro(unpipe) \ - macro(unshift) \ - macro(url) \ - macro(username) \ - macro(version) \ - macro(versions) \ - macro(view) \ - macro(whenSignalAborted) \ - macro(writable) \ - macro(write) \ - macro(writeAlgorithm) \ - macro(writeRequests) \ - macro(writer) \ - macro(writing) \ - macro(written) \ - BUN_ADDITIONAL_PRIVATE_IDENTIFIERS(macro) \ - -class BunBuiltinNames { -public: - // FIXME: Remove the __attribute__((nodebug)) when <rdar://68246686> is fixed. -#if COMPILER(CLANG) - __attribute__((nodebug)) -#endif - explicit BunBuiltinNames(JSC::VM& vm) - : m_vm(vm) - BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(INITIALIZE_BUILTIN_NAMES) - { -#define EXPORT_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); - BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(EXPORT_NAME) -#undef EXPORT_NAME - } - - BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) - -private: - JSC::VM& m_vm; - 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 deleted file mode 100644 index 67b8882ee..000000000 --- a/src/bun.js/builtins/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# JavaScript Builtins - -**TLDR** — When files in this directory change, run: - -```bash -# Delete the built files -$ make regenerate-bindings -# Re-link the binary without compiling zig (so it's faster) -$ make bun-link-lld-debug -``` - -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 -export function foo() { - return $getByIdDirectPrivate(this, "superSecret"); -} -``` - -It looks kind of like decorators but they're not. They let you directly call engine intrinsics and help with avoiding prototype pollution issues. - -V8 has a [similar feature](https://v8.dev/blog/embedded-builtins) (they use `%` instead of `@`) - -They usually are accompanied by a C++ file. - -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 -``` - -You'll want to also rebuild all the C++ bindings or you will get strange crashes on start - -```bash -$ 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/WebCoreJSBuiltins.cpp b/src/bun.js/builtins/WebCoreJSBuiltins.cpp deleted file mode 100644 index 614c34a1a..000000000 --- a/src/bun.js/builtins/WebCoreJSBuiltins.cpp +++ /dev/null @@ -1,2985 +0,0 @@ -// 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 = 419; -static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireESMCode = "(function (i){\"use strict\";var a=@Loader.registry.@get(i);if(!a||!a.evaluated)a=@loadCJS2ESM(i);if(!a||!a.evaluated||!a.module)@throwTypeError(`require() failed to evaluate module \"${i}\". This is an internal consistentency error.`);var E=@Loader.getModuleNamespaceObject(a.module);if(E[@commonJSSymbol]===0)return;var b=E.default,f=b\?.[@commonJSSymbol];if(f===0)return b;else if(f&&@isCallable(b))return b();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 = 611; -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);const j=@requireMap.@get(n);if(j)return j;return @requireMap.@set(n,F),F}})\n"; - -// createRequireCache -const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKind = JSC::ConstructorKind::None; -const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; -const int s_importMetaObjectCreateRequireCacheCodeLength = 891; -static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";class r{id;parent;filename;children=[];paths=[];constructor(w){this.id=w;const c=w.lastIndexOf(\"/\");if(c!==-1&&w.length>c+1)this.filename=w.substring(c+1);else this.filename=w}get loaded(){return!0}require(w){return @internalRequire(@resolveSync(w,this.id))}get exports(){return @requireMap.@get(this.id)\?\?{}}set exports(w){@requireMap.@set(this.id,w)}}var _=new Map;return new Proxy({},{get(w,c){if(@requireMap.@get(c)){var g=_.@get(c);if(!g)g=new r(c),_.@set(c,g);return g}},set(w,c,b){if(!_.@has(c))_.@set(c,new r(c));return @requireMap.@set(c,b\?.exports),!0},has(w,c){return @requireMap.@has(c)},deleteProperty(w,c){return _.@delete(c),@requireMap.@delete(c),@Loader.registry.@delete(c),!0},ownKeys(w){return[...@requireMap.@keys()]},getPrototypeOf(w){return null},getOwnPropertyDescriptor(w,c){if(@requireMap.@has(c))return{configurable:!0,enumerable:!0}}})})\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 = 271; -static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var f=@getByIdDirectPrivate(_,\"underlyingSource\");if(f!==@undefined)return @readableStreamToArrayBufferDirect(_,f);var A=@Bun.readableStreamToArray(_);if(@isPromise(A))return A.@then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(A)})\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 deleted file mode 100644 index a39c38348..000000000 --- a/src/bun.js/builtins/WebCoreJSBuiltins.d.ts +++ /dev/null @@ -1,199 +0,0 @@ -// 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 deleted file mode 100644 index 3414ed847..000000000 --- a/src/bun.js/builtins/WebCoreJSBuiltins.h +++ /dev/null @@ -1,5512 +0,0 @@ -// 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; - -// createRequireCache -#define WEBCORE_BUILTIN_IMPORTMETAOBJECT_CREATEREQUIRECACHE 1 -extern const char* const s_importMetaObjectCreateRequireCacheCode; -extern const int s_importMetaObjectCreateRequireCacheCodeLength; -extern const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility; -extern const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKind; -extern const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility; - -// 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(createRequireCache, importMetaObjectCreateRequireCache, 0) \ - 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(importMetaObjectCreateRequireCacheCode, createRequireCache, ASCIILiteral(), s_importMetaObjectCreateRequireCacheCodeLength) \ - 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(createRequireCache) \ - 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 deleted file mode 100644 index 7bd3e4fae..000000000 --- a/src/bun.js/builtins/builtins.d.ts +++ /dev/null @@ -1,533 +0,0 @@ -// 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 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 deleted file mode 100644 index e96d79c63..000000000 --- a/src/bun.js/builtins/codegen/builtin-parser.ts +++ /dev/null @@ -1,89 +0,0 @@ -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 deleted file mode 100644 index 6345f8ffa..000000000 --- a/src/bun.js/builtins/codegen/helpers.ts +++ /dev/null @@ -1,25 +0,0 @@ -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 deleted file mode 100644 index c9e44ec06..000000000 --- a/src/bun.js/builtins/codegen/index.ts +++ /dev/null @@ -1,624 +0,0 @@ -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 deleted file mode 100644 index 05c81b901..000000000 --- a/src/bun.js/builtins/codegen/replacements.ts +++ /dev/null @@ -1,100 +0,0 @@ -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/ts/BundlerPlugin.ts b/src/bun.js/builtins/ts/BundlerPlugin.ts deleted file mode 100644 index 831a6614e..000000000 --- a/src/bun.js/builtins/ts/BundlerPlugin.ts +++ /dev/null @@ -1,370 +0,0 @@ -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/ts/ByteLengthQueuingStrategy.ts b/src/bun.js/builtins/ts/ByteLengthQueuingStrategy.ts deleted file mode 100644 index fc3f3d998..000000000 --- a/src/bun.js/builtins/ts/ByteLengthQueuingStrategy.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2015 Canon Inc. - * Copyright (C) 2015 Igalia S.L. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -$getter; -export function highWaterMark(this: any) { - const highWaterMark = $getByIdDirectPrivate(this, "highWaterMark"); - if (highWaterMark === undefined) - throw new TypeError("ByteLengthQueuingStrategy.highWaterMark getter called on incompatible |this| value."); - - return highWaterMark; -} - -export function size(chunk) { - return chunk.byteLength; -} - -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 deleted file mode 100644 index 45746459a..000000000 --- a/src/bun.js/builtins/ts/ConsoleObject.ts +++ /dev/null @@ -1,84 +0,0 @@ -$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/ts/CountQueuingStrategy.ts b/src/bun.js/builtins/ts/CountQueuingStrategy.ts deleted file mode 100644 index a72dca1ca..000000000 --- a/src/bun.js/builtins/ts/CountQueuingStrategy.ts +++ /dev/null @@ -1,42 +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. - */ - -$getter; -export function highWaterMark(this: any) { - const highWaterMark = $getByIdDirectPrivate(this, "highWaterMark"); - - if (highWaterMark === undefined) - throw new TypeError("CountQueuingStrategy.highWaterMark getter called on incompatible |this| value."); - - return highWaterMark; -} - -export function size() { - return 1; -} - -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 deleted file mode 100644 index 2df0f0c98..000000000 --- a/src/bun.js/builtins/ts/ImportMetaObject.ts +++ /dev/null @@ -1,257 +0,0 @@ -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); - if (exports[$commonJSSymbol] === 0) { - // CommonJS module created via `Bun::CommonJSModuleRecord` - // We will refer to the requireMap to get the exports - return; - } - - 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); - const cachedExports = $requireMap.$get(resolved); - if (cachedExports) { - return cachedExports; - } - - $requireMap.$set(resolved, exports); - return exports; - } -} - -export function createRequireCache() { - class Module { - id; - parent; - filename; - children = []; - paths = []; - - constructor(filename) { - this.id = filename; - // TODO: windows - const lastSlash = filename.lastIndexOf("/"); - if (lastSlash !== -1 && filename.length > lastSlash + 1) { - this.filename = filename.substring(lastSlash + 1); - } else { - this.filename = filename; - } - } - - get loaded() { - return true; - } - - require(path) { - return $internalRequire($resolveSync(path, this.id)); - } - - get exports() { - return $requireMap.$get(this.id) ?? {}; - } - - set exports(value) { - $requireMap.$set(this.id, value); - } - } - - var moduleMap = new Map(); - - return new Proxy( - {}, - { - get(target, key: string) { - const entry = $requireMap.$get(key); - if (entry) { - var mod = moduleMap.$get(key); - if (!mod) { - mod = new Module(key); - moduleMap.$set(key, mod); - } - return mod; - } - }, - set(target, key: string, value) { - if (!moduleMap.$has(key)) { - moduleMap.$set(key, new Module(key)); - } - - $requireMap.$set(key, value?.exports); - - return true; - }, - - has(target, key: string) { - return $requireMap.$has(key); - }, - - deleteProperty(target, key: string) { - moduleMap.$delete(key); - $requireMap.$delete(key); - Loader.registry.$delete(key); - return true; - }, - - ownKeys(target) { - return [...$requireMap.$keys()]; - }, - - // In Node, require.cache has a null prototype - getPrototypeOf(target) { - return null; - }, - - getOwnPropertyDescriptor(target, key: string) { - if ($requireMap.$has(key)) { - return { - configurable: true, - enumerable: true, - }; - } - }, - }, - ); -} - -$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 deleted file mode 100644 index debc62d51..000000000 --- a/src/bun.js/builtins/ts/JSBufferConstructor.ts +++ /dev/null @@ -1,67 +0,0 @@ -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 deleted file mode 100644 index 97b25b9b2..000000000 --- a/src/bun.js/builtins/ts/JSBufferPrototype.ts +++ /dev/null @@ -1,495 +0,0 @@ -// 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/ts/ProcessObjectInternals.ts b/src/bun.js/builtins/ts/ProcessObjectInternals.ts deleted file mode 100644 index 8b24e68ba..000000000 --- a/src/bun.js/builtins/ts/ProcessObjectInternals.ts +++ /dev/null @@ -1,676 +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. - */ - -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"); - var constants = globalThis[cache]; - if (!constants) { - // 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", - ); - constants = { - fs, - zlib: {}, - crypto: {}, - os: Bun._Os().constants, - }; - globalThis[cache] = constants; - } - return constants; -} - -export function getStdioWriteStream(fd_, rawRequire) { - var module = { path: "node:process", require: rawRequire }; - var require = path => module.require(path); - - function createStdioWriteStream(fd_) { - var { Duplex, eos, destroy } = require("node:stream"); - var StdioWriteStream = class StdioWriteStream extends Duplex { - #writeStream; - #readStream; - - #readable = true; - #writable = true; - #fdPath; - - #onClose; - #onDrain; - #onFinish; - #onReadable; - #isTTY; - - get isTTY() { - return (this.#isTTY ??= require("node:tty").isatty(fd_)); - } - - get fd() { - return fd_; - } - - constructor(fd) { - super({ readable: true, writable: true }); - this.#fdPath = `/dev/fd/${fd}`; - } - - #onFinished(err) { - const cb = this.#onClose; - this.#onClose = null; - - if (cb) { - cb(err); - } else if (err) { - this.destroy(err); - } else if (!this.#readable && !this.#writable) { - this.destroy(); - } - } - - _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)}`); - } - super(message, options); - this.code = "ABORT_ERR"; - this.name = "AbortError"; - } - }; - err = new AbortError(); - } - - this.#onDrain = null; - this.#onFinish = null; - if (this.#onClose === null) { - callback(err); - } else { - this.#onClose = callback; - if (this.#writeStream) destroy(this.#writeStream, err); - if (this.#readStream) destroy(this.#readStream, err); - } - } - - _write(chunk, encoding, callback) { - if (!this.#writeStream) { - var { createWriteStream } = require("node:fs"); - var stream = (this.#writeStream = createWriteStream(this.#fdPath)); - - stream.on("finish", () => { - if (this.#onFinish) { - const cb = this.#onFinish; - this.#onFinish = null; - cb(); - } - }); - - stream.on("drain", () => { - if (this.#onDrain) { - const cb = this.#onDrain; - this.#onDrain = null; - cb(); - } - }); - - eos(stream, err => { - this.#writable = false; - if (err) { - destroy(stream, err); - } - this.#onFinished(err); - }); - } - if (stream.write(chunk, encoding)) { - callback(); - } else { - this.#onDrain = callback; - } - } - - _final(callback) { - this.#writeStream && this.#writeStream.end(); - this.#onFinish = callback; - } - - #loadReadStream() { - var { createReadStream } = require("node:fs"); - - var readStream = (this.#readStream = createReadStream(this.#fdPath)); - - readStream.on("readable", () => { - if (this.#onReadable) { - const cb = this.#onReadable; - this.#onReadable = null; - cb(); - } else { - this.read(); - } - }); - - readStream.on("end", () => { - this.push(null); - }); - - eos(readStream, err => { - this.#readable = false; - if (err) { - destroy(readStream, err); - } - this.#onFinished(err); - }); - return readStream; - } - - _read() { - var stream = this.#readStream; - if (!stream) { - stream = this.#loadReadStream(); - } - - while (true) { - const buf = stream.read(); - if (buf === null || !this.push(buf)) { - return; - } - } - } - }; - return new StdioWriteStream(fd_); - } - - var { EventEmitter } = require("node:events"); - - function isFastEncoding(encoding) { - if (!encoding) return true; - - var normalied = encoding.toLowerCase(); - return normalied === "utf8" || normalied === "utf-8" || normalied === "buffer" || normalied === "binary"; - } - - var readline; - - var FastStdioWriteStream = class StdioWriteStream extends EventEmitter { - #fd; - #innerStream; - #writer; - #isTTY; - - bytesWritten = 0; - - setDefaultEncoding(encoding) { - if (this.#innerStream || !isFastEncoding(encoding)) { - this.#ensureInnerStream(); - return this.#innerStream.setDefaultEncoding(encoding); - } - } - - #createWriter() { - switch (this.#fd) { - case 1: { - var writer = Bun.stdout.writer({ highWaterMark: 0 }); - writer.unref(); - return writer; - } - - case 2: { - var writer = Bun.stderr.writer({ highWaterMark: 0 }); - writer.unref(); - return writer; - } - default: { - throw new Error("Unsupported writer"); - } - } - } - - #getWriter() { - return (this.#writer ??= this.#createWriter()); - } - - constructor(fd_) { - super(); - this.#fd = fd_; - } - - get fd() { - return this.#fd; - } - - get isTTY() { - return (this.#isTTY ??= require("node:tty").isatty(this.#fd)); - } - - cursorTo(x, y, callback) { - return (readline ??= require("readline")).cursorTo(this, x, y, callback); - } - - moveCursor(dx, dy, callback) { - return (readline ??= require("readline")).moveCursor(this, dx, dy, callback); - } - - clearLine(dir, callback) { - return (readline ??= require("readline")).clearLine(this, dir, callback); - } - - clearScreenDown(callback) { - return (readline ??= require("readline")).clearScreenDown(this, callback); - } - - // TODO: once implemented this.columns and this.rows should be uncommented - // getWindowSize() { - // return [this.columns, this.rows]; - // } - - ref() { - this.#getWriter().ref(); - } - - unref() { - this.#getWriter().unref(); - } - - on(event, listener) { - if (event === "close" || event === "finish") { - this.#ensureInnerStream(); - return this.#innerStream.on(event, listener); - } - - if (event === "drain") { - return super.on("drain", listener); - } - - if (event === "error") { - return super.on("error", listener); - } - - return super.on(event, listener); - } - - get _writableState() { - this.#ensureInnerStream(); - return this.#innerStream._writableState; - } - - get _readableState() { - this.#ensureInnerStream(); - return this.#innerStream._readableState; - } - - pipe(destination) { - this.#ensureInnerStream(); - return this.#innerStream.pipe(destination); - } - - unpipe(destination) { - this.#ensureInnerStream(); - return this.#innerStream.unpipe(destination); - } - - #ensureInnerStream() { - if (this.#innerStream) return; - this.#innerStream = createStdioWriteStream(this.#fd); - const events = this.eventNames(); - for (const event of events) { - this.#innerStream.on(event, (...args) => { - this.emit(event, ...args); - }); - } - } - - #write1(chunk) { - var writer = this.#getWriter(); - const writeResult = writer.write(chunk); - this.bytesWritten += writeResult; - const flushResult = writer.flush(false); - return !!(writeResult || flushResult); - } - - #writeWithEncoding(chunk, encoding) { - if (!isFastEncoding(encoding)) { - this.#ensureInnerStream(); - return this.#innerStream.write(chunk, encoding); - } - - return this.#write1(chunk); - } - - #performCallback(cb, err?: any) { - if (err) { - this.emit("error", err); - } - - try { - cb(err ? err : null); - } catch (err2) { - this.emit("error", err2); - } - } - - #writeWithCallbackAndEncoding(chunk, encoding, callback) { - if (!isFastEncoding(encoding)) { - this.#ensureInnerStream(); - return this.#innerStream.write(chunk, encoding, callback); - } - - var writer = this.#getWriter(); - const writeResult = writer.write(chunk); - const flushResult = writer.flush(true); - if (flushResult?.then) { - flushResult.then( - () => { - this.#performCallback(callback); - this.emit("drain"); - }, - err => this.#performCallback(callback, err), - ); - return false; - } - - queueMicrotask(() => { - this.#performCallback(callback); - }); - - return !!(writeResult || flushResult); - } - - write(chunk, encoding, callback) { - const result = this._write(chunk, encoding, callback); - - if (result) { - this.emit("drain"); - } - - return result; - } - - get hasColors() { - return Bun.tty[this.#fd].hasColors; - } - - _write(chunk, encoding, callback) { - var inner = this.#innerStream; - if (inner) { - return inner.write(chunk, encoding, callback); - } - - switch (arguments.length) { - case 0: { - var error = new Error("Invalid arguments"); - error.code = "ERR_INVALID_ARG_TYPE"; - throw error; - } - case 1: { - return this.#write1(chunk); - } - case 2: { - if (typeof encoding === "function") { - return this.#writeWithCallbackAndEncoding(chunk, "", encoding); - } else if (typeof encoding === "string") { - return this.#writeWithEncoding(chunk, encoding); - } - } - default: { - if ( - (typeof encoding !== "undefined" && typeof encoding !== "string") || - (typeof callback !== "undefined" && typeof callback !== "function") - ) { - var error = new Error("Invalid arguments"); - error.code = "ERR_INVALID_ARG_TYPE"; - throw error; - } - - if (typeof callback === "undefined") { - return this.#writeWithEncoding(chunk, encoding); - } - - return this.#writeWithCallbackAndEncoding(chunk, encoding, callback); - } - } - } - - destroy() { - return this; - } - - end() { - return this; - } - }; - - return new FastStdioWriteStream(fd_); -} - -export function getStdinStream(fd_, rawRequire, Bun) { - var module = { path: "node:process", require: rawRequire }; - var require = path => module.require(path); - - var { Duplex, eos, destroy } = require("node:stream"); - - var StdinStream = class StdinStream extends Duplex { - #reader; - // TODO: investigate https://github.com/oven-sh/bun/issues/1607 - - #readRef; - #writeStream; - - #readable = true; - #unrefOnRead = false; - #writable = true; - - #onFinish; - #onClose; - #onDrain; - - get isTTY() { - return require("tty").isatty(fd_); - } - - get fd() { - return fd_; - } - - constructor() { - super({ readable: true, writable: true }); - } - - #onFinished(err?) { - const cb = this.#onClose; - this.#onClose = null; - - if (cb) { - cb(err); - } else if (err) { - this.destroy(err); - } else if (!this.#readable && !this.#writable) { - this.destroy(); - } - } - - _destroy(err, callback) { - if (!err && this.#onClose !== null) { - var AbortError = class AbortError extends Error { - 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)}`); - } - super(message, options); - this.code = "ABORT_ERR"; - this.name = "AbortError"; - } - }; - err = new AbortError(); - } - - if (this.#onClose === null) { - callback(err); - } else { - this.#onClose = callback; - if (this.#writeStream) destroy(this.#writeStream, err); - } - } - - setRawMode(mode) {} - - on(name, callback) { - // Streams don't generally required to present any data when only - // `readable` events are present, i.e. `readableFlowing === false` - // - // However, Node.js has a this quirk whereby `process.stdin.read()` - // blocks under TTY mode, thus looping `.read()` in this particular - // case would not result in truncation. - // - // Therefore the following hack is only specific to `process.stdin` - // and does not apply to the underlying Stream implementation. - if (name === "readable") { - this.ref(); - this.#unrefOnRead = true; - } - return super.on(name, callback); - } - - pause() { - this.unref(); - return super.pause(); - } - - resume() { - this.ref(); - return super.resume(); - } - - ref() { - this.#reader ??= Bun.stdin.stream().getReader(); - this.#readRef ??= setInterval(() => {}, 1 << 30); - } - - unref() { - if (this.#readRef) { - clearInterval(this.#readRef); - this.#readRef = null; - } - } - - async #readInternal() { - try { - var done, value; - const read = this.#reader.readMany(); - - // read same-tick if possible - if (!read?.then) { - ({ done, value } = read); - } else { - ({ done, value } = await read); - } - - if (!done) { - this.push(value[0]); - - // shouldn't actually happen, but just in case - const length = value.length; - for (let i = 1; i < length; i++) { - this.push(value[i]); - } - } else { - this.push(null); - this.pause(); - this.#readable = false; - this.#onFinished(); - } - } catch (err) { - this.#readable = false; - this.#onFinished(err); - } - } - - _read(size) { - if (this.#unrefOnRead) { - this.unref(); - this.#unrefOnRead = false; - } - this.#readInternal(); - } - - #constructWriteStream() { - var { createWriteStream } = require("node:fs"); - var writeStream = (this.#writeStream = createWriteStream("/dev/fd/0")); - - writeStream.on("finish", () => { - if (this.#onFinish) { - const cb = this.#onFinish; - this.#onFinish = null; - cb(); - } - }); - - writeStream.on("drain", () => { - if (this.#onDrain) { - const cb = this.#onDrain; - this.#onDrain = null; - cb(); - } - }); - - eos(writeStream, err => { - this.#writable = false; - if (err) { - destroy(writeStream, err); - } - this.#onFinished(err); - }); - - return writeStream; - } - - _write(chunk, encoding, callback) { - var writeStream = this.#writeStream; - if (!writeStream) { - writeStream = this.#constructWriteStream(); - } - - if (writeStream.write(chunk, encoding)) { - callback(); - } else { - this.#onDrain = callback; - } - } - - _final(callback) { - this.#writeStream.end(); - this.#onFinish = (...args) => callback(...args); - } - }; - - return new StdinStream(); -} diff --git a/src/bun.js/builtins/ts/ReadableByteStreamController.ts b/src/bun.js/builtins/ts/ReadableByteStreamController.ts deleted file mode 100644 index 888f241bc..000000000 --- a/src/bun.js/builtins/ts/ReadableByteStreamController.ts +++ /dev/null @@ -1,93 +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. - */ - -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 deleted file mode 100644 index f44c385b4..000000000 --- a/src/bun.js/builtins/ts/ReadableByteStreamInternals.ts +++ /dev/null @@ -1,656 +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 - -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 deleted file mode 100644 index 613f869e5..000000000 --- a/src/bun.js/builtins/ts/ReadableStream.ts +++ /dev/null @@ -1,421 +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. - */ - -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: ReadableStream): Promise<unknown[]> { - // 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: ReadableStream): Promise<string> { - // 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: ReadableStream<ArrayBuffer>): Promise<ArrayBuffer> | ArrayBuffer { - // this is a direct stream - var underlyingSource = $getByIdDirectPrivate(stream, "underlyingSource"); - - if (underlyingSource !== undefined) { - return $readableStreamToArrayBufferDirect(stream, underlyingSource); - } - - var array = Bun.readableStreamToArray(stream); - if ($isPromise(array)) { - return array.$then(Bun.concatArrayBuffers); - } - - return Bun.concatArrayBuffers(array); -} - -$linkTimeConstant; -export function readableStreamToJSON(stream: ReadableStream): unknown { - return Bun.readableStreamToText(stream).$then(globalThis.JSON.parse); -} - -$linkTimeConstant; -export function readableStreamToBlob(stream: ReadableStream): Promise<Blob> { - 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 deleted file mode 100644 index 5ebfddb19..000000000 --- a/src/bun.js/builtins/ts/ReadableStreamBYOBReader.ts +++ /dev/null @@ -1,80 +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. - */ - -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 deleted file mode 100644 index 1354f9349..000000000 --- a/src/bun.js/builtins/ts/ReadableStreamBYOBRequest.ts +++ /dev/null @@ -1,66 +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. - */ - -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 deleted file mode 100644 index 912cd1acb..000000000 --- a/src/bun.js/builtins/ts/ReadableStreamDefaultController.ts +++ /dev/null @@ -1,63 +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. - */ - -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 deleted file mode 100644 index ecd553ed5..000000000 --- a/src/bun.js/builtins/ts/ReadableStreamDefaultReader.ts +++ /dev/null @@ -1,185 +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. - */ - -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 deleted file mode 100644 index 0c4e816f4..000000000 --- a/src/bun.js/builtins/ts/ReadableStreamInternals.ts +++ /dev/null @@ -1,1799 +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 - -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; - } -} - -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 deleted file mode 100644 index b42dc2f57..000000000 --- a/src/bun.js/builtins/ts/StreamInternals.ts +++ /dev/null @@ -1,268 +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 - -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 deleted file mode 100644 index 54467db39..000000000 --- a/src/bun.js/builtins/ts/TransformStream.ts +++ /dev/null @@ -1,106 +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. - */ - -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/ts/TransformStreamDefaultController.ts b/src/bun.js/builtins/ts/TransformStreamDefaultController.ts deleted file mode 100644 index 1045498b8..000000000 --- a/src/bun.js/builtins/ts/TransformStreamDefaultController.ts +++ /dev/null @@ -1,60 +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. - */ - -export function initializeTransformStreamDefaultController(this) { - return this; -} - -$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"); - - return $readableStreamDefaultControllerGetDesiredSize(readableController); -} - -export function enqueue(this, chunk) { - if (!$isTransformStreamDefaultController(this)) - throw $makeThisTypeError("TransformStreamDefaultController", "enqueue"); - - $transformStreamDefaultControllerEnqueue(this, chunk); -} - -export function error(this, e) { - if (!$isTransformStreamDefaultController(this)) throw $makeThisTypeError("TransformStreamDefaultController", "error"); - - $transformStreamDefaultControllerError(this, e); -} - -export function terminate(this) { - if (!$isTransformStreamDefaultController(this)) - throw $makeThisTypeError("TransformStreamDefaultController", "terminate"); - - $transformStreamDefaultControllerTerminate(this); -} diff --git a/src/bun.js/builtins/ts/TransformStreamInternals.ts b/src/bun.js/builtins/ts/TransformStreamInternals.ts deleted file mode 100644 index 9994d1282..000000000 --- a/src/bun.js/builtins/ts/TransformStreamInternals.ts +++ /dev/null @@ -1,348 +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 - -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/ts/WritableStreamDefaultController.ts b/src/bun.js/builtins/ts/WritableStreamDefaultController.ts deleted file mode 100644 index 1a3ddc290..000000000 --- a/src/bun.js/builtins/ts/WritableStreamDefaultController.ts +++ /dev/null @@ -1,48 +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. - */ - -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; -} - -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); -} diff --git a/src/bun.js/builtins/ts/WritableStreamDefaultWriter.ts b/src/bun.js/builtins/ts/WritableStreamDefaultWriter.ts deleted file mode 100644 index 795b43892..000000000 --- a/src/bun.js/builtins/ts/WritableStreamDefaultWriter.ts +++ /dev/null @@ -1,104 +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. - */ - -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 deleted file mode 100644 index f436a285e..000000000 --- a/src/bun.js/builtins/ts/WritableStreamInternals.ts +++ /dev/null @@ -1,790 +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 - -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 deleted file mode 100644 index 612488c5f..000000000 --- a/src/bun.js/builtins/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../../tsconfig.base.json", - "compilerOptions": { - "noEmit": true - }, - "include": [".", "builtins.d.ts", "WebCoreJSBuiltins.d.ts", "../../../packages/bun-types/index.d.ts"] -} |