diff options
author | 2023-07-19 17:20:00 -0700 | |
---|---|---|
committer | 2023-07-19 17:20:00 -0700 | |
commit | 9b6dc49575df5fb953918c284505f24741138130 (patch) | |
tree | 3a052876fa8c6524e0c8d18479aabe38e2d5a52a | |
parent | 723e9d1ea7c7fdb424ecedd0fb023524366322c4 (diff) | |
download | bun-9b6dc49575df5fb953918c284505f24741138130.tar.gz bun-9b6dc49575df5fb953918c284505f24741138130.tar.zst bun-9b6dc49575df5fb953918c284505f24741138130.zip |
Implement `AsyncLocalStorage` (#3089)
* work to get async local storage working.
* a
* a
* everything but queueMicrotask
* sdfghj
* .
* finish
* tests
* test
* ok
* done
* im so stupid
* Upgrade WebKit
* refactor
* refactor
* changes requested
* oops
* cool
* fix runInAsyncScope
67 files changed, 4915 insertions, 3668 deletions
diff --git a/.github/workflows/bun-linux-aarch64.yml b/.github/workflows/bun-linux-aarch64.yml index 567723e5d..df6a75892 100644 --- a/.github/workflows/bun-linux-aarch64.yml +++ b/.github/workflows/bun-linux-aarch64.yml @@ -36,7 +36,7 @@ jobs: arch: aarch64 build_arch: arm64 runner: linux-arm64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-linux-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-linux-arm64-lto.tar.gz" webkit_basename: "bun-webkit-linux-arm64-lto" build_machine_arch: aarch64 diff --git a/.github/workflows/bun-linux-build.yml b/.github/workflows/bun-linux-build.yml index 212d7ce83..00a7443a0 100644 --- a/.github/workflows/bun-linux-build.yml +++ b/.github/workflows/bun-linux-build.yml @@ -46,7 +46,7 @@ jobs: arch: x86_64 build_arch: amd64 runner: big-ubuntu - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-linux-amd64-lto.tar.gz" webkit_basename: "bun-webkit-linux-amd64-lto" build_machine_arch: x86_64 - cpu: nehalem @@ -54,7 +54,7 @@ jobs: arch: x86_64 build_arch: amd64 runner: big-ubuntu - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-linux-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-linux-amd64-lto.tar.gz" webkit_basename: "bun-webkit-linux-amd64-lto" build_machine_arch: x86_64 diff --git a/.github/workflows/bun-mac-aarch64.yml b/.github/workflows/bun-mac-aarch64.yml index 09014a9b8..13fb3aa0b 100644 --- a/.github/workflows/bun-mac-aarch64.yml +++ b/.github/workflows/bun-mac-aarch64.yml @@ -117,7 +117,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false # - cpu: haswell @@ -126,7 +126,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false # - cpu: nehalem @@ -135,7 +135,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true # - cpu: haswell @@ -144,7 +144,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true - cpu: native @@ -152,7 +152,7 @@ jobs: tag: bun-darwin-aarch64 obj: bun-obj-darwin-aarch64 artifact: bun-obj-darwin-aarch64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-arm64-lto.tar.gz" runner: macos-arm64 dependencies: true compile_obj: true @@ -257,7 +257,7 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: haswell # arch: x86_64 # tag: bun-darwin-x64 @@ -265,14 +265,14 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" - cpu: native arch: aarch64 tag: bun-darwin-aarch64 obj: bun-obj-darwin-aarch64 package: bun-darwin-aarch64 artifact: bun-obj-darwin-aarch64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-arm64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-arm64-lto.tar.gz" runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/bun-mac-x64-baseline.yml b/.github/workflows/bun-mac-x64-baseline.yml index 9f9e4b9a0..163d8cac8 100644 --- a/.github/workflows/bun-mac-x64-baseline.yml +++ b/.github/workflows/bun-mac-x64-baseline.yml @@ -117,7 +117,7 @@ jobs: obj: bun-obj-darwin-x64-baseline runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" dependencies: true compile_obj: false # - cpu: haswell @@ -126,7 +126,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false - cpu: nehalem @@ -135,7 +135,7 @@ jobs: obj: bun-obj-darwin-x64-baseline runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" dependencies: false compile_obj: true # - cpu: haswell @@ -144,7 +144,7 @@ jobs: # obj: bun-obj-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true # - cpu: native @@ -152,7 +152,7 @@ jobs: # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # runner: macos-arm64 # dependencies: true # compile_obj: true @@ -258,7 +258,7 @@ jobs: package: bun-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64-baseline - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: haswell # arch: x86_64 # tag: bun-darwin-x64 @@ -266,14 +266,14 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: native # arch: aarch64 # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # package: bun-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/bun-mac-x64.yml b/.github/workflows/bun-mac-x64.yml index 0bd95f537..d3ed46015 100644 --- a/.github/workflows/bun-mac-x64.yml +++ b/.github/workflows/bun-mac-x64.yml @@ -117,7 +117,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: true # compile_obj: false - cpu: haswell @@ -126,7 +126,7 @@ jobs: obj: bun-obj-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" dependencies: true compile_obj: false # - cpu: nehalem @@ -135,7 +135,7 @@ jobs: # obj: bun-obj-darwin-x64-baseline # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # dependencies: false # compile_obj: true - cpu: haswell @@ -144,7 +144,7 @@ jobs: obj: bun-obj-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" dependencies: false compile_obj: true # - cpu: native @@ -152,7 +152,7 @@ jobs: # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-arm64-lto.tar.gz" # runner: macos-arm64 # dependencies: true # compile_obj: true @@ -260,7 +260,7 @@ jobs: # package: bun-darwin-x64 # runner: macos-11 # artifact: bun-obj-darwin-x64-baseline - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" - cpu: haswell arch: x86_64 tag: bun-darwin-x64 @@ -268,14 +268,14 @@ jobs: package: bun-darwin-x64 runner: macos-11 artifact: bun-obj-darwin-x64 - webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-amd64-lto.tar.gz" + webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-amd64-lto.tar.gz" # - cpu: native # arch: aarch64 # tag: bun-darwin-aarch64 # obj: bun-obj-darwin-aarch64 # package: bun-darwin-aarch64 # artifact: bun-obj-darwin-aarch64 - # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-4/bun-webkit-macos-arm64-lto.tar.gz" + # webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20-5/bun-webkit-macos-arm64-lto.tar.gz" # runner: macos-arm64 steps: - uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index 3b0e270d8..eb970e815 100644 --- a/.gitignore +++ b/.gitignore @@ -123,3 +123,5 @@ cold-jsc-start.d /test.ts src/js/out/modules_dev + +make-dev-stats.csv diff --git a/.scripts/make-dev-timer.ts b/.scripts/make-dev-timer.ts new file mode 100644 index 000000000..4b5f8d535 --- /dev/null +++ b/.scripts/make-dev-timer.ts @@ -0,0 +1,21 @@ +// I would have made this a bash script but there isn't an easy way to track +// time in bash sub-second cross platform. +import fs from "fs"; +const start = Date.now() + 5; +const result = Bun.spawnSync(process.argv.slice(2), { + stdio: ["inherit", "inherit", "inherit"], +}); +const end = Date.now(); +const diff = (Math.max(Math.round(end - start), 0) / 1000).toFixed(3); +const success = result.exitCode === 0; +try { + const line = `${new Date().toISOString()}, ${success ? "success" : "fail"}, ${diff}\n`; + if (fs.existsSync(".scripts/make-dev-stats.csv")) { + fs.appendFileSync(".scripts/make-dev-stats.csv", line); + } else { + fs.writeFileSync(".scripts/make-dev-stats.csv", line); + } +} catch { + // Ignore +} +process.exit(result.exitCode); diff --git a/Dockerfile b/Dockerfile index dea0e8f62..5b7ecc4f0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ ARG ARCH=x86_64 ARG BUILD_MACHINE_ARCH=x86_64 ARG TRIPLET=${ARCH}-linux-gnu ARG BUILDARCH=amd64 -ARG WEBKIT_TAG=may20-4 +ARG WEBKIT_TAG=may20-5 ARG ZIG_TAG=jul1 ARG ZIG_VERSION="0.11.0-dev.4006+bf827d0b5" ARG WEBKIT_BASENAME="bun-webkit-linux-$BUILDARCH" @@ -52,6 +52,8 @@ endif BUN_OR_NODE = $(shell which bun 2>/dev/null || which node 2>/dev/null) + + CXX_VERSION=c++2a TRIPLET = $(OS_NAME)-$(ARCH_NAME) PACKAGE_NAME = bun-$(TRIPLET) @@ -1091,9 +1093,25 @@ test/wiptest/run: test/wiptest/run.o release-bin-dir: echo $(PACKAGE_DIR) + +.PHONY: dev-obj-track +dev-obj-track: + bun .scripts/make-dev-timer.ts $(ZIG) build obj -freference-trace -Dcpu="$(CPU_TARGET)" + +.PHONY: dev-obj-notrack +dev-obj-notrack: + $(ZIG) build obj -freference-trace -Dcpu="$(CPU_TARGET)" + + .PHONY: dev-obj dev-obj: - $(ZIG) build obj -freference-trace -Dcpu="$(CPU_TARGET)" + +ifeq ($(shell which bun),) +dev-obj : dev-obj-notrack +else +dev-obj : dev-obj-track +endif + .PHONY: dev-obj-linux dev-obj-linux: @@ -1185,7 +1203,7 @@ jsc-build-mac-compile: -DPORT="JSCOnly" \ -DENABLE_STATIC_JSC=ON \ -DENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE=ON \ - -DCMAKE_BUILD_TYPE=relwithdebuginfo \ + -DCMAKE_BUILD_TYPE=Release \ -DUSE_THIN_ARCHIVES=OFF \ -DBUN_FAST_TLS=ON \ -DENABLE_FTL_JIT=ON \ @@ -1252,7 +1270,7 @@ jsc-build-linux-compile-config: cmake \ -DPORT="JSCOnly" \ -DENABLE_STATIC_JSC=ON \ - -DCMAKE_BUILD_TYPE=relwithdebuginfo \ + -DCMAKE_BUILD_TYPE=Release \ -DUSE_THIN_ARCHIVES=OFF \ -DENABLE_FTL_JIT=ON \ -DENABLE_REMOTE_INSPECTOR=ON \ diff --git a/bench/async/AsyncLocalStorage.mjs b/bench/async/AsyncLocalStorage.mjs new file mode 100644 index 000000000..9b21ca350 --- /dev/null +++ b/bench/async/AsyncLocalStorage.mjs @@ -0,0 +1,30 @@ +// https://github.com/nodejs/node/issues/34493 +import { AsyncLocalStorage } from "async_hooks"; +const asyncLocalStorage = new AsyncLocalStorage(); + +// let fn = () => Promise.resolve(2).then(() => new Promise(resolve => queueMicrotask(resolve))); +let fn = () => /test/.test("test"); + +let runWithExpiry = async (expiry, fn) => { + let iterations = 0; + while (Date.now() < expiry) { + await fn(); + iterations++; + } + return iterations; +}; + +console.log(`Performed ${await runWithExpiry(Date.now() + 1000, fn)} iterations to warmup`); + +let withAls; +await asyncLocalStorage.run(123, async () => { + withAls = await runWithExpiry(Date.now() + 45000, fn); + console.log(`Performed ${withAls} iterations (with ALS enabled)`); +}); + +asyncLocalStorage.disable(); + +let withoutAls = await runWithExpiry(Date.now() + 45000, fn); +console.log(`Performed ${withoutAls} iterations (with ALS disabled)`); + +console.log("ALS penalty: " + Math.round((1 - withAls / withoutAls) * 10000) / 100 + "%"); diff --git a/bench/snippets/async-overhead.mjs b/bench/snippets/async-overhead.mjs index 753af1632..7af987bff 100644 --- a/bench/snippets/async-overhead.mjs +++ b/bench/snippets/async-overhead.mjs @@ -1,4 +1,4 @@ -import { bench, run } from "../node_modules/mitata/src/cli.mjs"; +import { bench, run } from "mitata"; bench("noop", function () {}); bench("async function(){}", async function () {}); Binary files differdiff --git a/package.json b/package.json index 60e572514..f8f511eb0 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@types/ws": "^8.5.5", "@typescript-eslint/eslint-plugin": "^5.31.0", "@typescript-eslint/parser": "^5.31.0", - "bun-webkit": "0.0.1-dcaa801946a9526c0c4a40dceb9168b81aeb7973" + "bun-webkit": "0.0.1-770ebc986b8ae9a0dd2e85f8f94646b410110b7f" }, "version": "0.0.0", "prettier": "./.prettierrc.cjs" diff --git a/packages/bun-types/async_hooks.d.ts b/packages/bun-types/async_hooks.d.ts new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/packages/bun-types/async_hooks.d.ts diff --git a/packages/bun-types/sqlite.d.ts b/packages/bun-types/sqlite.d.ts index c5b1af1c8..632910386 100644 --- a/packages/bun-types/sqlite.d.ts +++ b/packages/bun-types/sqlite.d.ts @@ -235,7 +235,7 @@ declare module "bun:sqlite" { ParamsType extends SQLQueryBindings | SQLQueryBindings[], >( sqlQuery: string, - params?: ParamsType + params?: ParamsType, ): Statement< ReturnType, ParamsType extends Array<any> ? ParamsType : [ParamsType] diff --git a/src/bun.js/WebKit b/src/bun.js/WebKit -Subproject 26c819733315f0ab64ae8e8e65b77d77d31211e +Subproject 5e65b9ae7756b6353cfeac5206f7076b00e9ecf diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index d63765b16..85d2e7f83 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -4197,10 +4197,12 @@ pub const Timer = struct { 0, ); - Timer.set(id, globalThis, callback, interval, arguments, false) catch + const wrappedCallback = callback.withAsyncContextIfNeeded(globalThis); + + Timer.set(id, globalThis, wrappedCallback, interval, arguments, false) catch return JSValue.jsUndefined(); - return TimerObject.init(globalThis, id, .setTimeout, interval, callback, arguments); + return TimerObject.init(globalThis, id, .setTimeout, interval, wrappedCallback, arguments); } pub fn setInterval( globalThis: *JSGlobalObject, @@ -4212,16 +4214,18 @@ pub const Timer = struct { const id = globalThis.bunVM().timer.last_id; globalThis.bunVM().timer.last_id +%= 1; + const wrappedCallback = callback.withAsyncContextIfNeeded(globalThis); + // We don't deal with nesting levels directly // but we do set the minimum timeout to be 1ms for repeating timers const interval: i32 = @max( countdown.coerce(i32, globalThis), 1, ); - Timer.set(id, globalThis, callback, interval, arguments, true) catch + Timer.set(id, globalThis, wrappedCallback, interval, arguments, true) catch return JSValue.jsUndefined(); - return TimerObject.init(globalThis, id, .setInterval, interval, callback, arguments); + return TimerObject.init(globalThis, id, .setInterval, interval, wrappedCallback, arguments); } pub fn clearTimer(timer_id_value: JSValue, globalThis: *JSGlobalObject, repeats: bool) void { diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig index 1bc7f234a..4fb02b8af 100644 --- a/src/bun.js/api/bun/subprocess.zig +++ b/src/bun.js/api/bun/subprocess.zig @@ -1153,7 +1153,7 @@ pub const Subprocess = struct { globalThis.throwInvalidArguments("onExit must be a function or undefined", .{}); return .zero; } - on_exit_callback = onExit_; + on_exit_callback = onExit_.withAsyncContextIfNeeded(globalThis); } } diff --git a/src/bun.js/api/html_rewriter.zig b/src/bun.js/api/html_rewriter.zig index 651db981b..92e9790c6 100644 --- a/src/bun.js/api/html_rewriter.zig +++ b/src/bun.js/api/html_rewriter.zig @@ -846,11 +846,11 @@ fn HandlerCallback( }; var result = JSC.C.JSObjectCallAsFunctionReturnValue( this.global, - @field(this, callback_name).?.asObjectRef(), + @field(this, callback_name).?, if (comptime @hasField(HandlerType, "thisObject")) - @field(this, "thisObject").asObjectRef() + @field(this, "thisObject") else - null, + JSValue.zero, 1, &args, ); diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index fbf22678b..4da7c6300 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -795,15 +795,17 @@ pub const ServerConfig = struct { } return args; } - JSC.C.JSValueProtect(global, onError.asObjectRef()); - args.onError = onError; + const onErrorSnapshot = onError.withAsyncContextIfNeeded(global); + args.onError = onErrorSnapshot; + onErrorSnapshot.protect(); } - if (arg.getTruthy(global, "fetch")) |onRequest| { - if (!onRequest.isCallable(global.vm())) { + if (arg.getTruthy(global, "fetch")) |onRequest_| { + if (!onRequest_.isCallable(global.vm())) { JSC.throwInvalidArguments("Expected fetch() to be a function", .{}, global, exception); return args; } + const onRequest = onRequest_.withAsyncContextIfNeeded(global); JSC.C.JSValueProtect(global, onRequest.asObjectRef()); args.onRequest = onRequest; } else { @@ -2643,8 +2645,11 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp JSC.markBinding(@src()); if (!this.server.config.onError.isEmpty() and !this.flags.has_called_error_handler) { this.flags.has_called_error_handler = true; - var args = [_]JSC.C.JSValueRef{value.asObjectRef()}; - const result = JSC.C.JSObjectCallAsFunctionReturnValue(this.server.globalThis, this.server.config.onError.asObjectRef(), this.server.thisObject.asObjectRef(), 1, &args); + const result = this.server.config.onError.callWithThis( + this.server.globalThis, + this.server.thisObject, + &.{value}, + ); defer result.ensureStillAlive(); if (!result.isEmptyOrUndefinedOrNull()) { if (result.toError()) |err| { @@ -3010,54 +3015,58 @@ pub const WebSocketServer = struct { var vm = globalObject.vm(); var valid = false; - if (object.getTruthy(globalObject, "message")) |message| { - if (!message.isCallable(vm)) { + if (object.getTruthy(globalObject, "message")) |message_| { + if (!message_.isCallable(vm)) { globalObject.throwInvalidArguments("websocket expects a function for the message option", .{}); return null; } + const message = message_.withAsyncContextIfNeeded(globalObject); handler.onMessage = message; message.ensureStillAlive(); valid = true; } - if (object.getTruthy(globalObject, "open")) |open| { - if (!open.isCallable(vm)) { + if (object.getTruthy(globalObject, "open")) |open_| { + if (!open_.isCallable(vm)) { globalObject.throwInvalidArguments("websocket expects a function for the open option", .{}); return null; } + const open = open_.withAsyncContextIfNeeded(globalObject); handler.onOpen = open; open.ensureStillAlive(); valid = true; } - if (object.getTruthy(globalObject, "close")) |close| { - if (!close.isCallable(vm)) { + if (object.getTruthy(globalObject, "close")) |close_| { + if (!close_.isCallable(vm)) { globalObject.throwInvalidArguments("websocket expects a function for the close option", .{}); return null; } + const close = close_.withAsyncContextIfNeeded(globalObject); handler.onClose = close; close.ensureStillAlive(); valid = true; } - if (object.getTruthy(globalObject, "drain")) |drain| { - if (!drain.isCallable(vm)) { + if (object.getTruthy(globalObject, "drain")) |drain_| { + if (!drain_.isCallable(vm)) { globalObject.throwInvalidArguments("websocket expects a function for the drain option", .{}); return null; } + const drain = drain_.withAsyncContextIfNeeded(globalObject); handler.onDrain = drain; drain.ensureStillAlive(); valid = true; } - if (object.getTruthy(globalObject, "error")) |cb| { - if (!cb.isCallable(vm)) { - globalObject.throwInvalidArguments("websocket expects a function for the error option", .{}); + if (object.getTruthy(globalObject, "onError")) |onError_| { + if (!onError_.isCallable(vm)) { + globalObject.throwInvalidArguments("websocket expects a function for the onError option", .{}); return null; } - handler.onError = cb; - cb.ensureStillAlive(); - valid = true; + const onError = onError_.withAsyncContextIfNeeded(globalObject); + handler.onError = onError; + onError.ensureStillAlive(); } if (object.getTruthy(globalObject, "ping")) |cb| { @@ -4912,8 +4921,8 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { var args_ = [_]JSC.C.JSValueRef{request.toJS(this.globalThis).asObjectRef()}; const response_value = JSC.C.JSObjectCallAsFunctionReturnValue( this.globalThis, - this.config.onRequest.asObjectRef(), - this.thisObject.asObjectRef(), + this.config.onRequest, + this.thisObject, 1, &args_, ); diff --git a/src/bun.js/bindings/AsyncContextFrame.cpp b/src/bun.js/bindings/AsyncContextFrame.cpp new file mode 100644 index 000000000..326350664 --- /dev/null +++ b/src/bun.js/bindings/AsyncContextFrame.cpp @@ -0,0 +1,107 @@ +#pragma once + +#include "root.h" +#include "ZigGlobalObject.h" +#include "AsyncContextFrame.h" +#include "JavaScriptCore/InternalFieldTuple.h" + +using namespace JSC; +using namespace WebCore; + +const ClassInfo AsyncContextFrame::s_info = { "AsyncContextFrame"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(AsyncContextFrame) }; + +AsyncContextFrame* AsyncContextFrame::create(VM& vm, JSC::Structure* structure, JSValue callback, JSValue context) +{ + AsyncContextFrame* asyncContextData = new (NotNull, allocateCell<AsyncContextFrame>(vm)) AsyncContextFrame(vm, structure); + asyncContextData->finishCreation(vm); + asyncContextData->callback.set(vm, asyncContextData, callback); + asyncContextData->context.set(vm, asyncContextData, context); + return asyncContextData; +} + +AsyncContextFrame* AsyncContextFrame::create(JSGlobalObject* global, JSValue callback, JSValue context) +{ + auto& vm = global->vm(); + AsyncContextFrame* asyncContextData = new (NotNull, allocateCell<AsyncContextFrame>(vm)) AsyncContextFrame(vm, static_cast<Zig::GlobalObject*>(global)->AsyncContextFrameStructure()); + asyncContextData->finishCreation(vm); + asyncContextData->callback.set(vm, asyncContextData, callback); + asyncContextData->context.set(vm, asyncContextData, context); + return asyncContextData; +} + +JSC::Structure* AsyncContextFrame::createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject) +{ + return Structure::create(vm, globalObject, jsNull(), TypeInfo(ObjectType, StructureFlags), info()); +} + +JSValue AsyncContextFrame::withAsyncContextIfNeeded(JSGlobalObject* globalObject, JSValue callback) +{ + JSValue context = globalObject->m_asyncContextData.get()->getInternalField(0); + + // If there is no async context, do not snapshot the callback. + if (context.isUndefined()) { + return callback; + } + + // Construct a low-overhead wrapper + auto& vm = globalObject->vm(); + return AsyncContextFrame::create( + vm, + static_cast<Zig::GlobalObject*>(globalObject)->AsyncContextFrameStructure(), + callback, + context); +} + +template<typename Visitor> +void AsyncContextFrame::visitChildrenImpl(JSCell* cell, Visitor& visitor) +{ + auto* thisObject = jsCast<AsyncContextFrame*>(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, info()); + Base::visitChildren(thisObject, visitor); + visitor.append(thisObject->callback); + visitor.append(thisObject->context); +} + +DEFINE_VISIT_CHILDREN(AsyncContextFrame); + +extern "C" EncodedJSValue AsyncContextFrame__withAsyncContextIfNeeded(JSGlobalObject* globalObject, EncodedJSValue callback) +{ + return JSValue::encode(AsyncContextFrame::withAsyncContextIfNeeded(globalObject, JSValue::decode(callback))); +} + +#define ASYNCCONTEXTFRAME_CALL_IMPL(...) \ + if (!functionObject.isCell()) \ + return jsUndefined(); \ + auto& vm = global->vm(); \ + JSValue restoreAsyncContext; \ + InternalFieldTuple* asyncContextData = nullptr; \ + if (auto* wrapper = jsDynamicCast<AsyncContextFrame*>(functionObject)) { \ + functionObject = jsCast<JSC::JSObject*>(wrapper->callback.get()); \ + asyncContextData = global->m_asyncContextData.get(); \ + restoreAsyncContext = asyncContextData->getInternalField(0); \ + asyncContextData->putInternalField(vm, 0, wrapper->context.get()); \ + } \ + auto result = JSC::call(__VA_ARGS__); \ + if (asyncContextData) { \ + asyncContextData->putInternalField(vm, 0, restoreAsyncContext); \ + } \ + return result; + +JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject, const ArgList& args, ASCIILiteral errorMessage) +{ + ASYNCCONTEXTFRAME_CALL_IMPL(global, functionObject, args, errorMessage); +} +JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args, ASCIILiteral errorMessage) +{ + ASYNCCONTEXTFRAME_CALL_IMPL(global, functionObject, thisValue, args, errorMessage); +} +JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args) +{ + ASYNCCONTEXTFRAME_CALL_IMPL(global, functionObject, JSC::getCallData(functionObject), thisValue, args); +} +JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args, NakedPtr<Exception>& returnedException) +{ + ASYNCCONTEXTFRAME_CALL_IMPL(global, functionObject, JSC::getCallData(functionObject), thisValue, args, returnedException); +} + +#undef ASYNCCONTEXTFRAME_CALL_IMPL diff --git a/src/bun.js/bindings/AsyncContextFrame.h b/src/bun.js/bindings/AsyncContextFrame.h new file mode 100644 index 000000000..52ca0d160 --- /dev/null +++ b/src/bun.js/bindings/AsyncContextFrame.h @@ -0,0 +1,51 @@ +#pragma once + +#include "root.h" +#include "BunClientData.h" +#include "JavaScriptCore/CallData.h" + +class AsyncContextFrame : public JSC::JSNonFinalObject { +public: + using Base = JSC::JSNonFinalObject; + static constexpr unsigned StructureFlags = Base::StructureFlags; + + static AsyncContextFrame* create(JSC::VM& vm, JSC::Structure* structure, JSC::JSValue callback, JSC::JSValue context); + static AsyncContextFrame* create(JSC::JSGlobalObject* global, JSC::JSValue callback, JSC::JSValue context); + + static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject); + + // When given a JSFunction that you want to call later, wrap it with this function + static JSC::JSValue withAsyncContextIfNeeded(JSC::JSGlobalObject* globalObject, JSC::JSValue callback); + + // The following is JSC::call but + // - it unwraps AsyncContextFrame + // - does not take a CallData, because JSC::getCallData(AsyncContextFrame) -> not callable + static JSC::JSValue call(JSC::JSGlobalObject*, JSC::JSValue functionObject, const JSC::ArgList&, ASCIILiteral errorMessage); + static JSC::JSValue call(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&, ASCIILiteral errorMessage); + static JSC::JSValue call(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&); + static JSC::JSValue call(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&, NakedPtr<JSC::Exception>& returnedException); + + DECLARE_INFO; + DECLARE_VISIT_CHILDREN; + + mutable JSC::WriteBarrier<JSC::Unknown> callback; + mutable JSC::WriteBarrier<JSC::Unknown> context; + + template<typename, JSC::SubspaceAccess mode> + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + if constexpr (mode == JSC::SubspaceAccess::Concurrently) + return nullptr; + return WebCore::subspaceForImpl<AsyncContextFrame, Bun::UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForAsyncContextFrame.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForAsyncContextFrame = std::forward<decltype(space)>(space); }, + [](auto& spaces) { return spaces.m_subspaceForAsyncContextFrame.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForAsyncContextFrame = std::forward<decltype(space)>(space); }); + } + + AsyncContextFrame(JSC::VM& vm, JSC::Structure* structure) + : JSNonFinalObject(vm, structure) + { + } +}; diff --git a/src/bun.js/bindings/CallSite.cpp b/src/bun.js/bindings/CallSite.cpp index e4b2fc3a7..48fe82275 100644 --- a/src/bun.js/bindings/CallSite.cpp +++ b/src/bun.js/bindings/CallSite.cpp @@ -86,7 +86,8 @@ void CallSite::visitChildrenImpl(JSCell* cell, Visitor& visitor) visitor.append(thisCallSite->m_sourceURL); } -void CallSite::formatAsString(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WTF::StringBuilder &sb) { +void CallSite::formatAsString(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WTF::StringBuilder& sb) +{ JSString* myTypeName = jsTypeStringForValue(globalObject, thisValue()); JSString* myFunction = functionName().toString(globalObject); JSString* myFunctionName = functionName().toString(globalObject); diff --git a/src/bun.js/bindings/CallSite.h b/src/bun.js/bindings/CallSite.h index 8780eb8fb..93ce9a46b 100644 --- a/src/bun.js/bindings/CallSite.h +++ b/src/bun.js/bindings/CallSite.h @@ -80,7 +80,7 @@ public: void setLineNumber(JSC::JSValue lineNumber) { m_lineNumber = lineNumber; } void setColumnNumber(JSC::JSValue columnNumber) { m_columnNumber = columnNumber; } - void formatAsString(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WTF::StringBuilder &sb); + void formatAsString(JSC::VM& vm, JSC::JSGlobalObject* globalObject, WTF::StringBuilder& sb); private: CallSite(JSC::VM& vm, JSC::Structure* structure) diff --git a/src/bun.js/bindings/JSMockFunction.cpp b/src/bun.js/bindings/JSMockFunction.cpp index 3a84f0139..4a9b936b4 100644 --- a/src/bun.js/bindings/JSMockFunction.cpp +++ b/src/bun.js/bindings/JSMockFunction.cpp @@ -168,8 +168,6 @@ public: [](auto& spaces, auto&& space) { spaces.m_subspaceForJSMockImplementation = std::forward<decltype(space)>(space); }); } - static constexpr unsigned numberOfInternalFields = 2; - // either a function or a return value, depends on kind mutable JSC::WriteBarrier<Unknown> underlyingValue; diff --git a/src/bun.js/bindings/JSSink.cpp b/src/bun.js/bindings/JSSink.cpp index 09a5a396c..782c6e326 100644 --- a/src/bun.js/bindings/JSSink.cpp +++ b/src/bun.js/bindings/JSSink.cpp @@ -1,6 +1,6 @@ // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at 2023-07-17T20:32:20.223Z +// Generated by 'make generate-sink' // To regenerate this file, run: // // make generate-sink @@ -10,6 +10,7 @@ #include "BunClientData.h" #include "JSSink.h" +#include "AsyncContextFrame.h" #include "ActiveDOMObject.h" #include "ExtendedDOMClientIsoSubspaces.h" @@ -68,6 +69,8 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic JSC::JSValue readableStream = callFrame->argument(0); JSC::JSValue onPull = callFrame->argument(1); JSC::JSValue onClose = callFrame->argument(2); + JSC::JSValue asyncContext = callFrame->argument(3); + if (!readableStream.isObject()) { scope.throwException(globalObject, JSC::createTypeError(globalObject, "Expected ReadableStream"_s)); return JSC::JSValue::encode(JSC::jsUndefined()); @@ -75,22 +78,23 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic if (!onPull.isObject() || !onPull.isCallable()) { onPull = JSC::jsUndefined(); + } else if (!asyncContext.isUndefined()) { + onPull = AsyncContextFrame::create(globalObject, onPull, asyncContext); } if (!onClose.isObject() || !onClose.isCallable()) { onClose = JSC::jsUndefined(); + } else if (!asyncContext.isUndefined()) { + onClose = AsyncContextFrame::create(globalObject, onClose, asyncContext); } - JSC::JSFunction* onPullFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onPull); - JSC::JSFunction* onCloseFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onClose); - if (WebCore::JSReadableArrayBufferSinkController* ArrayBufferSinkController = JSC::jsDynamicCast<WebCore::JSReadableArrayBufferSinkController*>(callFrame->thisValue())) { if (ArrayBufferSinkController->wrapped() == nullptr) { scope.throwException(globalObject, JSC::createTypeError(globalObject, "Cannot start stream with closed controller"_s)); return JSC::JSValue::encode(JSC::jsUndefined()); } - ArrayBufferSinkController->start(globalObject, readableStream, onPullFunction, onCloseFunction); + ArrayBufferSinkController->start(globalObject, readableStream, onPull, onClose); } else if (WebCore::JSReadableFileSinkController* FileSinkController = JSC::jsDynamicCast<WebCore::JSReadableFileSinkController*>(callFrame->thisValue())) { @@ -99,7 +103,7 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic return JSC::JSValue::encode(JSC::jsUndefined()); } - FileSinkController->start(globalObject, readableStream, onPullFunction, onCloseFunction); + FileSinkController->start(globalObject, readableStream, onPull, onClose); } else if (WebCore::JSReadableHTTPResponseSinkController* HTTPResponseSinkController = JSC::jsDynamicCast<WebCore::JSReadableHTTPResponseSinkController*>(callFrame->thisValue())) { @@ -108,7 +112,7 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic return JSC::JSValue::encode(JSC::jsUndefined()); } - HTTPResponseSinkController->start(globalObject, readableStream, onPullFunction, onCloseFunction); + HTTPResponseSinkController->start(globalObject, readableStream, onPull, onClose); } else if (WebCore::JSReadableHTTPSResponseSinkController* HTTPSResponseSinkController = JSC::jsDynamicCast<WebCore::JSReadableHTTPSResponseSinkController*>(callFrame->thisValue())) { @@ -117,7 +121,7 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic return JSC::JSValue::encode(JSC::jsUndefined()); } - HTTPSResponseSinkController->start(globalObject, readableStream, onPullFunction, onCloseFunction); + HTTPSResponseSinkController->start(globalObject, readableStream, onPull, onClose); } else { @@ -927,7 +931,7 @@ void JSArrayBufferSink::visitChildrenImpl(JSCell* cell, Visitor& visitor) DEFINE_VISIT_CHILDREN(JSArrayBufferSink); -void JSReadableArrayBufferSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose) +void JSReadableArrayBufferSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSValue onPull, JSC::JSValue onClose) { this->m_weakReadableStream = JSC::Weak<JSC::JSObject>(readableStream.getObject()); this->m_onPull.set(globalObject->vm(), this, onPull); @@ -1181,7 +1185,7 @@ void JSFileSink::visitChildrenImpl(JSCell* cell, Visitor& visitor) DEFINE_VISIT_CHILDREN(JSFileSink); -void JSReadableFileSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose) +void JSReadableFileSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSValue onPull, JSC::JSValue onClose) { this->m_weakReadableStream = JSC::Weak<JSC::JSObject>(readableStream.getObject()); this->m_onPull.set(globalObject->vm(), this, onPull); @@ -1435,7 +1439,7 @@ void JSHTTPResponseSink::visitChildrenImpl(JSCell* cell, Visitor& visitor) DEFINE_VISIT_CHILDREN(JSHTTPResponseSink); -void JSReadableHTTPResponseSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose) +void JSReadableHTTPResponseSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSValue onPull, JSC::JSValue onClose) { this->m_weakReadableStream = JSC::Weak<JSC::JSObject>(readableStream.getObject()); this->m_onPull.set(globalObject->vm(), this, onPull); @@ -1689,7 +1693,7 @@ void JSHTTPSResponseSink::visitChildrenImpl(JSCell* cell, Visitor& visitor) DEFINE_VISIT_CHILDREN(JSHTTPSResponseSink); -void JSReadableHTTPSResponseSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose) +void JSReadableHTTPSResponseSinkController::start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSValue onPull, JSC::JSValue onClose) { this->m_weakReadableStream = JSC::Weak<JSC::JSObject>(readableStream.getObject()); this->m_onPull.set(globalObject->vm(), this, onPull); @@ -1824,18 +1828,17 @@ extern "C" void ArrayBufferSink__onReady(JSC__JSValue controllerValue, JSC__JSVa { WebCore::JSReadableArrayBufferSinkController* controller = JSC::jsCast<WebCore::JSReadableArrayBufferSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onPull.get(); - if (function == nullptr) + JSC::JSValue function = controller->m_onPull.get(); + if (!function) return; JSC::JSGlobalObject* globalObject = controller->globalObject(); - auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; arguments.append(controller); arguments.append(JSC::JSValue::decode(amt)); arguments.append(JSC::JSValue::decode(offset)); - JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); + AsyncContextFrame::call(globalObject, function, JSC::jsUndefined(), arguments); } extern "C" void ArrayBufferSink__onStart(JSC__JSValue controllerValue) @@ -1846,20 +1849,19 @@ extern "C" void ArrayBufferSink__onClose(JSC__JSValue controllerValue, JSC__JSVa { WebCore::JSReadableArrayBufferSinkController* controller = JSC::jsCast<WebCore::JSReadableArrayBufferSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onClose.get(); - if (function == nullptr) + JSC::JSValue function = controller->m_onClose.get(); + if (!function) return; // only call close once controller->m_onClose.clear(); JSC::JSGlobalObject* globalObject = controller->globalObject(); - auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; auto readableStream = controller->m_weakReadableStream.get(); arguments.append(readableStream ? readableStream : JSC::jsUndefined()); arguments.append(JSC::JSValue::decode(reason)); - JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); + AsyncContextFrame::call(globalObject, function, JSC::jsUndefined(), arguments); } extern "C" JSC__JSValue FileSink__createObject(JSC__JSGlobalObject* arg0, void* sinkPtr) @@ -1910,18 +1912,17 @@ extern "C" void FileSink__onReady(JSC__JSValue controllerValue, JSC__JSValue amt { WebCore::JSReadableFileSinkController* controller = JSC::jsCast<WebCore::JSReadableFileSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onPull.get(); - if (function == nullptr) + JSC::JSValue function = controller->m_onPull.get(); + if (!function) return; JSC::JSGlobalObject* globalObject = controller->globalObject(); - auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; arguments.append(controller); arguments.append(JSC::JSValue::decode(amt)); arguments.append(JSC::JSValue::decode(offset)); - JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); + AsyncContextFrame::call(globalObject, function, JSC::jsUndefined(), arguments); } extern "C" void FileSink__onStart(JSC__JSValue controllerValue) @@ -1932,20 +1933,19 @@ extern "C" void FileSink__onClose(JSC__JSValue controllerValue, JSC__JSValue rea { WebCore::JSReadableFileSinkController* controller = JSC::jsCast<WebCore::JSReadableFileSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onClose.get(); - if (function == nullptr) + JSC::JSValue function = controller->m_onClose.get(); + if (!function) return; // only call close once controller->m_onClose.clear(); JSC::JSGlobalObject* globalObject = controller->globalObject(); - auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; auto readableStream = controller->m_weakReadableStream.get(); arguments.append(readableStream ? readableStream : JSC::jsUndefined()); arguments.append(JSC::JSValue::decode(reason)); - JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); + AsyncContextFrame::call(globalObject, function, JSC::jsUndefined(), arguments); } extern "C" JSC__JSValue HTTPResponseSink__createObject(JSC__JSGlobalObject* arg0, void* sinkPtr) @@ -1996,18 +1996,17 @@ extern "C" void HTTPResponseSink__onReady(JSC__JSValue controllerValue, JSC__JSV { WebCore::JSReadableHTTPResponseSinkController* controller = JSC::jsCast<WebCore::JSReadableHTTPResponseSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onPull.get(); - if (function == nullptr) + JSC::JSValue function = controller->m_onPull.get(); + if (!function) return; JSC::JSGlobalObject* globalObject = controller->globalObject(); - auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; arguments.append(controller); arguments.append(JSC::JSValue::decode(amt)); arguments.append(JSC::JSValue::decode(offset)); - JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); + AsyncContextFrame::call(globalObject, function, JSC::jsUndefined(), arguments); } extern "C" void HTTPResponseSink__onStart(JSC__JSValue controllerValue) @@ -2018,20 +2017,19 @@ extern "C" void HTTPResponseSink__onClose(JSC__JSValue controllerValue, JSC__JSV { WebCore::JSReadableHTTPResponseSinkController* controller = JSC::jsCast<WebCore::JSReadableHTTPResponseSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onClose.get(); - if (function == nullptr) + JSC::JSValue function = controller->m_onClose.get(); + if (!function) return; // only call close once controller->m_onClose.clear(); JSC::JSGlobalObject* globalObject = controller->globalObject(); - auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; auto readableStream = controller->m_weakReadableStream.get(); arguments.append(readableStream ? readableStream : JSC::jsUndefined()); arguments.append(JSC::JSValue::decode(reason)); - JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); + AsyncContextFrame::call(globalObject, function, JSC::jsUndefined(), arguments); } extern "C" JSC__JSValue HTTPSResponseSink__createObject(JSC__JSGlobalObject* arg0, void* sinkPtr) @@ -2082,18 +2080,17 @@ extern "C" void HTTPSResponseSink__onReady(JSC__JSValue controllerValue, JSC__JS { WebCore::JSReadableHTTPSResponseSinkController* controller = JSC::jsCast<WebCore::JSReadableHTTPSResponseSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onPull.get(); - if (function == nullptr) + JSC::JSValue function = controller->m_onPull.get(); + if (!function) return; JSC::JSGlobalObject* globalObject = controller->globalObject(); - auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; arguments.append(controller); arguments.append(JSC::JSValue::decode(amt)); arguments.append(JSC::JSValue::decode(offset)); - JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); + AsyncContextFrame::call(globalObject, function, JSC::jsUndefined(), arguments); } extern "C" void HTTPSResponseSink__onStart(JSC__JSValue controllerValue) @@ -2104,18 +2101,17 @@ extern "C" void HTTPSResponseSink__onClose(JSC__JSValue controllerValue, JSC__JS { WebCore::JSReadableHTTPSResponseSinkController* controller = JSC::jsCast<WebCore::JSReadableHTTPSResponseSinkController*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction* function = controller->m_onClose.get(); - if (function == nullptr) + JSC::JSValue function = controller->m_onClose.get(); + if (!function) return; // only call close once controller->m_onClose.clear(); JSC::JSGlobalObject* globalObject = controller->globalObject(); - auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; auto readableStream = controller->m_weakReadableStream.get(); arguments.append(readableStream ? readableStream : JSC::jsUndefined()); arguments.append(JSC::JSValue::decode(reason)); - JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); + AsyncContextFrame::call(globalObject, function, JSC::jsUndefined(), arguments); } diff --git a/src/bun.js/bindings/JSSink.h b/src/bun.js/bindings/JSSink.h index 46111a0a2..3a419562d 100644 --- a/src/bun.js/bindings/JSSink.h +++ b/src/bun.js/bindings/JSSink.h @@ -1,6 +1,6 @@ // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at 2023-07-17T20:32:20.222Z +// Generated by 'make generate-sink' // #pragma once @@ -143,14 +143,14 @@ public: void* wrapped() const { return m_sinkPtr; } void detach(); - void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose); + void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSValue onPull, JSC::JSValue onClose); DECLARE_VISIT_CHILDREN; static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); void* m_sinkPtr; - mutable WriteBarrier<JSC::JSFunction> m_onPull; - mutable WriteBarrier<JSC::JSFunction> m_onClose; + mutable WriteBarrier<JSC::Unknown> m_onPull; + mutable WriteBarrier<JSC::Unknown> m_onClose; mutable JSC::Weak<JSObject> m_weakReadableStream; JSReadableArrayBufferSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) @@ -290,14 +290,14 @@ public: void* wrapped() const { return m_sinkPtr; } void detach(); - void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose); + void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSValue onPull, JSC::JSValue onClose); DECLARE_VISIT_CHILDREN; static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); void* m_sinkPtr; - mutable WriteBarrier<JSC::JSFunction> m_onPull; - mutable WriteBarrier<JSC::JSFunction> m_onClose; + mutable WriteBarrier<JSC::Unknown> m_onPull; + mutable WriteBarrier<JSC::Unknown> m_onClose; mutable JSC::Weak<JSObject> m_weakReadableStream; JSReadableFileSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) @@ -437,14 +437,14 @@ public: void* wrapped() const { return m_sinkPtr; } void detach(); - void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose); + void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSValue onPull, JSC::JSValue onClose); DECLARE_VISIT_CHILDREN; static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); void* m_sinkPtr; - mutable WriteBarrier<JSC::JSFunction> m_onPull; - mutable WriteBarrier<JSC::JSFunction> m_onClose; + mutable WriteBarrier<JSC::Unknown> m_onPull; + mutable WriteBarrier<JSC::Unknown> m_onClose; mutable JSC::Weak<JSObject> m_weakReadableStream; JSReadableHTTPResponseSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) @@ -584,14 +584,14 @@ public: void* wrapped() const { return m_sinkPtr; } void detach(); - void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSFunction* onPull, JSC::JSFunction* onClose); + void start(JSC::JSGlobalObject* globalObject, JSC::JSValue readableStream, JSC::JSValue onPull, JSC::JSValue onClose); DECLARE_VISIT_CHILDREN; static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); void* m_sinkPtr; - mutable WriteBarrier<JSC::JSFunction> m_onPull; - mutable WriteBarrier<JSC::JSFunction> m_onClose; + mutable WriteBarrier<JSC::Unknown> m_onPull; + mutable WriteBarrier<JSC::Unknown> m_onClose; mutable JSC::Weak<JSObject> m_weakReadableStream; JSReadableHTTPSResponseSinkController(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) diff --git a/src/bun.js/bindings/JSSinkLookupTable.h b/src/bun.js/bindings/JSSinkLookupTable.h index e4ed81629..b678db453 100644 --- a/src/bun.js/bindings/JSSinkLookupTable.h +++ b/src/bun.js/bindings/JSSinkLookupTable.h @@ -1,8 +1,4 @@ -// Automatically generated from src/bun.js/bindings/JSSink.cpp using /home/cirospaciari/Repos/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT! - - - - +// Automatically generated from src/bun.js/bindings/JSSink.cpp using /Users/dave/code/bun/src/bun.js/WebKit/Source/JavaScriptCore/create_hash_table. DO NOT EDIT! static const struct CompactHashIndex JSArrayBufferSinkPrototypeTableIndex[19] = { { -1, -1 }, @@ -27,23 +23,16 @@ static const struct CompactHashIndex JSArrayBufferSinkPrototypeTableIndex[19] = }; static const struct HashTableValue JSArrayBufferSinkPrototypeTableValues[7] = { - { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__doClose, 0 } }, - { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__flush, 1 } }, - { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__end, 0 } }, - { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__start, 1 } }, - { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__write, 1 } }, - { "ref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__ref, 0 } }, - { "unref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__unref, 0 } }, + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__doClose, 0 } }, + { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__flush, 1 } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__end, 0 } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__start, 1 } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__write, 1 } }, + { "ref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__ref, 0 } }, + { "unref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__unref, 0 } }, }; -static const struct HashTable JSArrayBufferSinkPrototypeTable = - { 7, 15, false, nullptr, JSArrayBufferSinkPrototypeTableValues, JSArrayBufferSinkPrototypeTableIndex }; - - - - - - +static const struct HashTable JSArrayBufferSinkPrototypeTable = { 7, 15, false, nullptr, JSArrayBufferSinkPrototypeTableValues, JSArrayBufferSinkPrototypeTableIndex }; static const struct CompactHashIndex JSReadableArrayBufferSinkControllerPrototypeTableIndex[19] = { { -1, -1 }, @@ -68,21 +57,14 @@ static const struct CompactHashIndex JSReadableArrayBufferSinkControllerPrototyp }; static const struct HashTableValue JSReadableArrayBufferSinkControllerPrototypeTableValues[5] = { - { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableArrayBufferSinkController__close, 0 } }, - { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__flush, 1 } }, - { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableArrayBufferSinkController__end, 0 } }, - { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__start, 1 } }, - { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__write, 1 } }, + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableArrayBufferSinkController__close, 0 } }, + { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__flush, 1 } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableArrayBufferSinkController__end, 0 } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__start, 1 } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, ArrayBufferSink__write, 1 } }, }; -static const struct HashTable JSReadableArrayBufferSinkControllerPrototypeTable = - { 5, 15, false, nullptr, JSReadableArrayBufferSinkControllerPrototypeTableValues, JSReadableArrayBufferSinkControllerPrototypeTableIndex }; - - - - - - +static const struct HashTable JSReadableArrayBufferSinkControllerPrototypeTable = { 5, 15, false, nullptr, JSReadableArrayBufferSinkControllerPrototypeTableValues, JSReadableArrayBufferSinkControllerPrototypeTableIndex }; static const struct CompactHashIndex JSFileSinkPrototypeTableIndex[19] = { { -1, -1 }, @@ -107,23 +89,16 @@ static const struct CompactHashIndex JSFileSinkPrototypeTableIndex[19] = { }; static const struct HashTableValue JSFileSinkPrototypeTableValues[7] = { - { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__doClose, 0 } }, - { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__flush, 1 } }, - { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__end, 0 } }, - { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__start, 1 } }, - { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__write, 1 } }, - { "ref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__ref, 0 } }, - { "unref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__unref, 0 } }, + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__doClose, 0 } }, + { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__flush, 1 } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__end, 0 } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__start, 1 } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__write, 1 } }, + { "ref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__ref, 0 } }, + { "unref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__unref, 0 } }, }; -static const struct HashTable JSFileSinkPrototypeTable = - { 7, 15, false, nullptr, JSFileSinkPrototypeTableValues, JSFileSinkPrototypeTableIndex }; - - - - - - +static const struct HashTable JSFileSinkPrototypeTable = { 7, 15, false, nullptr, JSFileSinkPrototypeTableValues, JSFileSinkPrototypeTableIndex }; static const struct CompactHashIndex JSReadableFileSinkControllerPrototypeTableIndex[19] = { { -1, -1 }, @@ -148,21 +123,14 @@ static const struct CompactHashIndex JSReadableFileSinkControllerPrototypeTableI }; static const struct HashTableValue JSReadableFileSinkControllerPrototypeTableValues[5] = { - { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableFileSinkController__close, 0 } }, - { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__flush, 1 } }, - { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableFileSinkController__end, 0 } }, - { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__start, 1 } }, - { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__write, 1 } }, + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableFileSinkController__close, 0 } }, + { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__flush, 1 } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableFileSinkController__end, 0 } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__start, 1 } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, FileSink__write, 1 } }, }; -static const struct HashTable JSReadableFileSinkControllerPrototypeTable = - { 5, 15, false, nullptr, JSReadableFileSinkControllerPrototypeTableValues, JSReadableFileSinkControllerPrototypeTableIndex }; - - - - - - +static const struct HashTable JSReadableFileSinkControllerPrototypeTable = { 5, 15, false, nullptr, JSReadableFileSinkControllerPrototypeTableValues, JSReadableFileSinkControllerPrototypeTableIndex }; static const struct CompactHashIndex JSHTTPResponseSinkPrototypeTableIndex[19] = { { -1, -1 }, @@ -187,23 +155,16 @@ static const struct CompactHashIndex JSHTTPResponseSinkPrototypeTableIndex[19] = }; static const struct HashTableValue JSHTTPResponseSinkPrototypeTableValues[7] = { - { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__doClose, 0 } }, - { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__flush, 1 } }, - { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__end, 0 } }, - { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__start, 1 } }, - { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__write, 1 } }, - { "ref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__ref, 0 } }, - { "unref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__unref, 0 } }, + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__doClose, 0 } }, + { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__flush, 1 } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__end, 0 } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__start, 1 } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__write, 1 } }, + { "ref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__ref, 0 } }, + { "unref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__unref, 0 } }, }; -static const struct HashTable JSHTTPResponseSinkPrototypeTable = - { 7, 15, false, nullptr, JSHTTPResponseSinkPrototypeTableValues, JSHTTPResponseSinkPrototypeTableIndex }; - - - - - - +static const struct HashTable JSHTTPResponseSinkPrototypeTable = { 7, 15, false, nullptr, JSHTTPResponseSinkPrototypeTableValues, JSHTTPResponseSinkPrototypeTableIndex }; static const struct CompactHashIndex JSReadableHTTPResponseSinkControllerPrototypeTableIndex[19] = { { -1, -1 }, @@ -228,21 +189,14 @@ static const struct CompactHashIndex JSReadableHTTPResponseSinkControllerPrototy }; static const struct HashTableValue JSReadableHTTPResponseSinkControllerPrototypeTableValues[5] = { - { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableHTTPResponseSinkController__close, 0 } }, - { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__flush, 1 } }, - { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableHTTPResponseSinkController__end, 0 } }, - { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__start, 1 } }, - { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__write, 1 } }, + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableHTTPResponseSinkController__close, 0 } }, + { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__flush, 1 } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableHTTPResponseSinkController__end, 0 } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__start, 1 } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPResponseSink__write, 1 } }, }; -static const struct HashTable JSReadableHTTPResponseSinkControllerPrototypeTable = - { 5, 15, false, nullptr, JSReadableHTTPResponseSinkControllerPrototypeTableValues, JSReadableHTTPResponseSinkControllerPrototypeTableIndex }; - - - - - - +static const struct HashTable JSReadableHTTPResponseSinkControllerPrototypeTable = { 5, 15, false, nullptr, JSReadableHTTPResponseSinkControllerPrototypeTableValues, JSReadableHTTPResponseSinkControllerPrototypeTableIndex }; static const struct CompactHashIndex JSHTTPSResponseSinkPrototypeTableIndex[19] = { { -1, -1 }, @@ -267,23 +221,16 @@ static const struct CompactHashIndex JSHTTPSResponseSinkPrototypeTableIndex[19] }; static const struct HashTableValue JSHTTPSResponseSinkPrototypeTableValues[7] = { - { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__doClose, 0 } }, - { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__flush, 1 } }, - { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__end, 0 } }, - { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__start, 1 } }, - { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__write, 1 } }, - { "ref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__ref, 0 } }, - { "unref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__unref, 0 } }, + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__doClose, 0 } }, + { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__flush, 1 } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__end, 0 } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__start, 1 } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__write, 1 } }, + { "ref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__ref, 0 } }, + { "unref"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__unref, 0 } }, }; -static const struct HashTable JSHTTPSResponseSinkPrototypeTable = - { 7, 15, false, nullptr, JSHTTPSResponseSinkPrototypeTableValues, JSHTTPSResponseSinkPrototypeTableIndex }; - - - - - - +static const struct HashTable JSHTTPSResponseSinkPrototypeTable = { 7, 15, false, nullptr, JSHTTPSResponseSinkPrototypeTableValues, JSHTTPSResponseSinkPrototypeTableIndex }; static const struct CompactHashIndex JSReadableHTTPSResponseSinkControllerPrototypeTableIndex[19] = { { -1, -1 }, @@ -308,14 +255,11 @@ static const struct CompactHashIndex JSReadableHTTPSResponseSinkControllerProtot }; static const struct HashTableValue JSReadableHTTPSResponseSinkControllerPrototypeTableValues[5] = { - { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableHTTPSResponseSinkController__close, 0 } }, - { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__flush, 1 } }, - { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableHTTPSResponseSinkController__end, 0 } }, - { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__start, 1 } }, - { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly|PropertyAttribute::DontDelete|PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__write, 1 } }, + { "close"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableHTTPSResponseSinkController__close, 0 } }, + { "flush"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__flush, 1 } }, + { "end"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, JSReadableHTTPSResponseSinkController__end, 0 } }, + { "start"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__start, 1 } }, + { "write"_s, static_cast<unsigned>(PropertyAttribute::ReadOnly | PropertyAttribute::DontDelete | PropertyAttribute::Function), NoIntrinsic, { HashTableValue::NativeFunctionType, HTTPSResponseSink__write, 1 } }, }; -static const struct HashTable JSReadableHTTPSResponseSinkControllerPrototypeTable = - { 5, 15, false, nullptr, JSReadableHTTPSResponseSinkControllerPrototypeTableValues, JSReadableHTTPSResponseSinkControllerPrototypeTableIndex }; - - +static const struct HashTable JSReadableHTTPSResponseSinkControllerPrototypeTable = { 5, 15, false, nullptr, JSReadableHTTPSResponseSinkControllerPrototypeTableValues, JSReadableHTTPSResponseSinkControllerPrototypeTableIndex }; diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 6c58c94dd..5d44bbae4 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -1,4 +1,5 @@ #include "Process.h" +#include "JavaScriptCore/InternalFieldTuple.h" #include "JavaScriptCore/JSMicrotask.h" #include "JavaScriptCore/ObjectConstructor.h" #include "JavaScriptCore/NumberPrototype.h" @@ -179,22 +180,19 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionNextTick, } Zig::GlobalObject* global = JSC::jsCast<Zig::GlobalObject*>(globalObject); + JSC::JSValue asyncContextValue = globalObject->m_asyncContextData.get()->getInternalField(0); switch (callFrame->argumentCount()) { case 1: { - global->queueMicrotask(global->performMicrotaskFunction(), job, JSC::JSValue {}, JSC::JSValue {}, JSC::JSValue {}); + global->queueMicrotask(global->performMicrotaskFunction(), job, asyncContextValue, JSC::JSValue {}, JSC::JSValue {}); break; } case 2: { - global->queueMicrotask(global->performMicrotaskFunction(), job, callFrame->uncheckedArgument(1), JSC::JSValue {}, JSC::JSValue {}); + global->queueMicrotask(global->performMicrotaskFunction(), job, asyncContextValue, callFrame->uncheckedArgument(1), JSC::JSValue {}); break; } case 3: { - global->queueMicrotask(global->performMicrotaskFunction(), job, callFrame->uncheckedArgument(1), callFrame->uncheckedArgument(2), JSC::JSValue {}); - break; - } - case 4: { - global->queueMicrotask(global->performMicrotaskFunction(), job, callFrame->uncheckedArgument(1), callFrame->uncheckedArgument(2), callFrame->uncheckedArgument(3)); + global->queueMicrotask(global->performMicrotaskFunction(), job, asyncContextValue, callFrame->uncheckedArgument(1), callFrame->uncheckedArgument(2)); break; } default: { @@ -210,7 +208,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionNextTick, } global->queueMicrotask( - global->performMicrotaskVariadicFunction(), job, args, JSValue {}, JSC::JSValue {}); + global->performMicrotaskVariadicFunction(), job, args, asyncContextValue, JSC::JSValue {}); break; } diff --git a/src/bun.js/bindings/WebCoreOpaqueRoot.h b/src/bun.js/bindings/WebCoreOpaqueRoot.h index 93388c5c0..dff351fd2 100644 --- a/src/bun.js/bindings/WebCoreOpaqueRoot.h +++ b/src/bun.js/bindings/WebCoreOpaqueRoot.h @@ -26,7 +26,6 @@ #pragma once - namespace WebCore { class WebCoreOpaqueRoot { @@ -37,7 +36,7 @@ public: { } - WebCoreOpaqueRoot(std::nullptr_t) { } + WebCoreOpaqueRoot(std::nullptr_t) {} bool isNode() const { return false; } void* pointer() const { return m_pointer; } diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h index f0d491c0b..0e0675c8f 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMClientIsoSubspaces.h @@ -1,35 +1,56 @@ std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBlob; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBlobConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBuildArtifact; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBlobConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBuildArtifact; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBuildMessage; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBuildMessageConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasher; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasherConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDirent; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDirentConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpect; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectAny; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForBuildMessageConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasher; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCryptoHasherConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDirent; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForDirentConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpect; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectAny; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectAnything; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectStringContaining; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForExpectStringMatching; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFSWatcher; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFileSystemRouter; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFileSystemRouterConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForListener; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForFileSystemRouterConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForListener; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD4; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD4Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD5; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD5Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMatchedRoute; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD4Constructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD5; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMD5Constructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMatchedRoute; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForNodeJSFS; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForNodeJSFSConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequest; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequestConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResolveMessage; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResolveMessageConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResponse; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResponseConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA1; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA1Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA224; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA224Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA256; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA256Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA384; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA384Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA512; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA512Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA512_256; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA512_256Constructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForServerWebSocket; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForServerWebSocketConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForStats; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForStatsConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSubprocess; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForNodeJSFSConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequest; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForRequestConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResolveMessage; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResolveMessageConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResponse; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForResponseConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA1; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA1Constructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA224; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA224Constructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA256; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA256Constructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA384; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA384Constructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA512; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA512Constructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA512_256; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSHA512_256Constructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForServerWebSocket; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForServerWebSocketConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForStats; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForStatsConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForSubprocess; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTCPSocket; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTLSSocket; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextDecoder; -std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextDecoderConstructor;std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTimeout; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTextDecoderConstructor; +std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTimeout; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTranspiler; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForTranspilerConstructor;
\ No newline at end of file diff --git a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h index 02a9adbca..f93cfac1e 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+DOMIsoSubspaces.h @@ -1,35 +1,56 @@ std::unique_ptr<IsoSubspace> m_subspaceForBlob; -std::unique_ptr<IsoSubspace> m_subspaceForBlobConstructor;std::unique_ptr<IsoSubspace> m_subspaceForBuildArtifact; +std::unique_ptr<IsoSubspace> m_subspaceForBlobConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForBuildArtifact; std::unique_ptr<IsoSubspace> m_subspaceForBuildMessage; -std::unique_ptr<IsoSubspace> m_subspaceForBuildMessageConstructor;std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasher; -std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasherConstructor;std::unique_ptr<IsoSubspace> m_subspaceForDirent; -std::unique_ptr<IsoSubspace> m_subspaceForDirentConstructor;std::unique_ptr<IsoSubspace> m_subspaceForExpect; -std::unique_ptr<IsoSubspace> m_subspaceForExpectConstructor;std::unique_ptr<IsoSubspace> m_subspaceForExpectAny; +std::unique_ptr<IsoSubspace> m_subspaceForBuildMessageConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasher; +std::unique_ptr<IsoSubspace> m_subspaceForCryptoHasherConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForDirent; +std::unique_ptr<IsoSubspace> m_subspaceForDirentConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForExpect; +std::unique_ptr<IsoSubspace> m_subspaceForExpectConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForExpectAny; std::unique_ptr<IsoSubspace> m_subspaceForExpectAnything; std::unique_ptr<IsoSubspace> m_subspaceForExpectStringContaining; std::unique_ptr<IsoSubspace> m_subspaceForExpectStringMatching; std::unique_ptr<IsoSubspace> m_subspaceForFSWatcher; std::unique_ptr<IsoSubspace> m_subspaceForFileSystemRouter; -std::unique_ptr<IsoSubspace> m_subspaceForFileSystemRouterConstructor;std::unique_ptr<IsoSubspace> m_subspaceForListener; +std::unique_ptr<IsoSubspace> m_subspaceForFileSystemRouterConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForListener; std::unique_ptr<IsoSubspace> m_subspaceForMD4; -std::unique_ptr<IsoSubspace> m_subspaceForMD4Constructor;std::unique_ptr<IsoSubspace> m_subspaceForMD5; -std::unique_ptr<IsoSubspace> m_subspaceForMD5Constructor;std::unique_ptr<IsoSubspace> m_subspaceForMatchedRoute; +std::unique_ptr<IsoSubspace> m_subspaceForMD4Constructor; +std::unique_ptr<IsoSubspace> m_subspaceForMD5; +std::unique_ptr<IsoSubspace> m_subspaceForMD5Constructor; +std::unique_ptr<IsoSubspace> m_subspaceForMatchedRoute; std::unique_ptr<IsoSubspace> m_subspaceForNodeJSFS; -std::unique_ptr<IsoSubspace> m_subspaceForNodeJSFSConstructor;std::unique_ptr<IsoSubspace> m_subspaceForRequest; -std::unique_ptr<IsoSubspace> m_subspaceForRequestConstructor;std::unique_ptr<IsoSubspace> m_subspaceForResolveMessage; -std::unique_ptr<IsoSubspace> m_subspaceForResolveMessageConstructor;std::unique_ptr<IsoSubspace> m_subspaceForResponse; -std::unique_ptr<IsoSubspace> m_subspaceForResponseConstructor;std::unique_ptr<IsoSubspace> m_subspaceForSHA1; -std::unique_ptr<IsoSubspace> m_subspaceForSHA1Constructor;std::unique_ptr<IsoSubspace> m_subspaceForSHA224; -std::unique_ptr<IsoSubspace> m_subspaceForSHA224Constructor;std::unique_ptr<IsoSubspace> m_subspaceForSHA256; -std::unique_ptr<IsoSubspace> m_subspaceForSHA256Constructor;std::unique_ptr<IsoSubspace> m_subspaceForSHA384; -std::unique_ptr<IsoSubspace> m_subspaceForSHA384Constructor;std::unique_ptr<IsoSubspace> m_subspaceForSHA512; -std::unique_ptr<IsoSubspace> m_subspaceForSHA512Constructor;std::unique_ptr<IsoSubspace> m_subspaceForSHA512_256; -std::unique_ptr<IsoSubspace> m_subspaceForSHA512_256Constructor;std::unique_ptr<IsoSubspace> m_subspaceForServerWebSocket; -std::unique_ptr<IsoSubspace> m_subspaceForServerWebSocketConstructor;std::unique_ptr<IsoSubspace> m_subspaceForStats; -std::unique_ptr<IsoSubspace> m_subspaceForStatsConstructor;std::unique_ptr<IsoSubspace> m_subspaceForSubprocess; +std::unique_ptr<IsoSubspace> m_subspaceForNodeJSFSConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForRequest; +std::unique_ptr<IsoSubspace> m_subspaceForRequestConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForResolveMessage; +std::unique_ptr<IsoSubspace> m_subspaceForResolveMessageConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForResponse; +std::unique_ptr<IsoSubspace> m_subspaceForResponseConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForSHA1; +std::unique_ptr<IsoSubspace> m_subspaceForSHA1Constructor; +std::unique_ptr<IsoSubspace> m_subspaceForSHA224; +std::unique_ptr<IsoSubspace> m_subspaceForSHA224Constructor; +std::unique_ptr<IsoSubspace> m_subspaceForSHA256; +std::unique_ptr<IsoSubspace> m_subspaceForSHA256Constructor; +std::unique_ptr<IsoSubspace> m_subspaceForSHA384; +std::unique_ptr<IsoSubspace> m_subspaceForSHA384Constructor; +std::unique_ptr<IsoSubspace> m_subspaceForSHA512; +std::unique_ptr<IsoSubspace> m_subspaceForSHA512Constructor; +std::unique_ptr<IsoSubspace> m_subspaceForSHA512_256; +std::unique_ptr<IsoSubspace> m_subspaceForSHA512_256Constructor; +std::unique_ptr<IsoSubspace> m_subspaceForServerWebSocket; +std::unique_ptr<IsoSubspace> m_subspaceForServerWebSocketConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForStats; +std::unique_ptr<IsoSubspace> m_subspaceForStatsConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForSubprocess; std::unique_ptr<IsoSubspace> m_subspaceForTCPSocket; std::unique_ptr<IsoSubspace> m_subspaceForTLSSocket; std::unique_ptr<IsoSubspace> m_subspaceForTextDecoder; -std::unique_ptr<IsoSubspace> m_subspaceForTextDecoderConstructor;std::unique_ptr<IsoSubspace> m_subspaceForTimeout; +std::unique_ptr<IsoSubspace> m_subspaceForTextDecoderConstructor; +std::unique_ptr<IsoSubspace> m_subspaceForTimeout; std::unique_ptr<IsoSubspace> m_subspaceForTranspiler; std::unique_ptr<IsoSubspace> m_subspaceForTranspilerConstructor;
\ No newline at end of file diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h index ac03032e6..b3e738abc 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureHeader.h @@ -1,204 +1,204 @@ JSC::Structure* JSBlobStructure() { return m_JSBlob.getInitializedOnMainThread(this); } - JSC::JSObject* JSBlobConstructor() { return m_JSBlob.constructorInitializedOnMainThread(this); } - JSC::JSValue JSBlobPrototype() { return m_JSBlob.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSBlob; - bool hasJSBlobSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSBlobSetterValue; +JSC::JSObject* JSBlobConstructor() { return m_JSBlob.constructorInitializedOnMainThread(this); } +JSC::JSValue JSBlobPrototype() { return m_JSBlob.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSBlob; +bool hasJSBlobSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSBlobSetterValue; JSC::Structure* JSBuildArtifactStructure() { return m_JSBuildArtifact.getInitializedOnMainThread(this); } - JSC::JSObject* JSBuildArtifactConstructor() { return m_JSBuildArtifact.constructorInitializedOnMainThread(this); } - JSC::JSValue JSBuildArtifactPrototype() { return m_JSBuildArtifact.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSBuildArtifact; - bool hasJSBuildArtifactSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSBuildArtifactSetterValue; +JSC::JSObject* JSBuildArtifactConstructor() { return m_JSBuildArtifact.constructorInitializedOnMainThread(this); } +JSC::JSValue JSBuildArtifactPrototype() { return m_JSBuildArtifact.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSBuildArtifact; +bool hasJSBuildArtifactSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSBuildArtifactSetterValue; JSC::Structure* JSBuildMessageStructure() { return m_JSBuildMessage.getInitializedOnMainThread(this); } - JSC::JSObject* JSBuildMessageConstructor() { return m_JSBuildMessage.constructorInitializedOnMainThread(this); } - JSC::JSValue JSBuildMessagePrototype() { return m_JSBuildMessage.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSBuildMessage; - bool hasJSBuildMessageSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSBuildMessageSetterValue; +JSC::JSObject* JSBuildMessageConstructor() { return m_JSBuildMessage.constructorInitializedOnMainThread(this); } +JSC::JSValue JSBuildMessagePrototype() { return m_JSBuildMessage.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSBuildMessage; +bool hasJSBuildMessageSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSBuildMessageSetterValue; JSC::Structure* JSCryptoHasherStructure() { return m_JSCryptoHasher.getInitializedOnMainThread(this); } - JSC::JSObject* JSCryptoHasherConstructor() { return m_JSCryptoHasher.constructorInitializedOnMainThread(this); } - JSC::JSValue JSCryptoHasherPrototype() { return m_JSCryptoHasher.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSCryptoHasher; - bool hasJSCryptoHasherSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSCryptoHasherSetterValue; +JSC::JSObject* JSCryptoHasherConstructor() { return m_JSCryptoHasher.constructorInitializedOnMainThread(this); } +JSC::JSValue JSCryptoHasherPrototype() { return m_JSCryptoHasher.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSCryptoHasher; +bool hasJSCryptoHasherSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSCryptoHasherSetterValue; JSC::Structure* JSDirentStructure() { return m_JSDirent.getInitializedOnMainThread(this); } - JSC::JSObject* JSDirentConstructor() { return m_JSDirent.constructorInitializedOnMainThread(this); } - JSC::JSValue JSDirentPrototype() { return m_JSDirent.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSDirent; - bool hasJSDirentSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSDirentSetterValue; +JSC::JSObject* JSDirentConstructor() { return m_JSDirent.constructorInitializedOnMainThread(this); } +JSC::JSValue JSDirentPrototype() { return m_JSDirent.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSDirent; +bool hasJSDirentSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSDirentSetterValue; JSC::Structure* JSExpectStructure() { return m_JSExpect.getInitializedOnMainThread(this); } - JSC::JSObject* JSExpectConstructor() { return m_JSExpect.constructorInitializedOnMainThread(this); } - JSC::JSValue JSExpectPrototype() { return m_JSExpect.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSExpect; - bool hasJSExpectSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSExpectSetterValue; +JSC::JSObject* JSExpectConstructor() { return m_JSExpect.constructorInitializedOnMainThread(this); } +JSC::JSValue JSExpectPrototype() { return m_JSExpect.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSExpect; +bool hasJSExpectSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSExpectSetterValue; JSC::Structure* JSExpectAnyStructure() { return m_JSExpectAny.getInitializedOnMainThread(this); } - JSC::JSObject* JSExpectAnyConstructor() { return m_JSExpectAny.constructorInitializedOnMainThread(this); } - JSC::JSValue JSExpectAnyPrototype() { return m_JSExpectAny.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSExpectAny; - bool hasJSExpectAnySetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSExpectAnySetterValue; +JSC::JSObject* JSExpectAnyConstructor() { return m_JSExpectAny.constructorInitializedOnMainThread(this); } +JSC::JSValue JSExpectAnyPrototype() { return m_JSExpectAny.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSExpectAny; +bool hasJSExpectAnySetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSExpectAnySetterValue; JSC::Structure* JSExpectAnythingStructure() { return m_JSExpectAnything.getInitializedOnMainThread(this); } - JSC::JSObject* JSExpectAnythingConstructor() { return m_JSExpectAnything.constructorInitializedOnMainThread(this); } - JSC::JSValue JSExpectAnythingPrototype() { return m_JSExpectAnything.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSExpectAnything; - bool hasJSExpectAnythingSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSExpectAnythingSetterValue; +JSC::JSObject* JSExpectAnythingConstructor() { return m_JSExpectAnything.constructorInitializedOnMainThread(this); } +JSC::JSValue JSExpectAnythingPrototype() { return m_JSExpectAnything.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSExpectAnything; +bool hasJSExpectAnythingSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSExpectAnythingSetterValue; JSC::Structure* JSExpectStringContainingStructure() { return m_JSExpectStringContaining.getInitializedOnMainThread(this); } - JSC::JSObject* JSExpectStringContainingConstructor() { return m_JSExpectStringContaining.constructorInitializedOnMainThread(this); } - JSC::JSValue JSExpectStringContainingPrototype() { return m_JSExpectStringContaining.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSExpectStringContaining; - bool hasJSExpectStringContainingSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSExpectStringContainingSetterValue; +JSC::JSObject* JSExpectStringContainingConstructor() { return m_JSExpectStringContaining.constructorInitializedOnMainThread(this); } +JSC::JSValue JSExpectStringContainingPrototype() { return m_JSExpectStringContaining.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSExpectStringContaining; +bool hasJSExpectStringContainingSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSExpectStringContainingSetterValue; JSC::Structure* JSExpectStringMatchingStructure() { return m_JSExpectStringMatching.getInitializedOnMainThread(this); } - JSC::JSObject* JSExpectStringMatchingConstructor() { return m_JSExpectStringMatching.constructorInitializedOnMainThread(this); } - JSC::JSValue JSExpectStringMatchingPrototype() { return m_JSExpectStringMatching.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSExpectStringMatching; - bool hasJSExpectStringMatchingSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSExpectStringMatchingSetterValue; +JSC::JSObject* JSExpectStringMatchingConstructor() { return m_JSExpectStringMatching.constructorInitializedOnMainThread(this); } +JSC::JSValue JSExpectStringMatchingPrototype() { return m_JSExpectStringMatching.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSExpectStringMatching; +bool hasJSExpectStringMatchingSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSExpectStringMatchingSetterValue; JSC::Structure* JSFSWatcherStructure() { return m_JSFSWatcher.getInitializedOnMainThread(this); } - JSC::JSObject* JSFSWatcherConstructor() { return m_JSFSWatcher.constructorInitializedOnMainThread(this); } - JSC::JSValue JSFSWatcherPrototype() { return m_JSFSWatcher.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSFSWatcher; - bool hasJSFSWatcherSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSFSWatcherSetterValue; +JSC::JSObject* JSFSWatcherConstructor() { return m_JSFSWatcher.constructorInitializedOnMainThread(this); } +JSC::JSValue JSFSWatcherPrototype() { return m_JSFSWatcher.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSFSWatcher; +bool hasJSFSWatcherSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSFSWatcherSetterValue; JSC::Structure* JSFileSystemRouterStructure() { return m_JSFileSystemRouter.getInitializedOnMainThread(this); } - JSC::JSObject* JSFileSystemRouterConstructor() { return m_JSFileSystemRouter.constructorInitializedOnMainThread(this); } - JSC::JSValue JSFileSystemRouterPrototype() { return m_JSFileSystemRouter.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSFileSystemRouter; - bool hasJSFileSystemRouterSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSFileSystemRouterSetterValue; +JSC::JSObject* JSFileSystemRouterConstructor() { return m_JSFileSystemRouter.constructorInitializedOnMainThread(this); } +JSC::JSValue JSFileSystemRouterPrototype() { return m_JSFileSystemRouter.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSFileSystemRouter; +bool hasJSFileSystemRouterSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSFileSystemRouterSetterValue; JSC::Structure* JSListenerStructure() { return m_JSListener.getInitializedOnMainThread(this); } - JSC::JSObject* JSListenerConstructor() { return m_JSListener.constructorInitializedOnMainThread(this); } - JSC::JSValue JSListenerPrototype() { return m_JSListener.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSListener; - bool hasJSListenerSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSListenerSetterValue; +JSC::JSObject* JSListenerConstructor() { return m_JSListener.constructorInitializedOnMainThread(this); } +JSC::JSValue JSListenerPrototype() { return m_JSListener.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSListener; +bool hasJSListenerSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSListenerSetterValue; JSC::Structure* JSMD4Structure() { return m_JSMD4.getInitializedOnMainThread(this); } - JSC::JSObject* JSMD4Constructor() { return m_JSMD4.constructorInitializedOnMainThread(this); } - JSC::JSValue JSMD4Prototype() { return m_JSMD4.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSMD4; - bool hasJSMD4SetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSMD4SetterValue; +JSC::JSObject* JSMD4Constructor() { return m_JSMD4.constructorInitializedOnMainThread(this); } +JSC::JSValue JSMD4Prototype() { return m_JSMD4.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSMD4; +bool hasJSMD4SetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSMD4SetterValue; JSC::Structure* JSMD5Structure() { return m_JSMD5.getInitializedOnMainThread(this); } - JSC::JSObject* JSMD5Constructor() { return m_JSMD5.constructorInitializedOnMainThread(this); } - JSC::JSValue JSMD5Prototype() { return m_JSMD5.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSMD5; - bool hasJSMD5SetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSMD5SetterValue; +JSC::JSObject* JSMD5Constructor() { return m_JSMD5.constructorInitializedOnMainThread(this); } +JSC::JSValue JSMD5Prototype() { return m_JSMD5.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSMD5; +bool hasJSMD5SetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSMD5SetterValue; JSC::Structure* JSMatchedRouteStructure() { return m_JSMatchedRoute.getInitializedOnMainThread(this); } - JSC::JSObject* JSMatchedRouteConstructor() { return m_JSMatchedRoute.constructorInitializedOnMainThread(this); } - JSC::JSValue JSMatchedRoutePrototype() { return m_JSMatchedRoute.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSMatchedRoute; - bool hasJSMatchedRouteSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSMatchedRouteSetterValue; +JSC::JSObject* JSMatchedRouteConstructor() { return m_JSMatchedRoute.constructorInitializedOnMainThread(this); } +JSC::JSValue JSMatchedRoutePrototype() { return m_JSMatchedRoute.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSMatchedRoute; +bool hasJSMatchedRouteSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSMatchedRouteSetterValue; JSC::Structure* JSNodeJSFSStructure() { return m_JSNodeJSFS.getInitializedOnMainThread(this); } - JSC::JSObject* JSNodeJSFSConstructor() { return m_JSNodeJSFS.constructorInitializedOnMainThread(this); } - JSC::JSValue JSNodeJSFSPrototype() { return m_JSNodeJSFS.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSNodeJSFS; - bool hasJSNodeJSFSSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSNodeJSFSSetterValue; +JSC::JSObject* JSNodeJSFSConstructor() { return m_JSNodeJSFS.constructorInitializedOnMainThread(this); } +JSC::JSValue JSNodeJSFSPrototype() { return m_JSNodeJSFS.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSNodeJSFS; +bool hasJSNodeJSFSSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSNodeJSFSSetterValue; JSC::Structure* JSRequestStructure() { return m_JSRequest.getInitializedOnMainThread(this); } - JSC::JSObject* JSRequestConstructor() { return m_JSRequest.constructorInitializedOnMainThread(this); } - JSC::JSValue JSRequestPrototype() { return m_JSRequest.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSRequest; - bool hasJSRequestSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSRequestSetterValue; +JSC::JSObject* JSRequestConstructor() { return m_JSRequest.constructorInitializedOnMainThread(this); } +JSC::JSValue JSRequestPrototype() { return m_JSRequest.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSRequest; +bool hasJSRequestSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSRequestSetterValue; JSC::Structure* JSResolveMessageStructure() { return m_JSResolveMessage.getInitializedOnMainThread(this); } - JSC::JSObject* JSResolveMessageConstructor() { return m_JSResolveMessage.constructorInitializedOnMainThread(this); } - JSC::JSValue JSResolveMessagePrototype() { return m_JSResolveMessage.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSResolveMessage; - bool hasJSResolveMessageSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSResolveMessageSetterValue; +JSC::JSObject* JSResolveMessageConstructor() { return m_JSResolveMessage.constructorInitializedOnMainThread(this); } +JSC::JSValue JSResolveMessagePrototype() { return m_JSResolveMessage.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSResolveMessage; +bool hasJSResolveMessageSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSResolveMessageSetterValue; JSC::Structure* JSResponseStructure() { return m_JSResponse.getInitializedOnMainThread(this); } - JSC::JSObject* JSResponseConstructor() { return m_JSResponse.constructorInitializedOnMainThread(this); } - JSC::JSValue JSResponsePrototype() { return m_JSResponse.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSResponse; - bool hasJSResponseSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSResponseSetterValue; +JSC::JSObject* JSResponseConstructor() { return m_JSResponse.constructorInitializedOnMainThread(this); } +JSC::JSValue JSResponsePrototype() { return m_JSResponse.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSResponse; +bool hasJSResponseSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSResponseSetterValue; JSC::Structure* JSSHA1Structure() { return m_JSSHA1.getInitializedOnMainThread(this); } - JSC::JSObject* JSSHA1Constructor() { return m_JSSHA1.constructorInitializedOnMainThread(this); } - JSC::JSValue JSSHA1Prototype() { return m_JSSHA1.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSSHA1; - bool hasJSSHA1SetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSSHA1SetterValue; +JSC::JSObject* JSSHA1Constructor() { return m_JSSHA1.constructorInitializedOnMainThread(this); } +JSC::JSValue JSSHA1Prototype() { return m_JSSHA1.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSSHA1; +bool hasJSSHA1SetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSSHA1SetterValue; JSC::Structure* JSSHA224Structure() { return m_JSSHA224.getInitializedOnMainThread(this); } - JSC::JSObject* JSSHA224Constructor() { return m_JSSHA224.constructorInitializedOnMainThread(this); } - JSC::JSValue JSSHA224Prototype() { return m_JSSHA224.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSSHA224; - bool hasJSSHA224SetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSSHA224SetterValue; +JSC::JSObject* JSSHA224Constructor() { return m_JSSHA224.constructorInitializedOnMainThread(this); } +JSC::JSValue JSSHA224Prototype() { return m_JSSHA224.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSSHA224; +bool hasJSSHA224SetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSSHA224SetterValue; JSC::Structure* JSSHA256Structure() { return m_JSSHA256.getInitializedOnMainThread(this); } - JSC::JSObject* JSSHA256Constructor() { return m_JSSHA256.constructorInitializedOnMainThread(this); } - JSC::JSValue JSSHA256Prototype() { return m_JSSHA256.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSSHA256; - bool hasJSSHA256SetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSSHA256SetterValue; +JSC::JSObject* JSSHA256Constructor() { return m_JSSHA256.constructorInitializedOnMainThread(this); } +JSC::JSValue JSSHA256Prototype() { return m_JSSHA256.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSSHA256; +bool hasJSSHA256SetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSSHA256SetterValue; JSC::Structure* JSSHA384Structure() { return m_JSSHA384.getInitializedOnMainThread(this); } - JSC::JSObject* JSSHA384Constructor() { return m_JSSHA384.constructorInitializedOnMainThread(this); } - JSC::JSValue JSSHA384Prototype() { return m_JSSHA384.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSSHA384; - bool hasJSSHA384SetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSSHA384SetterValue; +JSC::JSObject* JSSHA384Constructor() { return m_JSSHA384.constructorInitializedOnMainThread(this); } +JSC::JSValue JSSHA384Prototype() { return m_JSSHA384.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSSHA384; +bool hasJSSHA384SetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSSHA384SetterValue; JSC::Structure* JSSHA512Structure() { return m_JSSHA512.getInitializedOnMainThread(this); } - JSC::JSObject* JSSHA512Constructor() { return m_JSSHA512.constructorInitializedOnMainThread(this); } - JSC::JSValue JSSHA512Prototype() { return m_JSSHA512.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSSHA512; - bool hasJSSHA512SetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSSHA512SetterValue; +JSC::JSObject* JSSHA512Constructor() { return m_JSSHA512.constructorInitializedOnMainThread(this); } +JSC::JSValue JSSHA512Prototype() { return m_JSSHA512.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSSHA512; +bool hasJSSHA512SetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSSHA512SetterValue; JSC::Structure* JSSHA512_256Structure() { return m_JSSHA512_256.getInitializedOnMainThread(this); } - JSC::JSObject* JSSHA512_256Constructor() { return m_JSSHA512_256.constructorInitializedOnMainThread(this); } - JSC::JSValue JSSHA512_256Prototype() { return m_JSSHA512_256.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSSHA512_256; - bool hasJSSHA512_256SetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSSHA512_256SetterValue; +JSC::JSObject* JSSHA512_256Constructor() { return m_JSSHA512_256.constructorInitializedOnMainThread(this); } +JSC::JSValue JSSHA512_256Prototype() { return m_JSSHA512_256.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSSHA512_256; +bool hasJSSHA512_256SetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSSHA512_256SetterValue; JSC::Structure* JSServerWebSocketStructure() { return m_JSServerWebSocket.getInitializedOnMainThread(this); } - JSC::JSObject* JSServerWebSocketConstructor() { return m_JSServerWebSocket.constructorInitializedOnMainThread(this); } - JSC::JSValue JSServerWebSocketPrototype() { return m_JSServerWebSocket.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSServerWebSocket; - bool hasJSServerWebSocketSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSServerWebSocketSetterValue; +JSC::JSObject* JSServerWebSocketConstructor() { return m_JSServerWebSocket.constructorInitializedOnMainThread(this); } +JSC::JSValue JSServerWebSocketPrototype() { return m_JSServerWebSocket.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSServerWebSocket; +bool hasJSServerWebSocketSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSServerWebSocketSetterValue; JSC::Structure* JSStatsStructure() { return m_JSStats.getInitializedOnMainThread(this); } - JSC::JSObject* JSStatsConstructor() { return m_JSStats.constructorInitializedOnMainThread(this); } - JSC::JSValue JSStatsPrototype() { return m_JSStats.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSStats; - bool hasJSStatsSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSStatsSetterValue; +JSC::JSObject* JSStatsConstructor() { return m_JSStats.constructorInitializedOnMainThread(this); } +JSC::JSValue JSStatsPrototype() { return m_JSStats.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSStats; +bool hasJSStatsSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSStatsSetterValue; JSC::Structure* JSSubprocessStructure() { return m_JSSubprocess.getInitializedOnMainThread(this); } - JSC::JSObject* JSSubprocessConstructor() { return m_JSSubprocess.constructorInitializedOnMainThread(this); } - JSC::JSValue JSSubprocessPrototype() { return m_JSSubprocess.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSSubprocess; - bool hasJSSubprocessSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSSubprocessSetterValue; +JSC::JSObject* JSSubprocessConstructor() { return m_JSSubprocess.constructorInitializedOnMainThread(this); } +JSC::JSValue JSSubprocessPrototype() { return m_JSSubprocess.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSSubprocess; +bool hasJSSubprocessSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSSubprocessSetterValue; JSC::Structure* JSTCPSocketStructure() { return m_JSTCPSocket.getInitializedOnMainThread(this); } - JSC::JSObject* JSTCPSocketConstructor() { return m_JSTCPSocket.constructorInitializedOnMainThread(this); } - JSC::JSValue JSTCPSocketPrototype() { return m_JSTCPSocket.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSTCPSocket; - bool hasJSTCPSocketSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSTCPSocketSetterValue; +JSC::JSObject* JSTCPSocketConstructor() { return m_JSTCPSocket.constructorInitializedOnMainThread(this); } +JSC::JSValue JSTCPSocketPrototype() { return m_JSTCPSocket.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSTCPSocket; +bool hasJSTCPSocketSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSTCPSocketSetterValue; JSC::Structure* JSTLSSocketStructure() { return m_JSTLSSocket.getInitializedOnMainThread(this); } - JSC::JSObject* JSTLSSocketConstructor() { return m_JSTLSSocket.constructorInitializedOnMainThread(this); } - JSC::JSValue JSTLSSocketPrototype() { return m_JSTLSSocket.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSTLSSocket; - bool hasJSTLSSocketSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSTLSSocketSetterValue; +JSC::JSObject* JSTLSSocketConstructor() { return m_JSTLSSocket.constructorInitializedOnMainThread(this); } +JSC::JSValue JSTLSSocketPrototype() { return m_JSTLSSocket.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSTLSSocket; +bool hasJSTLSSocketSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSTLSSocketSetterValue; JSC::Structure* JSTextDecoderStructure() { return m_JSTextDecoder.getInitializedOnMainThread(this); } - JSC::JSObject* JSTextDecoderConstructor() { return m_JSTextDecoder.constructorInitializedOnMainThread(this); } - JSC::JSValue JSTextDecoderPrototype() { return m_JSTextDecoder.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSTextDecoder; - bool hasJSTextDecoderSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSTextDecoderSetterValue; +JSC::JSObject* JSTextDecoderConstructor() { return m_JSTextDecoder.constructorInitializedOnMainThread(this); } +JSC::JSValue JSTextDecoderPrototype() { return m_JSTextDecoder.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSTextDecoder; +bool hasJSTextDecoderSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSTextDecoderSetterValue; JSC::Structure* JSTimeoutStructure() { return m_JSTimeout.getInitializedOnMainThread(this); } - JSC::JSObject* JSTimeoutConstructor() { return m_JSTimeout.constructorInitializedOnMainThread(this); } - JSC::JSValue JSTimeoutPrototype() { return m_JSTimeout.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSTimeout; - bool hasJSTimeoutSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSTimeoutSetterValue; +JSC::JSObject* JSTimeoutConstructor() { return m_JSTimeout.constructorInitializedOnMainThread(this); } +JSC::JSValue JSTimeoutPrototype() { return m_JSTimeout.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSTimeout; +bool hasJSTimeoutSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSTimeoutSetterValue; JSC::Structure* JSTranspilerStructure() { return m_JSTranspiler.getInitializedOnMainThread(this); } - JSC::JSObject* JSTranspilerConstructor() { return m_JSTranspiler.constructorInitializedOnMainThread(this); } - JSC::JSValue JSTranspilerPrototype() { return m_JSTranspiler.prototypeInitializedOnMainThread(this); } - JSC::LazyClassStructure m_JSTranspiler; - bool hasJSTranspilerSetterValue { false }; - mutable JSC::WriteBarrier<JSC::Unknown> m_JSTranspilerSetterValue;
\ No newline at end of file +JSC::JSObject* JSTranspilerConstructor() { return m_JSTranspiler.constructorInitializedOnMainThread(this); } +JSC::JSValue JSTranspilerPrototype() { return m_JSTranspiler.prototypeInitializedOnMainThread(this); } +JSC::LazyClassStructure m_JSTranspiler; +bool hasJSTranspilerSetterValue { false }; +mutable JSC::WriteBarrier<JSC::Unknown> m_JSTranspilerSetterValue;
\ No newline at end of file diff --git a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h index b3b5327a4..5ff00ee8a 100644 --- a/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h +++ b/src/bun.js/bindings/ZigGeneratedClasses+lazyStructureImpl.h @@ -1,244 +1,267 @@ -void GlobalObject::initGeneratedLazyClasses() { +void GlobalObject::initGeneratedLazyClasses() +{ m_JSBlob.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSBlob::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSBlob::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSBlob::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSBlob::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSBlob::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSBlob::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSBuildArtifact.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSBuildArtifact::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSBuildArtifact::createStructure(init.vm, init.global, init.prototype)); - - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSBuildArtifact::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSBuildArtifact::createStructure(init.vm, init.global, init.prototype)); + }); m_JSBuildMessage.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSBuildMessage::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSBuildMessage::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSBuildMessage::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSBuildMessage::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSBuildMessage::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSBuildMessage::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSCryptoHasher.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSCryptoHasher::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSCryptoHasher::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSCryptoHasher::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSCryptoHasher::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSCryptoHasher::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSCryptoHasher::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSDirent.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSDirent::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSDirent::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSDirent::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSDirent::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSDirent::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSDirent::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSExpect.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSExpect::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSExpect::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSExpect::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSExpect::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSExpect::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSExpect::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSExpectAny.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSExpectAny::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSExpectAny::createStructure(init.vm, init.global, init.prototype)); - - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSExpectAny::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSExpectAny::createStructure(init.vm, init.global, init.prototype)); + }); m_JSExpectAnything.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSExpectAnything::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSExpectAnything::createStructure(init.vm, init.global, init.prototype)); - - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSExpectAnything::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSExpectAnything::createStructure(init.vm, init.global, init.prototype)); + }); m_JSExpectStringContaining.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSExpectStringContaining::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSExpectStringContaining::createStructure(init.vm, init.global, init.prototype)); - - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSExpectStringContaining::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSExpectStringContaining::createStructure(init.vm, init.global, init.prototype)); + }); m_JSExpectStringMatching.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSExpectStringMatching::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSExpectStringMatching::createStructure(init.vm, init.global, init.prototype)); - - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSExpectStringMatching::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSExpectStringMatching::createStructure(init.vm, init.global, init.prototype)); + }); m_JSFSWatcher.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSFSWatcher::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSFSWatcher::createStructure(init.vm, init.global, init.prototype)); - - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSFSWatcher::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSFSWatcher::createStructure(init.vm, init.global, init.prototype)); + }); m_JSFileSystemRouter.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSFileSystemRouter::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSFileSystemRouter::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSFileSystemRouter::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSFileSystemRouter::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSFileSystemRouter::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSFileSystemRouter::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSListener.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSListener::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSListener::createStructure(init.vm, init.global, init.prototype)); - - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSListener::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSListener::createStructure(init.vm, init.global, init.prototype)); + }); m_JSMD4.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSMD4::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSMD4::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSMD4::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSMD4::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSMD4::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSMD4::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSMD5.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSMD5::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSMD5::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSMD5::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSMD5::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSMD5::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSMD5::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSMatchedRoute.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSMatchedRoute::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSMatchedRoute::createStructure(init.vm, init.global, init.prototype)); - - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSMatchedRoute::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSMatchedRoute::createStructure(init.vm, init.global, init.prototype)); + }); m_JSNodeJSFS.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSNodeJSFS::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSNodeJSFS::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSNodeJSFS::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSNodeJSFS::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSNodeJSFS::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSNodeJSFS::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSRequest.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSRequest::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSRequest::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSRequest::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSRequest::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSRequest::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSRequest::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSResolveMessage.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSResolveMessage::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSResolveMessage::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSResolveMessage::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSResolveMessage::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSResolveMessage::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSResolveMessage::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSResponse.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSResponse::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSResponse::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSResponse::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSResponse::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSResponse::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSResponse::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSSHA1.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSSHA1::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSSHA1::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSHA1::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSSHA1::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSSHA1::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSSHA1::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSSHA224.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSSHA224::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSSHA224::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSHA224::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSSHA224::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSSHA224::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSSHA224::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSSHA256.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSSHA256::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSSHA256::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSHA256::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSSHA256::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSSHA256::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSSHA256::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSSHA384.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSSHA384::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSSHA384::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSHA384::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSSHA384::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSSHA384::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSSHA384::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSSHA512.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSSHA512::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSSHA512::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSHA512::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSSHA512::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSSHA512::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSSHA512::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSSHA512_256.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSSHA512_256::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSSHA512_256::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSSHA512_256::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSSHA512_256::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSSHA512_256::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSSHA512_256::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSServerWebSocket.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSServerWebSocket::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSServerWebSocket::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSServerWebSocket::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSServerWebSocket::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSServerWebSocket::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSServerWebSocket::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSStats.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSStats::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSStats::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSStats::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSStats::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSStats::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSStats::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSSubprocess.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSSubprocess::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSSubprocess::createStructure(init.vm, init.global, init.prototype)); - - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSSubprocess::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSSubprocess::createStructure(init.vm, init.global, init.prototype)); + }); m_JSTCPSocket.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSTCPSocket::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSTCPSocket::createStructure(init.vm, init.global, init.prototype)); - - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSTCPSocket::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSTCPSocket::createStructure(init.vm, init.global, init.prototype)); + }); m_JSTLSSocket.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSTLSSocket::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSTLSSocket::createStructure(init.vm, init.global, init.prototype)); - - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSTLSSocket::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSTLSSocket::createStructure(init.vm, init.global, init.prototype)); + }); m_JSTextDecoder.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSTextDecoder::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSTextDecoder::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSTextDecoder::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSTextDecoder::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSTextDecoder::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSTextDecoder::createConstructor(init.vm, init.global, init.prototype)); + }); m_JSTimeout.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSTimeout::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSTimeout::createStructure(init.vm, init.global, init.prototype)); - - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSTimeout::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSTimeout::createStructure(init.vm, init.global, init.prototype)); + }); m_JSTranspiler.initLater( - [](LazyClassStructure::Initializer& init) { - init.setPrototype(WebCore::JSTranspiler::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); - init.setStructure(WebCore::JSTranspiler::createStructure(init.vm, init.global, init.prototype)); - init.setConstructor(WebCore::JSTranspiler::createConstructor(init.vm, init.global, init.prototype)); - }); + [](LazyClassStructure::Initializer& init) { + init.setPrototype(WebCore::JSTranspiler::createPrototype(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.global))); + init.setStructure(WebCore::JSTranspiler::createStructure(init.vm, init.global, init.prototype)); + init.setConstructor(WebCore::JSTranspiler::createConstructor(init.vm, init.global, init.prototype)); + }); } template<typename Visitor> -void GlobalObject::visitGeneratedLazyClasses(GlobalObject *thisObject, Visitor& visitor) +void GlobalObject::visitGeneratedLazyClasses(GlobalObject* thisObject, Visitor& visitor) { - thisObject->m_JSBlob.visit(visitor); visitor.append(thisObject->m_JSBlobSetterValue); - thisObject->m_JSBuildArtifact.visit(visitor); visitor.append(thisObject->m_JSBuildArtifactSetterValue); - thisObject->m_JSBuildMessage.visit(visitor); visitor.append(thisObject->m_JSBuildMessageSetterValue); - thisObject->m_JSCryptoHasher.visit(visitor); visitor.append(thisObject->m_JSCryptoHasherSetterValue); - thisObject->m_JSDirent.visit(visitor); visitor.append(thisObject->m_JSDirentSetterValue); - thisObject->m_JSExpect.visit(visitor); visitor.append(thisObject->m_JSExpectSetterValue); - thisObject->m_JSExpectAny.visit(visitor); visitor.append(thisObject->m_JSExpectAnySetterValue); - thisObject->m_JSExpectAnything.visit(visitor); visitor.append(thisObject->m_JSExpectAnythingSetterValue); - thisObject->m_JSExpectStringContaining.visit(visitor); visitor.append(thisObject->m_JSExpectStringContainingSetterValue); - thisObject->m_JSExpectStringMatching.visit(visitor); visitor.append(thisObject->m_JSExpectStringMatchingSetterValue); - thisObject->m_JSFSWatcher.visit(visitor); visitor.append(thisObject->m_JSFSWatcherSetterValue); - thisObject->m_JSFileSystemRouter.visit(visitor); visitor.append(thisObject->m_JSFileSystemRouterSetterValue); - thisObject->m_JSListener.visit(visitor); visitor.append(thisObject->m_JSListenerSetterValue); - thisObject->m_JSMD4.visit(visitor); visitor.append(thisObject->m_JSMD4SetterValue); - thisObject->m_JSMD5.visit(visitor); visitor.append(thisObject->m_JSMD5SetterValue); - thisObject->m_JSMatchedRoute.visit(visitor); visitor.append(thisObject->m_JSMatchedRouteSetterValue); - thisObject->m_JSNodeJSFS.visit(visitor); visitor.append(thisObject->m_JSNodeJSFSSetterValue); - thisObject->m_JSRequest.visit(visitor); visitor.append(thisObject->m_JSRequestSetterValue); - thisObject->m_JSResolveMessage.visit(visitor); visitor.append(thisObject->m_JSResolveMessageSetterValue); - thisObject->m_JSResponse.visit(visitor); visitor.append(thisObject->m_JSResponseSetterValue); - thisObject->m_JSSHA1.visit(visitor); visitor.append(thisObject->m_JSSHA1SetterValue); - thisObject->m_JSSHA224.visit(visitor); visitor.append(thisObject->m_JSSHA224SetterValue); - thisObject->m_JSSHA256.visit(visitor); visitor.append(thisObject->m_JSSHA256SetterValue); - thisObject->m_JSSHA384.visit(visitor); visitor.append(thisObject->m_JSSHA384SetterValue); - thisObject->m_JSSHA512.visit(visitor); visitor.append(thisObject->m_JSSHA512SetterValue); - thisObject->m_JSSHA512_256.visit(visitor); visitor.append(thisObject->m_JSSHA512_256SetterValue); - thisObject->m_JSServerWebSocket.visit(visitor); visitor.append(thisObject->m_JSServerWebSocketSetterValue); - thisObject->m_JSStats.visit(visitor); visitor.append(thisObject->m_JSStatsSetterValue); - thisObject->m_JSSubprocess.visit(visitor); visitor.append(thisObject->m_JSSubprocessSetterValue); - thisObject->m_JSTCPSocket.visit(visitor); visitor.append(thisObject->m_JSTCPSocketSetterValue); - thisObject->m_JSTLSSocket.visit(visitor); visitor.append(thisObject->m_JSTLSSocketSetterValue); - thisObject->m_JSTextDecoder.visit(visitor); visitor.append(thisObject->m_JSTextDecoderSetterValue); - thisObject->m_JSTimeout.visit(visitor); visitor.append(thisObject->m_JSTimeoutSetterValue); - thisObject->m_JSTranspiler.visit(visitor); visitor.append(thisObject->m_JSTranspilerSetterValue); + thisObject->m_JSBlob.visit(visitor); + visitor.append(thisObject->m_JSBlobSetterValue); + thisObject->m_JSBuildArtifact.visit(visitor); + visitor.append(thisObject->m_JSBuildArtifactSetterValue); + thisObject->m_JSBuildMessage.visit(visitor); + visitor.append(thisObject->m_JSBuildMessageSetterValue); + thisObject->m_JSCryptoHasher.visit(visitor); + visitor.append(thisObject->m_JSCryptoHasherSetterValue); + thisObject->m_JSDirent.visit(visitor); + visitor.append(thisObject->m_JSDirentSetterValue); + thisObject->m_JSExpect.visit(visitor); + visitor.append(thisObject->m_JSExpectSetterValue); + thisObject->m_JSExpectAny.visit(visitor); + visitor.append(thisObject->m_JSExpectAnySetterValue); + thisObject->m_JSExpectAnything.visit(visitor); + visitor.append(thisObject->m_JSExpectAnythingSetterValue); + thisObject->m_JSExpectStringContaining.visit(visitor); + visitor.append(thisObject->m_JSExpectStringContainingSetterValue); + thisObject->m_JSExpectStringMatching.visit(visitor); + visitor.append(thisObject->m_JSExpectStringMatchingSetterValue); + thisObject->m_JSFSWatcher.visit(visitor); + visitor.append(thisObject->m_JSFSWatcherSetterValue); + thisObject->m_JSFileSystemRouter.visit(visitor); + visitor.append(thisObject->m_JSFileSystemRouterSetterValue); + thisObject->m_JSListener.visit(visitor); + visitor.append(thisObject->m_JSListenerSetterValue); + thisObject->m_JSMD4.visit(visitor); + visitor.append(thisObject->m_JSMD4SetterValue); + thisObject->m_JSMD5.visit(visitor); + visitor.append(thisObject->m_JSMD5SetterValue); + thisObject->m_JSMatchedRoute.visit(visitor); + visitor.append(thisObject->m_JSMatchedRouteSetterValue); + thisObject->m_JSNodeJSFS.visit(visitor); + visitor.append(thisObject->m_JSNodeJSFSSetterValue); + thisObject->m_JSRequest.visit(visitor); + visitor.append(thisObject->m_JSRequestSetterValue); + thisObject->m_JSResolveMessage.visit(visitor); + visitor.append(thisObject->m_JSResolveMessageSetterValue); + thisObject->m_JSResponse.visit(visitor); + visitor.append(thisObject->m_JSResponseSetterValue); + thisObject->m_JSSHA1.visit(visitor); + visitor.append(thisObject->m_JSSHA1SetterValue); + thisObject->m_JSSHA224.visit(visitor); + visitor.append(thisObject->m_JSSHA224SetterValue); + thisObject->m_JSSHA256.visit(visitor); + visitor.append(thisObject->m_JSSHA256SetterValue); + thisObject->m_JSSHA384.visit(visitor); + visitor.append(thisObject->m_JSSHA384SetterValue); + thisObject->m_JSSHA512.visit(visitor); + visitor.append(thisObject->m_JSSHA512SetterValue); + thisObject->m_JSSHA512_256.visit(visitor); + visitor.append(thisObject->m_JSSHA512_256SetterValue); + thisObject->m_JSServerWebSocket.visit(visitor); + visitor.append(thisObject->m_JSServerWebSocketSetterValue); + thisObject->m_JSStats.visit(visitor); + visitor.append(thisObject->m_JSStatsSetterValue); + thisObject->m_JSSubprocess.visit(visitor); + visitor.append(thisObject->m_JSSubprocessSetterValue); + thisObject->m_JSTCPSocket.visit(visitor); + visitor.append(thisObject->m_JSTCPSocketSetterValue); + thisObject->m_JSTLSSocket.visit(visitor); + visitor.append(thisObject->m_JSTLSSocketSetterValue); + thisObject->m_JSTextDecoder.visit(visitor); + visitor.append(thisObject->m_JSTextDecoderSetterValue); + thisObject->m_JSTimeout.visit(visitor); + visitor.append(thisObject->m_JSTimeoutSetterValue); + thisObject->m_JSTranspiler.visit(visitor); + visitor.append(thisObject->m_JSTranspilerSetterValue); }
\ No newline at end of file diff --git a/src/bun.js/bindings/ZigGeneratedCode.cpp b/src/bun.js/bindings/ZigGeneratedCode.cpp index 29f92bab0..6a57e43ea 100644 --- a/src/bun.js/bindings/ZigGeneratedCode.cpp +++ b/src/bun.js/bindings/ZigGeneratedCode.cpp @@ -1,703 +1,670 @@ - #include "root.h" - #include "headers.h" - - #include <JavaScriptCore/DOMJITAbstractHeap.h> - #include "DOMJITIDLConvert.h" - #include "DOMJITIDLType.h" - #include "DOMJITIDLTypeFilter.h" - #include "DOMJITHelpers.h" - #include <JavaScriptCore/DFGAbstractHeap.h> - - #include "JSDOMConvertBufferSource.h" - - using namespace JSC; - using namespace WebCore; - - - /* -- BEGIN DOMCall DEFINITIONS -- */ - +#include "root.h" +#include "headers.h" -extern "C" JSC_DECLARE_HOST_FUNCTION(FFI__ptr__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(FFI__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, JSC::JSUint8Array*)); +#include <JavaScriptCore/DOMJITAbstractHeap.h> +#include "DOMJITIDLConvert.h" +#include "DOMJITIDLType.h" +#include "DOMJITIDLTypeFilter.h" +#include "DOMJITHelpers.h" +#include <JavaScriptCore/DFGAbstractHeap.h> -JSC_DEFINE_JIT_OPERATION(FFI__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg1)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return FFI__ptr__fastpath(lexicalGlobalObject, thisValue, arg1); -} -JSC_DEFINE_HOST_FUNCTION(FFI__ptr__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +#include "JSDOMConvertBufferSource.h" + +using namespace JSC; +using namespace WebCore; + +/* -- BEGIN DOMCall DEFINITIONS -- */ + +extern "C" JSC_DECLARE_HOST_FUNCTION(FFI__ptr__slowpathWrapper); +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(FFI__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array*)); + +JSC_DEFINE_JIT_OPERATION(FFI__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg1)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return FFI__ptr__fastpath(lexicalGlobalObject, thisValue, arg1); +} +JSC_DEFINE_HOST_FUNCTION(FFI__ptr__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return FFI__ptr__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void FFI__ptr__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_ptr_signature( - FFI__ptr__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecDoubleReal, - JSC::SpecUint8Array - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 1, - String("ptr"_s), - FFI__ptr__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, FFI__ptr__slowpathWrapper, - &DOMJIT_ptr_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "ptr"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void FFI__ptr__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_ptr_signature( + FFI__ptr__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecDoubleReal, + JSC::SpecUint8Array); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 1, + String("ptr"_s), + FFI__ptr__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, FFI__ptr__slowpathWrapper, + &DOMJIT_ptr_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "ptr"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__u8__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); - -JSC_DEFINE_JIT_OPERATION(Reader__u8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Reader__u8__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Reader__u8__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__u8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Reader__u8__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__u8__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Reader__u8__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Reader__u8__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_u8_signature( - Reader__u8__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecInt32Only, - JSC::SpecInt52Any, - JSC::SpecInt32Only - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("u8"_s), - Reader__u8__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u8__slowpathWrapper, - &DOMJIT_u8_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "u8"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Reader__u8__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_u8_signature( + Reader__u8__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt32Only, + JSC::SpecInt52Any, + JSC::SpecInt32Only); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("u8"_s), + Reader__u8__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u8__slowpathWrapper, + &DOMJIT_u8_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "u8"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__u16__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); - -JSC_DEFINE_JIT_OPERATION(Reader__u16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Reader__u16__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Reader__u16__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__u16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Reader__u16__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__u16__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Reader__u16__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Reader__u16__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_u16_signature( - Reader__u16__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecInt32Only, - JSC::SpecInt52Any, - JSC::SpecInt32Only - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("u16"_s), - Reader__u16__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u16__slowpathWrapper, - &DOMJIT_u16_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "u16"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Reader__u16__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_u16_signature( + Reader__u16__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt32Only, + JSC::SpecInt52Any, + JSC::SpecInt32Only); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("u16"_s), + Reader__u16__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u16__slowpathWrapper, + &DOMJIT_u16_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "u16"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__u32__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); - -JSC_DEFINE_JIT_OPERATION(Reader__u32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Reader__u32__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Reader__u32__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__u32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Reader__u32__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__u32__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Reader__u32__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Reader__u32__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_u32_signature( - Reader__u32__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecInt32Only, - JSC::SpecInt52Any, - JSC::SpecInt32Only - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("u32"_s), - Reader__u32__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u32__slowpathWrapper, - &DOMJIT_u32_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "u32"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Reader__u32__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_u32_signature( + Reader__u32__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt32Only, + JSC::SpecInt52Any, + JSC::SpecInt32Only); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("u32"_s), + Reader__u32__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u32__slowpathWrapper, + &DOMJIT_u32_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "u32"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__ptr__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); - -JSC_DEFINE_JIT_OPERATION(Reader__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Reader__ptr__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Reader__ptr__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Reader__ptr__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__ptr__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Reader__ptr__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Reader__ptr__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_ptr_signature( - Reader__ptr__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecInt52Any, - JSC::SpecInt52Any, - JSC::SpecInt32Only - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("ptr"_s), - Reader__ptr__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__ptr__slowpathWrapper, - &DOMJIT_ptr_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "ptr"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Reader__ptr__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_ptr_signature( + Reader__ptr__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt52Any, + JSC::SpecInt52Any, + JSC::SpecInt32Only); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("ptr"_s), + Reader__ptr__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__ptr__slowpathWrapper, + &DOMJIT_ptr_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "ptr"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__i8__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); - -JSC_DEFINE_JIT_OPERATION(Reader__i8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Reader__i8__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Reader__i8__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__i8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Reader__i8__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__i8__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Reader__i8__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Reader__i8__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_i8_signature( - Reader__i8__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecInt32Only, - JSC::SpecInt52Any, - JSC::SpecInt32Only - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("i8"_s), - Reader__i8__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i8__slowpathWrapper, - &DOMJIT_i8_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "i8"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Reader__i8__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_i8_signature( + Reader__i8__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt32Only, + JSC::SpecInt52Any, + JSC::SpecInt32Only); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("i8"_s), + Reader__i8__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i8__slowpathWrapper, + &DOMJIT_i8_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "i8"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__i16__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); - -JSC_DEFINE_JIT_OPERATION(Reader__i16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Reader__i16__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Reader__i16__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__i16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Reader__i16__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__i16__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Reader__i16__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Reader__i16__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_i16_signature( - Reader__i16__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecInt32Only, - JSC::SpecInt52Any, - JSC::SpecInt32Only - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("i16"_s), - Reader__i16__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i16__slowpathWrapper, - &DOMJIT_i16_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "i16"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Reader__i16__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_i16_signature( + Reader__i16__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt32Only, + JSC::SpecInt52Any, + JSC::SpecInt32Only); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("i16"_s), + Reader__i16__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i16__slowpathWrapper, + &DOMJIT_i16_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "i16"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__i32__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); - -JSC_DEFINE_JIT_OPERATION(Reader__i32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Reader__i32__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Reader__i32__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__i32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Reader__i32__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__i32__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Reader__i32__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Reader__i32__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_i32_signature( - Reader__i32__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecInt32Only, - JSC::SpecInt52Any, - JSC::SpecInt32Only - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("i32"_s), - Reader__i32__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i32__slowpathWrapper, - &DOMJIT_i32_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "i32"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Reader__i32__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_i32_signature( + Reader__i32__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt32Only, + JSC::SpecInt52Any, + JSC::SpecInt32Only); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("i32"_s), + Reader__i32__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i32__slowpathWrapper, + &DOMJIT_i32_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "i32"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__i64__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); - -JSC_DEFINE_JIT_OPERATION(Reader__i64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Reader__i64__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Reader__i64__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__i64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Reader__i64__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__i64__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Reader__i64__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Reader__i64__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_i64_signature( - Reader__i64__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecHeapTop, - JSC::SpecInt52Any, - JSC::SpecInt32Only - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("i64"_s), - Reader__i64__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i64__slowpathWrapper, - &DOMJIT_i64_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "i64"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Reader__i64__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_i64_signature( + Reader__i64__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecHeapTop, + JSC::SpecInt52Any, + JSC::SpecInt32Only); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("i64"_s), + Reader__i64__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i64__slowpathWrapper, + &DOMJIT_i64_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "i64"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__u64__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); - -JSC_DEFINE_JIT_OPERATION(Reader__u64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Reader__u64__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Reader__u64__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__u64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Reader__u64__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__u64__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Reader__u64__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Reader__u64__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_u64_signature( - Reader__u64__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecHeapTop, - JSC::SpecInt52Any, - JSC::SpecInt32Only - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("u64"_s), - Reader__u64__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u64__slowpathWrapper, - &DOMJIT_u64_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "u64"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Reader__u64__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_u64_signature( + Reader__u64__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecHeapTop, + JSC::SpecInt52Any, + JSC::SpecInt32Only); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("u64"_s), + Reader__u64__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u64__slowpathWrapper, + &DOMJIT_u64_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "u64"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__intptr__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__intptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); - -JSC_DEFINE_JIT_OPERATION(Reader__intptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Reader__intptr__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Reader__intptr__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__intptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__intptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Reader__intptr__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__intptr__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Reader__intptr__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Reader__intptr__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_intptr_signature( - Reader__intptr__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecInt52Any, - JSC::SpecInt52Any, - JSC::SpecInt32Only - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("intptr"_s), - Reader__intptr__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__intptr__slowpathWrapper, - &DOMJIT_intptr_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "intptr"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Reader__intptr__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_intptr_signature( + Reader__intptr__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecInt52Any, + JSC::SpecInt52Any, + JSC::SpecInt32Only); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("intptr"_s), + Reader__intptr__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__intptr__slowpathWrapper, + &DOMJIT_intptr_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "intptr"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__f32__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__f32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); - -JSC_DEFINE_JIT_OPERATION(Reader__f32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Reader__f32__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Reader__f32__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__f32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__f32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Reader__f32__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__f32__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Reader__f32__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Reader__f32__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_f32_signature( - Reader__f32__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecDoubleReal, - JSC::SpecInt52Any, - JSC::SpecInt32Only - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("f32"_s), - Reader__f32__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__f32__slowpathWrapper, - &DOMJIT_f32_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "f32"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Reader__f32__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_f32_signature( + Reader__f32__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecDoubleReal, + JSC::SpecInt52Any, + JSC::SpecInt32Only); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("f32"_s), + Reader__f32__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__f32__slowpathWrapper, + &DOMJIT_f32_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "f32"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Reader__f64__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__f64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t, int32_t)); - -JSC_DEFINE_JIT_OPERATION(Reader__f64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Reader__f64__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Reader__f64__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__f64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t)); + +JSC_DEFINE_JIT_OPERATION(Reader__f64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Reader__f64__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Reader__f64__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Reader__f64__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Reader__f64__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_f64_signature( - Reader__f64__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecDoubleReal, - JSC::SpecInt52Any, - JSC::SpecInt32Only - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("f64"_s), - Reader__f64__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__f64__slowpathWrapper, - &DOMJIT_f64_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "f64"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Reader__f64__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_f64_signature( + Reader__f64__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecDoubleReal, + JSC::SpecInt52Any, + JSC::SpecInt32Only); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("f64"_s), + Reader__f64__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__f64__slowpathWrapper, + &DOMJIT_f64_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "f64"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Crypto__getRandomValues__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Crypto__getRandomValues__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, JSC::JSUint8Array*)); - -JSC_DEFINE_JIT_OPERATION(Crypto__getRandomValues__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg1)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Crypto__getRandomValues__fastpath(lexicalGlobalObject, thisValue, arg1); -} -JSC_DEFINE_HOST_FUNCTION(Crypto__getRandomValues__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Crypto__getRandomValues__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array*)); + +JSC_DEFINE_JIT_OPERATION(Crypto__getRandomValues__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg1)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Crypto__getRandomValues__fastpath(lexicalGlobalObject, thisValue, arg1); +} +JSC_DEFINE_HOST_FUNCTION(Crypto__getRandomValues__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Crypto__getRandomValues__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Crypto__getRandomValues__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_getRandomValues_signature( - Crypto__getRandomValues__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecHeapTop, - JSC::SpecUint8Array - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 1, - String("getRandomValues"_s), - Crypto__getRandomValues__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Crypto__getRandomValues__slowpathWrapper, - &DOMJIT_getRandomValues_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "getRandomValues"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Crypto__getRandomValues__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_getRandomValues_signature( + Crypto__getRandomValues__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecHeapTop, + JSC::SpecUint8Array); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 1, + String("getRandomValues"_s), + Crypto__getRandomValues__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Crypto__getRandomValues__slowpathWrapper, + &DOMJIT_getRandomValues_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "getRandomValues"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Crypto__randomUUID__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Crypto__randomUUID__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue)); - -JSC_DEFINE_JIT_OPERATION(Crypto__randomUUID__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Crypto__randomUUID__fastpath(lexicalGlobalObject, thisValue); -} -JSC_DEFINE_HOST_FUNCTION(Crypto__randomUUID__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Crypto__randomUUID__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue)); + +JSC_DEFINE_JIT_OPERATION(Crypto__randomUUID__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Crypto__randomUUID__fastpath(lexicalGlobalObject, thisValue); +} +JSC_DEFINE_HOST_FUNCTION(Crypto__randomUUID__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Crypto__randomUUID__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Crypto__randomUUID__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_randomUUID_signature( - Crypto__randomUUID__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecString); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 0, - String("randomUUID"_s), - Crypto__randomUUID__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Crypto__randomUUID__slowpathWrapper, - &DOMJIT_randomUUID_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "randomUUID"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); +extern "C" void Crypto__randomUUID__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_randomUUID_signature( + Crypto__randomUUID__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecString); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 0, + String("randomUUID"_s), + Crypto__randomUUID__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Crypto__randomUUID__slowpathWrapper, + &DOMJIT_randomUUID_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "randomUUID"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); } - - extern "C" JSC_DECLARE_HOST_FUNCTION(Crypto__timingSafeEqual__slowpathWrapper); -extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Crypto__timingSafeEqual__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, JSC::JSUint8Array*, JSC::JSUint8Array*)); - -JSC_DEFINE_JIT_OPERATION(Crypto__timingSafeEqual__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject* lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg1, JSC::JSUint8Array* arg2)) { -VM& vm = JSC::getVM(lexicalGlobalObject); -IGNORE_WARNINGS_BEGIN("frame-address") -CallFrame* callFrame = DECLARE_CALL_FRAME(vm); -IGNORE_WARNINGS_END -JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); -return Crypto__timingSafeEqual__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); -} -JSC_DEFINE_HOST_FUNCTION(Crypto__timingSafeEqual__slowpathWrapper, (JSC::JSGlobalObject *globalObject, JSC::CallFrame* frame)) { +extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Crypto__timingSafeEqual__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array*, JSC::JSUint8Array*)); + +JSC_DEFINE_JIT_OPERATION(Crypto__timingSafeEqual__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg1, JSC::JSUint8Array* arg2)) +{ + VM& vm = JSC::getVM(lexicalGlobalObject); + IGNORE_WARNINGS_BEGIN("frame-address") + CallFrame* callFrame = DECLARE_CALL_FRAME(vm); + IGNORE_WARNINGS_END + JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame); + return Crypto__timingSafeEqual__fastpath(lexicalGlobalObject, thisValue, arg1, arg2); +} +JSC_DEFINE_HOST_FUNCTION(Crypto__timingSafeEqual__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame)) +{ return Crypto__timingSafeEqual__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount()); } -extern "C" void Crypto__timingSafeEqual__put(JSC::JSGlobalObject *globalObject, JSC::EncodedJSValue value) { - JSC::JSObject *thisObject = JSC::jsCast<JSC::JSObject *>(JSC::JSValue::decode(value)); - static const JSC::DOMJIT::Signature DOMJIT_timingSafeEqual_signature( - Crypto__timingSafeEqual__fastpathWrapper, - thisObject->classInfo(), -JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), - JSC::SpecHeapTop, - JSC::SpecUint8Array, - JSC::SpecUint8Array - ); - JSFunction* function = JSFunction::create( - globalObject->vm(), - globalObject, - 2, - String("timingSafeEqual"_s), - Crypto__timingSafeEqual__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Crypto__timingSafeEqual__slowpathWrapper, - &DOMJIT_timingSafeEqual_signature - ); - thisObject->putDirect( - globalObject->vm(), - Identifier::fromString(globalObject->vm(), "timingSafeEqual"_s), - function, - JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0 - ); -} - - - /* -- END DOMCall DEFINITIONS-- */ - +extern "C" void Crypto__timingSafeEqual__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value) +{ + JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value)); + static const JSC::DOMJIT::Signature DOMJIT_timingSafeEqual_signature( + Crypto__timingSafeEqual__fastpathWrapper, + thisObject->classInfo(), + JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()), + JSC::SpecHeapTop, + JSC::SpecUint8Array, + JSC::SpecUint8Array); + JSFunction* function = JSFunction::create( + globalObject->vm(), + globalObject, + 2, + String("timingSafeEqual"_s), + Crypto__timingSafeEqual__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Crypto__timingSafeEqual__slowpathWrapper, + &DOMJIT_timingSafeEqual_signature); + thisObject->putDirect( + globalObject->vm(), + Identifier::fromString(globalObject->vm(), "timingSafeEqual"_s), + function, + JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction | 0); +} + +/* -- END DOMCall DEFINITIONS-- */ diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 34ef5e38a..602c60f29 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -5,6 +5,7 @@ #include "BunClientData.h" #include "JavaScriptCore/AggregateError.h" +#include "JavaScriptCore/InternalFieldTuple.h" #include "JavaScriptCore/BytecodeIndex.h" #include "JavaScriptCore/CallFrameInlines.h" #include "JavaScriptCore/ClassInfo.h" @@ -92,6 +93,7 @@ #include "JSReadableState.h" #include "JSReadableHelper.h" #include "Process.h" +#include "AsyncContextFrame.h" #include "WebCoreJSBuiltins.h" #include "JSBuffer.h" @@ -1050,9 +1052,10 @@ JSC_DEFINE_HOST_FUNCTION(functionQueueMicrotask, } Zig::GlobalObject* global = JSC::jsCast<Zig::GlobalObject*>(globalObject); + JSC::JSValue asyncContext = global->m_asyncContextData.get()->getInternalField(0); // This is a JSC builtin function - globalObject->queueMicrotask(global->performMicrotaskFunction(), job, JSC::JSValue {}, + globalObject->queueMicrotask(global->performMicrotaskFunction(), job, asyncContext, JSC::JSValue {}, JSC::JSValue {}); return JSC::JSValue::encode(JSC::jsUndefined()); @@ -1499,6 +1502,23 @@ JSC_DEFINE_HOST_FUNCTION(functionFileURLToPath, (JSC::JSGlobalObject * globalObj return JSC::JSValue::encode(JSC::jsString(vm, url.fileSystemPath())); } +static void cleanupAsyncHooksData(JSC::VM& vm) +{ + vm.setOnEachMicrotaskTick(nullptr); + Bun__getDefaultGlobal()->m_asyncContextData.get()->putInternalField(vm, 0, jsUndefined()); +} + +// $lazy("async_hooks").cleanupLater +JSC_DEFINE_HOST_FUNCTION(asyncHooksCleanupLater, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame)) +{ + // assumptions and notes: + // - nobody else uses setOnEachMicrotaskTick + // - this is called by js if we set async context in a way we may not clear it + // - AsyncLocalStorage.prototype.run cleans up after itself and does not call this cb + globalObject->vm().setOnEachMicrotaskTick(&cleanupAsyncHooksData); + return JSC::JSValue::encode(JSC::jsUndefined()); +} + JSC_DEFINE_CUSTOM_GETTER(noop_getter, (JSGlobalObject*, EncodedJSValue, PropertyName)) { return JSC::JSValue::encode(JSC::jsUndefined()); @@ -1563,7 +1583,6 @@ JSC: return JSC::JSValue::encode(JSC::JSValue {}); } default: { - JSC::JSValue moduleName = callFrame->argument(0); if (moduleName.isNumber()) { switch (moduleName.toInt32(globalObject)) { @@ -1698,6 +1717,20 @@ JSC: return JSValue::encode(obj); } + if (string == "async_hooks"_s) { + auto* obj = constructEmptyObject(globalObject); + obj->putDirect( + vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "get"_s)), + JSC::JSFunction::create(vm, asyncContextGetAsyncContextCodeGenerator(vm), globalObject), 0); + obj->putDirect( + vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "set"_s)), + JSC::JSFunction::create(vm, asyncContextSetAsyncContextCodeGenerator(vm), globalObject), 0); + obj->putDirect( + vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "cleanupLater"_s)), + JSC::JSFunction::create(vm, globalObject, 0, "cleanupLater"_s, asyncHooksCleanupLater, ImplementationVisibility::Public), 0); + return JSValue::encode(obj); + } + if (UNLIKELY(string == "noop"_s)) { auto* obj = constructEmptyObject(globalObject); obj->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "getterSetter"_s)), JSC::CustomGetterSetter::create(vm, noop_getter, noop_setter), 0); @@ -2773,24 +2806,25 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionPerformMicrotask, (JSGlobalObject * globalObj JSValue result; WTF::NakedPtr<JSC::Exception> exceptionPtr; + JSValue restoreAsyncContext = {}; + InternalFieldTuple* asyncContextData = nullptr; + auto setAsyncContext = callframe->argument(1); + if (!setAsyncContext.isUndefined()) { + asyncContextData = globalObject->m_asyncContextData.get(); + restoreAsyncContext = asyncContextData->getInternalField(0); + asyncContextData->putInternalField(vm, 0, setAsyncContext); + } + size_t argCount = callframe->argumentCount(); switch (argCount) { - case 1: { - break; - } - case 2: { - arguments.append(callframe->uncheckedArgument(1)); - break; - } case 3: { - arguments.append(callframe->uncheckedArgument(1)); arguments.append(callframe->uncheckedArgument(2)); break; } case 4: { - arguments.append(callframe->uncheckedArgument(1)); arguments.append(callframe->uncheckedArgument(2)); arguments.append(callframe->uncheckedArgument(3)); + break; } default: break; @@ -2798,6 +2832,10 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionPerformMicrotask, (JSGlobalObject * globalObj JSC::call(globalObject, job, callData, jsUndefined(), arguments, exceptionPtr); + if (asyncContextData) { + asyncContextData->putInternalField(vm, 0, restoreAsyncContext); + } + if (auto* exception = exceptionPtr.get()) { Bun__reportUnhandledError(globalObject, JSValue::encode(exception)); } @@ -2843,12 +2881,25 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionPerformMicrotaskVariadic, (JSGlobalObject * g WTF::NakedPtr<JSC::Exception> exceptionPtr; JSValue thisValue = jsUndefined(); - if (callframe->argumentCount() > 2) { - thisValue = callframe->argument(2); + if (callframe->argumentCount() > 3) { + thisValue = callframe->argument(3); + } + + JSValue restoreAsyncContext = {}; + InternalFieldTuple* asyncContextData = nullptr; + auto setAsyncContext = callframe->argument(2); + if (!setAsyncContext.isUndefined()) { + asyncContextData = globalObject->m_asyncContextData.get(); + restoreAsyncContext = asyncContextData->getInternalField(0); + asyncContextData->putInternalField(vm, 0, setAsyncContext); } JSC::call(globalObject, job, callData, thisValue, arguments, exceptionPtr); + if (asyncContextData) { + asyncContextData->putInternalField(vm, 0, restoreAsyncContext); + } + if (auto* exception = exceptionPtr.get()) { Bun__reportUnhandledError(globalObject, JSValue::encode(exception)); } @@ -3194,6 +3245,10 @@ void GlobalObject::finishCreation(VM& vm) [](const Initializer<JSWeakMap>& init) { init.set(JSWeakMap::create(init.vm, init.owner->weakMapStructure())); }); + // m_asyncHooksContext.initLater( + // [](const Initializer<JSC::JSMap>& init) { + // init.set(JSC::JSMap::create(init.vm, init.owner->mapStructure())); + // }); m_JSBufferSubclassStructure.initLater( [](const Initializer<Structure>& init) { @@ -3387,6 +3442,11 @@ void GlobalObject::finishCreation(VM& vm) init.set(Zig::ImportMetaObject::createStructure(init.vm, init.owner)); }); + m_asyncBoundFunctionStructure.initLater( + [](const JSC::LazyProperty<JSC::JSGlobalObject, JSC::Structure>::Initializer& init) { + init.set(AsyncContextFrame::createStructure(init.vm, init.owner)); + }); + m_JSFileSinkClassStructure.initLater( [](LazyClassStructure::Initializer& init) { auto* prototype = createJSSinkPrototype(init.vm, init.global, WebCore::SinkID::FileSink); @@ -3670,18 +3730,6 @@ JSC_DEFINE_HOST_FUNCTION(functionBunPeekStatus, return JSValue::encode(jsUndefined()); } -extern "C" void Bun__setOnEachMicrotaskTick(JSC::VM* vm, void* ptr, void (*callback)(void* ptr)) -{ - if (callback == nullptr) { - vm->setOnEachMicrotaskTick(nullptr); - return; - } - - vm->setOnEachMicrotaskTick([=](JSC::VM& vm) { - callback(ptr); - }); -} - JSC_DEFINE_CUSTOM_GETTER(BunCommonJSModule_getter, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName)) { Zig::GlobalObject* bunGlobalObject = jsCast<Zig::GlobalObject*>(globalObject); @@ -4548,6 +4596,7 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) thisObject->m_importMetaRequireFunctionUnbound.visit(visitor); thisObject->m_importMetaRequireResolveFunctionUnbound.visit(visitor); thisObject->m_importMetaObjectStructure.visit(visitor); + thisObject->m_asyncBoundFunctionStructure.visit(visitor); thisObject->m_dnsObject.visit(visitor); thisObject->m_lazyRequireCacheObject.visit(visitor); diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h index 7501be89e..956724b49 100644 --- a/src/bun.js/bindings/ZigGlobalObject.h +++ b/src/bun.js/bindings/ZigGlobalObject.h @@ -277,6 +277,7 @@ public: JSObject* lazyPreloadTestModuleObject() { return m_lazyPreloadTestModuleObject.getInitializedOnMainThread(this); } Structure* CommonJSModuleObjectStructure() { return m_commonJSModuleObjectStructure.getInitializedOnMainThread(this); } Structure* ImportMetaObjectStructure() { return m_importMetaObjectStructure.getInitializedOnMainThread(this); } + Structure* AsyncContextFrameStructure() { return m_asyncBoundFunctionStructure.getInitializedOnMainThread(this); } Structure* commonJSFunctionArgumentsStructure() { return m_commonJSFunctionArgumentsStructure.getInitializedOnMainThread(this); } @@ -524,6 +525,7 @@ private: LazyProperty<JSGlobalObject, JSC::JSObject> m_importMetaRequireFunctionUnbound; LazyProperty<JSGlobalObject, JSC::JSObject> m_importMetaRequireResolveFunctionUnbound; LazyProperty<JSGlobalObject, JSC::Structure> m_importMetaObjectStructure; + LazyProperty<JSGlobalObject, JSC::Structure> m_asyncBoundFunctionStructure; DOMGuardedObjectSet m_guardedObjects WTF_GUARDED_BY_LOCK(m_gcLock); void* m_bunVM; diff --git a/src/bun.js/bindings/ZigLazyStaticFunctions.h b/src/bun.js/bindings/ZigLazyStaticFunctions.h index 9f7211cd2..38033b52d 100644 --- a/src/bun.js/bindings/ZigLazyStaticFunctions.h +++ b/src/bun.js/bindings/ZigLazyStaticFunctions.h @@ -3,21 +3,19 @@ #include "root.h" namespace Zig { - class GlobalObject; - class JSFFIFunction; - - class LazyStaticFunctions { - public: +class GlobalObject; +class JSFFIFunction; +class LazyStaticFunctions { +public: void init(Zig::GlobalObject* globalObject); template<typename Visitor> void visit(Visitor& visitor); + /* -- BEGIN FUNCTION DEFINITIONS -- */ - /* -- BEGIN FUNCTION DEFINITIONS -- */ - - /* -- END FUNCTION DEFINITIONS-- */ - }; + /* -- END FUNCTION DEFINITIONS-- */ +}; } // namespace Zig diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index 1c97a57a4..55f718207 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -95,6 +95,9 @@ #include <JavaScriptCore/JSWeakMap.h> #include "JSURLSearchParams.h" +#include "AsyncContextFrame.h" +#include "JavaScriptCore/InternalFieldTuple.h" + template<typename UWSResponse> static void copyToUWS(WebCore::FetchHeaders* headers, UWSResponse* res) { @@ -1734,22 +1737,27 @@ bool JSC__JSValue__jestDeepMatch(JSC__JSValue JSValue0, JSC__JSValue JSValue1, J // This is the same as the C API version, except it returns a JSValue which may be a *Exception // We want that so we can return stack traces. -JSC__JSValue JSObjectCallAsFunctionReturnValue(JSContextRef ctx, JSObjectRef object, - JSObjectRef thisObject, size_t argumentCount, - const JSValueRef* arguments); - -JSC__JSValue JSObjectCallAsFunctionReturnValue(JSContextRef ctx, JSObjectRef object, - JSObjectRef thisObject, size_t argumentCount, +extern "C" JSC__JSValue JSObjectCallAsFunctionReturnValue(JSContextRef ctx, JSC__JSValue object, + JSC__JSValue thisObject, size_t argumentCount, const JSValueRef* arguments) { JSC::JSGlobalObject* globalObject = toJS(ctx); JSC::VM& vm = globalObject->vm(); - if (!object) + if (UNLIKELY(!object)) return JSC::JSValue::encode(JSC::JSValue()); - JSC::JSObject* jsObject = toJS(object); - JSC::JSObject* jsThisObject = toJS(thisObject); + JSC::JSValue jsObject = JSValue::decode(object); + JSC::JSValue jsThisObject = JSValue::decode(thisObject); + + JSValue restoreAsyncContext; + InternalFieldTuple* asyncContextData = nullptr; + if (auto* wrapper = jsDynamicCast<AsyncContextFrame*>(jsObject)) { + jsObject = jsCast<JSC::JSObject*>(wrapper->callback.get()); + asyncContextData = globalObject->m_asyncContextData.get(); + restoreAsyncContext = asyncContextData->getInternalField(0); + asyncContextData->putInternalField(vm, 0, wrapper->context.get()); + } if (!jsThisObject) jsThisObject = globalObject->globalThis(); @@ -1765,6 +1773,10 @@ JSC__JSValue JSObjectCallAsFunctionReturnValue(JSContextRef ctx, JSObjectRef obj NakedPtr<JSC::Exception> returnedException = nullptr; auto result = JSC::call(globalObject, jsObject, callData, jsThisObject, argList, returnedException); + if (asyncContextData) { + asyncContextData->putInternalField(vm, 0, restoreAsyncContext); + } + if (returnedException.get()) { return JSC::JSValue::encode(JSC::JSValue(returnedException.get())); } @@ -1775,11 +1787,6 @@ JSC__JSValue JSObjectCallAsFunctionReturnValue(JSContextRef ctx, JSObjectRef obj JSC__JSValue JSObjectCallAsFunctionReturnValueHoldingAPILock(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, - const JSValueRef* arguments); - -JSC__JSValue JSObjectCallAsFunctionReturnValueHoldingAPILock(JSContextRef ctx, JSObjectRef object, - JSObjectRef thisObject, - size_t argumentCount, const JSValueRef* arguments) { JSC::JSGlobalObject* globalObject = toJS(ctx); @@ -2543,9 +2550,9 @@ void JSC__JSPromise__rejectOnNextTickWithHandled(JSC__JSPromise* promise, JSC__J globalObject->queueMicrotask( globalObject->performMicrotaskFunction(), globalObject->rejectPromiseFunction(), + globalObject->m_asyncContextData.get()->getInternalField(0), promise, - value, - JSValue {}); + value); RETURN_IF_EXCEPTION(scope, void()); } } @@ -4331,14 +4338,14 @@ extern "C" size_t JSC__VM__externalMemorySize(JSC__VM* vm) #endif } -extern "C" void JSC__JSGlobalObject__queueMicrotaskJob(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue JSValue2, JSC__JSValue JSValue3, JSC__JSValue JSValue4) +extern "C" void JSC__JSGlobalObject__queueMicrotaskJob(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue JSValue3, JSC__JSValue JSValue4) { Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0); JSC::VM& vm = globalObject->vm(); globalObject->queueMicrotask( JSValue(globalObject->performMicrotaskFunction()), JSC::JSValue::decode(JSValue1), - JSC::JSValue::decode(JSValue2), + globalObject->m_asyncContextData.get()->getInternalField(0), JSC::JSValue::decode(JSValue3), JSC::JSValue::decode(JSValue4)); } diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 46f76d21d..64958cb3e 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -2508,6 +2508,10 @@ pub const JSGlobalObject = extern struct { return JSGlobalObject__setTimeZone(this, timeZone); } + pub inline fn toJS(globalThis: *JSGlobalObject) JSValue { + return @enumFromInt(@as(JSValue.Type, @bitCast(@intFromPtr(globalThis)))); + } + pub fn throwInvalidArguments( this: *JSGlobalObject, comptime fmt: string, @@ -2759,7 +2763,6 @@ pub const JSGlobalObject = extern struct { function, if (args.len > 0) args[0] else .zero, if (args.len > 1) args[1] else .zero, - if (args.len > 2) args[2] else .zero, ); } @@ -2768,14 +2771,12 @@ pub const JSGlobalObject = extern struct { function: JSValue, first: JSValue, second: JSValue, - third: JSValue, ) void { shim.cppFn("queueMicrotaskJob", .{ this, function, first, second, - third, }); } @@ -3141,6 +3142,8 @@ pub const JSValue = enum(JSValueReprInt) { DerivedStringObject, // End StringObject s. + InternalFieldTuple, + MaxJS = 0b11111111, Event = 0b11101111, DOMWrapper = 0b11101110, @@ -3472,8 +3475,8 @@ pub const JSValue = enum(JSValueReprInt) { JSC.markBinding(@src()); return JSC.C.JSObjectCallAsFunctionReturnValue( globalThis, - this.asObjectRef(), - @as(JSC.C.JSValueRef, @ptrCast(globalThis)), + this, + globalThis.toJS(), args.len, @as(?[*]const JSC.C.JSValueRef, @ptrCast(args.ptr)), ); @@ -3483,8 +3486,8 @@ pub const JSValue = enum(JSValueReprInt) { JSC.markBinding(@src()); return JSC.C.JSObjectCallAsFunctionReturnValue( globalThis, - this.asObjectRef(), - @as(JSC.C.JSValueRef, @ptrCast(thisValue.asNullableVoid())), + this, + thisValue, args.len, @as(?[*]const JSC.C.JSValueRef, @ptrCast(args.ptr)), ); @@ -4874,8 +4877,21 @@ pub const JSValue = enum(JSValueReprInt) { "jestStrictDeepEquals", "jestDeepMatch", }; + + // For any callback JSValue created in JS that you will not call *immediatly*, you must wrap it + // in an AsyncContextFrame with this function. This allows AsyncLocalStorage to work by + // snapshotting it's state and restoring it when called. + // - If there is no current context, this returns the callback as-is. + // - It is safe to run .call() on the resulting JSValue. This includes automatic unwrapping. + // - Do not pass the callback as-is to JS; The wrapped object is NOT a function. + // - If passed to C++, call it with AsyncContextFrame::call() instead of JSC::call() + pub inline fn withAsyncContextIfNeeded(this: JSValue, global: *JSGlobalObject) JSValue { + return AsyncContextFrame__withAsyncContextIfNeeded(global, this); + } }; +extern "c" fn AsyncContextFrame__withAsyncContextIfNeeded(global: *JSGlobalObject, callback: JSValue) JSValue; + extern "c" fn Microtask__run(*Microtask, *JSGlobalObject) void; extern "c" fn Microtask__run_default(*MicrotaskForDefaultGlobalObject, *JSGlobalObject) void; @@ -4982,32 +4998,6 @@ pub const VM = extern struct { return cppFn("deleteAllCode", .{ vm, global_object }); } - extern fn Bun__setOnEachMicrotaskTick(vm: *VM, ptr: ?*anyopaque, callback: ?*const fn (*anyopaque) callconv(.C) void) void; - - pub fn onEachMicrotask(vm: *VM, comptime Ptr: type, ptr: *Ptr, comptime callback: *const fn (*Ptr) void) void { - if (comptime is_bindgen) { - return; - } - - const callback_ = callback; - const Wrapper = struct { - pub fn run(ptr_: *anyopaque) callconv(.C) void { - var ptr__ = @as(*Ptr, @ptrCast(@alignCast(ptr_))); - callback_(ptr__); - } - }; - - Bun__setOnEachMicrotaskTick(vm, ptr, Wrapper.run); - } - - pub fn clearMicrotaskCallback(vm: *VM) void { - if (comptime is_bindgen) { - return; - } - - Bun__setOnEachMicrotaskTick(vm, null, null); - } - pub fn whenIdle( vm: *VM, callback: *const fn (...) callconv(.C) void, diff --git a/src/bun.js/bindings/headers.h b/src/bun.js/bindings/headers.h index 9bc8cd793..508e4c4d8 100644 --- a/src/bun.js/bindings/headers.h +++ b/src/bun.js/bindings/headers.h @@ -285,7 +285,7 @@ CPP_DECL JSC__JSValue JSC__JSGlobalObject__generateHeapSnapshot(JSC__JSGlobalObj CPP_DECL JSC__JSValue JSC__JSGlobalObject__getCachedObject(JSC__JSGlobalObject* arg0, const ZigString* arg1); CPP_DECL void JSC__JSGlobalObject__handleRejectedPromises(JSC__JSGlobalObject* arg0); CPP_DECL JSC__JSValue JSC__JSGlobalObject__putCachedObject(JSC__JSGlobalObject* arg0, const ZigString* arg1, JSC__JSValue JSValue2); -CPP_DECL void JSC__JSGlobalObject__queueMicrotaskJob(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue JSValue2, JSC__JSValue JSValue3, JSC__JSValue JSValue4); +CPP_DECL void JSC__JSGlobalObject__queueMicrotaskJob(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1, JSC__JSValue JSValue3, JSC__JSValue JSValue4); CPP_DECL void JSC__JSGlobalObject__reload(JSC__JSGlobalObject* arg0); CPP_DECL bool JSC__JSGlobalObject__startRemoteInspector(JSC__JSGlobalObject* arg0, unsigned char* arg1, uint16_t arg2); CPP_DECL JSC__VM* JSC__JSGlobalObject__vm(JSC__JSGlobalObject* arg0); diff --git a/src/bun.js/bindings/headers.zig b/src/bun.js/bindings/headers.zig index dade6c8ae..499c77000 100644 --- a/src/bun.js/bindings/headers.zig +++ b/src/bun.js/bindings/headers.zig @@ -191,7 +191,7 @@ pub extern fn JSC__JSGlobalObject__generateHeapSnapshot(arg0: *bindings.JSGlobal pub extern fn JSC__JSGlobalObject__getCachedObject(arg0: *bindings.JSGlobalObject, arg1: [*c]const ZigString) JSC__JSValue; pub extern fn JSC__JSGlobalObject__handleRejectedPromises(arg0: *bindings.JSGlobalObject) void; pub extern fn JSC__JSGlobalObject__putCachedObject(arg0: *bindings.JSGlobalObject, arg1: [*c]const ZigString, JSValue2: JSC__JSValue) JSC__JSValue; -pub extern fn JSC__JSGlobalObject__queueMicrotaskJob(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, JSValue2: JSC__JSValue, JSValue3: JSC__JSValue, JSValue4: JSC__JSValue) void; +pub extern fn JSC__JSGlobalObject__queueMicrotaskJob(arg0: *bindings.JSGlobalObject, JSValue1: JSC__JSValue, JSValue3: JSC__JSValue, JSValue4: JSC__JSValue) void; pub extern fn JSC__JSGlobalObject__reload(arg0: *bindings.JSGlobalObject) void; pub extern fn JSC__JSGlobalObject__startRemoteInspector(arg0: *bindings.JSGlobalObject, arg1: [*c]u8, arg2: u16) bool; pub extern fn JSC__JSGlobalObject__vm(arg0: *bindings.JSGlobalObject) *bindings.VM; diff --git a/src/bun.js/bindings/simdutf.h b/src/bun.js/bindings/simdutf.h index 7fb388e9e..4c04ae467 100644 --- a/src/bun.js/bindings/simdutf.h +++ b/src/bun.js/bindings/simdutf.h @@ -78,7 +78,7 @@ #include <machine/endian.h> #elif defined(sun) || defined(__sun) // defined(__APPLE__) || defined(__FreeBSD__) #include <sys/byteorder.h> -#else // defined(__APPLE__) || defined(__FreeBSD__) +#else // defined(__APPLE__) || defined(__FreeBSD__) #ifdef __has_include #if __has_include(<endian.h>) @@ -88,7 +88,6 @@ #endif // defined(__APPLE__) || defined(__FreeBSD__) - #ifndef !defined(__BYTE_ORDER__) || !defined(__ORDER_LITTLE_ENDIAN__) #define SIMDUTF_IS_BIG_ENDIAN 0 #endif @@ -101,7 +100,6 @@ #endif // defined __BYTE_ORDER__ && defined __ORDER_BIG_ENDIAN__ - /** * At this point in time, SIMDUTF_IS_BIG_ENDIAN is defined. */ @@ -139,9 +137,9 @@ #elif defined(__aarch64__) || defined(_M_ARM64) #define SIMDUTF_IS_ARM64 1 #elif defined(__PPC64__) || defined(_M_PPC64) -//#define SIMDUTF_IS_PPC64 1 -// The simdutf library does yet support SIMD acceleration under -// POWER processors. Please see https://github.com/lemire/simdutf/issues/51 +// #define SIMDUTF_IS_PPC64 1 +// The simdutf library does yet support SIMD acceleration under +// POWER processors. Please see https://github.com/lemire/simdutf/issues/51 #elif defined(__s390__) // s390 IBM system. Big endian. #elif (defined(__riscv) || defined(__riscv__)) && __riscv_xlen == 64 @@ -200,14 +198,14 @@ use a 64-bit target such as x64, 64-bit ARM or 64-bit PPC.") // warning: clang attribute push can't be used within a namespace in clang up // til 8.0 so SIMDUTF_TARGET_REGION and SIMDUTF_UNTARGET_REGION must be *outside* of a // namespace. -#define SIMDUTF_TARGET_REGION(T) \ - _Pragma(SIMDUTF_STRINGIFY( \ - clang attribute push(__attribute__((target(T))), apply_to = function))) +#define SIMDUTF_TARGET_REGION(T) \ + _Pragma(SIMDUTF_STRINGIFY( \ + clang attribute push(__attribute__((target(T))), apply_to = function))) #define SIMDUTF_UNTARGET_REGION _Pragma("clang attribute pop") #elif defined(__GNUC__) // GCC is easier -#define SIMDUTF_TARGET_REGION(T) \ - _Pragma("GCC push_options") _Pragma(SIMDUTF_STRINGIFY(GCC target(T))) +#define SIMDUTF_TARGET_REGION(T) \ + _Pragma("GCC push_options") _Pragma(SIMDUTF_STRINGIFY(GCC target(T))) #define SIMDUTF_UNTARGET_REGION _Pragma("GCC pop_options") #endif // clang then gcc @@ -260,7 +258,11 @@ use a 64-bit target such as x64, 64-bit ARM or 64-bit PPC.") #define SIMDUTF_ASSUME(COND) __assume(COND) #else #define SIMDUTF_UNREACHABLE() __builtin_unreachable(); -#define SIMDUTF_ASSUME(COND) do { if (!(COND)) __builtin_unreachable(); } while (0) +#define SIMDUTF_ASSUME(COND) \ + do { \ + if (!(COND)) \ + __builtin_unreachable(); \ + } while (0) #endif #else // NDEBUG @@ -270,14 +272,12 @@ use a 64-bit target such as x64, 64-bit ARM or 64-bit PPC.") #endif - #if defined(__GNUC__) && !defined(__clang__) #if __GNUC__ >= 11 #define SIMDUTF_GCC11ORMORE 1 #endif // __GNUC__ >= 11 #endif // defined(__GNUC__) && !defined(__clang__) - #endif // SIMDUTF_PORTABILITY_H /* end file include/simdutf/portability.h */ // dofile: invoked with prepath=/Users/jarred/Build/simdutf/include, filename=simdutf/avx512.h @@ -295,84 +295,86 @@ use a 64-bit target such as x64, 64-bit ARM or 64-bit PPC.") */ #ifndef SIMDUTF_HAS_AVX512F -# if defined(__AVX512F__) && __AVX512F__ == 1 -# define SIMDUTF_HAS_AVX512F 1 -# endif +#if defined(__AVX512F__) && __AVX512F__ == 1 +#define SIMDUTF_HAS_AVX512F 1 +#endif #endif #ifndef SIMDUTF_HAS_AVX512DQ -# if defined(__AVX512DQ__) && __AVX512DQ__ == 1 -# define SIMDUTF_HAS_AVX512DQ 1 -# endif +#if defined(__AVX512DQ__) && __AVX512DQ__ == 1 +#define SIMDUTF_HAS_AVX512DQ 1 +#endif #endif #ifndef SIMDUTF_HAS_AVX512IFMA -# if defined(__AVX512IFMA__) && __AVX512IFMA__ == 1 -# define SIMDUTF_HAS_AVX512IFMA 1 -# endif +#if defined(__AVX512IFMA__) && __AVX512IFMA__ == 1 +#define SIMDUTF_HAS_AVX512IFMA 1 +#endif #endif #ifndef SIMDUTF_HAS_AVX512CD -# if defined(__AVX512CD__) && __AVX512CD__ == 1 -# define SIMDUTF_HAS_AVX512CD 1 -# endif +#if defined(__AVX512CD__) && __AVX512CD__ == 1 +#define SIMDUTF_HAS_AVX512CD 1 +#endif #endif #ifndef SIMDUTF_HAS_AVX512BW -# if defined(__AVX512BW__) && __AVX512BW__ == 1 -# define SIMDUTF_HAS_AVX512BW 1 -# endif +#if defined(__AVX512BW__) && __AVX512BW__ == 1 +#define SIMDUTF_HAS_AVX512BW 1 +#endif #endif #ifndef SIMDUTF_HAS_AVX512VL -# if defined(__AVX512VL__) && __AVX512VL__ == 1 -# define SIMDUTF_HAS_AVX512VL 1 -# endif +#if defined(__AVX512VL__) && __AVX512VL__ == 1 +#define SIMDUTF_HAS_AVX512VL 1 +#endif #endif #ifndef SIMDUTF_HAS_AVX512VBMI -# if defined(__AVX512VBMI__) && __AVX512VBMI__ == 1 -# define SIMDUTF_HAS_AVX512VBMI 1 -# endif +#if defined(__AVX512VBMI__) && __AVX512VBMI__ == 1 +#define SIMDUTF_HAS_AVX512VBMI 1 +#endif #endif #ifndef SIMDUTF_HAS_AVX512VBMI2 -# if defined(__AVX512VBMI2__) && __AVX512VBMI2__ == 1 -# define SIMDUTF_HAS_AVX512VBMI2 1 -# endif +#if defined(__AVX512VBMI2__) && __AVX512VBMI2__ == 1 +#define SIMDUTF_HAS_AVX512VBMI2 1 +#endif #endif #ifndef SIMDUTF_HAS_AVX512VNNI -# if defined(__AVX512VNNI__) && __AVX512VNNI__ == 1 -# define SIMDUTF_HAS_AVX512VNNI 1 -# endif +#if defined(__AVX512VNNI__) && __AVX512VNNI__ == 1 +#define SIMDUTF_HAS_AVX512VNNI 1 +#endif #endif #ifndef SIMDUTF_HAS_AVX512BITALG -# if defined(__AVX512BITALG__) && __AVX512BITALG__ == 1 -# define SIMDUTF_HAS_AVX512BITALG 1 -# endif +#if defined(__AVX512BITALG__) && __AVX512BITALG__ == 1 +#define SIMDUTF_HAS_AVX512BITALG 1 +#endif #endif #ifndef SIMDUTF_HAS_AVX512VPOPCNTDQ -# if defined(__AVX512VPOPCNTDQ__) && __AVX512VPOPCNTDQ__ == 1 -# define SIMDUTF_HAS_AVX512VPOPCNTDQ 1 -# endif +#if defined(__AVX512VPOPCNTDQ__) && __AVX512VPOPCNTDQ__ == 1 +#define SIMDUTF_HAS_AVX512VPOPCNTDQ 1 +#endif #endif #endif // SIMDUTF_AVX512_H_ /* end file include/simdutf/avx512.h */ - #if defined(__GNUC__) - // Marks a block with a name so that MCA analysis can see it. - #define SIMDUTF_BEGIN_DEBUG_BLOCK(name) __asm volatile("# LLVM-MCA-BEGIN " #name); - #define SIMDUTF_END_DEBUG_BLOCK(name) __asm volatile("# LLVM-MCA-END " #name); - #define SIMDUTF_DEBUG_BLOCK(name, block) BEGIN_DEBUG_BLOCK(name); block; END_DEBUG_BLOCK(name); +// Marks a block with a name so that MCA analysis can see it. +#define SIMDUTF_BEGIN_DEBUG_BLOCK(name) __asm volatile("# LLVM-MCA-BEGIN " #name); +#define SIMDUTF_END_DEBUG_BLOCK(name) __asm volatile("# LLVM-MCA-END " #name); +#define SIMDUTF_DEBUG_BLOCK(name, block) \ + BEGIN_DEBUG_BLOCK(name); \ + block; \ + END_DEBUG_BLOCK(name); #else - #define SIMDUTF_BEGIN_DEBUG_BLOCK(name) - #define SIMDUTF_END_DEBUG_BLOCK(name) - #define SIMDUTF_DEBUG_BLOCK(name, block) +#define SIMDUTF_BEGIN_DEBUG_BLOCK(name) +#define SIMDUTF_END_DEBUG_BLOCK(name) +#define SIMDUTF_DEBUG_BLOCK(name, block) #endif // Align to N-byte boundary @@ -383,103 +385,108 @@ use a 64-bit target such as x64, 64-bit ARM or 64-bit PPC.") #if defined(SIMDUTF_REGULAR_VISUAL_STUDIO) - #define simdutf_really_inline __forceinline - #define simdutf_never_inline __declspec(noinline) - - #define simdutf_unused - #define simdutf_warn_unused - - #ifndef simdutf_likely - #define simdutf_likely(x) x - #endif - #ifndef simdutf_unlikely - #define simdutf_unlikely(x) x - #endif - - #define SIMDUTF_PUSH_DISABLE_WARNINGS __pragma(warning( push )) - #define SIMDUTF_PUSH_DISABLE_ALL_WARNINGS __pragma(warning( push, 0 )) - #define SIMDUTF_DISABLE_VS_WARNING(WARNING_NUMBER) __pragma(warning( disable : WARNING_NUMBER )) - // Get rid of Intellisense-only warnings (Code Analysis) - // Though __has_include is C++17, it is supported in Visual Studio 2017 or better (_MSC_VER>=1910). - #ifdef __has_include - #if __has_include(<CppCoreCheck\Warnings.h>) - #include <CppCoreCheck\Warnings.h> - #define SIMDUTF_DISABLE_UNDESIRED_WARNINGS SIMDUTF_DISABLE_VS_WARNING(ALL_CPPCORECHECK_WARNINGS) - #endif - #endif - - #ifndef SIMDUTF_DISABLE_UNDESIRED_WARNINGS - #define SIMDUTF_DISABLE_UNDESIRED_WARNINGS - #endif - - #define SIMDUTF_DISABLE_DEPRECATED_WARNING SIMDUTF_DISABLE_VS_WARNING(4996) - #define SIMDUTF_DISABLE_STRICT_OVERFLOW_WARNING - #define SIMDUTF_POP_DISABLE_WARNINGS __pragma(warning( pop )) +#define simdutf_really_inline __forceinline +#define simdutf_never_inline __declspec(noinline) + +#define simdutf_unused +#define simdutf_warn_unused + +#ifndef simdutf_likely +#define simdutf_likely(x) x +#endif +#ifndef simdutf_unlikely +#define simdutf_unlikely(x) x +#endif + +#define SIMDUTF_PUSH_DISABLE_WARNINGS __pragma(warning(push)) +#define SIMDUTF_PUSH_DISABLE_ALL_WARNINGS __pragma(warning(push, 0)) +#define SIMDUTF_DISABLE_VS_WARNING(WARNING_NUMBER) __pragma(warning(disable \ + : WARNING_NUMBER)) +// Get rid of Intellisense-only warnings (Code Analysis) +// Though __has_include is C++17, it is supported in Visual Studio 2017 or better (_MSC_VER>=1910). +#ifdef __has_include +#if __has_include(<CppCoreCheck\Warnings.h>) +#include <CppCoreCheck\Warnings.h> +#define SIMDUTF_DISABLE_UNDESIRED_WARNINGS SIMDUTF_DISABLE_VS_WARNING(ALL_CPPCORECHECK_WARNINGS) +#endif +#endif + +#ifndef SIMDUTF_DISABLE_UNDESIRED_WARNINGS +#define SIMDUTF_DISABLE_UNDESIRED_WARNINGS +#endif + +#define SIMDUTF_DISABLE_DEPRECATED_WARNING SIMDUTF_DISABLE_VS_WARNING(4996) +#define SIMDUTF_DISABLE_STRICT_OVERFLOW_WARNING +#define SIMDUTF_POP_DISABLE_WARNINGS __pragma(warning(pop)) #else // SIMDUTF_REGULAR_VISUAL_STUDIO - #define simdutf_really_inline inline __attribute__((always_inline)) - #define simdutf_never_inline inline __attribute__((noinline)) - - #define simdutf_unused __attribute__((unused)) - #define simdutf_warn_unused __attribute__((warn_unused_result)) - - #ifndef simdutf_likely - #define simdutf_likely(x) __builtin_expect(!!(x), 1) - #endif - #ifndef simdutf_unlikely - #define simdutf_unlikely(x) __builtin_expect(!!(x), 0) - #endif - - #define SIMDUTF_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push") - // gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary - #define SIMDUTF_PUSH_DISABLE_ALL_WARNINGS SIMDUTF_PUSH_DISABLE_WARNINGS \ - SIMDUTF_DISABLE_GCC_WARNING(-Weffc++) \ - SIMDUTF_DISABLE_GCC_WARNING(-Wall) \ - SIMDUTF_DISABLE_GCC_WARNING(-Wconversion) \ - SIMDUTF_DISABLE_GCC_WARNING(-Wextra) \ - SIMDUTF_DISABLE_GCC_WARNING(-Wattributes) \ - SIMDUTF_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \ - SIMDUTF_DISABLE_GCC_WARNING(-Wnon-virtual-dtor) \ - SIMDUTF_DISABLE_GCC_WARNING(-Wreturn-type) \ - SIMDUTF_DISABLE_GCC_WARNING(-Wshadow) \ - SIMDUTF_DISABLE_GCC_WARNING(-Wunused-parameter) \ - SIMDUTF_DISABLE_GCC_WARNING(-Wunused-variable) - #define SIMDUTF_PRAGMA(P) _Pragma(#P) - #define SIMDUTF_DISABLE_GCC_WARNING(WARNING) SIMDUTF_PRAGMA(GCC diagnostic ignored #WARNING) - #if defined(SIMDUTF_CLANG_VISUAL_STUDIO) - #define SIMDUTF_DISABLE_UNDESIRED_WARNINGS SIMDUTF_DISABLE_GCC_WARNING(-Wmicrosoft-include) - #else - #define SIMDUTF_DISABLE_UNDESIRED_WARNINGS - #endif - #define SIMDUTF_DISABLE_DEPRECATED_WARNING SIMDUTF_DISABLE_GCC_WARNING(-Wdeprecated-declarations) - #define SIMDUTF_DISABLE_STRICT_OVERFLOW_WARNING SIMDUTF_DISABLE_GCC_WARNING(-Wstrict-overflow) - #define SIMDUTF_POP_DISABLE_WARNINGS _Pragma("GCC diagnostic pop") +#define simdutf_really_inline inline __attribute__((always_inline)) +#define simdutf_never_inline inline __attribute__((noinline)) +#define simdutf_unused __attribute__((unused)) +#define simdutf_warn_unused __attribute__((warn_unused_result)) +#ifndef simdutf_likely +#define simdutf_likely(x) __builtin_expect(!!(x), 1) +#endif +#ifndef simdutf_unlikely +#define simdutf_unlikely(x) __builtin_expect(!!(x), 0) +#endif + +#define SIMDUTF_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push") +// gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary +#define SIMDUTF_PUSH_DISABLE_ALL_WARNINGS \ + SIMDUTF_PUSH_DISABLE_WARNINGS \ + SIMDUTF_DISABLE_GCC_WARNING(-Weffc++) \ + SIMDUTF_DISABLE_GCC_WARNING(-Wall) \ + SIMDUTF_DISABLE_GCC_WARNING(-Wconversion) \ + SIMDUTF_DISABLE_GCC_WARNING(-Wextra) \ + SIMDUTF_DISABLE_GCC_WARNING(-Wattributes) \ + SIMDUTF_DISABLE_GCC_WARNING(-Wimplicit - fallthrough) \ + SIMDUTF_DISABLE_GCC_WARNING(-Wnon - virtual - dtor) \ + SIMDUTF_DISABLE_GCC_WARNING(-Wreturn - type) \ + SIMDUTF_DISABLE_GCC_WARNING(-Wshadow) \ + SIMDUTF_DISABLE_GCC_WARNING(-Wunused - parameter) \ + SIMDUTF_DISABLE_GCC_WARNING(-Wunused - variable) +#define SIMDUTF_PRAGMA(P) _Pragma(#P) +#define SIMDUTF_DISABLE_GCC_WARNING(WARNING) SIMDUTF_PRAGMA(GCC diagnostic ignored #WARNING) +#if defined(SIMDUTF_CLANG_VISUAL_STUDIO) +#define SIMDUTF_DISABLE_UNDESIRED_WARNINGS SIMDUTF_DISABLE_GCC_WARNING(-Wmicrosoft - include) +#else +#define SIMDUTF_DISABLE_UNDESIRED_WARNINGS +#endif +#define SIMDUTF_DISABLE_DEPRECATED_WARNING SIMDUTF_DISABLE_GCC_WARNING(-Wdeprecated - declarations) +#define SIMDUTF_DISABLE_STRICT_OVERFLOW_WARNING SIMDUTF_DISABLE_GCC_WARNING(-Wstrict - overflow) +#define SIMDUTF_POP_DISABLE_WARNINGS _Pragma("GCC diagnostic pop") #endif // MSC_VER #ifndef SIMDUTF_DLLIMPORTEXPORT - #if defined(SIMDUTF_VISUAL_STUDIO) - /** - * It does not matter here whether you are using - * the regular visual studio or clang under visual - * studio. - */ - #if SIMDUTF_USING_LIBRARY - #define SIMDUTF_DLLIMPORTEXPORT __declspec(dllimport) - #else - #define SIMDUTF_DLLIMPORTEXPORT __declspec(dllexport) - #endif - #else - #define SIMDUTF_DLLIMPORTEXPORT - #endif +#if defined(SIMDUTF_VISUAL_STUDIO) +/** + * It does not matter here whether you are using + * the regular visual studio or clang under visual + * studio. + */ +#if SIMDUTF_USING_LIBRARY +#define SIMDUTF_DLLIMPORTEXPORT __declspec(dllimport) +#else +#define SIMDUTF_DLLIMPORTEXPORT __declspec(dllexport) +#endif +#else +#define SIMDUTF_DLLIMPORTEXPORT +#endif #endif /// If EXPR is an error, returns it. -#define SIMDUTF_TRY(EXPR) { auto _err = (EXPR); if (_err) { return _err; } } - +#define SIMDUTF_TRY(EXPR) \ + { \ + auto _err = (EXPR); \ + if (_err) { \ + return _err; \ + } \ + } #endif // SIMDUTF_COMMON_DEFS_H /* end file include/simdutf/common_defs.h */ @@ -490,19 +497,19 @@ use a 64-bit target such as x64, 64-bit ARM or 64-bit PPC.") namespace simdutf { enum encoding_type { - UTF8 = 1, // BOM 0xef 0xbb 0xbf - UTF16_LE = 2, // BOM 0xff 0xfe - UTF16_BE = 4, // BOM 0xfe 0xff - UTF32_LE = 8, // BOM 0xff 0xfe 0x00 0x00 - UTF32_BE = 16, // BOM 0x00 0x00 0xfe 0xff - Latin1 = 32, - - unspecified = 0 + UTF8 = 1, // BOM 0xef 0xbb 0xbf + UTF16_LE = 2, // BOM 0xff 0xfe + UTF16_BE = 4, // BOM 0xfe 0xff + UTF32_LE = 8, // BOM 0xff 0xfe 0x00 0x00 + UTF32_BE = 16, // BOM 0x00 0x00 0xfe 0xff + Latin1 = 32, + + unspecified = 0 }; enum endianness { - LITTLE, - BIG + LITTLE, + BIG }; bool match_system(endianness e); @@ -539,27 +546,27 @@ size_t bom_byte_size(encoding_type bom); namespace simdutf { enum error_code { - SUCCESS = 0, - HEADER_BITS, // Any byte must have fewer than 5 header bits. - TOO_SHORT, // The leading byte must be followed by N-1 continuation bytes, where N is the UTF-8 character length - // This is also the error when the input is truncated. - TOO_LONG, // We either have too many consecutive continuation bytes or the string starts with a continuation byte. - OVERLONG, // The decoded character must be above U+7F for two-byte characters, U+7FF for three-byte characters, - // and U+FFFF for four-byte characters. - TOO_LARGE, // The decoded character must be less than or equal to U+10FFFF,less than or equal than U+7F for ASCII OR less than equal than U+FF for Latin1 - SURROGATE, // The decoded character must be not be in U+D800...DFFF (UTF-8 or UTF-32) OR - // a high surrogate must be followed by a low surrogate and a low surrogate must be preceded by a high surrogate (UTF-16) OR - // there must be no surrogate at all (Latin1) - OTHER // Not related to validation/transcoding. + SUCCESS = 0, + HEADER_BITS, // Any byte must have fewer than 5 header bits. + TOO_SHORT, // The leading byte must be followed by N-1 continuation bytes, where N is the UTF-8 character length + // This is also the error when the input is truncated. + TOO_LONG, // We either have too many consecutive continuation bytes or the string starts with a continuation byte. + OVERLONG, // The decoded character must be above U+7F for two-byte characters, U+7FF for three-byte characters, + // and U+FFFF for four-byte characters. + TOO_LARGE, // The decoded character must be less than or equal to U+10FFFF,less than or equal than U+7F for ASCII OR less than equal than U+FF for Latin1 + SURROGATE, // The decoded character must be not be in U+D800...DFFF (UTF-8 or UTF-32) OR + // a high surrogate must be followed by a low surrogate and a low surrogate must be preceded by a high surrogate (UTF-16) OR + // there must be no surrogate at all (Latin1) + OTHER // Not related to validation/transcoding. }; struct result { - error_code error; - size_t count; // In case of error, indicates the position of the error. In case of success, indicates the number of words validated/written. + error_code error; + size_t count; // In case of error, indicates the position of the error. In case of success, indicates the number of words validated/written. - simdutf_really_inline result(); + simdutf_really_inline result(); - simdutf_really_inline result(error_code, size_t); + simdutf_really_inline result(error_code, size_t); }; } @@ -582,18 +589,18 @@ SIMDUTF_DISABLE_UNDESIRED_WARNINGS namespace simdutf { enum { - /** - * The major version (MAJOR.minor.revision) of simdutf being used. - */ - SIMDUTF_VERSION_MAJOR = 3, - /** - * The minor version (major.MINOR.revision) of simdutf being used. - */ - SIMDUTF_VERSION_MINOR = 2, - /** - * The revision (major.minor.REVISION) of simdutf being used. - */ - SIMDUTF_VERSION_REVISION = 14 + /** + * The major version (MAJOR.minor.revision) of simdutf being used. + */ + SIMDUTF_VERSION_MAJOR = 3, + /** + * The minor version (major.MINOR.revision) of simdutf being used. + */ + SIMDUTF_VERSION_MINOR = 2, + /** + * The revision (major.minor.REVISION) of simdutf being used. + */ + SIMDUTF_VERSION_REVISION = 14 }; } // namespace simdutf @@ -671,187 +678,192 @@ namespace simdutf { namespace internal { enum instruction_set { - DEFAULT = 0x0, - NEON = 0x1, - AVX2 = 0x4, - SSE42 = 0x8, - PCLMULQDQ = 0x10, - BMI1 = 0x20, - BMI2 = 0x40, - ALTIVEC = 0x80, - AVX512F = 0x100, - AVX512DQ = 0x200, - AVX512IFMA = 0x400, - AVX512PF = 0x800, - AVX512ER = 0x1000, - AVX512CD = 0x2000, - AVX512BW = 0x4000, - AVX512VL = 0x8000, - AVX512VBMI2 = 0x10000 + DEFAULT = 0x0, + NEON = 0x1, + AVX2 = 0x4, + SSE42 = 0x8, + PCLMULQDQ = 0x10, + BMI1 = 0x20, + BMI2 = 0x40, + ALTIVEC = 0x80, + AVX512F = 0x100, + AVX512DQ = 0x200, + AVX512IFMA = 0x400, + AVX512PF = 0x800, + AVX512ER = 0x1000, + AVX512CD = 0x2000, + AVX512BW = 0x4000, + AVX512VL = 0x8000, + AVX512VBMI2 = 0x10000 }; #if defined(__PPC64__) -static inline uint32_t detect_supported_architectures() { - return instruction_set::ALTIVEC; +static inline uint32_t detect_supported_architectures() +{ + return instruction_set::ALTIVEC; } #elif defined(__aarch64__) || defined(_M_ARM64) -static inline uint32_t detect_supported_architectures() { - return instruction_set::NEON; +static inline uint32_t detect_supported_architectures() +{ + return instruction_set::NEON; } #elif defined(__x86_64__) || defined(_M_AMD64) // x64 - namespace { namespace cpuid_bit { - // Can be found on Intel ISA Reference for CPUID - - // EAX = 0x01 - constexpr uint32_t pclmulqdq = uint32_t(1) << 1; ///< @private bit 1 of ECX for EAX=0x1 - constexpr uint32_t sse42 = uint32_t(1) << 20; ///< @private bit 20 of ECX for EAX=0x1 - constexpr uint32_t osxsave = (uint32_t(1) << 26) | (uint32_t(1) << 27); ///< @private bits 26+27 of ECX for EAX=0x1 - - // EAX = 0x7f (Structured Extended Feature Flags), ECX = 0x00 (Sub-leaf) - // See: "Table 3-8. Information Returned by CPUID Instruction" - namespace ebx { - constexpr uint32_t bmi1 = uint32_t(1) << 3; - constexpr uint32_t avx2 = uint32_t(1) << 5; - constexpr uint32_t bmi2 = uint32_t(1) << 8; - constexpr uint32_t avx512f = uint32_t(1) << 16; - constexpr uint32_t avx512dq = uint32_t(1) << 17; - constexpr uint32_t avx512ifma = uint32_t(1) << 21; - constexpr uint32_t avx512cd = uint32_t(1) << 28; - constexpr uint32_t avx512bw = uint32_t(1) << 30; - constexpr uint32_t avx512vl = uint32_t(1) << 31; - } - - namespace ecx { - constexpr uint32_t avx512vbmi = uint32_t(1) << 1; - constexpr uint32_t avx512vbmi2 = uint32_t(1) << 6; - constexpr uint32_t avx512vnni = uint32_t(1) << 11; - constexpr uint32_t avx512bitalg = uint32_t(1) << 12; - constexpr uint32_t avx512vpopcnt = uint32_t(1) << 14; - } - namespace edx { - constexpr uint32_t avx512vp2intersect = uint32_t(1) << 8; - } - namespace xcr0_bit { - constexpr uint64_t avx256_saved = uint64_t(1) << 2; ///< @private bit 2 = AVX - constexpr uint64_t avx512_saved = uint64_t(7) << 5; ///< @private bits 5,6,7 = opmask, ZMM_hi256, hi16_ZMM - } - } +// Can be found on Intel ISA Reference for CPUID + +// EAX = 0x01 +constexpr uint32_t pclmulqdq = uint32_t(1) << 1; ///< @private bit 1 of ECX for EAX=0x1 +constexpr uint32_t sse42 = uint32_t(1) << 20; ///< @private bit 20 of ECX for EAX=0x1 +constexpr uint32_t osxsave = (uint32_t(1) << 26) | (uint32_t(1) << 27); ///< @private bits 26+27 of ECX for EAX=0x1 + +// EAX = 0x7f (Structured Extended Feature Flags), ECX = 0x00 (Sub-leaf) +// See: "Table 3-8. Information Returned by CPUID Instruction" +namespace ebx { +constexpr uint32_t bmi1 = uint32_t(1) << 3; +constexpr uint32_t avx2 = uint32_t(1) << 5; +constexpr uint32_t bmi2 = uint32_t(1) << 8; +constexpr uint32_t avx512f = uint32_t(1) << 16; +constexpr uint32_t avx512dq = uint32_t(1) << 17; +constexpr uint32_t avx512ifma = uint32_t(1) << 21; +constexpr uint32_t avx512cd = uint32_t(1) << 28; +constexpr uint32_t avx512bw = uint32_t(1) << 30; +constexpr uint32_t avx512vl = uint32_t(1) << 31; } +namespace ecx { +constexpr uint32_t avx512vbmi = uint32_t(1) << 1; +constexpr uint32_t avx512vbmi2 = uint32_t(1) << 6; +constexpr uint32_t avx512vnni = uint32_t(1) << 11; +constexpr uint32_t avx512bitalg = uint32_t(1) << 12; +constexpr uint32_t avx512vpopcnt = uint32_t(1) << 14; +} +namespace edx { +constexpr uint32_t avx512vp2intersect = uint32_t(1) << 8; +} +namespace xcr0_bit { +constexpr uint64_t avx256_saved = uint64_t(1) << 2; ///< @private bit 2 = AVX +constexpr uint64_t avx512_saved = uint64_t(7) << 5; ///< @private bits 5,6,7 = opmask, ZMM_hi256, hi16_ZMM +} +} +} - -static inline void cpuid(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, - uint32_t *edx) { +static inline void cpuid(uint32_t* eax, uint32_t* ebx, uint32_t* ecx, + uint32_t* edx) +{ #if defined(_MSC_VER) - int cpu_info[4]; - __cpuidex(cpu_info, *eax, *ecx); - *eax = cpu_info[0]; - *ebx = cpu_info[1]; - *ecx = cpu_info[2]; - *edx = cpu_info[3]; + int cpu_info[4]; + __cpuidex(cpu_info, *eax, *ecx); + *eax = cpu_info[0]; + *ebx = cpu_info[1]; + *ecx = cpu_info[2]; + *edx = cpu_info[3]; #elif defined(HAVE_GCC_GET_CPUID) && defined(USE_GCC_GET_CPUID) - uint32_t level = *eax; - __get_cpuid(level, eax, ebx, ecx, edx); + uint32_t level = *eax; + __get_cpuid(level, eax, ebx, ecx, edx); #else - uint32_t a = *eax, b, c = *ecx, d; - asm volatile("cpuid\n\t" : "+a"(a), "=b"(b), "+c"(c), "=d"(d)); - *eax = a; - *ebx = b; - *ecx = c; - *edx = d; + uint32_t a = *eax, b, c = *ecx, d; + asm volatile("cpuid\n\t" + : "+a"(a), "=b"(b), "+c"(c), "=d"(d)); + *eax = a; + *ebx = b; + *ecx = c; + *edx = d; #endif } -static inline uint64_t xgetbv() { - #if defined(_MSC_VER) - return _xgetbv(0); - #else - uint32_t xcr0_lo, xcr0_hi; - asm volatile("xgetbv\n\t" : "=a" (xcr0_lo), "=d" (xcr0_hi) : "c" (0)); - return xcr0_lo | ((uint64_t)xcr0_hi << 32); - #endif - } - -static inline uint32_t detect_supported_architectures() { - uint32_t eax; - uint32_t ebx = 0; - uint32_t ecx = 0; - uint32_t edx = 0; - uint32_t host_isa = 0x0; - - // EBX for EAX=0x1 - eax = 0x1; - cpuid(&eax, &ebx, &ecx, &edx); - - if (ecx & cpuid_bit::sse42) { - host_isa |= instruction_set::SSE42; - } - - if (ecx & cpuid_bit::pclmulqdq) { - host_isa |= instruction_set::PCLMULQDQ; - } - - if ((ecx & cpuid_bit::osxsave) != cpuid_bit::osxsave) { - return host_isa; - } +static inline uint64_t xgetbv() +{ +#if defined(_MSC_VER) + return _xgetbv(0); +#else + uint32_t xcr0_lo, xcr0_hi; + asm volatile("xgetbv\n\t" + : "=a"(xcr0_lo), "=d"(xcr0_hi) + : "c"(0)); + return xcr0_lo | ((uint64_t)xcr0_hi << 32); +#endif +} - // xgetbv for checking if the OS saves registers - uint64_t xcr0 = xgetbv(); +static inline uint32_t detect_supported_architectures() +{ + uint32_t eax; + uint32_t ebx = 0; + uint32_t ecx = 0; + uint32_t edx = 0; + uint32_t host_isa = 0x0; - if ((xcr0 & cpuid_bit::xcr0_bit::avx256_saved) == 0) { - return host_isa; - } - // ECX for EAX=0x7 - eax = 0x7; - ecx = 0x0; // Sub-leaf = 0 - cpuid(&eax, &ebx, &ecx, &edx); - if (ebx & cpuid_bit::ebx::avx2) { - host_isa |= instruction_set::AVX2; - } - if (ebx & cpuid_bit::ebx::bmi1) { - host_isa |= instruction_set::BMI1; - } - if (ebx & cpuid_bit::ebx::bmi2) { - host_isa |= instruction_set::BMI2; - } - if (!((xcr0 & cpuid_bit::xcr0_bit::avx512_saved) == cpuid_bit::xcr0_bit::avx512_saved)) { + // EBX for EAX=0x1 + eax = 0x1; + cpuid(&eax, &ebx, &ecx, &edx); + + if (ecx & cpuid_bit::sse42) { + host_isa |= instruction_set::SSE42; + } + + if (ecx & cpuid_bit::pclmulqdq) { + host_isa |= instruction_set::PCLMULQDQ; + } + + if ((ecx & cpuid_bit::osxsave) != cpuid_bit::osxsave) { + return host_isa; + } + + // xgetbv for checking if the OS saves registers + uint64_t xcr0 = xgetbv(); + + if ((xcr0 & cpuid_bit::xcr0_bit::avx256_saved) == 0) { + return host_isa; + } + // ECX for EAX=0x7 + eax = 0x7; + ecx = 0x0; // Sub-leaf = 0 + cpuid(&eax, &ebx, &ecx, &edx); + if (ebx & cpuid_bit::ebx::avx2) { + host_isa |= instruction_set::AVX2; + } + if (ebx & cpuid_bit::ebx::bmi1) { + host_isa |= instruction_set::BMI1; + } + if (ebx & cpuid_bit::ebx::bmi2) { + host_isa |= instruction_set::BMI2; + } + if (!((xcr0 & cpuid_bit::xcr0_bit::avx512_saved) == cpuid_bit::xcr0_bit::avx512_saved)) { + return host_isa; + } + if (ebx & cpuid_bit::ebx::avx512f) { + host_isa |= instruction_set::AVX512F; + } + if (ebx & cpuid_bit::ebx::avx512bw) { + host_isa |= instruction_set::AVX512BW; + } + if (ebx & cpuid_bit::ebx::avx512cd) { + host_isa |= instruction_set::AVX512CD; + } + if (ebx & cpuid_bit::ebx::avx512dq) { + host_isa |= instruction_set::AVX512DQ; + } + if (ebx & cpuid_bit::ebx::avx512vl) { + host_isa |= instruction_set::AVX512VL; + } + if (ecx & cpuid_bit::ecx::avx512vbmi2) { + host_isa |= instruction_set::AVX512VBMI2; + } return host_isa; - } - if (ebx & cpuid_bit::ebx::avx512f) { - host_isa |= instruction_set::AVX512F; - } - if (ebx & cpuid_bit::ebx::avx512bw) { - host_isa |= instruction_set::AVX512BW; - } - if (ebx & cpuid_bit::ebx::avx512cd) { - host_isa |= instruction_set::AVX512CD; - } - if (ebx & cpuid_bit::ebx::avx512dq) { - host_isa |= instruction_set::AVX512DQ; - } - if (ebx & cpuid_bit::ebx::avx512vl) { - host_isa |= instruction_set::AVX512VL; - } - if (ecx & cpuid_bit::ecx::avx512vbmi2) { - host_isa |= instruction_set::AVX512VBMI2; - } - return host_isa; } #else // fallback // includes 32-bit ARM. -static inline uint32_t detect_supported_architectures() { - return instruction_set::DEFAULT; +static inline uint32_t detect_supported_architectures() +{ + return instruction_set::DEFAULT; } - #endif // end SIMD extension detection code } // namespace internal @@ -860,7 +872,6 @@ static inline uint32_t detect_supported_architectures() { #endif // SIMDutf_INTERNAL_ISADETECTION_H /* end file include/simdutf/internal/isadetection.h */ - namespace simdutf { /** @@ -873,9 +884,10 @@ namespace simdutf { * @param length the length of the string in bytes. * @return the detected encoding type */ -simdutf_warn_unused simdutf::encoding_type autodetect_encoding(const char * input, size_t length) noexcept; -simdutf_really_inline simdutf_warn_unused simdutf::encoding_type autodetect_encoding(const uint8_t * input, size_t length) noexcept { - return autodetect_encoding(reinterpret_cast<const char *>(input), length); +simdutf_warn_unused simdutf::encoding_type autodetect_encoding(const char* input, size_t length) noexcept; +simdutf_really_inline simdutf_warn_unused simdutf::encoding_type autodetect_encoding(const uint8_t* input, size_t length) noexcept +{ + return autodetect_encoding(reinterpret_cast<const char*>(input), length); } /** @@ -889,9 +901,10 @@ simdutf_really_inline simdutf_warn_unused simdutf::encoding_type autodetect_enco * @param length the length of the string in bytes. * @return the detected encoding type */ -simdutf_warn_unused int detect_encodings(const char * input, size_t length) noexcept; -simdutf_really_inline simdutf_warn_unused int detect_encodings(const uint8_t * input, size_t length) noexcept { - return detect_encodings(reinterpret_cast<const char *>(input), length); +simdutf_warn_unused int detect_encodings(const char* input, size_t length) noexcept; +simdutf_really_inline simdutf_warn_unused int detect_encodings(const uint8_t* input, size_t length) noexcept +{ + return detect_encodings(reinterpret_cast<const char*>(input), length); } /** @@ -905,7 +918,7 @@ simdutf_really_inline simdutf_warn_unused int detect_encodings(const uint8_t * i * @param len the length of the string in bytes. * @return true if and only if the string is valid UTF-8. */ -simdutf_warn_unused bool validate_utf8(const char *buf, size_t len) noexcept; +simdutf_warn_unused bool validate_utf8(const char* buf, size_t len) noexcept; /** * Validate the UTF-8 string and stop on error. @@ -916,7 +929,7 @@ simdutf_warn_unused bool validate_utf8(const char *buf, size_t len) noexcept; * @param len the length of the string in bytes. * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. */ -simdutf_warn_unused result validate_utf8_with_errors(const char *buf, size_t len) noexcept; +simdutf_warn_unused result validate_utf8_with_errors(const char* buf, size_t len) noexcept; /** * Validate the ASCII string. @@ -927,7 +940,7 @@ simdutf_warn_unused result validate_utf8_with_errors(const char *buf, size_t len * @param len the length of the string in bytes. * @return true if and only if the string is valid ASCII. */ -simdutf_warn_unused bool validate_ascii(const char *buf, size_t len) noexcept; +simdutf_warn_unused bool validate_ascii(const char* buf, size_t len) noexcept; /** * Validate the ASCII string and stop on error. It might be faster than @@ -939,7 +952,7 @@ simdutf_warn_unused bool validate_ascii(const char *buf, size_t len) noexcept; * @param len the length of the string in bytes. * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. */ -simdutf_warn_unused result validate_ascii_with_errors(const char *buf, size_t len) noexcept; +simdutf_warn_unused result validate_ascii_with_errors(const char* buf, size_t len) noexcept; /** * Using native endianness; Validate the UTF-16 string. @@ -954,7 +967,7 @@ simdutf_warn_unused result validate_ascii_with_errors(const char *buf, size_t le * @param len the length of the string in number of 2-byte words (char16_t). * @return true if and only if the string is valid UTF-16. */ -simdutf_warn_unused bool validate_utf16(const char16_t *buf, size_t len) noexcept; +simdutf_warn_unused bool validate_utf16(const char16_t* buf, size_t len) noexcept; /** * Validate the UTF-16LE string. This function may be best when you expect @@ -969,7 +982,7 @@ simdutf_warn_unused bool validate_utf16(const char16_t *buf, size_t len) noexcep * @param len the length of the string in number of 2-byte words (char16_t). * @return true if and only if the string is valid UTF-16LE. */ -simdutf_warn_unused bool validate_utf16le(const char16_t *buf, size_t len) noexcept; +simdutf_warn_unused bool validate_utf16le(const char16_t* buf, size_t len) noexcept; /** * Validate the UTF-16BE string. This function may be best when you expect @@ -984,7 +997,7 @@ simdutf_warn_unused bool validate_utf16le(const char16_t *buf, size_t len) noexc * @param len the length of the string in number of 2-byte words (char16_t). * @return true if and only if the string is valid UTF-16BE. */ -simdutf_warn_unused bool validate_utf16be(const char16_t *buf, size_t len) noexcept; +simdutf_warn_unused bool validate_utf16be(const char16_t* buf, size_t len) noexcept; /** * Using native endianness; Validate the UTF-16 string and stop on error. @@ -998,7 +1011,7 @@ simdutf_warn_unused bool validate_utf16be(const char16_t *buf, size_t len) noexc * @param len the length of the string in number of 2-byte words (char16_t). * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. */ -simdutf_warn_unused result validate_utf16_with_errors(const char16_t *buf, size_t len) noexcept; +simdutf_warn_unused result validate_utf16_with_errors(const char16_t* buf, size_t len) noexcept; /** * Validate the UTF-16LE string and stop on error. It might be faster than @@ -1012,7 +1025,7 @@ simdutf_warn_unused result validate_utf16_with_errors(const char16_t *buf, size_ * @param len the length of the string in number of 2-byte words (char16_t). * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. */ -simdutf_warn_unused result validate_utf16le_with_errors(const char16_t *buf, size_t len) noexcept; +simdutf_warn_unused result validate_utf16le_with_errors(const char16_t* buf, size_t len) noexcept; /** * Validate the UTF-16BE string and stop on error. It might be faster than @@ -1026,7 +1039,7 @@ simdutf_warn_unused result validate_utf16le_with_errors(const char16_t *buf, siz * @param len the length of the string in number of 2-byte words (char16_t). * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. */ -simdutf_warn_unused result validate_utf16be_with_errors(const char16_t *buf, size_t len) noexcept; +simdutf_warn_unused result validate_utf16be_with_errors(const char16_t* buf, size_t len) noexcept; /** * Validate the UTF-32 string. This function may be best when you expect @@ -1041,7 +1054,7 @@ simdutf_warn_unused result validate_utf16be_with_errors(const char16_t *buf, siz * @param len the length of the string in number of 4-byte words (char32_t). * @return true if and only if the string is valid UTF-32. */ -simdutf_warn_unused bool validate_utf32(const char32_t *buf, size_t len) noexcept; +simdutf_warn_unused bool validate_utf32(const char32_t* buf, size_t len) noexcept; /** * Validate the UTF-32 string and stop on error. It might be faster than @@ -1055,69 +1068,68 @@ simdutf_warn_unused bool validate_utf32(const char32_t *buf, size_t len) noexcep * @param len the length of the string in number of 4-byte words (char32_t). * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. */ -simdutf_warn_unused result validate_utf32_with_errors(const char32_t *buf, size_t len) noexcept; - - /** - * Convert Latin1 string into UTF8 string. - * - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the Latin1 string to convert - * @param length the length of the string in bytes - * @param latin1_output the pointer to buffer that can hold conversion result - * @return the number of written char; 0 if conversion is not possible - */ - simdutf_warn_unused size_t convert_latin1_to_utf8(const char * input, size_t length, char* utf8_output) noexcept; - - - /** - * Convert possibly Latin1 string into UTF-16LE string. - * - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the Latin1 string to convert - * @param length the length of the string in bytes - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return the number of written char16_t; 0 if conversion is not possible - */ - simdutf_warn_unused size_t convert_latin1_to_utf16le(const char * input, size_t length, char16_t* utf16_output) noexcept; - - /** - * Convert Latin1 string into UTF-16BE string. - * - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the Latin1 string to convert - * @param length the length of the string in bytes - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return the number of written char16_t; 0 if conversion is not possible - */ - simdutf_warn_unused size_t convert_latin1_to_utf16be(const char * input, size_t length, char16_t* utf16_output) noexcept; - - /** - * Convert Latin1 string into UTF-32 string. - * - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the Latin1 string to convert - * @param length the length of the string in bytes - * @param utf32_buffer the pointer to buffer that can hold conversion result - * @return the number of written char32_t; 0 if conversion is not possible - */ - simdutf_warn_unused size_t convert_latin1_to_utf32(const char * input, size_t length, char32_t* utf32_buffer) noexcept; - - /** - * Convert possibly broken UTF-8 string into latin1 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param latin1_output the pointer to buffer that can hold conversion result - * @return the number of written char; 0 if the input was not valid UTF-8 string - */ - simdutf_warn_unused size_t convert_utf8_to_latin1(const char * input, size_t length, char* latin1_output) noexcept; +simdutf_warn_unused result validate_utf32_with_errors(const char32_t* buf, size_t len) noexcept; + +/** + * Convert Latin1 string into UTF8 string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return the number of written char; 0 if conversion is not possible + */ +simdutf_warn_unused size_t convert_latin1_to_utf8(const char* input, size_t length, char* utf8_output) noexcept; + +/** + * Convert possibly Latin1 string into UTF-16LE string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t; 0 if conversion is not possible + */ +simdutf_warn_unused size_t convert_latin1_to_utf16le(const char* input, size_t length, char16_t* utf16_output) noexcept; + +/** + * Convert Latin1 string into UTF-16BE string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t; 0 if conversion is not possible + */ +simdutf_warn_unused size_t convert_latin1_to_utf16be(const char* input, size_t length, char16_t* utf16_output) noexcept; + +/** + * Convert Latin1 string into UTF-32 string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param utf32_buffer the pointer to buffer that can hold conversion result + * @return the number of written char32_t; 0 if conversion is not possible + */ +simdutf_warn_unused size_t convert_latin1_to_utf32(const char* input, size_t length, char32_t* utf32_buffer) noexcept; + +/** + * Convert possibly broken UTF-8 string into latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return the number of written char; 0 if the input was not valid UTF-8 string + */ +simdutf_warn_unused size_t convert_utf8_to_latin1(const char* input, size_t length, char* latin1_output) noexcept; /** * Using native endianness; Convert possibly broken UTF-8 string into UTF-16 string. @@ -1130,7 +1142,7 @@ simdutf_warn_unused result validate_utf32_with_errors(const char32_t *buf, size_ * @param utf16_buffer the pointer to buffer that can hold conversion result * @return the number of written char16_t; 0 if the input was not valid UTF-8 string */ -simdutf_warn_unused size_t convert_utf8_to_utf16(const char * input, size_t length, char16_t* utf16_output) noexcept; +simdutf_warn_unused size_t convert_utf8_to_utf16(const char* input, size_t length, char16_t* utf16_output) noexcept; /** * Convert possibly broken UTF-8 string into UTF-16LE string. @@ -1143,7 +1155,7 @@ simdutf_warn_unused size_t convert_utf8_to_utf16(const char * input, size_t leng * @param utf16_buffer the pointer to buffer that can hold conversion result * @return the number of written char16_t; 0 if the input was not valid UTF-8 string */ -simdutf_warn_unused size_t convert_utf8_to_utf16le(const char * input, size_t length, char16_t* utf16_output) noexcept; +simdutf_warn_unused size_t convert_utf8_to_utf16le(const char* input, size_t length, char16_t* utf16_output) noexcept; /** * Convert possibly broken UTF-8 string into UTF-16BE string. @@ -1156,21 +1168,20 @@ simdutf_warn_unused size_t convert_utf8_to_utf16le(const char * input, size_t le * @param utf16_buffer the pointer to buffer that can hold conversion result * @return the number of written char16_t; 0 if the input was not valid UTF-8 string */ -simdutf_warn_unused size_t convert_utf8_to_utf16be(const char * input, size_t length, char16_t* utf16_output) noexcept; - +simdutf_warn_unused size_t convert_utf8_to_utf16be(const char* input, size_t length, char16_t* utf16_output) noexcept; - /** - * Convert possibly broken UTF-8 string into latin1 string. with errors - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param latin1_output the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. - */ - simdutf_warn_unused result convert_utf8_to_latin1_with_errors(const char * input, size_t length, char* latin1_output) noexcept; +/** + * Convert possibly broken UTF-8 string into latin1 string. with errors + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. + */ +simdutf_warn_unused result convert_utf8_to_latin1_with_errors(const char* input, size_t length, char* latin1_output) noexcept; /** * Using native endianness; Convert possibly broken UTF-8 string into UTF-16 @@ -1184,7 +1195,7 @@ simdutf_warn_unused size_t convert_utf8_to_utf16be(const char * input, size_t le * @param utf16_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char16_t written if successful. */ -simdutf_warn_unused result convert_utf8_to_utf16_with_errors(const char * input, size_t length, char16_t* utf16_output) noexcept; +simdutf_warn_unused result convert_utf8_to_utf16_with_errors(const char* input, size_t length, char16_t* utf16_output) noexcept; /** * Convert possibly broken UTF-8 string into UTF-16LE string and stop on error. @@ -1197,7 +1208,7 @@ simdutf_warn_unused result convert_utf8_to_utf16_with_errors(const char * input, * @param utf16_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char16_t written if successful. */ -simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char * input, size_t length, char16_t* utf16_output) noexcept; +simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char* input, size_t length, char16_t* utf16_output) noexcept; /** * Convert possibly broken UTF-8 string into UTF-16BE string and stop on error. @@ -1210,7 +1221,7 @@ simdutf_warn_unused result convert_utf8_to_utf16le_with_errors(const char * inpu * @param utf16_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char16_t written if successful. */ -simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char * input, size_t length, char16_t* utf16_output) noexcept; +simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char* input, size_t length, char16_t* utf16_output) noexcept; /** * Convert possibly broken UTF-8 string into UTF-32 string. @@ -1223,7 +1234,7 @@ simdutf_warn_unused result convert_utf8_to_utf16be_with_errors(const char * inpu * @param utf32_buffer the pointer to buffer that can hold conversion result * @return the number of written char32_t; 0 if the input was not valid UTF-8 string */ -simdutf_warn_unused size_t convert_utf8_to_utf32(const char * input, size_t length, char32_t* utf32_output) noexcept; +simdutf_warn_unused size_t convert_utf8_to_utf32(const char* input, size_t length, char32_t* utf32_output) noexcept; /** * Convert possibly broken UTF-8 string into UTF-32 string and stop on error. @@ -1236,22 +1247,21 @@ simdutf_warn_unused size_t convert_utf8_to_utf32(const char * input, size_t leng * @param utf32_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char32_t written if successful. */ -simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char * input, size_t length, char32_t* utf32_output) noexcept; - - /** - * Convert valid UTF-8 string into latin1 string. - * - * This function assumes that the input string is valid UTF-8. - * - * This function is not BOM-aware. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param latin1_output the pointer to buffer that can hold conversion result - * @return the number of written char; 0 if the input was not valid UTF-8 string - */ - simdutf_warn_unused size_t convert_valid_utf8_to_latin1(const char * input, size_t length, char* latin1_output) noexcept; +simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char* input, size_t length, char32_t* utf32_output) noexcept; +/** + * Convert valid UTF-8 string into latin1 string. + * + * This function assumes that the input string is valid UTF-8. + * + * This function is not BOM-aware. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return the number of written char; 0 if the input was not valid UTF-8 string + */ +simdutf_warn_unused size_t convert_valid_utf8_to_latin1(const char* input, size_t length, char* latin1_output) noexcept; /** * Using native endianness; Convert valid UTF-8 string into UTF-16 string. @@ -1263,7 +1273,7 @@ simdutf_warn_unused result convert_utf8_to_utf32_with_errors(const char * input, * @param utf16_buffer the pointer to buffer that can hold conversion result * @return the number of written char16_t */ -simdutf_warn_unused size_t convert_valid_utf8_to_utf16(const char * input, size_t length, char16_t* utf16_buffer) noexcept; +simdutf_warn_unused size_t convert_valid_utf8_to_utf16(const char* input, size_t length, char16_t* utf16_buffer) noexcept; /** * Convert valid UTF-8 string into UTF-16LE string. @@ -1275,7 +1285,7 @@ simdutf_warn_unused size_t convert_valid_utf8_to_utf16(const char * input, size_ * @param utf16_buffer the pointer to buffer that can hold conversion result * @return the number of written char16_t */ -simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char * input, size_t length, char16_t* utf16_buffer) noexcept; +simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char* input, size_t length, char16_t* utf16_buffer) noexcept; /** * Convert valid UTF-8 string into UTF-16BE string. @@ -1287,7 +1297,7 @@ simdutf_warn_unused size_t convert_valid_utf8_to_utf16le(const char * input, siz * @param utf16_buffer the pointer to buffer that can hold conversion result * @return the number of written char16_t */ -simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char * input, size_t length, char16_t* utf16_buffer) noexcept; +simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char* input, size_t length, char16_t* utf16_buffer) noexcept; /** * Convert valid UTF-8 string into UTF-32 string. @@ -1299,30 +1309,29 @@ simdutf_warn_unused size_t convert_valid_utf8_to_utf16be(const char * input, siz * @param utf32_buffer the pointer to buffer that can hold conversion result * @return the number of written char32_t */ -simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char * input, size_t length, char32_t* utf32_buffer) noexcept; - +simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char* input, size_t length, char32_t* utf32_buffer) noexcept; - /** - * Return the number of bytes that this Latin1 string would require in UTF-8 format. - * - * @param input the Latin1 string to convert - * @param length the length of the string bytes - * @return the number of bytes required to encode the Latin1 string as UTF-8 - */ - simdutf_warn_unused size_t utf8_length_from_latin1(const char * input, size_t length) noexcept; +/** + * Return the number of bytes that this Latin1 string would require in UTF-8 format. + * + * @param input the Latin1 string to convert + * @param length the length of the string bytes + * @return the number of bytes required to encode the Latin1 string as UTF-8 + */ +simdutf_warn_unused size_t utf8_length_from_latin1(const char* input, size_t length) noexcept; - /** - * Compute the number of bytes that this UTF-8 string would require in Latin1 format. - * - * This function does not validate the input. - * - * This function is not BOM-aware. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in byte - * @return the number of bytes required to encode the UTF-8 string as Latin1 - */ - simdutf_warn_unused size_t latin1_length_from_utf8(const char * input, size_t length) noexcept; +/** + * Compute the number of bytes that this UTF-8 string would require in Latin1 format. + * + * This function does not validate the input. + * + * This function is not BOM-aware. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in byte + * @return the number of bytes required to encode the UTF-8 string as Latin1 + */ +simdutf_warn_unused size_t latin1_length_from_utf8(const char* input, size_t length) noexcept; /** * Compute the number of 2-byte words that this UTF-8 string would require in UTF-16LE format. @@ -1335,7 +1344,7 @@ simdutf_warn_unused size_t convert_valid_utf8_to_utf32(const char * input, size_ * @param length the length of the string in bytes * @return the number of char16_t words required to encode the UTF-8 string as UTF-16LE */ -simdutf_warn_unused size_t utf16_length_from_utf8(const char * input, size_t length) noexcept; +simdutf_warn_unused size_t utf16_length_from_utf8(const char* input, size_t length) noexcept; /** * Compute the number of 4-byte words that this UTF-8 string would require in UTF-32 format. @@ -1350,7 +1359,7 @@ simdutf_warn_unused size_t utf16_length_from_utf8(const char * input, size_t len * @param length the length of the string in bytes * @return the number of char32_t words required to encode the UTF-8 string as UTF-32 */ -simdutf_warn_unused size_t utf32_length_from_utf8(const char * input, size_t length) noexcept; +simdutf_warn_unused size_t utf32_length_from_utf8(const char* input, size_t length) noexcept; /** * Using native endianness; Convert possibly broken UTF-16 string into UTF-8 string. @@ -1365,39 +1374,37 @@ simdutf_warn_unused size_t utf32_length_from_utf8(const char * input, size_t len * @param utf8_buffer the pointer to buffer that can hold conversion result * @return number of written words; 0 if input is not a valid UTF-16LE string */ -simdutf_warn_unused size_t convert_utf16_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) noexcept; - - - /** - * Convert possibly broken UTF-16LE string into Latin1 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if input is not a valid UTF-16LE string - */ - simdutf_warn_unused size_t convert_utf16le_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) noexcept; - - /** - * Convert possibly broken UTF-16BE string into Latin1 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. - */ - simdutf_warn_unused size_t convert_utf16be_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) noexcept; +simdutf_warn_unused size_t convert_utf16_to_utf8(const char16_t* input, size_t length, char* utf8_buffer) noexcept; + +/** + * Convert possibly broken UTF-16LE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-16LE string + */ +simdutf_warn_unused size_t convert_utf16le_to_latin1(const char16_t* input, size_t length, char* latin1_buffer) noexcept; +/** + * Convert possibly broken UTF-16BE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ +simdutf_warn_unused size_t convert_utf16be_to_latin1(const char16_t* input, size_t length, char* latin1_buffer) noexcept; /** * Convert possibly broken UTF-16LE string into UTF-8 string. @@ -1412,7 +1419,7 @@ simdutf_warn_unused size_t convert_utf16_to_utf8(const char16_t * input, size_t * @param utf8_buffer the pointer to buffer that can hold conversion result * @return number of written words; 0 if input is not a valid UTF-16LE string */ -simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) noexcept; +simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t* input, size_t length, char* utf8_buffer) noexcept; /** * Convert possibly broken UTF-16BE string into UTF-8 string. @@ -1427,36 +1434,35 @@ simdutf_warn_unused size_t convert_utf16le_to_utf8(const char16_t * input, size_ * @param utf8_buffer the pointer to buffer that can hold conversion result * @return number of written words; 0 if input is not a valid UTF-16LE string */ -simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) noexcept; - - /** - * Convert possibly broken UTF-16LE string into Latin1 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. - */ - simdutf_warn_unused result convert_utf16le_to_latin1_with_errors(const char16_t * input, size_t length, char* latin1_buffer) noexcept; - - /** - * Convert possibly broken UTF-16BE string into Latin1 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. - */ - simdutf_warn_unused result convert_utf16be_to_latin1_with_errors(const char16_t * input, size_t length, char* latin1_buffer) noexcept; +simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t* input, size_t length, char* utf8_buffer) noexcept; +/** + * Convert possibly broken UTF-16LE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ +simdutf_warn_unused result convert_utf16le_to_latin1_with_errors(const char16_t* input, size_t length, char* latin1_buffer) noexcept; + +/** + * Convert possibly broken UTF-16BE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ +simdutf_warn_unused result convert_utf16be_to_latin1_with_errors(const char16_t* input, size_t length, char* latin1_buffer) noexcept; /** * Using native endianness; Convert possibly broken UTF-16 string into UTF-8 string and stop on error. @@ -1471,7 +1477,7 @@ simdutf_warn_unused size_t convert_utf16be_to_utf8(const char16_t * input, size_ * @param utf8_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. */ -simdutf_warn_unused result convert_utf16_to_utf8_with_errors(const char16_t * input, size_t length, char* utf8_buffer) noexcept; +simdutf_warn_unused result convert_utf16_to_utf8_with_errors(const char16_t* input, size_t length, char* utf8_buffer) noexcept; /** * Convert possibly broken UTF-16LE string into UTF-8 string and stop on error. @@ -1486,7 +1492,7 @@ simdutf_warn_unused result convert_utf16_to_utf8_with_errors(const char16_t * in * @param utf8_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. */ -simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t * input, size_t length, char* utf8_buffer) noexcept; +simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t* input, size_t length, char* utf8_buffer) noexcept; /** * Convert possibly broken UTF-16BE string into UTF-8 string and stop on error. @@ -1501,7 +1507,7 @@ simdutf_warn_unused result convert_utf16le_to_utf8_with_errors(const char16_t * * @param utf8_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. */ -simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t * input, size_t length, char* utf8_buffer) noexcept; +simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t* input, size_t length, char* utf8_buffer) noexcept; /** * Using native endianness; Convert valid UTF-16 string into UTF-8 string. @@ -1515,37 +1521,35 @@ simdutf_warn_unused result convert_utf16be_to_utf8_with_errors(const char16_t * * @param utf8_buffer the pointer to buffer that can hold the conversion result * @return number of written words; 0 if conversion is not possible */ -simdutf_warn_unused size_t convert_valid_utf16_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) noexcept; - +simdutf_warn_unused size_t convert_valid_utf16_to_utf8(const char16_t* input, size_t length, char* utf8_buffer) noexcept; - /** - * Convert valid UTF-16LE string into Latin1 string. - * - * This function assumes that the input string is valid UTF-8. - - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused size_t convert_valid_utf16le_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) noexcept; +/** + * Convert valid UTF-16LE string into Latin1 string. + * + * This function assumes that the input string is valid UTF-8. - /** - * Convert valid UTF-16BE string into Latin1 string. - * - * This function assumes that the input string is valid UTF-8. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused size_t convert_valid_utf16be_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) noexcept; + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if conversion is not possible + */ +simdutf_warn_unused size_t convert_valid_utf16le_to_latin1(const char16_t* input, size_t length, char* latin1_buffer) noexcept; +/** + * Convert valid UTF-16BE string into Latin1 string. + * + * This function assumes that the input string is valid UTF-8. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if conversion is not possible + */ +simdutf_warn_unused size_t convert_valid_utf16be_to_latin1(const char16_t* input, size_t length, char* latin1_buffer) noexcept; /** * Convert valid UTF-16LE string into UTF-8 string. @@ -1559,7 +1563,7 @@ simdutf_warn_unused size_t convert_valid_utf16_to_utf8(const char16_t * input, s * @param utf8_buffer the pointer to buffer that can hold the conversion result * @return number of written words; 0 if conversion is not possible */ -simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) noexcept; +simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t* input, size_t length, char* utf8_buffer) noexcept; /** * Convert valid UTF-16BE string into UTF-8 string. @@ -1573,7 +1577,7 @@ simdutf_warn_unused size_t convert_valid_utf16le_to_utf8(const char16_t * input, * @param utf8_buffer the pointer to buffer that can hold the conversion result * @return number of written words; 0 if conversion is not possible */ -simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) noexcept; +simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t* input, size_t length, char* utf8_buffer) noexcept; /** * Using native endianness; Convert possibly broken UTF-16 string into UTF-32 string. @@ -1588,7 +1592,7 @@ simdutf_warn_unused size_t convert_valid_utf16be_to_utf8(const char16_t * input, * @param utf32_buffer the pointer to buffer that can hold conversion result * @return number of written words; 0 if input is not a valid UTF-16LE string */ -simdutf_warn_unused size_t convert_utf16_to_utf32(const char16_t * input, size_t length, char32_t* utf32_buffer) noexcept; +simdutf_warn_unused size_t convert_utf16_to_utf32(const char16_t* input, size_t length, char32_t* utf32_buffer) noexcept; /** * Convert possibly broken UTF-16LE string into UTF-32 string. @@ -1603,7 +1607,7 @@ simdutf_warn_unused size_t convert_utf16_to_utf32(const char16_t * input, size_t * @param utf32_buffer the pointer to buffer that can hold conversion result * @return number of written words; 0 if input is not a valid UTF-16LE string */ -simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t * input, size_t length, char32_t* utf32_buffer) noexcept; +simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t* input, size_t length, char32_t* utf32_buffer) noexcept; /** * Convert possibly broken UTF-16BE string into UTF-32 string. @@ -1618,7 +1622,7 @@ simdutf_warn_unused size_t convert_utf16le_to_utf32(const char16_t * input, size * @param utf32_buffer the pointer to buffer that can hold conversion result * @return number of written words; 0 if input is not a valid UTF-16LE string */ -simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t * input, size_t length, char32_t* utf32_buffer) noexcept; +simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t* input, size_t length, char32_t* utf32_buffer) noexcept; /** * Using native endianness; Convert possibly broken UTF-16 string into @@ -1634,7 +1638,7 @@ simdutf_warn_unused size_t convert_utf16be_to_utf32(const char16_t * input, size * @param utf32_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char32_t written if successful. */ -simdutf_warn_unused result convert_utf16_to_utf32_with_errors(const char16_t * input, size_t length, char32_t* utf32_buffer) noexcept; +simdutf_warn_unused result convert_utf16_to_utf32_with_errors(const char16_t* input, size_t length, char32_t* utf32_buffer) noexcept; /** * Convert possibly broken UTF-16LE string into UTF-32 string and stop on error. @@ -1649,7 +1653,7 @@ simdutf_warn_unused result convert_utf16_to_utf32_with_errors(const char16_t * i * @param utf32_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char32_t written if successful. */ -simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t * input, size_t length, char32_t* utf32_buffer) noexcept; +simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t* input, size_t length, char32_t* utf32_buffer) noexcept; /** * Convert possibly broken UTF-16BE string into UTF-32 string and stop on error. @@ -1664,7 +1668,7 @@ simdutf_warn_unused result convert_utf16le_to_utf32_with_errors(const char16_t * * @param utf32_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char32_t written if successful. */ -simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t * input, size_t length, char32_t* utf32_buffer) noexcept; +simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t* input, size_t length, char32_t* utf32_buffer) noexcept; /** * Using native endianness; Convert valid UTF-16 string into UTF-32 string. @@ -1678,7 +1682,7 @@ simdutf_warn_unused result convert_utf16be_to_utf32_with_errors(const char16_t * * @param utf32_buffer the pointer to buffer that can hold the conversion result * @return number of written words; 0 if conversion is not possible */ -simdutf_warn_unused size_t convert_valid_utf16_to_utf32(const char16_t * input, size_t length, char32_t* utf32_buffer) noexcept; +simdutf_warn_unused size_t convert_valid_utf16_to_utf32(const char16_t* input, size_t length, char32_t* utf32_buffer) noexcept; /** * Convert valid UTF-16LE string into UTF-32 string. @@ -1692,7 +1696,7 @@ simdutf_warn_unused size_t convert_valid_utf16_to_utf32(const char16_t * input, * @param utf32_buffer the pointer to buffer that can hold the conversion result * @return number of written words; 0 if conversion is not possible */ -simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t * input, size_t length, char32_t* utf32_buffer) noexcept; +simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t* input, size_t length, char32_t* utf32_buffer) noexcept; /** * Convert valid UTF-16BE string into UTF-32 string. @@ -1706,22 +1710,20 @@ simdutf_warn_unused size_t convert_valid_utf16le_to_utf32(const char16_t * input * @param utf32_buffer the pointer to buffer that can hold the conversion result * @return number of written words; 0 if conversion is not possible */ -simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t * input, size_t length, char32_t* utf32_buffer) noexcept; - +simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t* input, size_t length, char32_t* utf32_buffer) noexcept; /* - * Compute the number of bytes that this UTF-16LE/BE string would require in Latin1 format. - * - * This function does not validate the input. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @return the number of bytes required to encode the UTF-16LE string as Latin1 - */ - simdutf_warn_unused size_t latin1_length_from_utf16(size_t length) noexcept; - + * Compute the number of bytes that this UTF-16LE/BE string would require in Latin1 format. + * + * This function does not validate the input. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @return the number of bytes required to encode the UTF-16LE string as Latin1 + */ +simdutf_warn_unused size_t latin1_length_from_utf16(size_t length) noexcept; /** * Using native endianness; Compute the number of bytes that this UTF-16 @@ -1733,7 +1735,7 @@ simdutf_warn_unused size_t convert_valid_utf16be_to_utf32(const char16_t * input * @param length the length of the string in 2-byte words (char16_t) * @return the number of bytes required to encode the UTF-16LE string as UTF-8 */ -simdutf_warn_unused size_t utf8_length_from_utf16(const char16_t * input, size_t length) noexcept; +simdutf_warn_unused size_t utf8_length_from_utf16(const char16_t* input, size_t length) noexcept; /** * Compute the number of bytes that this UTF-16LE string would require in UTF-8 format. @@ -1744,7 +1746,7 @@ simdutf_warn_unused size_t utf8_length_from_utf16(const char16_t * input, size_t * @param length the length of the string in 2-byte words (char16_t) * @return the number of bytes required to encode the UTF-16LE string as UTF-8 */ -simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t * input, size_t length) noexcept; +simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t* input, size_t length) noexcept; /** * Compute the number of bytes that this UTF-16BE string would require in UTF-8 format. @@ -1755,7 +1757,7 @@ simdutf_warn_unused size_t utf8_length_from_utf16le(const char16_t * input, size * @param length the length of the string in 2-byte words (char16_t) * @return the number of bytes required to encode the UTF-16BE string as UTF-8 */ -simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t * input, size_t length) noexcept; +simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t* input, size_t length) noexcept; /** * Convert possibly broken UTF-32 string into UTF-8 string. @@ -1770,7 +1772,7 @@ simdutf_warn_unused size_t utf8_length_from_utf16be(const char16_t * input, size * @param utf8_buffer the pointer to buffer that can hold conversion result * @return number of written words; 0 if input is not a valid UTF-32 string */ -simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t * input, size_t length, char* utf8_buffer) noexcept; +simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t* input, size_t length, char* utf8_buffer) noexcept; /** * Convert possibly broken UTF-32 string into UTF-8 string and stop on error. @@ -1785,7 +1787,7 @@ simdutf_warn_unused size_t convert_utf32_to_utf8(const char32_t * input, size_t * @param utf8_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. */ -simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t * input, size_t length, char* utf8_buffer) noexcept; +simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t* input, size_t length, char* utf8_buffer) noexcept; /** * Convert valid UTF-32 string into UTF-8 string. @@ -1799,7 +1801,7 @@ simdutf_warn_unused result convert_utf32_to_utf8_with_errors(const char32_t * in * @param utf8_buffer the pointer to buffer that can hold the conversion result * @return number of written words; 0 if conversion is not possible */ -simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t * input, size_t length, char* utf8_buffer) noexcept; +simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t* input, size_t length, char* utf8_buffer) noexcept; /** * Using native endianness; Convert possibly broken UTF-32 string into UTF-16 string. @@ -1814,7 +1816,7 @@ simdutf_warn_unused size_t convert_valid_utf32_to_utf8(const char32_t * input, s * @param utf16_buffer the pointer to buffer that can hold conversion result * @return number of written words; 0 if input is not a valid UTF-32 string */ -simdutf_warn_unused size_t convert_utf32_to_utf16(const char32_t * input, size_t length, char16_t* utf16_buffer) noexcept; +simdutf_warn_unused size_t convert_utf32_to_utf16(const char32_t* input, size_t length, char16_t* utf16_buffer) noexcept; /** * Convert possibly broken UTF-32 string into UTF-16LE string. @@ -1829,54 +1831,53 @@ simdutf_warn_unused size_t convert_utf32_to_utf16(const char32_t * input, size_t * @param utf16_buffer the pointer to buffer that can hold conversion result * @return number of written words; 0 if input is not a valid UTF-32 string */ -simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t * input, size_t length, char16_t* utf16_buffer) noexcept; - - /** - * Convert possibly broken UTF-32 string into Latin1 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if input is not a valid UTF-32 string - */ - - simdutf_warn_unused size_t convert_utf32_to_latin1(const char32_t * input, size_t length, char* latin1_buffer) noexcept; - - - /** - * Convert possibly broken UTF-32 string into Latin1 string and stop on error. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. - */ - - simdutf_warn_unused result convert_utf32_to_latin1_with_errors(const char32_t * input, size_t length, char* latin1_buffer) noexcept; - - /** - * Convert valid UTF-32 string into Latin1 string. - * - * This function assumes that the input string is valid UTF-32. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param latin1_buffer the pointer to buffer that can hold the conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused size_t convert_valid_utf32_to_latin1(const char32_t * input, size_t length, char* latin1_buffer) noexcept; +simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t* input, size_t length, char16_t* utf16_buffer) noexcept; + +/** + * Convert possibly broken UTF-32 string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-32 string + */ + +simdutf_warn_unused size_t convert_utf32_to_latin1(const char32_t* input, size_t length, char* latin1_buffer) noexcept; + +/** + * Convert possibly broken UTF-32 string into Latin1 string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + +simdutf_warn_unused result convert_utf32_to_latin1_with_errors(const char32_t* input, size_t length, char* latin1_buffer) noexcept; + +/** + * Convert valid UTF-32 string into Latin1 string. + * + * This function assumes that the input string is valid UTF-32. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param latin1_buffer the pointer to buffer that can hold the conversion result + * @return number of written words; 0 if conversion is not possible + */ +simdutf_warn_unused size_t convert_valid_utf32_to_latin1(const char32_t* input, size_t length, char* latin1_buffer) noexcept; /** * Convert possibly broken UTF-32 string into UTF-16BE string. @@ -1891,7 +1892,7 @@ simdutf_warn_unused size_t convert_utf32_to_utf16le(const char32_t * input, size * @param utf16_buffer the pointer to buffer that can hold conversion result * @return number of written words; 0 if input is not a valid UTF-32 string */ -simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t * input, size_t length, char16_t* utf16_buffer) noexcept; +simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t* input, size_t length, char16_t* utf16_buffer) noexcept; /** * Using native endianness; Convert possibly broken UTF-32 string into UTF-16 @@ -1907,7 +1908,7 @@ simdutf_warn_unused size_t convert_utf32_to_utf16be(const char32_t * input, size * @param utf16_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char16_t written if successful. */ -simdutf_warn_unused result convert_utf32_to_utf16_with_errors(const char32_t * input, size_t length, char16_t* utf16_buffer) noexcept; +simdutf_warn_unused result convert_utf32_to_utf16_with_errors(const char32_t* input, size_t length, char16_t* utf16_buffer) noexcept; /** * Convert possibly broken UTF-32 string into UTF-16LE string and stop on error. @@ -1922,7 +1923,7 @@ simdutf_warn_unused result convert_utf32_to_utf16_with_errors(const char32_t * i * @param utf16_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char16_t written if successful. */ -simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t * input, size_t length, char16_t* utf16_buffer) noexcept; +simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t* input, size_t length, char16_t* utf16_buffer) noexcept; /** * Convert possibly broken UTF-32 string into UTF-16BE string and stop on error. @@ -1937,7 +1938,7 @@ simdutf_warn_unused result convert_utf32_to_utf16le_with_errors(const char32_t * * @param utf16_buffer the pointer to buffer that can hold conversion result * @return a result pair struct with an error code and either the position of the error if any or the number of char16_t written if successful. */ -simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t * input, size_t length, char16_t* utf16_buffer) noexcept; +simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t* input, size_t length, char16_t* utf16_buffer) noexcept; /** * Using native endianness; Convert valid UTF-32 string into UTF-16 string. @@ -1951,7 +1952,7 @@ simdutf_warn_unused result convert_utf32_to_utf16be_with_errors(const char32_t * * @param utf16_buffer the pointer to buffer that can hold the conversion result * @return number of written words; 0 if conversion is not possible */ -simdutf_warn_unused size_t convert_valid_utf32_to_utf16(const char32_t * input, size_t length, char16_t* utf16_buffer) noexcept; +simdutf_warn_unused size_t convert_valid_utf32_to_utf16(const char32_t* input, size_t length, char16_t* utf16_buffer) noexcept; /** * Convert valid UTF-32 string into UTF-16LE string. @@ -1965,7 +1966,7 @@ simdutf_warn_unused size_t convert_valid_utf32_to_utf16(const char32_t * input, * @param utf16_buffer the pointer to buffer that can hold the conversion result * @return number of written words; 0 if conversion is not possible */ -simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t * input, size_t length, char16_t* utf16_buffer) noexcept; +simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t* input, size_t length, char16_t* utf16_buffer) noexcept; /** * Convert valid UTF-32 string into UTF-16BE string. @@ -1979,7 +1980,7 @@ simdutf_warn_unused size_t convert_valid_utf32_to_utf16le(const char32_t * input * @param utf16_buffer the pointer to buffer that can hold the conversion result * @return number of written words; 0 if conversion is not possible */ -simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t * input, size_t length, char16_t* utf16_buffer) noexcept; +simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t* input, size_t length, char16_t* utf16_buffer) noexcept; /** * Change the endianness of the input. Can be used to go from UTF-16LE to UTF-16BE or @@ -1993,7 +1994,7 @@ simdutf_warn_unused size_t convert_valid_utf32_to_utf16be(const char32_t * input * @param length the length of the string in 2-byte words (char16_t) * @param output the pointer to buffer that can hold the conversion result */ -void change_endianness_utf16(const char16_t * input, size_t length, char16_t * output) noexcept; +void change_endianness_utf16(const char16_t* input, size_t length, char16_t* output) noexcept; /** * Compute the number of bytes that this UTF-32 string would require in UTF-8 format. @@ -2004,7 +2005,7 @@ void change_endianness_utf16(const char16_t * input, size_t length, char16_t * o * @param length the length of the string in 4-byte words (char32_t) * @return the number of bytes required to encode the UTF-32 string as UTF-8 */ -simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t * input, size_t length) noexcept; +simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t* input, size_t length) noexcept; /** * Compute the number of two-byte words that this UTF-32 string would require in UTF-16 format. @@ -2015,7 +2016,7 @@ simdutf_warn_unused size_t utf8_length_from_utf32(const char32_t * input, size_t * @param length the length of the string in 4-byte words (char32_t) * @return the number of bytes required to encode the UTF-32 string as UTF-16 */ -simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t * input, size_t length) noexcept; +simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t* input, size_t length) noexcept; /** * Using native endianness; Compute the number of bytes that this UTF-16 @@ -2031,7 +2032,7 @@ simdutf_warn_unused size_t utf16_length_from_utf32(const char32_t * input, size_ * @param length the length of the string in 2-byte words (char16_t) * @return the number of bytes required to encode the UTF-16LE string as UTF-32 */ -simdutf_warn_unused size_t utf32_length_from_utf16(const char16_t * input, size_t length) noexcept; +simdutf_warn_unused size_t utf32_length_from_utf16(const char16_t* input, size_t length) noexcept; /** * Compute the number of bytes that this UTF-16LE string would require in UTF-32 format. @@ -2046,7 +2047,7 @@ simdutf_warn_unused size_t utf32_length_from_utf16(const char16_t * input, size_ * @param length the length of the string in 2-byte words (char16_t) * @return the number of bytes required to encode the UTF-16LE string as UTF-32 */ -simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t * input, size_t length) noexcept; +simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t* input, size_t length) noexcept; /** * Compute the number of bytes that this UTF-16BE string would require in UTF-32 format. @@ -2061,7 +2062,7 @@ simdutf_warn_unused size_t utf32_length_from_utf16le(const char16_t * input, siz * @param length the length of the string in 2-byte words (char16_t) * @return the number of bytes required to encode the UTF-16BE string as UTF-32 */ -simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t * input, size_t length) noexcept; +simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t* input, size_t length) noexcept; /** * Count the number of code points (characters) in the string assuming that @@ -2075,7 +2076,7 @@ simdutf_warn_unused size_t utf32_length_from_utf16be(const char16_t * input, siz * @param length the length of the string in 2-byte words (char16_t) * @return number of code points */ -simdutf_warn_unused size_t count_utf16(const char16_t * input, size_t length) noexcept; +simdutf_warn_unused size_t count_utf16(const char16_t* input, size_t length) noexcept; /** * Count the number of code points (characters) in the string assuming that @@ -2089,7 +2090,7 @@ simdutf_warn_unused size_t count_utf16(const char16_t * input, size_t length) no * @param length the length of the string in 2-byte words (char16_t) * @return number of code points */ -simdutf_warn_unused size_t count_utf16le(const char16_t * input, size_t length) noexcept; +simdutf_warn_unused size_t count_utf16le(const char16_t* input, size_t length) noexcept; /** * Count the number of code points (characters) in the string assuming that @@ -2103,7 +2104,7 @@ simdutf_warn_unused size_t count_utf16le(const char16_t * input, size_t length) * @param length the length of the string in 2-byte words (char16_t) * @return number of code points */ -simdutf_warn_unused size_t count_utf16be(const char16_t * input, size_t length) noexcept; +simdutf_warn_unused size_t count_utf16be(const char16_t* input, size_t length) noexcept; /** * Count the number of code points (characters) in the string assuming that @@ -2115,7 +2116,7 @@ simdutf_warn_unused size_t count_utf16be(const char16_t * input, size_t length) * @param length the length of the string in bytes * @return number of code points */ -simdutf_warn_unused size_t count_utf8(const char * input, size_t length) noexcept; +simdutf_warn_unused size_t count_utf8(const char* input, size_t length) noexcept; /** * An implementation of simdutf for a particular CPU architecture. @@ -2125,1090 +2126,1080 @@ simdutf_warn_unused size_t count_utf8(const char * input, size_t length) noexcep */ class implementation { public: + /** + * The name of this implementation. + * + * const implementation *impl = simdutf::active_implementation; + * cout << "simdutf is optimized for " << impl->name() << "(" << impl->description() << ")" << endl; + * + * @return the name of the implementation, e.g. "haswell", "westmere", "arm64" + */ + virtual const std::string& name() const { return _name; } - /** - * The name of this implementation. - * - * const implementation *impl = simdutf::active_implementation; - * cout << "simdutf is optimized for " << impl->name() << "(" << impl->description() << ")" << endl; - * - * @return the name of the implementation, e.g. "haswell", "westmere", "arm64" - */ - virtual const std::string &name() const { return _name; } - - /** - * The description of this implementation. - * - * const implementation *impl = simdutf::active_implementation; - * cout << "simdutf is optimized for " << impl->name() << "(" << impl->description() << ")" << endl; - * - * @return the name of the implementation, e.g. "haswell", "westmere", "arm64" - */ - virtual const std::string &description() const { return _description; } - - /** - * The instruction sets this implementation is compiled against - * and the current CPU match. This function may poll the current CPU/system - * and should therefore not be called too often if performance is a concern. - * - * - * @return true if the implementation can be safely used on the current system (determined at runtime) - */ - bool supported_by_runtime_system() const; - - /** - * This function will try to detect the encoding - * @param input the string to identify - * @param length the length of the string in bytes. - * @return the encoding type detected - */ - virtual encoding_type autodetect_encoding(const char * input, size_t length) const noexcept; - - /** - * This function will try to detect the possible encodings in one pass - * @param input the string to identify - * @param length the length of the string in bytes. - * @return the encoding type detected - */ - virtual int detect_encodings(const char * input, size_t length) const noexcept = 0; - - /** - * @private For internal implementation use - * - * The instruction sets this implementation is compiled against. - * - * @return a mask of all required `internal::instruction_set::` values - */ - virtual uint32_t required_instruction_sets() const { return _required_instruction_sets; } - - - /** - * Validate the UTF-8 string. - * - * Overridden by each implementation. - * - * @param buf the UTF-8 string to validate. - * @param len the length of the string in bytes. - * @return true if and only if the string is valid UTF-8. - */ - simdutf_warn_unused virtual bool validate_utf8(const char *buf, size_t len) const noexcept = 0; - - /** - * Validate the UTF-8 string and stop on errors. - * - * Overridden by each implementation. - * - * @param buf the UTF-8 string to validate. - * @param len the length of the string in bytes. - * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. - */ - simdutf_warn_unused virtual result validate_utf8_with_errors(const char *buf, size_t len) const noexcept = 0; - - /** - * Validate the ASCII string. - * - * Overridden by each implementation. - * - * @param buf the ASCII string to validate. - * @param len the length of the string in bytes. - * @return true if and only if the string is valid ASCII. - */ - simdutf_warn_unused virtual bool validate_ascii(const char *buf, size_t len) const noexcept = 0; - - /** - * Validate the ASCII string and stop on error. - * - * Overridden by each implementation. - * - * @param buf the ASCII string to validate. - * @param len the length of the string in bytes. - * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. - */ - simdutf_warn_unused virtual result validate_ascii_with_errors(const char *buf, size_t len) const noexcept = 0; - - /** - * Validate the UTF-16LE string.This function may be best when you expect - * the input to be almost always valid. Otherwise, consider using - * validate_utf16le_with_errors. - * - * Overridden by each implementation. - * - * This function is not BOM-aware. - * - * @param buf the UTF-16LE string to validate. - * @param len the length of the string in number of 2-byte words (char16_t). - * @return true if and only if the string is valid UTF-16LE. - */ - simdutf_warn_unused virtual bool validate_utf16le(const char16_t *buf, size_t len) const noexcept = 0; - - /** - * Validate the UTF-16BE string. This function may be best when you expect - * the input to be almost always valid. Otherwise, consider using - * validate_utf16be_with_errors. - * - * Overridden by each implementation. - * - * This function is not BOM-aware. - * - * @param buf the UTF-16BE string to validate. - * @param len the length of the string in number of 2-byte words (char16_t). - * @return true if and only if the string is valid UTF-16BE. - */ - simdutf_warn_unused virtual bool validate_utf16be(const char16_t *buf, size_t len) const noexcept = 0; - - /** - * Validate the UTF-16LE string and stop on error. It might be faster than - * validate_utf16le when an error is expected to occur early. - * - * Overridden by each implementation. - * - * This function is not BOM-aware. - * - * @param buf the UTF-16LE string to validate. - * @param len the length of the string in number of 2-byte words (char16_t). - * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. - */ - simdutf_warn_unused virtual result validate_utf16le_with_errors(const char16_t *buf, size_t len) const noexcept = 0; - - /** - * Validate the UTF-16BE string and stop on error. It might be faster than - * validate_utf16be when an error is expected to occur early. - * - * Overridden by each implementation. - * - * This function is not BOM-aware. - * - * @param buf the UTF-16BE string to validate. - * @param len the length of the string in number of 2-byte words (char16_t). - * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. - */ - simdutf_warn_unused virtual result validate_utf16be_with_errors(const char16_t *buf, size_t len) const noexcept = 0; - - /** - * Validate the UTF-32 string. - * - * Overridden by each implementation. - * - * This function is not BOM-aware. - * - * @param buf the UTF-32 string to validate. - * @param len the length of the string in number of 4-byte words (char32_t). - * @return true if and only if the string is valid UTF-32. - */ - simdutf_warn_unused virtual bool validate_utf32(const char32_t *buf, size_t len) const noexcept = 0; - - /** - * Validate the UTF-32 string and stop on error. - * - * Overridden by each implementation. - * - * This function is not BOM-aware. - * - * @param buf the UTF-32 string to validate. - * @param len the length of the string in number of 4-byte words (char32_t). - * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. - */ - simdutf_warn_unused virtual result validate_utf32_with_errors(const char32_t *buf, size_t len) const noexcept = 0; - - /** - * Convert Latin1 string into UTF8 string. - * - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the Latin1 string to convert - * @param length the length of the string in bytes - * @param latin1_output the pointer to buffer that can hold conversion result - * @return the number of written char; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_latin1_to_utf8(const char * input, size_t length, char* utf8_output) const noexcept = 0; - - - /** - * Convert possibly Latin1 string into UTF-16LE string. - * - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the Latin1 string to convert - * @param length the length of the string in bytes - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return the number of written char16_t; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_latin1_to_utf16le(const char * input, size_t length, char16_t* utf16_output) const noexcept = 0; - - /** - * Convert Latin1 string into UTF-16BE string. - * - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the Latin1 string to convert - * @param length the length of the string in bytes - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return the number of written char16_t; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_latin1_to_utf16be(const char * input, size_t length, char16_t* utf16_output) const noexcept = 0; - - /** - * Convert Latin1 string into UTF-32 string. - * - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the Latin1 string to convert - * @param length the length of the string in bytes - * @param utf32_buffer the pointer to buffer that can hold conversion result - * @return the number of written char32_t; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_latin1_to_utf32(const char * input, size_t length, char32_t* utf32_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-8 string into latin1 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param latin1_output the pointer to buffer that can hold conversion result - * @return the number of written char; 0 if the input was not valid UTF-8 string - */ - simdutf_warn_unused virtual size_t convert_utf8_to_latin1(const char * input, size_t length, char* latin1_output) const noexcept = 0; - - /** - * Convert possibly broken UTF-8 string into latin1 string. with errors - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param latin1_output the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. - */ - simdutf_warn_unused virtual result convert_utf8_to_latin1_with_errors(const char * input, size_t length, char* latin1_output) const noexcept = 0; - - /** - * Convert valid UTF-8 string into latin1 string. - * - * This function assumes that the input string is valid UTF-8. - * - * This function is not BOM-aware. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param latin1_output the pointer to buffer that can hold conversion result - * @return the number of written char; 0 if the input was not valid UTF-8 string - */ - simdutf_warn_unused virtual size_t convert_valid_utf8_to_latin1(const char * input, size_t length, char* latin1_output) const noexcept = 0; - - - /** - * Convert possibly broken UTF-8 string into UTF-16LE string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return the number of written char16_t; 0 if the input was not valid UTF-8 string - */ - simdutf_warn_unused virtual size_t convert_utf8_to_utf16le(const char * input, size_t length, char16_t* utf16_output) const noexcept = 0; - - /** - * Convert possibly broken UTF-8 string into UTF-16BE string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return the number of written char16_t; 0 if the input was not valid UTF-8 string - */ - simdutf_warn_unused virtual size_t convert_utf8_to_utf16be(const char * input, size_t length, char16_t* utf16_output) const noexcept = 0; - - /** - * Convert possibly broken UTF-8 string into UTF-16LE string and stop on error. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. - */ - simdutf_warn_unused virtual result convert_utf8_to_utf16le_with_errors(const char * input, size_t length, char16_t* utf16_output) const noexcept = 0; - - /** - * Convert possibly broken UTF-8 string into UTF-16BE string and stop on error. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. - */ - simdutf_warn_unused virtual result convert_utf8_to_utf16be_with_errors(const char * input, size_t length, char16_t* utf16_output) const noexcept = 0; - - /** - * Convert possibly broken UTF-8 string into UTF-32 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param utf32_buffer the pointer to buffer that can hold conversion result - * @return the number of written char16_t; 0 if the input was not valid UTF-8 string - */ - simdutf_warn_unused virtual size_t convert_utf8_to_utf32(const char * input, size_t length, char32_t* utf32_output) const noexcept = 0; - - /** - * Convert possibly broken UTF-8 string into UTF-32 string and stop on error. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param utf32_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char32_t written if successful. - */ - simdutf_warn_unused virtual result convert_utf8_to_utf32_with_errors(const char * input, size_t length, char32_t* utf32_output) const noexcept = 0; - - /** - * Convert valid UTF-8 string into UTF-16LE string. - * - * This function assumes that the input string is valid UTF-8. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return the number of written char16_t - */ - simdutf_warn_unused virtual size_t convert_valid_utf8_to_utf16le(const char * input, size_t length, char16_t* utf16_buffer) const noexcept = 0; - -/** - * Convert valid UTF-8 string into UTF-16BE string. - * - * This function assumes that the input string is valid UTF-8. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return the number of written char16_t - */ - simdutf_warn_unused virtual size_t convert_valid_utf8_to_utf16be(const char * input, size_t length, char16_t* utf16_buffer) const noexcept = 0; - - /** - * Convert valid UTF-8 string into UTF-32 string. - * - * This function assumes that the input string is valid UTF-8. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in bytes - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return the number of written char32_t - */ - simdutf_warn_unused virtual size_t convert_valid_utf8_to_utf32(const char * input, size_t length, char32_t* utf32_buffer) const noexcept = 0; - - /** - * Compute the number of 2-byte words that this UTF-8 string would require in UTF-16LE format. - * - * This function does not validate the input. - * - * @param input the UTF-8 string to process - * @param length the length of the string in bytes - * @return the number of char16_t words required to encode the UTF-8 string as UTF-16LE - */ - simdutf_warn_unused virtual size_t utf16_length_from_utf8(const char * input, size_t length) const noexcept = 0; - - /** - * Compute the number of 4-byte words that this UTF-8 string would require in UTF-32 format. - * - * This function is equivalent to count_utf8. - * - * This function does not validate the input. - * - * @param input the UTF-8 string to process - * @param length the length of the string in bytes - * @return the number of char32_t words required to encode the UTF-8 string as UTF-32 - */ - simdutf_warn_unused virtual size_t utf32_length_from_utf8(const char * input, size_t length) const noexcept = 0; - - /** - * Convert possibly broken UTF-16LE string into Latin1 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if input is not a valid UTF-16LE string - */ - simdutf_warn_unused virtual size_t convert_utf16le_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-16BE string into Latin1 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. - */ - simdutf_warn_unused virtual size_t convert_utf16be_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-16LE string into Latin1 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. - */ - simdutf_warn_unused virtual result convert_utf16le_to_latin1_with_errors(const char16_t * input, size_t length, char* latin1_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-16BE string into Latin1 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. - */ - simdutf_warn_unused virtual result convert_utf16be_to_latin1_with_errors(const char16_t * input, size_t length, char* latin1_buffer) const noexcept = 0; - - /** - * Convert valid UTF-16LE string into Latin1 string. - * - * This function assumes that the input string is valid UTF-8. - - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_valid_utf16le_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) const noexcept = 0; - - /** - * Convert valid UTF-16BE string into Latin1 string. - * - * This function assumes that the input string is valid UTF-8. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_valid_utf16be_to_latin1(const char16_t * input, size_t length, char* latin1_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-16LE string into UTF-8 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param utf8_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if input is not a valid UTF-16LE string - */ - simdutf_warn_unused virtual size_t convert_utf16le_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-16BE string into UTF-8 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param utf8_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if input is not a valid UTF-16BE string - */ - simdutf_warn_unused virtual size_t convert_utf16be_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-16LE string into UTF-8 string and stop on error. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param utf8_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. - */ - simdutf_warn_unused virtual result convert_utf16le_to_utf8_with_errors(const char16_t * input, size_t length, char* utf8_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-16BE string into UTF-8 string and stop on error. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param utf8_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. - */ - simdutf_warn_unused virtual result convert_utf16be_to_utf8_with_errors(const char16_t * input, size_t length, char* utf8_buffer) const noexcept = 0; - - /** - * Convert valid UTF-16LE string into UTF-8 string. - * - * This function assumes that the input string is valid UTF-16LE. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param utf8_buffer the pointer to buffer that can hold the conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_valid_utf16le_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) const noexcept = 0; - - /** - * Convert valid UTF-16BE string into UTF-8 string. - * - * This function assumes that the input string is valid UTF-16BE. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param utf8_buffer the pointer to buffer that can hold the conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_valid_utf16be_to_utf8(const char16_t * input, size_t length, char* utf8_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-16LE string into UTF-32 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param utf32_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if input is not a valid UTF-16LE string - */ - simdutf_warn_unused virtual size_t convert_utf16le_to_utf32(const char16_t * input, size_t length, char32_t* utf32_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-16BE string into UTF-32 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param utf32_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if input is not a valid UTF-16BE string - */ - simdutf_warn_unused virtual size_t convert_utf16be_to_utf32(const char16_t * input, size_t length, char32_t* utf32_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-16LE string into UTF-32 string and stop on error. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param utf32_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char32_t written if successful. - */ - simdutf_warn_unused virtual result convert_utf16le_to_utf32_with_errors(const char16_t * input, size_t length, char32_t* utf32_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-16BE string into UTF-32 string and stop on error. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param utf32_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char32_t written if successful. - */ - simdutf_warn_unused virtual result convert_utf16be_to_utf32_with_errors(const char16_t * input, size_t length, char32_t* utf32_buffer) const noexcept = 0; - - /** - * Convert valid UTF-16LE string into UTF-32 string. - * - * This function assumes that the input string is valid UTF-16LE. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param utf32_buffer the pointer to buffer that can hold the conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_valid_utf16le_to_utf32(const char16_t * input, size_t length, char32_t* utf32_buffer) const noexcept = 0; - - /** - * Convert valid UTF-16LE string into UTF-32BE string. - * - * This function assumes that the input string is valid UTF-16BE. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @param utf32_buffer the pointer to buffer that can hold the conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_valid_utf16be_to_utf32(const char16_t * input, size_t length, char32_t* utf32_buffer) const noexcept = 0; - - /** - * Compute the number of bytes that this UTF-16LE string would require in UTF-8 format. - * - * This function does not validate the input. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @return the number of bytes required to encode the UTF-16LE string as UTF-8 - */ - simdutf_warn_unused virtual size_t utf8_length_from_utf16le(const char16_t * input, size_t length) const noexcept = 0; - - /** - * Compute the number of bytes that this UTF-16BE string would require in UTF-8 format. - * - * This function does not validate the input. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @return the number of bytes required to encode the UTF-16BE string as UTF-8 - */ - simdutf_warn_unused virtual size_t utf8_length_from_utf16be(const char16_t * input, size_t length) const noexcept = 0; - - /** - * Convert possibly broken UTF-32 string into Latin1 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if input is not a valid UTF-32 string - */ - - simdutf_warn_unused virtual size_t convert_utf32_to_latin1(const char32_t * input, size_t length, char* latin1_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-32 string into Latin1 string and stop on error. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param latin1_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. - */ - - simdutf_warn_unused virtual result convert_utf32_to_latin1_with_errors(const char32_t * input, size_t length, char* latin1_buffer) const noexcept = 0; - - /** - * Convert valid UTF-32 string into Latin1 string. - * - * This function assumes that the input string is valid UTF-32. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param latin1_buffer the pointer to buffer that can hold the conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_valid_utf32_to_latin1(const char32_t * input, size_t length, char* latin1_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-32 string into UTF-8 string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param utf8_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if input is not a valid UTF-32 string - */ - simdutf_warn_unused virtual size_t convert_utf32_to_utf8(const char32_t * input, size_t length, char* utf8_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-32 string into UTF-8 string and stop on error. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param utf8_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. - */ - simdutf_warn_unused virtual result convert_utf32_to_utf8_with_errors(const char32_t * input, size_t length, char* utf8_buffer) const noexcept = 0; - - /** - * Convert valid UTF-32 string into UTF-8 string. - * - * This function assumes that the input string is valid UTF-32. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param utf8_buffer the pointer to buffer that can hold the conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_valid_utf32_to_utf8(const char32_t * input, size_t length, char* utf8_buffer) const noexcept = 0; - - - /** - * Return the number of bytes that this UTF-16 string would require in Latin1 format. - * - * - * @param input the UTF-16 string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @return the number of bytes required to encode the UTF-16 string as Latin1 - */ + /** + * The description of this implementation. + * + * const implementation *impl = simdutf::active_implementation; + * cout << "simdutf is optimized for " << impl->name() << "(" << impl->description() << ")" << endl; + * + * @return the name of the implementation, e.g. "haswell", "westmere", "arm64" + */ + virtual const std::string& description() const { return _description; } + + /** + * The instruction sets this implementation is compiled against + * and the current CPU match. This function may poll the current CPU/system + * and should therefore not be called too often if performance is a concern. + * + * + * @return true if the implementation can be safely used on the current system (determined at runtime) + */ + bool supported_by_runtime_system() const; + + /** + * This function will try to detect the encoding + * @param input the string to identify + * @param length the length of the string in bytes. + * @return the encoding type detected + */ + virtual encoding_type autodetect_encoding(const char* input, size_t length) const noexcept; + + /** + * This function will try to detect the possible encodings in one pass + * @param input the string to identify + * @param length the length of the string in bytes. + * @return the encoding type detected + */ + virtual int detect_encodings(const char* input, size_t length) const noexcept = 0; + + /** + * @private For internal implementation use + * + * The instruction sets this implementation is compiled against. + * + * @return a mask of all required `internal::instruction_set::` values + */ + virtual uint32_t required_instruction_sets() const { return _required_instruction_sets; } + + /** + * Validate the UTF-8 string. + * + * Overridden by each implementation. + * + * @param buf the UTF-8 string to validate. + * @param len the length of the string in bytes. + * @return true if and only if the string is valid UTF-8. + */ + simdutf_warn_unused virtual bool validate_utf8(const char* buf, size_t len) const noexcept = 0; + + /** + * Validate the UTF-8 string and stop on errors. + * + * Overridden by each implementation. + * + * @param buf the UTF-8 string to validate. + * @param len the length of the string in bytes. + * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. + */ + simdutf_warn_unused virtual result validate_utf8_with_errors(const char* buf, size_t len) const noexcept = 0; + + /** + * Validate the ASCII string. + * + * Overridden by each implementation. + * + * @param buf the ASCII string to validate. + * @param len the length of the string in bytes. + * @return true if and only if the string is valid ASCII. + */ + simdutf_warn_unused virtual bool validate_ascii(const char* buf, size_t len) const noexcept = 0; + + /** + * Validate the ASCII string and stop on error. + * + * Overridden by each implementation. + * + * @param buf the ASCII string to validate. + * @param len the length of the string in bytes. + * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. + */ + simdutf_warn_unused virtual result validate_ascii_with_errors(const char* buf, size_t len) const noexcept = 0; + + /** + * Validate the UTF-16LE string.This function may be best when you expect + * the input to be almost always valid. Otherwise, consider using + * validate_utf16le_with_errors. + * + * Overridden by each implementation. + * + * This function is not BOM-aware. + * + * @param buf the UTF-16LE string to validate. + * @param len the length of the string in number of 2-byte words (char16_t). + * @return true if and only if the string is valid UTF-16LE. + */ + simdutf_warn_unused virtual bool validate_utf16le(const char16_t* buf, size_t len) const noexcept = 0; + + /** + * Validate the UTF-16BE string. This function may be best when you expect + * the input to be almost always valid. Otherwise, consider using + * validate_utf16be_with_errors. + * + * Overridden by each implementation. + * + * This function is not BOM-aware. + * + * @param buf the UTF-16BE string to validate. + * @param len the length of the string in number of 2-byte words (char16_t). + * @return true if and only if the string is valid UTF-16BE. + */ + simdutf_warn_unused virtual bool validate_utf16be(const char16_t* buf, size_t len) const noexcept = 0; + + /** + * Validate the UTF-16LE string and stop on error. It might be faster than + * validate_utf16le when an error is expected to occur early. + * + * Overridden by each implementation. + * + * This function is not BOM-aware. + * + * @param buf the UTF-16LE string to validate. + * @param len the length of the string in number of 2-byte words (char16_t). + * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. + */ + simdutf_warn_unused virtual result validate_utf16le_with_errors(const char16_t* buf, size_t len) const noexcept = 0; + + /** + * Validate the UTF-16BE string and stop on error. It might be faster than + * validate_utf16be when an error is expected to occur early. + * + * Overridden by each implementation. + * + * This function is not BOM-aware. + * + * @param buf the UTF-16BE string to validate. + * @param len the length of the string in number of 2-byte words (char16_t). + * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. + */ + simdutf_warn_unused virtual result validate_utf16be_with_errors(const char16_t* buf, size_t len) const noexcept = 0; + + /** + * Validate the UTF-32 string. + * + * Overridden by each implementation. + * + * This function is not BOM-aware. + * + * @param buf the UTF-32 string to validate. + * @param len the length of the string in number of 4-byte words (char32_t). + * @return true if and only if the string is valid UTF-32. + */ + simdutf_warn_unused virtual bool validate_utf32(const char32_t* buf, size_t len) const noexcept = 0; + + /** + * Validate the UTF-32 string and stop on error. + * + * Overridden by each implementation. + * + * This function is not BOM-aware. + * + * @param buf the UTF-32 string to validate. + * @param len the length of the string in number of 4-byte words (char32_t). + * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. + */ + simdutf_warn_unused virtual result validate_utf32_with_errors(const char32_t* buf, size_t len) const noexcept = 0; + + /** + * Convert Latin1 string into UTF8 string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return the number of written char; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_latin1_to_utf8(const char* input, size_t length, char* utf8_output) const noexcept = 0; + + /** + * Convert possibly Latin1 string into UTF-16LE string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_latin1_to_utf16le(const char* input, size_t length, char16_t* utf16_output) const noexcept = 0; + + /** + * Convert Latin1 string into UTF-16BE string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_latin1_to_utf16be(const char* input, size_t length, char16_t* utf16_output) const noexcept = 0; + + /** + * Convert Latin1 string into UTF-32 string. + * + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the Latin1 string to convert + * @param length the length of the string in bytes + * @param utf32_buffer the pointer to buffer that can hold conversion result + * @return the number of written char32_t; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_latin1_to_utf32(const char* input, size_t length, char32_t* utf32_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-8 string into latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return the number of written char; 0 if the input was not valid UTF-8 string + */ + simdutf_warn_unused virtual size_t convert_utf8_to_latin1(const char* input, size_t length, char* latin1_output) const noexcept = 0; + + /** + * Convert possibly broken UTF-8 string into latin1 string. with errors + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. + */ + simdutf_warn_unused virtual result convert_utf8_to_latin1_with_errors(const char* input, size_t length, char* latin1_output) const noexcept = 0; + + /** + * Convert valid UTF-8 string into latin1 string. + * + * This function assumes that the input string is valid UTF-8. + * + * This function is not BOM-aware. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param latin1_output the pointer to buffer that can hold conversion result + * @return the number of written char; 0 if the input was not valid UTF-8 string + */ + simdutf_warn_unused virtual size_t convert_valid_utf8_to_latin1(const char* input, size_t length, char* latin1_output) const noexcept = 0; + + /** + * Convert possibly broken UTF-8 string into UTF-16LE string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t; 0 if the input was not valid UTF-8 string + */ + simdutf_warn_unused virtual size_t convert_utf8_to_utf16le(const char* input, size_t length, char16_t* utf16_output) const noexcept = 0; + + /** + * Convert possibly broken UTF-8 string into UTF-16BE string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t; 0 if the input was not valid UTF-8 string + */ + simdutf_warn_unused virtual size_t convert_utf8_to_utf16be(const char* input, size_t length, char16_t* utf16_output) const noexcept = 0; + + /** + * Convert possibly broken UTF-8 string into UTF-16LE string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. + */ + simdutf_warn_unused virtual result convert_utf8_to_utf16le_with_errors(const char* input, size_t length, char16_t* utf16_output) const noexcept = 0; + + /** + * Convert possibly broken UTF-8 string into UTF-16BE string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of words validated if successful. + */ + simdutf_warn_unused virtual result convert_utf8_to_utf16be_with_errors(const char* input, size_t length, char16_t* utf16_output) const noexcept = 0; + + /** + * Convert possibly broken UTF-8 string into UTF-32 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param utf32_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t; 0 if the input was not valid UTF-8 string + */ + simdutf_warn_unused virtual size_t convert_utf8_to_utf32(const char* input, size_t length, char32_t* utf32_output) const noexcept = 0; + + /** + * Convert possibly broken UTF-8 string into UTF-32 string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param utf32_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char32_t written if successful. + */ + simdutf_warn_unused virtual result convert_utf8_to_utf32_with_errors(const char* input, size_t length, char32_t* utf32_output) const noexcept = 0; + + /** + * Convert valid UTF-8 string into UTF-16LE string. + * + * This function assumes that the input string is valid UTF-8. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t + */ + simdutf_warn_unused virtual size_t convert_valid_utf8_to_utf16le(const char* input, size_t length, char16_t* utf16_buffer) const noexcept = 0; + + /** + * Convert valid UTF-8 string into UTF-16BE string. + * + * This function assumes that the input string is valid UTF-8. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char16_t + */ + simdutf_warn_unused virtual size_t convert_valid_utf8_to_utf16be(const char* input, size_t length, char16_t* utf16_buffer) const noexcept = 0; + + /** + * Convert valid UTF-8 string into UTF-32 string. + * + * This function assumes that the input string is valid UTF-8. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in bytes + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return the number of written char32_t + */ + simdutf_warn_unused virtual size_t convert_valid_utf8_to_utf32(const char* input, size_t length, char32_t* utf32_buffer) const noexcept = 0; + + /** + * Compute the number of 2-byte words that this UTF-8 string would require in UTF-16LE format. + * + * This function does not validate the input. + * + * @param input the UTF-8 string to process + * @param length the length of the string in bytes + * @return the number of char16_t words required to encode the UTF-8 string as UTF-16LE + */ + simdutf_warn_unused virtual size_t utf16_length_from_utf8(const char* input, size_t length) const noexcept = 0; + + /** + * Compute the number of 4-byte words that this UTF-8 string would require in UTF-32 format. + * + * This function is equivalent to count_utf8. + * + * This function does not validate the input. + * + * @param input the UTF-8 string to process + * @param length the length of the string in bytes + * @return the number of char32_t words required to encode the UTF-8 string as UTF-32 + */ + simdutf_warn_unused virtual size_t utf32_length_from_utf8(const char* input, size_t length) const noexcept = 0; + + /** + * Convert possibly broken UTF-16LE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-16LE string + */ + simdutf_warn_unused virtual size_t convert_utf16le_to_latin1(const char16_t* input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16BE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + simdutf_warn_unused virtual size_t convert_utf16be_to_latin1(const char16_t* input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16LE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + simdutf_warn_unused virtual result convert_utf16le_to_latin1_with_errors(const char16_t* input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16BE string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + simdutf_warn_unused virtual result convert_utf16be_to_latin1_with_errors(const char16_t* input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert valid UTF-16LE string into Latin1 string. + * + * This function assumes that the input string is valid UTF-8. + + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf16le_to_latin1(const char16_t* input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert valid UTF-16BE string into Latin1 string. + * + * This function assumes that the input string is valid UTF-8. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf16be_to_latin1(const char16_t* input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16LE string into UTF-8 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param utf8_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-16LE string + */ + simdutf_warn_unused virtual size_t convert_utf16le_to_utf8(const char16_t* input, size_t length, char* utf8_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16BE string into UTF-8 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param utf8_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-16BE string + */ + simdutf_warn_unused virtual size_t convert_utf16be_to_utf8(const char16_t* input, size_t length, char* utf8_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16LE string into UTF-8 string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param utf8_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + simdutf_warn_unused virtual result convert_utf16le_to_utf8_with_errors(const char16_t* input, size_t length, char* utf8_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16BE string into UTF-8 string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param utf8_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + simdutf_warn_unused virtual result convert_utf16be_to_utf8_with_errors(const char16_t* input, size_t length, char* utf8_buffer) const noexcept = 0; + + /** + * Convert valid UTF-16LE string into UTF-8 string. + * + * This function assumes that the input string is valid UTF-16LE. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param utf8_buffer the pointer to buffer that can hold the conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf16le_to_utf8(const char16_t* input, size_t length, char* utf8_buffer) const noexcept = 0; + + /** + * Convert valid UTF-16BE string into UTF-8 string. + * + * This function assumes that the input string is valid UTF-16BE. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param utf8_buffer the pointer to buffer that can hold the conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf16be_to_utf8(const char16_t* input, size_t length, char* utf8_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16LE string into UTF-32 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param utf32_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-16LE string + */ + simdutf_warn_unused virtual size_t convert_utf16le_to_utf32(const char16_t* input, size_t length, char32_t* utf32_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16BE string into UTF-32 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param utf32_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-16BE string + */ + simdutf_warn_unused virtual size_t convert_utf16be_to_utf32(const char16_t* input, size_t length, char32_t* utf32_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16LE string into UTF-32 string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param utf32_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char32_t written if successful. + */ + simdutf_warn_unused virtual result convert_utf16le_to_utf32_with_errors(const char16_t* input, size_t length, char32_t* utf32_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-16BE string into UTF-32 string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param utf32_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char32_t written if successful. + */ + simdutf_warn_unused virtual result convert_utf16be_to_utf32_with_errors(const char16_t* input, size_t length, char32_t* utf32_buffer) const noexcept = 0; + + /** + * Convert valid UTF-16LE string into UTF-32 string. + * + * This function assumes that the input string is valid UTF-16LE. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param utf32_buffer the pointer to buffer that can hold the conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf16le_to_utf32(const char16_t* input, size_t length, char32_t* utf32_buffer) const noexcept = 0; + + /** + * Convert valid UTF-16LE string into UTF-32BE string. + * + * This function assumes that the input string is valid UTF-16BE. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @param utf32_buffer the pointer to buffer that can hold the conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf16be_to_utf32(const char16_t* input, size_t length, char32_t* utf32_buffer) const noexcept = 0; + + /** + * Compute the number of bytes that this UTF-16LE string would require in UTF-8 format. + * + * This function does not validate the input. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @return the number of bytes required to encode the UTF-16LE string as UTF-8 + */ + simdutf_warn_unused virtual size_t utf8_length_from_utf16le(const char16_t* input, size_t length) const noexcept = 0; + + /** + * Compute the number of bytes that this UTF-16BE string would require in UTF-8 format. + * + * This function does not validate the input. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @return the number of bytes required to encode the UTF-16BE string as UTF-8 + */ + simdutf_warn_unused virtual size_t utf8_length_from_utf16be(const char16_t* input, size_t length) const noexcept = 0; + + /** + * Convert possibly broken UTF-32 string into Latin1 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-32 string + */ + + simdutf_warn_unused virtual size_t convert_utf32_to_latin1(const char32_t* input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-32 string into Latin1 string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param latin1_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + + simdutf_warn_unused virtual result convert_utf32_to_latin1_with_errors(const char32_t* input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert valid UTF-32 string into Latin1 string. + * + * This function assumes that the input string is valid UTF-32. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param latin1_buffer the pointer to buffer that can hold the conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf32_to_latin1(const char32_t* input, size_t length, char* latin1_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-32 string into UTF-8 string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param utf8_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-32 string + */ + simdutf_warn_unused virtual size_t convert_utf32_to_utf8(const char32_t* input, size_t length, char* utf8_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-32 string into UTF-8 string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param utf8_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char written if successful. + */ + simdutf_warn_unused virtual result convert_utf32_to_utf8_with_errors(const char32_t* input, size_t length, char* utf8_buffer) const noexcept = 0; + + /** + * Convert valid UTF-32 string into UTF-8 string. + * + * This function assumes that the input string is valid UTF-32. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param utf8_buffer the pointer to buffer that can hold the conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf32_to_utf8(const char32_t* input, size_t length, char* utf8_buffer) const noexcept = 0; + + /** + * Return the number of bytes that this UTF-16 string would require in Latin1 format. + * + * + * @param input the UTF-16 string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @return the number of bytes required to encode the UTF-16 string as Latin1 + */ simdutf_warn_unused virtual size_t utf16_length_from_latin1(size_t length) const noexcept = 0; - /** - * Convert possibly broken UTF-32 string into UTF-16LE string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if input is not a valid UTF-32 string - */ - simdutf_warn_unused virtual size_t convert_utf32_to_utf16le(const char32_t * input, size_t length, char16_t* utf16_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-32 string into UTF-16BE string. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return number of written words; 0 if input is not a valid UTF-32 string - */ - simdutf_warn_unused virtual size_t convert_utf32_to_utf16be(const char32_t * input, size_t length, char16_t* utf16_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-32 string into UTF-16LE string and stop on error. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char16_t written if successful. - */ - simdutf_warn_unused virtual result convert_utf32_to_utf16le_with_errors(const char32_t * input, size_t length, char16_t* utf16_buffer) const noexcept = 0; - - /** - * Convert possibly broken UTF-32 string into UTF-16BE string and stop on error. - * - * During the conversion also validation of the input string is done. - * This function is suitable to work with inputs from untrusted sources. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param utf16_buffer the pointer to buffer that can hold conversion result - * @return a result pair struct with an error code and either the position of the error if any or the number of char16_t written if successful. - */ - simdutf_warn_unused virtual result convert_utf32_to_utf16be_with_errors(const char32_t * input, size_t length, char16_t* utf16_buffer) const noexcept = 0; - - /** - * Convert valid UTF-32 string into UTF-16LE string. - * - * This function assumes that the input string is valid UTF-32. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param utf16_buffer the pointer to buffer that can hold the conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_valid_utf32_to_utf16le(const char32_t * input, size_t length, char16_t* utf16_buffer) const noexcept = 0; - - /** - * Convert valid UTF-32 string into UTF-16BE string. - * - * This function assumes that the input string is valid UTF-32. - * - * This function is not BOM-aware. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @param utf16_buffer the pointer to buffer that can hold the conversion result - * @return number of written words; 0 if conversion is not possible - */ - simdutf_warn_unused virtual size_t convert_valid_utf32_to_utf16be(const char32_t * input, size_t length, char16_t* utf16_buffer) const noexcept = 0; - - /** - * Change the endianness of the input. Can be used to go from UTF-16LE to UTF-16BE or - * from UTF-16BE to UTF-16LE. - * - * This function does not validate the input. - * - * This function is not BOM-aware. - * - * @param input the UTF-16 string to process - * @param length the length of the string in 2-byte words (char16_t) - * @param output the pointer to buffer that can hold the conversion result - */ - virtual void change_endianness_utf16(const char16_t * input, size_t length, char16_t * output) const noexcept = 0; - - /** - * Return the number of bytes that this Latin1 string would require in UTF-8 format. - * - * @param input the Latin1 string to convert - * @param length the length of the string bytes - * @return the number of bytes required to encode the Latin1 string as UTF-8 - */ - simdutf_warn_unused virtual size_t utf8_length_from_latin1(const char * input, size_t length) const noexcept = 0; - - /** - * Compute the number of bytes that this UTF-32 string would require in UTF-8 format. - * - * This function does not validate the input. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @return the number of bytes required to encode the UTF-32 string as UTF-8 - */ - simdutf_warn_unused virtual size_t utf8_length_from_utf32(const char32_t * input, size_t length) const noexcept = 0; - - /** - * Compute the number of bytes that this UTF-32 string would require in Latin1 format. - * - * This function does not validate the input. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @return the number of bytes required to encode the UTF-32 string as Latin1 - */ - simdutf_warn_unused virtual size_t latin1_length_from_utf32( size_t length) const noexcept = 0; - - /** - * Compute the number of bytes that this UTF-8 string would require in Latin1 format. - * - * This function does not validate the input. - * - * @param input the UTF-8 string to convert - * @param length the length of the string in byte - * @return the number of bytes required to encode the UTF-8 string as Latin1 - */ - simdutf_warn_unused virtual size_t latin1_length_from_utf8(const char * input, size_t length) const noexcept = 0; + /** + * Convert possibly broken UTF-32 string into UTF-16LE string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-32 string + */ + simdutf_warn_unused virtual size_t convert_utf32_to_utf16le(const char32_t* input, size_t length, char16_t* utf16_buffer) const noexcept = 0; -/* - * Compute the number of bytes that this UTF-16LE/BE string would require in Latin1 format. - * - * This function does not validate the input. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @return the number of bytes required to encode the UTF-16LE string as Latin1 - */ - simdutf_warn_unused virtual size_t latin1_length_from_utf16(size_t length) const noexcept = 0; - - /** - * Compute the number of two-byte words that this UTF-32 string would require in UTF-16 format. - * - * This function does not validate the input. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @return the number of bytes required to encode the UTF-32 string as UTF-16 - */ - simdutf_warn_unused virtual size_t utf16_length_from_utf32(const char32_t * input, size_t length) const noexcept = 0; - - - /** - * Return the number of bytes that this UTF-32 string would require in Latin1 format. - * - * This function does not validate the input. - * - * @param input the UTF-32 string to convert - * @param length the length of the string in 4-byte words (char32_t) - * @return the number of bytes required to encode the UTF-32 string as Latin1 - */ + /** + * Convert possibly broken UTF-32 string into UTF-16BE string. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return number of written words; 0 if input is not a valid UTF-32 string + */ + simdutf_warn_unused virtual size_t convert_utf32_to_utf16be(const char32_t* input, size_t length, char16_t* utf16_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-32 string into UTF-16LE string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char16_t written if successful. + */ + simdutf_warn_unused virtual result convert_utf32_to_utf16le_with_errors(const char32_t* input, size_t length, char16_t* utf16_buffer) const noexcept = 0; + + /** + * Convert possibly broken UTF-32 string into UTF-16BE string and stop on error. + * + * During the conversion also validation of the input string is done. + * This function is suitable to work with inputs from untrusted sources. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param utf16_buffer the pointer to buffer that can hold conversion result + * @return a result pair struct with an error code and either the position of the error if any or the number of char16_t written if successful. + */ + simdutf_warn_unused virtual result convert_utf32_to_utf16be_with_errors(const char32_t* input, size_t length, char16_t* utf16_buffer) const noexcept = 0; + + /** + * Convert valid UTF-32 string into UTF-16LE string. + * + * This function assumes that the input string is valid UTF-32. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param utf16_buffer the pointer to buffer that can hold the conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf32_to_utf16le(const char32_t* input, size_t length, char16_t* utf16_buffer) const noexcept = 0; + + /** + * Convert valid UTF-32 string into UTF-16BE string. + * + * This function assumes that the input string is valid UTF-32. + * + * This function is not BOM-aware. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @param utf16_buffer the pointer to buffer that can hold the conversion result + * @return number of written words; 0 if conversion is not possible + */ + simdutf_warn_unused virtual size_t convert_valid_utf32_to_utf16be(const char32_t* input, size_t length, char16_t* utf16_buffer) const noexcept = 0; + + /** + * Change the endianness of the input. Can be used to go from UTF-16LE to UTF-16BE or + * from UTF-16BE to UTF-16LE. + * + * This function does not validate the input. + * + * This function is not BOM-aware. + * + * @param input the UTF-16 string to process + * @param length the length of the string in 2-byte words (char16_t) + * @param output the pointer to buffer that can hold the conversion result + */ + virtual void change_endianness_utf16(const char16_t* input, size_t length, char16_t* output) const noexcept = 0; + + /** + * Return the number of bytes that this Latin1 string would require in UTF-8 format. + * + * @param input the Latin1 string to convert + * @param length the length of the string bytes + * @return the number of bytes required to encode the Latin1 string as UTF-8 + */ + simdutf_warn_unused virtual size_t utf8_length_from_latin1(const char* input, size_t length) const noexcept = 0; + + /** + * Compute the number of bytes that this UTF-32 string would require in UTF-8 format. + * + * This function does not validate the input. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @return the number of bytes required to encode the UTF-32 string as UTF-8 + */ + simdutf_warn_unused virtual size_t utf8_length_from_utf32(const char32_t* input, size_t length) const noexcept = 0; + + /** + * Compute the number of bytes that this UTF-32 string would require in Latin1 format. + * + * This function does not validate the input. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @return the number of bytes required to encode the UTF-32 string as Latin1 + */ + simdutf_warn_unused virtual size_t latin1_length_from_utf32(size_t length) const noexcept = 0; + + /** + * Compute the number of bytes that this UTF-8 string would require in Latin1 format. + * + * This function does not validate the input. + * + * @param input the UTF-8 string to convert + * @param length the length of the string in byte + * @return the number of bytes required to encode the UTF-8 string as Latin1 + */ + simdutf_warn_unused virtual size_t latin1_length_from_utf8(const char* input, size_t length) const noexcept = 0; + + /* + * Compute the number of bytes that this UTF-16LE/BE string would require in Latin1 format. + * + * This function does not validate the input. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @return the number of bytes required to encode the UTF-16LE string as Latin1 + */ + simdutf_warn_unused virtual size_t latin1_length_from_utf16(size_t length) const noexcept = 0; + + /** + * Compute the number of two-byte words that this UTF-32 string would require in UTF-16 format. + * + * This function does not validate the input. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @return the number of bytes required to encode the UTF-32 string as UTF-16 + */ + simdutf_warn_unused virtual size_t utf16_length_from_utf32(const char32_t* input, size_t length) const noexcept = 0; + + /** + * Return the number of bytes that this UTF-32 string would require in Latin1 format. + * + * This function does not validate the input. + * + * @param input the UTF-32 string to convert + * @param length the length of the string in 4-byte words (char32_t) + * @return the number of bytes required to encode the UTF-32 string as Latin1 + */ simdutf_warn_unused virtual size_t utf32_length_from_latin1(size_t length) const noexcept = 0; - /* - * Compute the number of bytes that this UTF-16LE string would require in UTF-32 format. - * - * This function is equivalent to count_utf16le. - * - * This function does not validate the input. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @return the number of bytes required to encode the UTF-16LE string as UTF-32 - */ - simdutf_warn_unused virtual size_t utf32_length_from_utf16le(const char16_t * input, size_t length) const noexcept = 0; - - /* - * Compute the number of bytes that this UTF-16BE string would require in UTF-32 format. - * - * This function is equivalent to count_utf16be. - * - * This function does not validate the input. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to convert - * @param length the length of the string in 2-byte words (char16_t) - * @return the number of bytes required to encode the UTF-16BE string as UTF-32 - */ - simdutf_warn_unused virtual size_t utf32_length_from_utf16be(const char16_t * input, size_t length) const noexcept = 0; - - /** - * Count the number of code points (characters) in the string assuming that - * it is valid. - * - * This function assumes that the input string is valid UTF-16LE. - * - * This function is not BOM-aware. - * - * @param input the UTF-16LE string to process - * @param length the length of the string in 2-byte words (char16_t) - * @return number of code points - */ - simdutf_warn_unused virtual size_t count_utf16le(const char16_t * input, size_t length) const noexcept = 0; - - /** - * Count the number of code points (characters) in the string assuming that - * it is valid. - * - * This function assumes that the input string is valid UTF-16BE. - * - * This function is not BOM-aware. - * - * @param input the UTF-16BE string to process - * @param length the length of the string in 2-byte words (char16_t) - * @return number of code points - */ - simdutf_warn_unused virtual size_t count_utf16be(const char16_t * input, size_t length) const noexcept = 0; - - - /** - * Count the number of code points (characters) in the string assuming that - * it is valid. - * - * This function assumes that the input string is valid UTF-8. - * - * @param input the UTF-8 string to process - * @param length the length of the string in bytes - * @return number of code points - */ - simdutf_warn_unused virtual size_t count_utf8(const char * input, size_t length) const noexcept = 0; + /* + * Compute the number of bytes that this UTF-16LE string would require in UTF-32 format. + * + * This function is equivalent to count_utf16le. + * + * This function does not validate the input. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @return the number of bytes required to encode the UTF-16LE string as UTF-32 + */ + simdutf_warn_unused virtual size_t utf32_length_from_utf16le(const char16_t* input, size_t length) const noexcept = 0; + + /* + * Compute the number of bytes that this UTF-16BE string would require in UTF-32 format. + * + * This function is equivalent to count_utf16be. + * + * This function does not validate the input. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to convert + * @param length the length of the string in 2-byte words (char16_t) + * @return the number of bytes required to encode the UTF-16BE string as UTF-32 + */ + simdutf_warn_unused virtual size_t utf32_length_from_utf16be(const char16_t* input, size_t length) const noexcept = 0; + /** + * Count the number of code points (characters) in the string assuming that + * it is valid. + * + * This function assumes that the input string is valid UTF-16LE. + * + * This function is not BOM-aware. + * + * @param input the UTF-16LE string to process + * @param length the length of the string in 2-byte words (char16_t) + * @return number of code points + */ + simdutf_warn_unused virtual size_t count_utf16le(const char16_t* input, size_t length) const noexcept = 0; + /** + * Count the number of code points (characters) in the string assuming that + * it is valid. + * + * This function assumes that the input string is valid UTF-16BE. + * + * This function is not BOM-aware. + * + * @param input the UTF-16BE string to process + * @param length the length of the string in 2-byte words (char16_t) + * @return number of code points + */ + simdutf_warn_unused virtual size_t count_utf16be(const char16_t* input, size_t length) const noexcept = 0; + + /** + * Count the number of code points (characters) in the string assuming that + * it is valid. + * + * This function assumes that the input string is valid UTF-8. + * + * @param input the UTF-8 string to process + * @param length the length of the string in bytes + * @return number of code points + */ + simdutf_warn_unused virtual size_t count_utf8(const char* input, size_t length) const noexcept = 0; protected: - /** @private Construct an implementation with the given name and description. For subclasses. */ - simdutf_really_inline implementation( - std::string name, - std::string description, - uint32_t required_instruction_sets - ) : - _name(name), - _description(description), - _required_instruction_sets(required_instruction_sets) - { - } - virtual ~implementation()=default; + /** @private Construct an implementation with the given name and description. For subclasses. */ + simdutf_really_inline implementation( + std::string name, + std::string description, + uint32_t required_instruction_sets) + : _name(name) + , _description(description) + , _required_instruction_sets(required_instruction_sets) + { + } + virtual ~implementation() = default; private: - /** - * The name of this implementation. - */ - const std::string _name; - - /** - * The description of this implementation. - */ - const std::string _description; - - /** - * Instruction sets required for this implementation. - */ - const uint32_t _required_instruction_sets; + /** + * The name of this implementation. + */ + const std::string _name; + + /** + * The description of this implementation. + */ + const std::string _description; + + /** + * Instruction sets required for this implementation. + */ + const uint32_t _required_instruction_sets; }; /** @private */ @@ -3219,82 +3210,102 @@ namespace internal { */ class available_implementation_list { public: - /** Get the list of available implementations compiled into simdutf */ - simdutf_really_inline available_implementation_list() {} - /** Number of implementations */ - size_t size() const noexcept; - /** STL const begin() iterator */ - const implementation * const *begin() const noexcept; - /** STL const end() iterator */ - const implementation * const *end() const noexcept; - - /** - * Get the implementation with the given name. - * - * Case sensitive. - * - * const implementation *impl = simdutf::available_implementations["westmere"]; - * if (!impl) { exit(1); } - * if (!imp->supported_by_runtime_system()) { exit(1); } - * simdutf::active_implementation = impl; - * - * @param name the implementation to find, e.g. "westmere", "haswell", "arm64" - * @return the implementation, or nullptr if the parse failed. - */ - const implementation * operator[](const std::string &name) const noexcept { - for (const implementation * impl : *this) { - if (impl->name() == name) { return impl; } + /** Get the list of available implementations compiled into simdutf */ + simdutf_really_inline available_implementation_list() {} + /** Number of implementations */ + size_t size() const noexcept; + /** STL const begin() iterator */ + const implementation* const* begin() const noexcept; + /** STL const end() iterator */ + const implementation* const* end() const noexcept; + + /** + * Get the implementation with the given name. + * + * Case sensitive. + * + * const implementation *impl = simdutf::available_implementations["westmere"]; + * if (!impl) { exit(1); } + * if (!imp->supported_by_runtime_system()) { exit(1); } + * simdutf::active_implementation = impl; + * + * @param name the implementation to find, e.g. "westmere", "haswell", "arm64" + * @return the implementation, or nullptr if the parse failed. + */ + const implementation* operator[](const std::string& name) const noexcept + { + for (const implementation* impl : *this) { + if (impl->name() == name) { + return impl; + } + } + return nullptr; } - return nullptr; - } - - /** - * Detect the most advanced implementation supported by the current host. - * - * This is used to initialize the implementation on startup. - * - * const implementation *impl = simdutf::available_implementation::detect_best_supported(); - * simdutf::active_implementation = impl; - * - * @return the most advanced supported implementation for the current host, or an - * implementation that returns UNSUPPORTED_ARCHITECTURE if there is no supported - * implementation. Will never return nullptr. - */ - const implementation *detect_best_supported() const noexcept; + + /** + * Detect the most advanced implementation supported by the current host. + * + * This is used to initialize the implementation on startup. + * + * const implementation *impl = simdutf::available_implementation::detect_best_supported(); + * simdutf::active_implementation = impl; + * + * @return the most advanced supported implementation for the current host, or an + * implementation that returns UNSUPPORTED_ARCHITECTURE if there is no supported + * implementation. Will never return nullptr. + */ + const implementation* detect_best_supported() const noexcept; }; template<typename T> class atomic_ptr { public: - atomic_ptr(T *_ptr) : ptr{_ptr} {} + atomic_ptr(T* _ptr) + : ptr { _ptr } + { + } #if defined(SIMDUTF_NO_THREADS) - operator const T*() const { return ptr; } - const T& operator*() const { return *ptr; } - const T* operator->() const { return ptr; } - - operator T*() { return ptr; } - T& operator*() { return *ptr; } - T* operator->() { return ptr; } - atomic_ptr& operator=(T *_ptr) { ptr = _ptr; return *this; } + operator const T*() const + { + return ptr; + } + const T& operator*() const { return *ptr; } + const T* operator->() const { return ptr; } + + operator T*() { return ptr; } + T& operator*() { return *ptr; } + T* operator->() { return ptr; } + atomic_ptr& operator=(T* _ptr) + { + ptr = _ptr; + return *this; + } #else - operator const T*() const { return ptr.load(); } - const T& operator*() const { return *ptr; } - const T* operator->() const { return ptr.load(); } - - operator T*() { return ptr.load(); } - T& operator*() { return *ptr; } - T* operator->() { return ptr.load(); } - atomic_ptr& operator=(T *_ptr) { ptr = _ptr; return *this; } + operator const T*() const + { + return ptr.load(); + } + const T& operator*() const { return *ptr; } + const T* operator->() const { return ptr.load(); } + + operator T*() { return ptr.load(); } + T& operator*() { return *ptr; } + T* operator->() { return ptr.load(); } + atomic_ptr& operator=(T* _ptr) + { + ptr = _ptr; + return *this; + } #endif private: #if defined(SIMDUTF_NO_THREADS) - T* ptr; + T* ptr; #else - std::atomic<T*> ptr; + std::atomic<T*> ptr; #endif }; @@ -3308,25 +3319,22 @@ class detect_best_supported_implementation_on_first_use; extern SIMDUTF_DLLIMPORTEXPORT const internal::available_implementation_list& get_available_implementations(); /** - * The active implementation. - * - * Automatically initialized on first use to the most advanced implementation supported by this hardware. - */ + * The active implementation. + * + * Automatically initialized on first use to the most advanced implementation supported by this hardware. + */ extern SIMDUTF_DLLIMPORTEXPORT internal::atomic_ptr<const implementation>& get_active_implementation(); - } // namespace simdutf #endif // SIMDUTF_IMPLEMENTATION_H /* end file include/simdutf/implementation.h */ - // Implementation-internal files (must be included before the implementations themselves, to keep // amalgamation working--otherwise, the first time a file is included, it might be put inside the // #ifdef SIMDUTF_IMPLEMENTATION_ARM64/FALLBACK/etc., which means the other implementations can't // compile unless that implementation is turned on). - SIMDUTF_POP_DISABLE_WARNINGS #endif // SIMDUTF_H diff --git a/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h b/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h index 229897fad..740c6d9a9 100644 --- a/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h +++ b/src/bun.js/bindings/webcore/DOMClientIsoSubspaces.h @@ -37,6 +37,7 @@ public: std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForCommonJSModuleRecord; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForJSMockImplementation; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForJSMockFunction; + std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForAsyncContextFrame; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForMockWithImplementationCleanupData; std::unique_ptr<GCClient::IsoSubspace> m_clientSubspaceForProcessObject; diff --git a/src/bun.js/bindings/webcore/DOMIsoSubspaces.h b/src/bun.js/bindings/webcore/DOMIsoSubspaces.h index 682f27980..52be5872a 100644 --- a/src/bun.js/bindings/webcore/DOMIsoSubspaces.h +++ b/src/bun.js/bindings/webcore/DOMIsoSubspaces.h @@ -37,6 +37,7 @@ public: std::unique_ptr<IsoSubspace> m_subspaceForCommonJSModuleRecord; std::unique_ptr<IsoSubspace> m_subspaceForJSMockImplementation; std::unique_ptr<IsoSubspace> m_subspaceForJSMockFunction; + std::unique_ptr<IsoSubspace> m_subspaceForAsyncContextFrame; std::unique_ptr<IsoSubspace> m_subspaceForMockWithImplementationCleanupData; std::unique_ptr<IsoSubspace> m_subspaceForProcessObject; diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index fb855e047..f331fbf9f 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -2597,7 +2597,7 @@ pub const EventListenerMixin = struct { for (listeners.items) |listener_ref| { vm.tick(); - var result = js.JSObjectCallAsFunctionReturnValue(vm.global, listener_ref, null, 1, &fetch_args); + var result = js.JSObjectCallAsFunctionReturnValue(vm.global, JSValue.fromRef(listener_ref), JSValue.zero, 1, &fetch_args); vm.tick(); var promise = JSInternalPromise.resolvedPromise(vm.global, result); diff --git a/src/bun.js/javascript_core_c_api.zig b/src/bun.js/javascript_core_c_api.zig index 367b4e279..4e131f84f 100644 --- a/src/bun.js/javascript_core_c_api.zig +++ b/src/bun.js/javascript_core_c_api.zig @@ -353,7 +353,7 @@ pub const OpaqueJSPropertyNameAccumulator = struct_OpaqueJSPropertyNameAccumulat // This is a workaround for not receiving a JSException* object // This function lets us use the C API but returns a plain old JSValue // allowing us to have exceptions that include stack traces -pub extern "c" fn JSObjectCallAsFunctionReturnValue(ctx: JSContextRef, object: JSObjectRef, thisObject: JSObjectRef, argumentCount: usize, arguments: [*c]const JSValueRef) cpp.JSValue; +pub extern "c" fn JSObjectCallAsFunctionReturnValue(ctx: JSContextRef, object: cpp.JSValue, thisObject: cpp.JSValue, argumentCount: usize, arguments: [*c]const JSValueRef) cpp.JSValue; pub extern "c" fn JSObjectCallAsFunctionReturnValueHoldingAPILock(ctx: JSContextRef, object: JSObjectRef, thisObject: JSObjectRef, argumentCount: usize, arguments: [*c]const JSValueRef) cpp.JSValue; pub extern fn JSRemoteInspectorDisableAutoStart() void; diff --git a/src/bun.js/scripts/generate-jssink.js b/src/bun.js/scripts/generate-jssink.js index 715df1f82..dc8a117b3 100644 --- a/src/bun.js/scripts/generate-jssink.js +++ b/src/bun.js/scripts/generate-jssink.js @@ -149,14 +149,14 @@ function header() { void* wrapped() const { return m_sinkPtr; } void detach(); - void start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose); + void start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSValue onPull, JSC::JSValue onClose); DECLARE_VISIT_CHILDREN; static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); void* m_sinkPtr; - mutable WriteBarrier<JSC::JSFunction> m_onPull; - mutable WriteBarrier<JSC::JSFunction> m_onClose; + mutable WriteBarrier<JSC::Unknown> m_onPull; + mutable WriteBarrier<JSC::Unknown> m_onClose; mutable JSC::Weak<JSObject> m_weakReadableStream; ${controller}(JSC::VM& vm, JSC::Structure* structure, void* sinkPtr) @@ -175,7 +175,7 @@ JSC_DECLARE_CUSTOM_GETTER(function${name}__getter); const outer = ` // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at ${new Date().toISOString()} +// Generated by 'make generate-sink' // #pragma once @@ -211,7 +211,7 @@ Structure* createJSSinkControllerStructure(JSC::VM& vm, JSC::JSGlobalObject* glo async function implementation() { const head = ` // AUTO-GENERATED FILE. DO NOT EDIT. -// Generated by 'make generate-sink' at ${new Date().toISOString()} +// Generated by 'make generate-sink' // To regenerate this file, run: // // make generate-sink @@ -221,6 +221,7 @@ async function implementation() { #include "BunClientData.h" #include "JSSink.h" +#include "AsyncContextFrame.h" #include "ActiveDOMObject.h" #include "ExtendedDOMClientIsoSubspaces.h" @@ -285,6 +286,8 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic JSC::JSValue readableStream = callFrame->argument(0); JSC::JSValue onPull = callFrame->argument(1); JSC::JSValue onClose = callFrame->argument(2); + JSC::JSValue asyncContext = callFrame->argument(3); + if (!readableStream.isObject()) { scope.throwException(globalObject, JSC::createTypeError(globalObject, "Expected ReadableStream"_s)); return JSC::JSValue::encode(JSC::jsUndefined()); @@ -292,15 +295,16 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic if (!onPull.isObject() || !onPull.isCallable()) { onPull = JSC::jsUndefined(); + } else if (!asyncContext.isUndefined()) { + onPull = AsyncContextFrame::create(globalObject, onPull, asyncContext); } if (!onClose.isObject() || !onClose.isCallable()) { onClose = JSC::jsUndefined(); + } else if (!asyncContext.isUndefined()) { + onClose = AsyncContextFrame::create(globalObject, onClose, asyncContext); } - JSC::JSFunction *onPullFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onPull); - JSC::JSFunction *onCloseFunction = JSC::jsDynamicCast<JSC::JSFunction*>(onClose); - `; var templ = head; @@ -318,7 +322,7 @@ JSC_DEFINE_HOST_FUNCTION(functionStartDirectStream, (JSC::JSGlobalObject * lexic return JSC::JSValue::encode(JSC::jsUndefined()); } - ${name}Controller->start(globalObject, readableStream, onPullFunction, onCloseFunction); + ${name}Controller->start(globalObject, readableStream, onPull, onClose); } `; isFirst = false; @@ -771,7 +775,7 @@ void ${className}::visitChildrenImpl(JSCell* cell, Visitor& visitor) DEFINE_VISIT_CHILDREN(${className}); -void ${controller}::start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSFunction *onPull, JSC::JSFunction *onClose) { +void ${controller}::start(JSC::JSGlobalObject *globalObject, JSC::JSValue readableStream, JSC::JSValue onPull, JSC::JSValue onClose) { this->m_weakReadableStream = JSC::Weak<JSC::JSObject>(readableStream.getObject()); this->m_onPull.set(globalObject->vm(), this, onPull); this->m_onClose.set(globalObject->vm(), this, onClose); @@ -901,18 +905,17 @@ extern "C" void ${name}__onReady(JSC__JSValue controllerValue, JSC__JSValue amt, { WebCore::${controller}* controller = JSC::jsCast<WebCore::${controller}*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction *function = controller->m_onPull.get(); - if (function == nullptr) + JSC::JSValue function = controller->m_onPull.get(); + if (!function) return; JSC::JSGlobalObject *globalObject = controller->globalObject(); - auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; arguments.append(controller); arguments.append(JSC::JSValue::decode(amt)); arguments.append(JSC::JSValue::decode(offset)); - JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); + AsyncContextFrame::call(globalObject, function, JSC::jsUndefined(), arguments); } extern "C" void ${name}__onStart(JSC__JSValue controllerValue) @@ -924,20 +927,19 @@ extern "C" void ${name}__onClose(JSC__JSValue controllerValue, JSC__JSValue reas { WebCore::${controller}* controller = JSC::jsCast<WebCore::${controller}*>(JSC::JSValue::decode(controllerValue).getObject()); - JSC::JSFunction *function = controller->m_onClose.get(); - if (function == nullptr) + JSC::JSValue function = controller->m_onClose.get(); + if (!function) return; // only call close once controller->m_onClose.clear(); - JSC::JSGlobalObject *globalObject = controller->globalObject(); + JSC::JSGlobalObject* globalObject = controller->globalObject(); - auto callData = JSC::getCallData(function); JSC::MarkedArgumentBuffer arguments; auto readableStream = controller->m_weakReadableStream.get(); arguments.append(readableStream ? readableStream : JSC::jsUndefined()); arguments.append(JSC::JSValue::decode(reason)); - JSC::call(globalObject, function, callData, JSC::jsUndefined(), arguments); + AsyncContextFrame::call(globalObject, function, JSC::jsUndefined(), arguments); } `; diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig index 75ca900df..f53c8121c 100644 --- a/src/cli/test_command.zig +++ b/src/cli/test_command.zig @@ -846,7 +846,6 @@ pub const TestCommand = struct { } } - vm.global.vm().clearMicrotaskCallback(); vm.global.handleRejectedPromises(); if (repeat_index > 0) { vm.clearEntryPoint(); diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index 5bbc0a5fd..ccdcda20d 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -935,6 +935,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { } pub fn handleHandshake(this: *WebSocket, socket: Socket, success: i32, ssl_error: uws.us_bun_verify_error_t) void { + JSC.markBinding(@src()); _ = socket; _ = ssl_error; JSC.markBinding(@src()); diff --git a/src/js/build-esm.ts b/src/js/build-esm.ts index b3b13a4d3..762fc1e56 100644 --- a/src/js/build-esm.ts +++ b/src/js/build-esm.ts @@ -85,7 +85,7 @@ const build_prod_unminified = await Bun.build({ const build_dev = await Bun.build({ entrypoints: entrypoints, - minify: { syntax: true }, + minify: { syntax: false }, sourcemap: "external", ...devOpts, }); diff --git a/src/js/builtins/AsyncContext.ts b/src/js/builtins/AsyncContext.ts new file mode 100644 index 000000000..1c55feeba --- /dev/null +++ b/src/js/builtins/AsyncContext.ts @@ -0,0 +1,9 @@ +// Used by async_hooks to manipulate the async context + +export function getAsyncContext(): ReadonlyArray<any> | undefined { + return $getInternalField($asyncContext, 0); +} + +export function setAsyncContext(contextValue: ReadonlyArray<any> | undefined) { + return $putInternalField($asyncContext, 0, contextValue); +} diff --git a/src/js/builtins/ReadableStream.ts b/src/js/builtins/ReadableStream.ts index 08131130d..5a5b7e119 100644 --- a/src/js/builtins/ReadableStream.ts +++ b/src/js/builtins/ReadableStream.ts @@ -24,7 +24,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -export function initializeReadableStream(this: any, underlyingSource: UnderlyingSource, strategy: any) { +export function initializeReadableStream( + this: ReadableStream, + underlyingSource: UnderlyingSource, + strategy: QueuingStrategy, +) { if (underlyingSource === undefined) underlyingSource = { $bunNativeType: 0, $bunNativePtr: 0, $lazy: false } as UnderlyingSource; if (strategy === undefined) strategy = {}; @@ -47,6 +51,8 @@ export function initializeReadableStream(this: any, underlyingSource: Underlying $putByIdDirectPrivate(this, "bunNativeType", $getByIdDirectPrivate(underlyingSource, "bunNativeType") ?? 0); $putByIdDirectPrivate(this, "bunNativePtr", $getByIdDirectPrivate(underlyingSource, "bunNativePtr") ?? 0); + $putByIdDirectPrivate(this, "asyncContext", $getInternalField($asyncContext, 0)); + const isDirect = underlyingSource.type === "direct"; // direct streams are always lazy const isUnderlyingSourceLazy = !!underlyingSource.$lazy; diff --git a/src/js/builtins/ReadableStreamInternals.ts b/src/js/builtins/ReadableStreamInternals.ts index a9d67aa06..3bcf4f399 100644 --- a/src/js/builtins/ReadableStreamInternals.ts +++ b/src/js/builtins/ReadableStreamInternals.ts @@ -134,8 +134,18 @@ export function setupReadableStreamDefaultController( $isReadableStream, ); + var asyncContext = stream.$asyncContext; const pullAlgorithm = () => $promiseInvokeOrNoopMethod(underlyingSource, pullMethod, [controller]); - const cancelAlgorithm = reason => $promiseInvokeOrNoopMethod(underlyingSource, cancelMethod, [reason]); + const cancelAlgorithm = asyncContext + ? reason => { + var prev = $getInternalField($asyncContext, 0); + $putInternalField($asyncContext, 0, asyncContext); + // this does not throw, but can returns a rejected promise + var result = $promiseInvokeOrNoopMethod(underlyingSource, cancelMethod, [reason]); + $putInternalField($asyncContext, 0, prev); + return result; + } + : reason => $promiseInvokeOrNoopMethod(underlyingSource, cancelMethod, [reason]); $putByIdDirectPrivate(controller, "pullAlgorithm", pullAlgorithm); $putByIdDirectPrivate(controller, "cancelAlgorithm", cancelAlgorithm); @@ -645,7 +655,7 @@ export function readDirectStream(stream, sink, underlyingSource) { highWaterMark: !highWaterMark || highWaterMark < 64 ? 64 : highWaterMark, }); - $startDirectStream.$call(sink, stream, underlyingSource.pull, close); + $startDirectStream.$call(sink, stream, underlyingSource.pull, close, stream.$asyncContext); $putByIdDirectPrivate(stream, "reader", {}); var maybePromise = underlyingSource.pull(sink); @@ -692,7 +702,13 @@ export async function readStreamIntoSink(stream, sink, isNative) { var wroteCount = many.value.length; const highWaterMark = $getByIdDirectPrivate(stream, "highWaterMark"); if (isNative) - $startDirectStream.$call(sink, stream, undefined, () => !didThrow && $markPromiseAsHandled(stream.cancel())); + $startDirectStream.$call( + sink, + stream, + undefined, + () => !didThrow && $markPromiseAsHandled(stream.cancel()), + stream.$asyncContext, + ); sink.start({ highWaterMark: highWaterMark || 0 }); @@ -817,6 +833,12 @@ export function onPullDirectStream(controller) { var deferClose; var deferFlush; + var asyncContext = stream.$asyncContext; + if (asyncContext) { + var prev = $getInternalField($asyncContext, 0); + $putInternalField($asyncContext, 0, asyncContext); + } + // 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 @@ -839,6 +861,10 @@ export function onPullDirectStream(controller) { deferClose = controller._deferClose; deferFlush = controller._deferFlush; controller._deferFlush = controller._deferClose = 0; + + if (asyncContext) { + $putInternalField($asyncContext, 0, prev); + } } var promiseToReturn; diff --git a/src/js/builtins/builtins.d.ts b/src/js/builtins/builtins.d.ts index 57bde34a4..1b585ae7a 100644 --- a/src/js/builtins/builtins.d.ts +++ b/src/js/builtins/builtins.d.ts @@ -57,7 +57,10 @@ declare function $getPromiseInternalField<K extends PromiseFieldType, V>( promise: Promise<V>, key: K, ): PromiseFieldToValue<K, V>; -declare function $getInternalField(base: any, number: number): any; +declare function $getInternalField<Fields extends any[], N extends keyof Fields>( + base: InternalFieldObject<Fields>, + number: N, +): Fields[N]; declare function $fulfillPromise(...args: any[]): TODO; declare function $evaluateCommonJSModule(...args: any[]): TODO; declare function $loadCJS2ESM(...args: any[]): TODO; @@ -111,7 +114,11 @@ declare function $putByIdDirectPrivate(obj: any, key: PropertyKey, value: any): declare function $putByValDirect(obj: any, key: PropertyKey, value: any): void; declare function $putByValWithThisSloppy(): TODO; declare function $putByValWithThisStrict(): TODO; -declare function $putInternalField(base: any, number: number, value: any): any; +declare function $putInternalField<Fields extends any[], N extends keyof Fields>( + base: InternalFieldObject<Fields>, + number: N, + value: Fields[N], +): void; declare function $putPromiseInternalField<T extends PromiseFieldType, P extends Promise<any>>( promise: P, key: T, @@ -157,8 +164,8 @@ 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 $promiseFieldFlags: 0; +declare const $promiseFieldReactionsOrResult: 1; declare const $proxyFieldTarget: TODO; declare const $proxyFieldHandler: TODO; declare const $generatorFieldState: TODO; @@ -192,6 +199,7 @@ declare const $AsyncGeneratorSuspendReasonYield: TODO; declare const $AsyncGeneratorSuspendReasonAwait: TODO; declare const $AsyncGeneratorSuspendReasonNone: TODO; declare const $abstractModuleRecordFieldState: TODO; +declare const $asyncContext: InternalFieldObject<[ReadonlyArray<any> | undefined]>; // We define our intrinsics in ./BunBuiltinNames.h. Some of those are globals. @@ -420,6 +428,11 @@ declare function $newPromiseCapability(C: PromiseConstructor): TODO; declare function $makeTypeError(message: string): TypeError; declare function $newHandledRejectedPromise(error: unknown): Promise<never>; +declare const __internal: unique symbol; +interface InternalFieldObject<T extends any[]> { + [__internal]: T; +} + // Types used in the above functions type PromiseFieldType = typeof $promiseFieldFlags | typeof $promiseFieldReactionsOrResult; type PromiseFieldToValue<X extends PromiseFieldType, V> = X extends typeof $promiseFieldFlags diff --git a/src/js/node/async_hooks.js b/src/js/node/async_hooks.js deleted file mode 100644 index ec82ce8aa..000000000 --- a/src/js/node/async_hooks.js +++ /dev/null @@ -1,212 +0,0 @@ -// Hardcoded module "node:async_hooks" -import { drainMicrotasks } from "bun:jsc"; - -var notImplemented = () => { - console.warn( - "[bun] Warning: async_hooks has not been implemented yet. See https://github.com/oven-sh/bun/issues/1832", - ); - notImplemented = () => {}; -}; - -class AsyncLocalStorage { - #store; - _enabled; - - constructor() { - this._enabled = false; - this.#store = null; - } - - enterWith(store) { - this.#store = store; - notImplemented(); - - return this; - } - - exit(cb, ...args) { - this.#store = null; - notImplemented(); - typeof cb === "function" && cb(...args); - } - - run(store, callback, ...args) { - if (typeof callback !== "function") throw new TypeError("ERR_INVALID_CALLBACK"); - var result, err; - - process.nextTick(store => { - const prev = this.#store; - this.enterWith(store); - try { - result = callback(...args); - } catch (e) { - err = e; - } finally { - this.#store = prev; - } - }, store); - drainMicrotasks(); - if (typeof err !== "undefined") { - throw err; - } - return result; - } - - getStore() { - return this.#store; - } -} - -function createHook() { - return { - enable() { - notImplemented(); - }, - disable() { - notImplemented(); - }, - }; -} - -function executionAsyncId() { - return 0; -} - -function triggerAsyncId() { - return 0; -} - -function executionAsyncResource() { - return null; -} - -const asyncWrapProviders = { - NONE: 0, - DIRHANDLE: 1, - DNSCHANNEL: 2, - ELDHISTOGRAM: 3, - FILEHANDLE: 4, - FILEHANDLECLOSEREQ: 5, - FIXEDSIZEBLOBCOPY: 6, - FSEVENTWRAP: 7, - FSREQCALLBACK: 8, - FSREQPROMISE: 9, - GETADDRINFOREQWRAP: 10, - GETNAMEINFOREQWRAP: 11, - HEAPSNAPSHOT: 12, - HTTP2SESSION: 13, - HTTP2STREAM: 14, - HTTP2PING: 15, - HTTP2SETTINGS: 16, - HTTPINCOMINGMESSAGE: 17, - HTTPCLIENTREQUEST: 18, - JSSTREAM: 19, - JSUDPWRAP: 20, - MESSAGEPORT: 21, - PIPECONNECTWRAP: 22, - PIPESERVERWRAP: 23, - PIPEWRAP: 24, - PROCESSWRAP: 25, - PROMISE: 26, - QUERYWRAP: 27, - SHUTDOWNWRAP: 28, - SIGNALWRAP: 29, - STATWATCHER: 30, - STREAMPIPE: 31, - TCPCONNECTWRAP: 32, - TCPSERVERWRAP: 33, - TCPWRAP: 34, - TTYWRAP: 35, - UDPSENDWRAP: 36, - UDPWRAP: 37, - SIGINTWATCHDOG: 38, - WORKER: 39, - WORKERHEAPSNAPSHOT: 40, - WRITEWRAP: 41, - ZLIB: 42, - CHECKPRIMEREQUEST: 43, - PBKDF2REQUEST: 44, - KEYPAIRGENREQUEST: 45, - KEYGENREQUEST: 46, - KEYEXPORTREQUEST: 47, - CIPHERREQUEST: 48, - DERIVEBITSREQUEST: 49, - HASHREQUEST: 50, - RANDOMBYTESREQUEST: 51, - RANDOMPRIMEREQUEST: 52, - SCRYPTREQUEST: 53, - SIGNREQUEST: 54, - TLSWRAP: 55, - VERIFYREQUEST: 56, - INSPECTORJSBINDING: 57, -}; - -class AsyncResource { - constructor(type, triggerAsyncId) { - this.type = type; - this.triggerAsyncId = triggerAsyncId; - - if (AsyncResource.allowedRunInAsyncScope.has(type)) { - this.runInAsyncScope = this.#runInAsyncScope; - } - } - - // We probably will not fully support AsyncResource - // But some packages in the wild do depend on it - static allowedRunInAsyncScope = new Set(["prisma-client-request"]); - - type; - triggerAsyncId; - - emitBefore() { - return true; - } - - emitAfter() { - return true; - } - - emitDestroy() {} - - runInAsyncScope; - - #runInAsyncScope(fn, ...args) { - var result, err; - process.nextTick(fn => { - try { - result = fn(...args); - } catch (err2) { - err = err2; - } - }, fn); - drainMicrotasks(); - if (err) throw err; - return result; - } - - asyncId() { - return 0; - } -} - -export { - AsyncLocalStorage, - createHook, - executionAsyncId, - triggerAsyncId, - executionAsyncResource, - asyncWrapProviders, - AsyncResource, -}; - -export default { - AsyncLocalStorage, - createHook, - executionAsyncId, - triggerAsyncId, - executionAsyncResource, - asyncWrapProviders, - AsyncResource, - [Symbol.toStringTag]: "Module (not implemented yet)", - [Symbol.for("CommonJS")]: 0, -}; diff --git a/src/js/node/async_hooks.ts b/src/js/node/async_hooks.ts new file mode 100644 index 000000000..da9f6c136 --- /dev/null +++ b/src/js/node/async_hooks.ts @@ -0,0 +1,320 @@ +// Hardcoded module "node:async_hooks" +// Bun is only going to implement AsyncLocalStorage and AsyncResource (partial). +// The other functions are deprecated anyways, and would impact performance too much. +// API: https://nodejs.org/api/async_hooks.html +// +// JSC has been patched to include a special global variable $asyncContext which is set to +// a constant InternalFieldTuple<[AsyncContextData, never]>. `get` and `set` read/write to the +// first element of this tuple. Inside of PromiseOperations.js, we "snapshot" the context (store it +// in the promise reaction) and then just before we call .then, we restore it. +// +// This means context tracking is *kind-of* manual. If we recieve a callback in native code +// - In Zig, call jsValue.withAsyncContextIfNeeded(); which returns another JSValue. Store that and +// then run .call() on it later. +// - In C++, call AsyncContextFrame::withAsyncContextIfNeeded(jsValue). Then to call it, +// use AsyncContextFrame:: call(...) instead of JSC:: call. +// +// The above functions will return the same JSFunction if the context is empty, and there are many +// other checks to ensure that AsyncLocalStorage has virtually no impact on performance when not in +// use. But the nature of this approach makes the implementation *itself* very low-impact on performance. +// +// AsyncContextData is an immutable array managed in here, formatted [key, value, key, value] where +// each key is an AsyncLocalStorage object and the value is the associated value. +// +const { get, set, cleanupLater } = $lazy("async_hooks"); + +class AsyncLocalStorage { + #disableCalled = false; + + constructor() {} + + static bind(fn, ...args: any) { + return this.snapshot().bind(null, fn, ...args); + } + + static snapshot() { + var context = get(); + return (fn, ...args) => { + var prev = get(); + set(context); + try { + return fn(...args); + } catch (error) { + throw error; + } finally { + set(prev); + } + }; + } + + enterWith(store) { + cleanupLater(); + var context = get(); + if (!context) { + set([this, store]); + return; + } + var { length } = context; + for (var i = 0; i < length; i += 2) { + if (context[i] === this) { + const clone = context.slice(); + clone[i + 1] = store; + set(clone); + return; + } + } + set(context.concat(this, store)); + } + + exit(cb, ...args) { + return this.run(undefined, cb, ...args); + } + + run(store, callback, ...args) { + var context = get() as any[]; // we make sure to .slice() before mutating + var hasPrevious = false; + var previous; + var i = 0; + var contextWasInit = !context; + if (contextWasInit) { + set((context = [this, store])); + } else { + // it's safe to mutate context now that it was cloned + context = context!.slice(); + i = context.indexOf(this); + if (i > -1) { + hasPrevious = true; + previous = context[i + 1]; + context[i + 1] = store; + } else { + context.push(this, store); + } + set(context); + } + try { + return callback(...args); + } catch (e) { + throw e; + } finally { + // Note: early `return` will prevent `throw` above from working. I think... + // Set AsyncContextFrame to undefined if we are out of context values + if (!this.#disableCalled) { + var context2 = get()! as any[]; + if (context2 === context && contextWasInit) { + set(undefined); + } else { + context2 = context2.slice(); // array is cloned here + if (hasPrevious) { + context2[i + 1] = previous; + set(context2); + } else { + context2.splice(i, 2); + set(context2.length ? context2 : undefined); + } + } + } + } + } + + disable() { + // In this case, we actually do want to mutate the context state + if (!this.#disableCalled) { + var context = get() as any[]; + if (context) { + var { length } = context; + for (var i = 0; i < length; i += 2) { + if (context[i] === this) { + context.splice(i, 2); + set(context.length ? context : undefined); + break; + } + } + } + this.#disableCalled = true; + } + } + + getStore() { + var context = get(); + if (!context) return; + var { length } = context; + for (var i = 0; i < length; i += 2) { + if (context[i] === this) return context[i + 1]; + } + } +} + +class AsyncResource { + type; + #snapshot; + + constructor(type, options) { + if (typeof type !== "string") { + throw new TypeError('The "type" argument must be of type string. Received type ' + typeof type); + } + this.type = type; + this.#snapshot = get(); + } + + emitBefore() { + return true; + } + + emitAfter() { + return true; + } + + asyncId() { + return 0; + } + + triggerAsyncId() { + return 0; + } + + emitDestroy() { + // + } + + runInAsyncScope(fn, thisArg, ...args) { + var prev = get(); + set(this.#snapshot); + try { + return fn.apply(thisArg, args); + } catch (error) { + throw error; + } finally { + set(prev); + } + } +} + +// The rest of async_hooks is not implemented and is stubbed with no-ops and warnings. + +function createWarning(message) { + let warned = false; + var wrapped = function () { + if (warned) return; + + // zx does not need createHook to function + const isFromZX = new Error().stack!.includes("zx/build/core.js"); + if (isFromZX) return; + + warned = true; + console.warn("[bun] Warning:", message); + }; + return wrapped; +} + +const createHookNotImpl = createWarning( + "async_hooks.createHook is not implemented in Bun. Hooks can still be created but will never be called.", +); + +function createHook(callbacks) { + return { + enable: createHookNotImpl, + disable: createHookNotImpl, + }; +} + +const executionAsyncIdNotImpl = createWarning( + "async_hooks.executionAsyncId/triggerAsyncId are not implemented in Bun. It will return 0 every time.", +); +function executionAsyncId() { + executionAsyncIdNotImpl(); + return 0; +} + +function triggerAsyncId() { + return 0; +} + +const executionAsyncResourceWarning = createWarning( + "async_hooks.executionAsyncResource is not implemented in Bun. It returns a reference to process.stdin every time.", +); +function executionAsyncResource() { + executionAsyncResourceWarning(); + return process.stdin; +} + +const asyncWrapProviders = { + NONE: 0, + DIRHANDLE: 1, + DNSCHANNEL: 2, + ELDHISTOGRAM: 3, + FILEHANDLE: 4, + FILEHANDLECLOSEREQ: 5, + FIXEDSIZEBLOBCOPY: 6, + FSEVENTWRAP: 7, + FSREQCALLBACK: 8, + FSREQPROMISE: 9, + GETADDRINFOREQWRAP: 10, + GETNAMEINFOREQWRAP: 11, + HEAPSNAPSHOT: 12, + HTTP2SESSION: 13, + HTTP2STREAM: 14, + HTTP2PING: 15, + HTTP2SETTINGS: 16, + HTTPINCOMINGMESSAGE: 17, + HTTPCLIENTREQUEST: 18, + JSSTREAM: 19, + JSUDPWRAP: 20, + MESSAGEPORT: 21, + PIPECONNECTWRAP: 22, + PIPESERVERWRAP: 23, + PIPEWRAP: 24, + PROCESSWRAP: 25, + PROMISE: 26, + QUERYWRAP: 27, + SHUTDOWNWRAP: 28, + SIGNALWRAP: 29, + STATWATCHER: 30, + STREAMPIPE: 31, + TCPCONNECTWRAP: 32, + TCPSERVERWRAP: 33, + TCPWRAP: 34, + TTYWRAP: 35, + UDPSENDWRAP: 36, + UDPWRAP: 37, + SIGINTWATCHDOG: 38, + WORKER: 39, + WORKERHEAPSNAPSHOT: 40, + WRITEWRAP: 41, + ZLIB: 42, + CHECKPRIMEREQUEST: 43, + PBKDF2REQUEST: 44, + KEYPAIRGENREQUEST: 45, + KEYGENREQUEST: 46, + KEYEXPORTREQUEST: 47, + CIPHERREQUEST: 48, + DERIVEBITSREQUEST: 49, + HASHREQUEST: 50, + RANDOMBYTESREQUEST: 51, + RANDOMPRIMEREQUEST: 52, + SCRYPTREQUEST: 53, + SIGNREQUEST: 54, + TLSWRAP: 55, + VERIFYREQUEST: 56, + INSPECTORJSBINDING: 57, +}; + +export { + AsyncLocalStorage, + createHook, + executionAsyncId, + triggerAsyncId, + executionAsyncResource, + asyncWrapProviders, + AsyncResource, +}; + +export default { + AsyncLocalStorage, + createHook, + executionAsyncId, + triggerAsyncId, + executionAsyncResource, + asyncWrapProviders, + AsyncResource, + [Symbol.for("CommonJS")]: 0, +}; diff --git a/src/js/node/events.js b/src/js/node/events.js index 7b78193ca..09f89084a 100644 --- a/src/js/node/events.js +++ b/src/js/node/events.js @@ -453,11 +453,29 @@ function checkListener(listener) { } } +let AsyncResource = null; + class EventEmitterAsyncResource extends EventEmitter { - constructor(options = undefined) { - throwNotImplemented("EventEmitterAsyncResource", 1832); + triggerAsyncId; + asyncResource; + + constructor(options) { + if (!AsyncResource) AsyncResource = import.meta.require("async_hooks").AsyncResource; + var { captureRejections = false, triggerAsyncId, name = new.target.name, requireManualDestroy } = options || {}; + super({ captureRejections }); + this.triggerAsyncId = triggerAsyncId ?? 0; + this.asyncResource = new AsyncResource(name, { triggerAsyncId, requireManualDestroy }); + } + + emit(...args) { + this.asyncResource.runInAsyncScope(() => super.emit(...args)); + } + + emitDestroy() { + this.asyncResource.emitDestroy(); } } + const usingDomains = false; // EventEmitter[Symbol.for("CommonJS")] = 0; Object.assign(EventEmitter, { once, on, getEventListeners, setMaxListeners, listenerCount, EventEmitterAsyncResource }); diff --git a/src/js/out/WebCoreJSBuiltins.cpp b/src/js/out/WebCoreJSBuiltins.cpp index 310d23505..82a7bfabb 100644 --- a/src/js/out/WebCoreJSBuiltins.cpp +++ b/src/js/out/WebCoreJSBuiltins.cpp @@ -16,7 +16,7 @@ const JSC::ConstructorKind s_bundlerPluginRunSetupFunctionCodeConstructorKind = 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 (_,E){\"use strict\";var w=new Map,h=new Map;function q(D,F,G){if(!D||!@isObject(D))@throwTypeError('Expected an object with \"filter\" RegExp');if(!F||!@isCallable(F))@throwTypeError(\"callback must be a function\");var{filter:H,namespace:I=\"file\"}=D;if(!H)@throwTypeError('Expected an object with \"filter\" RegExp');if(!@isRegExpObject(H))@throwTypeError(\"filter must be a RegExp\");if(I&&typeof I!==\"string\")@throwTypeError(\"namespace must be a string\");if((I\?.length\?\?0)===0)I=\"file\";if(!/^([/@a-zA-Z0-9_\\\\-]+)$/.test(I))@throwTypeError(\"namespace can only contain $a-zA-Z0-9_\\\\-\");var J=G.@get(I);if(!J)G.@set(I,[[H,F]]);else @arrayPush(J,[H,F])}function z(D,F){q(D,F,w)}function A(D,F){q(D,F,h)}const B=()=>{var D=!1,F=!1;for(var[G,H]of w.entries())for(var[I]of H)this.addFilter(I,G,1),D=!0;for(var[G,H]of h.entries())for(var[I]of H)this.addFilter(I,G,0),F=!0;if(F){var J=this.onResolve;if(!J)this.onResolve=h;else for(var[G,H]of h.entries()){var K=J.@get(G);if(!K)J.@set(G,H);else J.@set(G,K.concat(H))}}if(D){var M=this.onLoad;if(!M)this.onLoad=w;else for(var[G,H]of w.entries()){var K=M.@get(G);if(!K)M.@set(G,H);else M.@set(G,K.concat(H))}}return D||F};var C=_({config:E,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:z,onResolve:A,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:{...E,bundle:!0,entryPoints:E.entrypoints\?\?E.entryPoints\?\?[],minify:typeof E.minify===\"boolean\"\?E.minify:!1,minifyIdentifiers:E.minify===!0||E.minify\?.identifiers,minifyWhitespace:E.minify===!0||E.minify\?.whitespace,minifySyntax:E.minify===!0||E.minify\?.syntax,outbase:E.root,platform:E.target===\"bun\"\?\"node\":E.target},esbuild:{}});if(C&&@isPromise(C))if(@getPromiseInternalField(C,@promiseFieldFlags)&@promiseStateFulfilled)C=@getPromiseInternalField(C,@promiseFieldReactionsOrResult);else return C.@then(B);return B()})\n"; +const char* const s_bundlerPluginRunSetupFunctionCode = "(function (J,_){\"use strict\";var D=new Map,F=new Map;function H(q,h,E){if(!q||!@isObject(q))@throwTypeError('Expected an object with \"filter\" RegExp');if(!h||!@isCallable(h))@throwTypeError(\"callback must be a function\");var{filter:w,namespace:z=\"file\"}=q;if(!w)@throwTypeError('Expected an object with \"filter\" RegExp');if(!@isRegExpObject(w))@throwTypeError(\"filter must be a RegExp\");if(z&&typeof z!==\"string\")@throwTypeError(\"namespace must be a string\");if((z\?.length\?\?0)===0)z=\"file\";if(!/^([/@a-zA-Z0-9_\\\\-]+)$/.test(z))@throwTypeError(\"namespace can only contain $a-zA-Z0-9_\\\\-\");var A=E.@get(z);if(!A)E.@set(z,[[w,h]]);else @arrayPush(A,[w,h])}function K(q,h){H(q,h,D)}function M(q,h){H(q,h,F)}const I=()=>{var q=!1,h=!1;for(var[E,w]of D.entries())for(var[z]of w)this.addFilter(z,E,1),q=!0;for(var[E,w]of F.entries())for(var[z]of w)this.addFilter(z,E,0),h=!0;if(h){var A=this.onResolve;if(!A)this.onResolve=F;else for(var[E,w]of F.entries()){var C=A.@get(E);if(!C)A.@set(E,w);else A.@set(E,C.concat(w))}}if(q){var G=this.onLoad;if(!G)this.onLoad=D;else for(var[E,w]of D.entries()){var C=G.@get(E);if(!C)G.@set(E,w);else G.@set(E,C.concat(w))}}return q||h};var B=J({config:_,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:K,onResolve:M,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:{..._,bundle:!0,entryPoints:_.entrypoints\?\?_.entryPoints\?\?[],minify:typeof _.minify===\"boolean\"\?_.minify:!1,minifyIdentifiers:_.minify===!0||_.minify\?.identifiers,minifyWhitespace:_.minify===!0||_.minify\?.whitespace,minifySyntax:_.minify===!0||_.minify\?.syntax,outbase:_.root,platform:_.target===\"bun\"\?\"node\":_.target},esbuild:{}});if(B&&@isPromise(B))if(@getPromiseInternalField(B,@promiseFieldFlags)&@promiseStateFulfilled)B=@getPromiseInternalField(B,@promiseFieldReactionsOrResult);else return B.@then(I);return I()})\n"; // runOnResolvePlugins const JSC::ConstructAbility s_bundlerPluginRunOnResolvePluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -24,7 +24,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnResolvePluginsCodeConstructorKind 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 (_,w,g,y,b){\"use strict\";const j=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][b];var q=(async(z,A,B,C)=>{var{onResolve:E,onLoad:F}=this,G=E.@get(A);if(!G)return this.onResolveAsync(y,null,null,null),null;for(let[O,Q]of G)if(O.test(z)){var H=Q({path:z,importer:B,namespace:A,kind:C});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=A,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=A;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(y,J,K,M),null}return this.onResolveAsync(y,null,null,null),null})(_,w,g,j);while(q&&@isPromise(q)&&(@getPromiseInternalField(q,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)q=@getPromiseInternalField(q,@promiseFieldReactionsOrResult);if(q&&@isPromise(q))q.then(()=>{},(z)=>{this.addError(y,z,0)})})\n"; +const char* const s_bundlerPluginRunOnResolvePluginsCode = "(function (C,E,F,b,G){\"use strict\";const H=[\"entry-point\",\"import-statement\",\"require-call\",\"dynamic-import\",\"require-resolve\",\"import-rule\",\"url-token\",\"internal\"][G];var g=(async(j,q,J,K)=>{var{onResolve:M,onLoad:A}=this,B=M.@get(q);if(!B)return this.onResolveAsync(b,null,null,null),null;for(let[O,Q]of B)if(O.test(j)){var _=Q({path:j,importer:J,namespace:q,kind:K});while(_&&@isPromise(_)&&(@getPromiseInternalField(_,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)_=@getPromiseInternalField(_,@promiseFieldReactionsOrResult);if(_&&@isPromise(_))_=await _;if(!_||!@isObject(_))continue;var{path:y,namespace:w=q,external:z}=_;if(typeof y!==\"string\"||typeof w!==\"string\")@throwTypeError(\"onResolve plugins must return an object with a string 'path' and string 'loader' field\");if(!y)continue;if(!w)w=q;if(typeof z!==\"boolean\"&&!@isUndefinedOrNull(z))@throwTypeError('onResolve plugins \"external\" field must be boolean or unspecified');if(!z){if(w===\"file\"){if(darwin!==\"win32\"){if(y[0]!==\"/\"||y.includes(\"..\"))@throwTypeError('onResolve plugin \"path\" must be absolute when the namespace is \"file\"')}}if(w===\"dataurl\"){if(!y.startsWith(\"data:\"))@throwTypeError('onResolve plugin \"path\" must start with \"data:\" when the namespace is \"dataurl\"')}if(w&&w!==\"file\"&&(!A||!A.@has(w)))@throwTypeError(`Expected onLoad plugin for namespace ${w} to exist`)}return this.onResolveAsync(b,y,w,z),null}return this.onResolveAsync(b,null,null,null),null})(C,E,F,H);while(g&&@isPromise(g)&&(@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)g=@getPromiseInternalField(g,@promiseFieldReactionsOrResult);if(g&&@isPromise(g))g.then(()=>{},(j)=>{this.addError(b,j,0)})})\n"; // runOnLoadPlugins const JSC::ConstructAbility s_bundlerPluginRunOnLoadPluginsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -32,7 +32,7 @@ const JSC::ConstructorKind s_bundlerPluginRunOnLoadPluginsCodeConstructorKind = 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,q){\"use strict\";const v={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},w=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][q];var x=(async(y,z,B,C)=>{var F=this.onLoad.@get(B);if(!F)return this.onLoadAsync(y,null,null),null;for(let[K,Q]of F)if(K.test(z)){var G=Q({path:z,namespace:B,loader:C});while(G&&@isPromise(G)&&(@getPromiseInternalField(G,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)G=@getPromiseInternalField(G,@promiseFieldReactionsOrResult);if(G&&@isPromise(G))G=await G;if(!G||!@isObject(G))continue;var{contents:H,loader:J=C}=G;if(typeof H!==\"string\"&&!@isTypedArrayView(H))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof J!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const T=v[J];if(T===@undefined)@throwTypeError(`Loader ${J} is not supported.`);return this.onLoadAsync(y,H,T),null}return this.onLoadAsync(y,null,null),null})(b,g,j,w);while(x&&@isPromise(x)&&(@getPromiseInternalField(x,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)x=@getPromiseInternalField(x,@promiseFieldReactionsOrResult);if(x&&@isPromise(x))x.then(()=>{},(y)=>{this.addError(b,y,1)})})\n"; +const char* const s_bundlerPluginRunOnLoadPluginsCode = "(function (w,F,G,H){\"use strict\";const J={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},K=[\"jsx\",\"js\",\"ts\",\"tsx\",\"css\",\"file\",\"json\",\"toml\",\"wasm\",\"napi\",\"base64\",\"dataurl\",\"text\"][H];var g=(async(j,x,y,z)=>{var B=this.onLoad.@get(y);if(!B)return this.onLoadAsync(j,null,null),null;for(let[Q,T]of B)if(Q.test(x)){var b=T({path:x,namespace:y,loader:z});while(b&&@isPromise(b)&&(@getPromiseInternalField(b,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)b=@getPromiseInternalField(b,@promiseFieldReactionsOrResult);if(b&&@isPromise(b))b=await b;if(!b||!@isObject(b))continue;var{contents:q,loader:v=z}=b;if(typeof q!==\"string\"&&!@isTypedArrayView(q))@throwTypeError('onLoad plugins must return an object with \"contents\" as a string or Uint8Array');if(typeof v!==\"string\")@throwTypeError('onLoad plugins must return an object with \"loader\" as a string');const C=J[v];if(C===@undefined)@throwTypeError(`Loader ${v} is not supported.`);return this.onLoadAsync(j,q,C),null}return this.onLoadAsync(j,null,null),null})(w,F,G,K);while(g&&@isPromise(g)&&(@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)===@promiseStateFulfilled)g=@getPromiseInternalField(g,@promiseFieldReactionsOrResult);if(g&&@isPromise(g))g.then(()=>{},(j)=>{this.addError(w,j,1)})})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -108,7 +108,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateWritableStreamCodeCons 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 (u,d,p,N,_,f){\"use strict\";@assert(typeof _===\"number\"&&!@isNaN(_)&&_>=0);const j={};@initializeWritableStreamSlots(j,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(j,q,u,d,p,N,_,f),@createWritableStreamFromInternal(j)})\n"; +const char* const s_writableStreamInternalsCreateWritableStreamCode = "(function (p,N,_,f,u,j){\"use strict\";@assert(typeof u===\"number\"&&!@isNaN(u)&&u>=0);const d={};@initializeWritableStreamSlots(d,{});const q=new @WritableStreamDefaultController;return @setUpWritableStreamDefaultController(d,q,p,N,_,f,u,j),@createWritableStreamFromInternal(d)})\n"; // createInternalWritableStreamFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -116,7 +116,7 @@ const JSC::ConstructorKind s_writableStreamInternalsCreateInternalWritableStream const JSC::ImplementationVisibility s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeLength = 920; static const JSC::Intrinsic s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,o){\"use strict\";const w={};if(f===@undefined)f={};if(o===@undefined)o={};if(!@isObject(f))@throwTypeError(\"WritableStream constructor takes an object as first argument\");if(\"type\"in f)@throwRangeError(\"Invalid type is specified\");const C=@extractSizeAlgorithm(o),E=@extractHighWaterMark(o,1),_={};if(\"start\"in f){if(_.start=f.start,typeof _.start!==\"function\")@throwTypeError(\"underlyingSink.start should be a function\")}if(\"write\"in f){if(_.write=f.write,typeof _.write!==\"function\")@throwTypeError(\"underlyingSink.write should be a function\")}if(\"close\"in f){if(_.close=f.close,typeof _.close!==\"function\")@throwTypeError(\"underlyingSink.close should be a function\")}if(\"abort\"in f){if(_.abort=f.abort,typeof _.abort!==\"function\")@throwTypeError(\"underlyingSink.abort should be a function\")}return @initializeWritableStreamSlots(w,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(w,f,_,E,C),w})\n"; +const char* const s_writableStreamInternalsCreateInternalWritableStreamFromUnderlyingSinkCode = "(function (f,w){\"use strict\";const C={};if(f===@undefined)f={};if(w===@undefined)w={};if(!@isObject(f))@throwTypeError(\"WritableStream constructor takes an object as first argument\");if(\"type\"in f)@throwRangeError(\"Invalid type is specified\");const E=@extractSizeAlgorithm(w),_=@extractHighWaterMark(w,1),o={};if(\"start\"in f){if(o.start=f.start,typeof o.start!==\"function\")@throwTypeError(\"underlyingSink.start should be a function\")}if(\"write\"in f){if(o.write=f.write,typeof o.write!==\"function\")@throwTypeError(\"underlyingSink.write should be a function\")}if(\"close\"in f){if(o.close=f.close,typeof o.close!==\"function\")@throwTypeError(\"underlyingSink.close should be a function\")}if(\"abort\"in f){if(o.abort=f.abort,typeof o.abort!==\"function\")@throwTypeError(\"underlyingSink.abort should be a function\")}return @initializeWritableStreamSlots(C,f),@setUpWritableStreamDefaultControllerFromUnderlyingSink(C,f,o,_,E),C})\n"; // initializeWritableStreamSlots const JSC::ConstructAbility s_writableStreamInternalsInitializeWritableStreamSlotsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -156,7 +156,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultWr 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,v){\"use strict\";if(@isWritableStreamLocked(v))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(n,\"stream\",v),@putByIdDirectPrivate(v,\"writer\",n);const g=@newPromiseCapability(@Promise),h=@newPromiseCapability(@Promise);@putByIdDirectPrivate(n,\"readyPromise\",g),@putByIdDirectPrivate(n,\"closedPromise\",h);const B=@getByIdDirectPrivate(v,\"state\");if(B===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(v)||!@getByIdDirectPrivate(v,\"backpressure\"))g.@resolve.@call()}else if(B===\"erroring\")g.@reject.@call(@undefined,@getByIdDirectPrivate(v,\"storedError\")),@markPromiseAsHandled(g.@promise);else if(B===\"closed\")g.@resolve.@call(),h.@resolve.@call();else{@assert(B===\"errored\");const _=@getByIdDirectPrivate(v,\"storedError\");g.@reject.@call(@undefined,_),@markPromiseAsHandled(g.@promise),h.@reject.@call(@undefined,_),@markPromiseAsHandled(h.@promise)}})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultWriterCode = "(function (g,n){\"use strict\";if(@isWritableStreamLocked(n))@throwTypeError(\"WritableStream is locked\");@putByIdDirectPrivate(g,\"stream\",n),@putByIdDirectPrivate(n,\"writer\",g);const v=@newPromiseCapability(@Promise),h=@newPromiseCapability(@Promise);@putByIdDirectPrivate(g,\"readyPromise\",v),@putByIdDirectPrivate(g,\"closedPromise\",h);const B=@getByIdDirectPrivate(n,\"state\");if(B===\"writable\"){if(@writableStreamCloseQueuedOrInFlight(n)||!@getByIdDirectPrivate(n,\"backpressure\"))v.@resolve.@call()}else if(B===\"erroring\")v.@reject.@call(@undefined,@getByIdDirectPrivate(n,\"storedError\")),@markPromiseAsHandled(v.@promise);else if(B===\"closed\")v.@resolve.@call(),h.@resolve.@call();else{@assert(B===\"errored\");const _=@getByIdDirectPrivate(n,\"storedError\");v.@reject.@call(@undefined,_),@markPromiseAsHandled(v.@promise),h.@reject.@call(@undefined,_),@markPromiseAsHandled(h.@promise)}})\n"; // writableStreamAbort const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAbortCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -164,7 +164,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamAbortCodeConst 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 (h,B){\"use strict\";const _=@getByIdDirectPrivate(h,\"state\");if(_===\"closed\"||_===\"errored\")return @Promise.@resolve();const f=@getByIdDirectPrivate(h,\"pendingAbortRequest\");if(f!==@undefined)return f.promise.@promise;@assert(_===\"writable\"||_===\"erroring\");let j=!1;if(_===\"erroring\")j=!0,B=@undefined;const c=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(h,\"pendingAbortRequest\",{promise:c,reason:B,wasAlreadyErroring:j}),!j)@writableStreamStartErroring(h,B);return c.@promise})\n"; +const char* const s_writableStreamInternalsWritableStreamAbortCode = "(function (h,B){\"use strict\";const c=@getByIdDirectPrivate(h,\"state\");if(c===\"closed\"||c===\"errored\")return @Promise.@resolve();const f=@getByIdDirectPrivate(h,\"pendingAbortRequest\");if(f!==@undefined)return f.promise.@promise;@assert(c===\"writable\"||c===\"erroring\");let _=!1;if(c===\"erroring\")_=!0,B=@undefined;const j=@newPromiseCapability(@Promise);if(@putByIdDirectPrivate(h,\"pendingAbortRequest\",{promise:j,reason:B,wasAlreadyErroring:_}),!_)@writableStreamStartErroring(h,B);return j.@promise})\n"; // writableStreamClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -172,7 +172,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamCloseCodeConst 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 (_){\"use strict\";const u=@getByIdDirectPrivate(_,\"state\");if(u===\"closed\"||u===\"errored\")return @Promise.@reject(@makeTypeError(\"Cannot close a writable stream that is closed or errored\"));@assert(u===\"writable\"||u===\"erroring\"),@assert(!@writableStreamCloseQueuedOrInFlight(_));const d=@newPromiseCapability(@Promise);@putByIdDirectPrivate(_,\"closeRequest\",d);const n=@getByIdDirectPrivate(_,\"writer\");if(n!==@undefined&&@getByIdDirectPrivate(_,\"backpressure\")&&u===\"writable\")@getByIdDirectPrivate(n,\"readyPromise\").@resolve.@call();return @writableStreamDefaultControllerClose(@getByIdDirectPrivate(_,\"controller\")),d.@promise})\n"; +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 u=@newPromiseCapability(@Promise);@putByIdDirectPrivate(n,\"closeRequest\",u);const d=@getByIdDirectPrivate(n,\"writer\");if(d!==@undefined&&@getByIdDirectPrivate(n,\"backpressure\")&&_===\"writable\")@getByIdDirectPrivate(d,\"readyPromise\").@resolve.@call();return @writableStreamDefaultControllerClose(@getByIdDirectPrivate(n,\"controller\")),u.@promise})\n"; // writableStreamAddWriteRequest const JSC::ConstructAbility s_writableStreamInternalsWritableStreamAddWriteRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -196,7 +196,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDealWithReject 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 i=@getByIdDirectPrivate(n,\"state\");if(i===\"writable\"){@writableStreamStartErroring(n,c);return}@assert(i===\"erroring\"),@writableStreamFinishErroring(n)})\n"; +const char* const s_writableStreamInternalsWritableStreamDealWithRejectionCode = "(function (i,c){\"use strict\";const n=@getByIdDirectPrivate(i,\"state\");if(n===\"writable\"){@writableStreamStartErroring(i,c);return}@assert(n===\"erroring\"),@writableStreamFinishErroring(i)})\n"; // writableStreamFinishErroring const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishErroringCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -204,7 +204,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishErroring 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 _=@getByIdDirectPrivate(i,\"controller\");@getByIdDirectPrivate(_,\"errorSteps\").@call();const p=@getByIdDirectPrivate(i,\"storedError\"),h=@getByIdDirectPrivate(i,\"writeRequests\");for(var A=h.shift();A;A=h.shift())A.@reject.@call(@undefined,p);@putByIdDirectPrivate(i,\"writeRequests\",@createFIFO());const B=@getByIdDirectPrivate(i,\"pendingAbortRequest\");if(B===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}if(@putByIdDirectPrivate(i,\"pendingAbortRequest\",@undefined),B.wasAlreadyErroring){B.promise.@reject.@call(@undefined,p),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}@getByIdDirectPrivate(_,\"abortSteps\").@call(@undefined,B.reason).@then(()=>{B.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)},(I)=>{B.promise.@reject.@call(@undefined,I),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)})})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishErroringCode = "(function (i){\"use strict\";@assert(@getByIdDirectPrivate(i,\"state\")===\"erroring\"),@assert(!@writableStreamHasOperationMarkedInFlight(i)),@putByIdDirectPrivate(i,\"state\",\"errored\");const h=@getByIdDirectPrivate(i,\"controller\");@getByIdDirectPrivate(h,\"errorSteps\").@call();const A=@getByIdDirectPrivate(i,\"storedError\"),B=@getByIdDirectPrivate(i,\"writeRequests\");for(var p=B.shift();p;p=B.shift())p.@reject.@call(@undefined,A);@putByIdDirectPrivate(i,\"writeRequests\",@createFIFO());const _=@getByIdDirectPrivate(i,\"pendingAbortRequest\");if(_===@undefined){@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}if(@putByIdDirectPrivate(i,\"pendingAbortRequest\",@undefined),_.wasAlreadyErroring){_.promise.@reject.@call(@undefined,A),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i);return}@getByIdDirectPrivate(h,\"abortSteps\").@call(@undefined,_.reason).@then(()=>{_.promise.@resolve.@call(),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)},(I)=>{_.promise.@reject.@call(@undefined,I),@writableStreamRejectCloseAndClosedPromiseIfNeeded(i)})})\n"; // writableStreamFinishInFlightClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -212,7 +212,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight 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 (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const n=@getByIdDirectPrivate(d,\"state\");if(@assert(n===\"writable\"||n===\"erroring\"),n===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const c=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(c!==@undefined)c.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const _=@getByIdDirectPrivate(d,\"writer\");if(_!==@undefined)@getByIdDirectPrivate(_,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; +const char* const s_writableStreamInternalsWritableStreamFinishInFlightCloseCode = "(function (d){\"use strict\";@getByIdDirectPrivate(d,\"inFlightCloseRequest\").@resolve.@call(),@putByIdDirectPrivate(d,\"inFlightCloseRequest\",@undefined);const i=@getByIdDirectPrivate(d,\"state\");if(@assert(i===\"writable\"||i===\"erroring\"),i===\"erroring\"){@putByIdDirectPrivate(d,\"storedError\",@undefined);const _=@getByIdDirectPrivate(d,\"pendingAbortRequest\");if(_!==@undefined)_.promise.@resolve.@call(),@putByIdDirectPrivate(d,\"pendingAbortRequest\",@undefined)}@putByIdDirectPrivate(d,\"state\",\"closed\");const n=@getByIdDirectPrivate(d,\"writer\");if(n!==@undefined)@getByIdDirectPrivate(n,\"closedPromise\").@resolve.@call();@assert(@getByIdDirectPrivate(d,\"pendingAbortRequest\")===@undefined),@assert(@getByIdDirectPrivate(d,\"storedError\")===@undefined)})\n"; // writableStreamFinishInFlightCloseWithError const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightCloseWithErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -220,7 +220,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamFinishInFlight 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 n=@getByIdDirectPrivate(c,\"inFlightCloseRequest\");@assert(n!==@undefined),n.@reject.@call(@undefined,_),@putByIdDirectPrivate(c,\"inFlightCloseRequest\",@undefined);const p=@getByIdDirectPrivate(c,\"state\");@assert(p===\"writable\"||p===\"erroring\");const d=@getByIdDirectPrivate(c,\"pendingAbortRequest\");if(d!==@undefined)d.promise.@reject.@call(@undefined,_),@putByIdDirectPrivate(c,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(c,_)})\n"; +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 n=@getByIdDirectPrivate(_,\"state\");@assert(n===\"writable\"||n===\"erroring\");const p=@getByIdDirectPrivate(_,\"pendingAbortRequest\");if(p!==@undefined)p.promise.@reject.@call(@undefined,c),@putByIdDirectPrivate(_,\"pendingAbortRequest\",@undefined);@writableStreamDealWithRejection(_,c)})\n"; // writableStreamFinishInFlightWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamFinishInFlightWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -260,7 +260,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamMarkFirstWrite 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 (d){\"use strict\";const h=@getByIdDirectPrivate(d,\"writeRequests\");@assert(@getByIdDirectPrivate(d,\"inFlightWriteRequest\")===@undefined),@assert(h.isNotEmpty());const c=h.shift();@putByIdDirectPrivate(d,\"inFlightWriteRequest\",c)})\n"; +const char* const s_writableStreamInternalsWritableStreamMarkFirstWriteRequestInFlightCode = "(function (c){\"use strict\";const d=@getByIdDirectPrivate(c,\"writeRequests\");@assert(@getByIdDirectPrivate(c,\"inFlightWriteRequest\")===@undefined),@assert(d.isNotEmpty());const h=d.shift();@putByIdDirectPrivate(c,\"inFlightWriteRequest\",h)})\n"; // writableStreamRejectCloseAndClosedPromiseIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamRejectCloseAndClosedPromiseIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -292,7 +292,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterA 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 (c,f){\"use strict\";const d=@getByIdDirectPrivate(c,\"stream\");return @assert(d!==@undefined),@writableStreamAbort(d,f)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterAbortCode = "(function (d,f){\"use strict\";const c=@getByIdDirectPrivate(d,\"stream\");return @assert(c!==@undefined),@writableStreamAbort(c,f)})\n"; // writableStreamDefaultWriterClose const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -300,7 +300,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterC 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 (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");return @assert(c!==@undefined),@writableStreamClose(c)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseCode = "(function (c){\"use strict\";const _=@getByIdDirectPrivate(c,\"stream\");return @assert(_!==@undefined),@writableStreamClose(_)})\n"; // writableStreamDefaultWriterCloseWithErrorPropagation const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -308,7 +308,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterC 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 l=@getByIdDirectPrivate(u,\"state\");if(@writableStreamCloseQueuedOrInFlight(u)||l===\"closed\")return @Promise.@resolve();if(l===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(u,\"storedError\"));return @assert(l===\"writable\"||l===\"erroring\"),@writableStreamDefaultWriterClose(c)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterCloseWithErrorPropagationCode = "(function (u){\"use strict\";const c=@getByIdDirectPrivate(u,\"stream\");@assert(c!==@undefined);const l=@getByIdDirectPrivate(c,\"state\");if(@writableStreamCloseQueuedOrInFlight(c)||l===\"closed\")return @Promise.@resolve();if(l===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(c,\"storedError\"));return @assert(l===\"writable\"||l===\"erroring\"),@writableStreamDefaultWriterClose(u)})\n"; // writableStreamDefaultWriterEnsureClosedPromiseRejected const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -316,7 +316,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterE 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 h=@getByIdDirectPrivate(n,\"closedPromise\"),u=h.@promise;if((@getPromiseInternalField(u,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)h=@newPromiseCapability(@Promise),u=h.@promise,@putByIdDirectPrivate(n,\"closedPromise\",h);h.@reject.@call(@undefined,_),@markPromiseAsHandled(u)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureClosedPromiseRejectedCode = "(function (h,u){\"use strict\";let _=@getByIdDirectPrivate(h,\"closedPromise\"),n=_.@promise;if((@getPromiseInternalField(n,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)_=@newPromiseCapability(@Promise),n=_.@promise,@putByIdDirectPrivate(h,\"closedPromise\",_);_.@reject.@call(@undefined,u),@markPromiseAsHandled(n)})\n"; // writableStreamDefaultWriterEnsureReadyPromiseRejected const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -324,7 +324,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterE 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 (c,g){\"use strict\";let n=@getByIdDirectPrivate(c,\"readyPromise\"),h=n.@promise;if((@getPromiseInternalField(h,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)n=@newPromiseCapability(@Promise),h=n.@promise,@putByIdDirectPrivate(c,\"readyPromise\",n);n.@reject.@call(@undefined,g),@markPromiseAsHandled(h)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterEnsureReadyPromiseRejectedCode = "(function (h,n){\"use strict\";let c=@getByIdDirectPrivate(h,\"readyPromise\"),g=c.@promise;if((@getPromiseInternalField(g,@promiseFieldFlags)&@promiseStateMask)!==@promiseStatePending)c=@newPromiseCapability(@Promise),g=c.@promise,@putByIdDirectPrivate(h,\"readyPromise\",c);c.@reject.@call(@undefined,n),@markPromiseAsHandled(g)})\n"; // writableStreamDefaultWriterGetDesiredSize const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -332,7 +332,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterG 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 l=@getByIdDirectPrivate(c,\"stream\");@assert(l!==@undefined);const _=@getByIdDirectPrivate(l,\"state\");if(_===\"errored\"||_===\"erroring\")return null;if(_===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(l,\"controller\"))})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterGetDesiredSizeCode = "(function (_){\"use strict\";const c=@getByIdDirectPrivate(_,\"stream\");@assert(c!==@undefined);const l=@getByIdDirectPrivate(c,\"state\");if(l===\"errored\"||l===\"erroring\")return null;if(l===\"closed\")return 0;return @writableStreamDefaultControllerGetDesiredSize(@getByIdDirectPrivate(c,\"controller\"))})\n"; // writableStreamDefaultWriterRelease const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultWriterReleaseCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -348,7 +348,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultWriterW 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,g){\"use strict\";const P=@getByIdDirectPrivate(d,\"stream\");@assert(P!==@undefined);const W=@getByIdDirectPrivate(P,\"controller\");@assert(W!==@undefined);const _=@writableStreamDefaultControllerGetChunkSize(W,g);if(P!==@getByIdDirectPrivate(d,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const b=@getByIdDirectPrivate(P,\"state\");if(b===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(P)||b===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(b===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(P,\"storedError\"));@assert(b===\"writable\");const f=@writableStreamAddWriteRequest(P);return @writableStreamDefaultControllerWrite(W,g,_),f})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultWriterWriteCode = "(function (W,_){\"use strict\";const d=@getByIdDirectPrivate(W,\"stream\");@assert(d!==@undefined);const P=@getByIdDirectPrivate(d,\"controller\");@assert(P!==@undefined);const b=@writableStreamDefaultControllerGetChunkSize(P,_);if(d!==@getByIdDirectPrivate(W,\"stream\"))return @Promise.@reject(@makeTypeError(\"writer is not stream's writer\"));const g=@getByIdDirectPrivate(d,\"state\");if(g===\"errored\")return @Promise.@reject(@getByIdDirectPrivate(d,\"storedError\"));if(@writableStreamCloseQueuedOrInFlight(d)||g===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(@writableStreamCloseQueuedOrInFlight(d)||g===\"closed\")return @Promise.@reject(@makeTypeError(\"stream is closing or closed\"));if(g===\"erroring\")return @Promise.@reject(@getByIdDirectPrivate(d,\"storedError\"));@assert(g===\"writable\");const f=@writableStreamAddWriteRequest(d);return @writableStreamDefaultControllerWrite(P,_,b),f})\n"; // setUpWritableStreamDefaultController const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -356,7 +356,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo 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,B,f,v,j,P,q){\"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\",B),@putByIdDirectPrivate(d,\"strategySizeAlgorithm\",q),@putByIdDirectPrivate(d,\"strategyHWM\",P),@putByIdDirectPrivate(d,\"writeAlgorithm\",f),@putByIdDirectPrivate(d,\"closeAlgorithm\",v),@putByIdDirectPrivate(d,\"abortAlgorithm\",j);const U=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(_,U),@writableStreamDefaultControllerStart(d)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerCode = "(function (B,_,v,P,U,d,f,j){\"use strict\";@assert(@isWritableStream(B)),@assert(@getByIdDirectPrivate(B,\"controller\")===@undefined),@putByIdDirectPrivate(_,\"stream\",B),@putByIdDirectPrivate(B,\"controller\",_),@resetQueue(@getByIdDirectPrivate(_,\"queue\")),@putByIdDirectPrivate(_,\"started\",-1),@putByIdDirectPrivate(_,\"startAlgorithm\",v),@putByIdDirectPrivate(_,\"strategySizeAlgorithm\",j),@putByIdDirectPrivate(_,\"strategyHWM\",f),@putByIdDirectPrivate(_,\"writeAlgorithm\",P),@putByIdDirectPrivate(_,\"closeAlgorithm\",U),@putByIdDirectPrivate(_,\"abortAlgorithm\",d);const q=@writableStreamDefaultControllerGetBackpressure(_);@writableStreamUpdateBackpressure(B,q),@writableStreamDefaultControllerStart(_)})\n"; // writableStreamDefaultControllerStart const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -364,7 +364,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl 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 (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const _=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(_.@call()).@then(()=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(u)=>{const p=@getByIdDirectPrivate(d,\"state\");@assert(p===\"writable\"||p===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(d,u)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerStartCode = "(function (i){\"use strict\";if(@getByIdDirectPrivate(i,\"started\")!==-1)return;@putByIdDirectPrivate(i,\"started\",0);const p=@getByIdDirectPrivate(i,\"startAlgorithm\");@putByIdDirectPrivate(i,\"startAlgorithm\",@undefined);const d=@getByIdDirectPrivate(i,\"stream\");return @Promise.@resolve(p.@call()).@then(()=>{const _=@getByIdDirectPrivate(d,\"state\");@assert(_===\"writable\"||_===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDefaultControllerAdvanceQueueIfNeeded(i)},(_)=>{const u=@getByIdDirectPrivate(d,\"state\");@assert(u===\"writable\"||u===\"erroring\"),@putByIdDirectPrivate(i,\"started\",1),@writableStreamDealWithRejection(d,_)})})\n"; // setUpWritableStreamDefaultControllerFromUnderlyingSink const JSC::ConstructAbility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -372,7 +372,7 @@ const JSC::ConstructorKind s_writableStreamInternalsSetUpWritableStreamDefaultCo const JSC::ImplementationVisibility s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeLength = 561; static const JSC::Intrinsic s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (_,p,x,O,B){\"use strict\";const f=new @WritableStreamDefaultController;let C=()=>{},j=()=>{return @Promise.@resolve()},E=()=>{return @Promise.@resolve()},q=()=>{return @Promise.@resolve()};if(\"start\"in x){const F=x.start;C=()=>@promiseInvokeOrNoopMethodNoCatch(p,F,[f])}if(\"write\"in x){const F=x.write;j=(v)=>@promiseInvokeOrNoopMethod(p,F,[v,f])}if(\"close\"in x){const F=x.close;E=()=>@promiseInvokeOrNoopMethod(p,F,[])}if(\"abort\"in x){const F=x.abort;q=(v)=>@promiseInvokeOrNoopMethod(p,F,[v])}@setUpWritableStreamDefaultController(_,f,C,j,E,q,O,B)})\n"; +const char* const s_writableStreamInternalsSetUpWritableStreamDefaultControllerFromUnderlyingSinkCode = "(function (C,O,_,E,F){\"use strict\";const f=new @WritableStreamDefaultController;let q=()=>{},v=()=>{return @Promise.@resolve()},x=()=>{return @Promise.@resolve()},B=()=>{return @Promise.@resolve()};if(\"start\"in _){const p=_.start;q=()=>@promiseInvokeOrNoopMethodNoCatch(O,p,[f])}if(\"write\"in _){const p=_.write;v=(j)=>@promiseInvokeOrNoopMethod(O,p,[j,f])}if(\"close\"in _){const p=_.close;x=()=>@promiseInvokeOrNoopMethod(O,p,[])}if(\"abort\"in _){const p=_.abort;B=(j)=>@promiseInvokeOrNoopMethod(O,p,[j])}@setUpWritableStreamDefaultController(C,f,q,v,x,B,E,F)})\n"; // writableStreamDefaultControllerAdvanceQueueIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerAdvanceQueueIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -412,7 +412,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl 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 (i,b){\"use strict\";const h=@getByIdDirectPrivate(i,\"stream\");@assert(h!==@undefined),@assert(@getByIdDirectPrivate(h,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(i),@writableStreamStartErroring(h,b)})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerErrorCode = "(function (h,b){\"use strict\";const i=@getByIdDirectPrivate(h,\"stream\");@assert(i!==@undefined),@assert(@getByIdDirectPrivate(i,\"state\")===\"writable\"),@writableStreamDefaultControllerClearAlgorithms(h),@writableStreamStartErroring(i,b)})\n"; // writableStreamDefaultControllerErrorIfNeeded const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerErrorIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -460,7 +460,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl 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 (d,_){\"use strict\";const q=@getByIdDirectPrivate(d,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(q),@getByIdDirectPrivate(d,\"writeAlgorithm\").@call(@undefined,_).@then(()=>{@writableStreamFinishInFlightWrite(q);const M=@getByIdDirectPrivate(q,\"state\");if(@assert(M===\"writable\"||M===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(d,\"queue\")),!@writableStreamCloseQueuedOrInFlight(q)&&M===\"writable\"){const i=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(q,i)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)},(M)=>{if(@getByIdDirectPrivate(q,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(d);@writableStreamFinishInFlightWriteWithError(q,M)})})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerProcessWriteCode = "(function (d,v){\"use strict\";const i=@getByIdDirectPrivate(d,\"stream\");@writableStreamMarkFirstWriteRequestInFlight(i),@getByIdDirectPrivate(d,\"writeAlgorithm\").@call(@undefined,v).@then(()=>{@writableStreamFinishInFlightWrite(i);const _=@getByIdDirectPrivate(i,\"state\");if(@assert(_===\"writable\"||_===\"erroring\"),@dequeueValue(@getByIdDirectPrivate(d,\"queue\")),!@writableStreamCloseQueuedOrInFlight(i)&&_===\"writable\"){const q=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(i,q)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)},(_)=>{if(@getByIdDirectPrivate(i,\"state\")===\"writable\")@writableStreamDefaultControllerClearAlgorithms(d);@writableStreamFinishInFlightWriteWithError(i,_)})})\n"; // writableStreamDefaultControllerWrite const JSC::ConstructAbility s_writableStreamInternalsWritableStreamDefaultControllerWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -468,7 +468,7 @@ const JSC::ConstructorKind s_writableStreamInternalsWritableStreamDefaultControl 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 (y,D,B){\"use strict\";try{@enqueueValueWithSize(@getByIdDirectPrivate(y,\"queue\"),D,B);const I=@getByIdDirectPrivate(y,\"stream\"),d=@getByIdDirectPrivate(I,\"state\");if(!@writableStreamCloseQueuedOrInFlight(I)&&d===\"writable\"){const _=@writableStreamDefaultControllerGetBackpressure(y);@writableStreamUpdateBackpressure(I,_)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(y)}catch(I){@writableStreamDefaultControllerErrorIfNeeded(y,I)}})\n"; +const char* const s_writableStreamInternalsWritableStreamDefaultControllerWriteCode = "(function (d,B,D){\"use strict\";try{@enqueueValueWithSize(@getByIdDirectPrivate(d,\"queue\"),B,D);const y=@getByIdDirectPrivate(d,\"stream\"),I=@getByIdDirectPrivate(y,\"state\");if(!@writableStreamCloseQueuedOrInFlight(y)&&I===\"writable\"){const _=@writableStreamDefaultControllerGetBackpressure(d);@writableStreamUpdateBackpressure(y,_)}@writableStreamDefaultControllerAdvanceQueueIfNeeded(d)}catch(y){@writableStreamDefaultControllerErrorIfNeeded(d,y)}})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -502,7 +502,7 @@ const JSC::ConstructorKind s_transformStreamInternalsCreateTransformStreamCodeCo 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 (j,x,_,B,c,D,q){\"use strict\";if(B===@undefined)B=1;if(c===@undefined)c=()=>1;if(D===@undefined)D=0;if(q===@undefined)q=()=>1;@assert(B>=0),@assert(D>=0);const E={};@putByIdDirectPrivate(E,\"TransformStream\",!0);const F=new @TransformStream(E),v=@newPromiseCapability(@Promise);@initializeTransformStream(F,v.@promise,B,c,D,q);const G=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(F,G,x,_),j().@then(()=>{v.@resolve.@call()},(I)=>{v.@reject.@call(@undefined,I)}),F})\n"; +const char* const s_transformStreamInternalsCreateTransformStreamCode = "(function (D,E,F,_,j,c,q){\"use strict\";if(_===@undefined)_=1;if(j===@undefined)j=()=>1;if(c===@undefined)c=0;if(q===@undefined)q=()=>1;@assert(_>=0),@assert(c>=0);const B={};@putByIdDirectPrivate(B,\"TransformStream\",!0);const v=new @TransformStream(B),x=@newPromiseCapability(@Promise);@initializeTransformStream(v,x.@promise,_,j,c,q);const G=new @TransformStreamDefaultController;return @setUpTransformStreamDefaultController(v,G,E,F),D().@then(()=>{x.@resolve.@call()},(I)=>{x.@reject.@call(@undefined,I)}),v})\n"; // initializeTransformStream const JSC::ConstructAbility s_transformStreamInternalsInitializeTransformStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -510,7 +510,7 @@ const JSC::ConstructorKind s_transformStreamInternalsInitializeTransformStreamCo 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 (v,F,C,D,T,J){\"use strict\";const j=()=>{return F},K=(q)=>{return @transformStreamDefaultSinkWriteAlgorithm(v,q)},L=(q)=>{return @transformStreamDefaultSinkAbortAlgorithm(v,q)},x=()=>{return @transformStreamDefaultSinkCloseAlgorithm(v)},G=@createWritableStream(j,K,x,L,C,D),f=()=>{return @transformStreamDefaultSourcePullAlgorithm(v)},B=(q)=>{return @transformStreamErrorWritableAndUnblockWrite(v,q),@Promise.@resolve()},I={};@putByIdDirectPrivate(I,\"start\",j),@putByIdDirectPrivate(I,\"pull\",f),@putByIdDirectPrivate(I,\"cancel\",B);const E={};@putByIdDirectPrivate(E,\"size\",J),@putByIdDirectPrivate(E,\"highWaterMark\",T);const N=new @ReadableStream(I,E);@putByIdDirectPrivate(v,\"writable\",G),@putByIdDirectPrivate(v,\"internalWritable\",@getInternalWritableStream(G)),@putByIdDirectPrivate(v,\"readable\",N),@putByIdDirectPrivate(v,\"backpressure\",@undefined),@putByIdDirectPrivate(v,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(v,!0),@putByIdDirectPrivate(v,\"controller\",@undefined)})\n"; +const char* const s_transformStreamInternalsInitializeTransformStreamCode = "(function (f,x,C,D,E,F){\"use strict\";const q=()=>{return x},G=(B)=>{return @transformStreamDefaultSinkWriteAlgorithm(f,B)},I=(B)=>{return @transformStreamDefaultSinkAbortAlgorithm(f,B)},J=()=>{return @transformStreamDefaultSinkCloseAlgorithm(f)},v=@createWritableStream(q,G,J,I,C,D),K=()=>{return @transformStreamDefaultSourcePullAlgorithm(f)},L=(B)=>{return @transformStreamErrorWritableAndUnblockWrite(f,B),@Promise.@resolve()},T={};@putByIdDirectPrivate(T,\"start\",q),@putByIdDirectPrivate(T,\"pull\",K),@putByIdDirectPrivate(T,\"cancel\",L);const j={};@putByIdDirectPrivate(j,\"size\",F),@putByIdDirectPrivate(j,\"highWaterMark\",E);const N=new @ReadableStream(T,j);@putByIdDirectPrivate(f,\"writable\",v),@putByIdDirectPrivate(f,\"internalWritable\",@getInternalWritableStream(v)),@putByIdDirectPrivate(f,\"readable\",N),@putByIdDirectPrivate(f,\"backpressure\",@undefined),@putByIdDirectPrivate(f,\"backpressureChangePromise\",@undefined),@transformStreamSetBackpressure(f,!0),@putByIdDirectPrivate(f,\"controller\",@undefined)})\n"; // transformStreamError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -534,7 +534,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamSetBackpress 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 (_,f){\"use strict\";@assert(@getByIdDirectPrivate(_,\"backpressure\")!==f);const d=@getByIdDirectPrivate(_,\"backpressureChangePromise\");if(d!==@undefined)d.@resolve.@call();@putByIdDirectPrivate(_,\"backpressureChangePromise\",@newPromiseCapability(@Promise)),@putByIdDirectPrivate(_,\"backpressure\",f)})\n"; +const char* const s_transformStreamInternalsTransformStreamSetBackpressureCode = "(function (_,d){\"use strict\";@assert(@getByIdDirectPrivate(_,\"backpressure\")!==d);const f=@getByIdDirectPrivate(_,\"backpressureChangePromise\");if(f!==@undefined)f.@resolve.@call();@putByIdDirectPrivate(_,\"backpressureChangePromise\",@newPromiseCapability(@Promise)),@putByIdDirectPrivate(_,\"backpressure\",d)})\n"; // setUpTransformStreamDefaultController const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -542,7 +542,7 @@ const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefault 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 (d,_,P,b){\"use strict\";@assert(@isTransformStream(d)),@assert(@getByIdDirectPrivate(d,\"controller\")===@undefined),@putByIdDirectPrivate(_,\"stream\",d),@putByIdDirectPrivate(d,\"controller\",_),@putByIdDirectPrivate(_,\"transformAlgorithm\",P),@putByIdDirectPrivate(_,\"flushAlgorithm\",b)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerCode = "(function (d,P,_,b){\"use strict\";@assert(@isTransformStream(d)),@assert(@getByIdDirectPrivate(d,\"controller\")===@undefined),@putByIdDirectPrivate(P,\"stream\",d),@putByIdDirectPrivate(d,\"controller\",P),@putByIdDirectPrivate(P,\"transformAlgorithm\",_),@putByIdDirectPrivate(P,\"flushAlgorithm\",b)})\n"; // setUpTransformStreamDefaultControllerFromTransformer const JSC::ConstructAbility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -550,7 +550,7 @@ const JSC::ConstructorKind s_transformStreamInternalsSetUpTransformStreamDefault const JSC::ImplementationVisibility s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeLength = 443; static const JSC::Intrinsic s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (_,d,p){\"use strict\";const v=new @TransformStreamDefaultController;let b=(q)=>{try{@transformStreamDefaultControllerEnqueue(v,q)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in p)b=(q)=>{return @promiseInvokeOrNoopMethod(d,p.transform,[q,v])};if(\"flush\"in p)j=()=>{return @promiseInvokeOrNoopMethod(d,p.flush,[v])};@setUpTransformStreamDefaultController(_,v,b,j)})\n"; +const char* const s_transformStreamInternalsSetUpTransformStreamDefaultControllerFromTransformerCode = "(function (q,v,_){\"use strict\";const d=new @TransformStreamDefaultController;let b=(p)=>{try{@transformStreamDefaultControllerEnqueue(d,p)}catch(w){return @Promise.@reject(w)}return @Promise.@resolve()},j=()=>{return @Promise.@resolve()};if(\"transform\"in _)b=(p)=>{return @promiseInvokeOrNoopMethod(v,_.transform,[p,d])};if(\"flush\"in _)j=()=>{return @promiseInvokeOrNoopMethod(v,_.flush,[d])};@setUpTransformStreamDefaultController(q,d,b,j)})\n"; // transformStreamDefaultControllerClearAlgorithms const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerClearAlgorithmsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -566,7 +566,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr 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 (_,W){\"use strict\";const f=@getByIdDirectPrivate(_,\"stream\"),g=@getByIdDirectPrivate(f,\"readable\"),i=@getByIdDirectPrivate(g,\"readableStreamController\");if(@assert(i!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(i))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(i,W)}catch(S){throw @transformStreamErrorWritableAndUnblockWrite(f,S),@getByIdDirectPrivate(g,\"storedError\")}const j=!@readableStreamDefaultControllerShouldCallPull(i);if(j!==@getByIdDirectPrivate(f,\"backpressure\"))@assert(j),@transformStreamSetBackpressure(f,!0)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerEnqueueCode = "(function (g,i){\"use strict\";const _=@getByIdDirectPrivate(g,\"stream\"),W=@getByIdDirectPrivate(_,\"readable\"),S=@getByIdDirectPrivate(W,\"readableStreamController\");if(@assert(S!==@undefined),!@readableStreamDefaultControllerCanCloseOrEnqueue(S))@throwTypeError(\"TransformStream.readable cannot close or enqueue\");try{@readableStreamDefaultControllerEnqueue(S,i)}catch(j){throw @transformStreamErrorWritableAndUnblockWrite(_,j),@getByIdDirectPrivate(W,\"storedError\")}const f=!@readableStreamDefaultControllerShouldCallPull(S);if(f!==@getByIdDirectPrivate(_,\"backpressure\"))@assert(f),@transformStreamSetBackpressure(_,!0)})\n"; // transformStreamDefaultControllerError const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -582,7 +582,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr 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 j=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(_,\"transformAlgorithm\").@call(@undefined,d).@then(()=>{j.@resolve()},(f)=>{@transformStreamError(@getByIdDirectPrivate(_,\"stream\"),f),j.@reject.@call(@undefined,f)}),j.@promise})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerPerformTransformCode = "(function (d,g){\"use strict\";const _=@newPromiseCapability(@Promise);return @getByIdDirectPrivate(d,\"transformAlgorithm\").@call(@undefined,g).@then(()=>{_.@resolve()},(f)=>{@transformStreamError(@getByIdDirectPrivate(d,\"stream\"),f),_.@reject.@call(@undefined,f)}),_.@promise})\n"; // transformStreamDefaultControllerTerminate const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultControllerTerminateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -590,7 +590,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultContr 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 _=@getByIdDirectPrivate(i,\"stream\"),f=@getByIdDirectPrivate(_,\"readable\"),k=@getByIdDirectPrivate(f,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(k))@readableStreamDefaultControllerClose(k);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(_,u)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultControllerTerminateCode = "(function (f){\"use strict\";const i=@getByIdDirectPrivate(f,\"stream\"),k=@getByIdDirectPrivate(i,\"readable\"),_=@getByIdDirectPrivate(k,\"readableStreamController\");if(@readableStreamDefaultControllerCanCloseOrEnqueue(_))@readableStreamDefaultControllerClose(_);const u=@makeTypeError(\"the stream has been terminated\");@transformStreamErrorWritableAndUnblockWrite(i,u)})\n"; // transformStreamDefaultSinkWriteAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -598,7 +598,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkW 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 v=@getByIdDirectPrivate(_,\"internalWritable\");@assert(@getByIdDirectPrivate(v,\"state\")===\"writable\");const f=@getByIdDirectPrivate(_,\"controller\");if(@getByIdDirectPrivate(_,\"backpressure\")){const j=@newPromiseCapability(@Promise),q=@getByIdDirectPrivate(_,\"backpressureChangePromise\");return @assert(q!==@undefined),q.@promise.@then(()=>{const x=@getByIdDirectPrivate(v,\"state\");if(x===\"erroring\"){j.@reject.@call(@undefined,@getByIdDirectPrivate(v,\"storedError\"));return}@assert(x===\"writable\"),@transformStreamDefaultControllerPerformTransform(f,d).@then(()=>{j.@resolve()},(z)=>{j.@reject.@call(@undefined,z)})},(x)=>{j.@reject.@call(@undefined,x)}),j.@promise}return @transformStreamDefaultControllerPerformTransform(f,d)})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkWriteAlgorithmCode = "(function (d,j){\"use strict\";const f=@getByIdDirectPrivate(d,\"internalWritable\");@assert(@getByIdDirectPrivate(f,\"state\")===\"writable\");const q=@getByIdDirectPrivate(d,\"controller\");if(@getByIdDirectPrivate(d,\"backpressure\")){const _=@newPromiseCapability(@Promise),x=@getByIdDirectPrivate(d,\"backpressureChangePromise\");return @assert(x!==@undefined),x.@promise.@then(()=>{const v=@getByIdDirectPrivate(f,\"state\");if(v===\"erroring\"){_.@reject.@call(@undefined,@getByIdDirectPrivate(f,\"storedError\"));return}@assert(v===\"writable\"),@transformStreamDefaultControllerPerformTransform(q,j).@then(()=>{_.@resolve()},(z)=>{_.@reject.@call(@undefined,z)})},(v)=>{_.@reject.@call(@undefined,v)}),_.@promise}return @transformStreamDefaultControllerPerformTransform(q,j)})\n"; // transformStreamDefaultSinkAbortAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSinkAbortAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -614,7 +614,7 @@ const JSC::ConstructorKind s_transformStreamInternalsTransformStreamDefaultSinkC 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 q=@getByIdDirectPrivate(_,\"readable\"),f=@getByIdDirectPrivate(_,\"controller\"),j=@getByIdDirectPrivate(q,\"readableStreamController\"),k=@getByIdDirectPrivate(f,\"flushAlgorithm\");@assert(k!==@undefined);const u=@getByIdDirectPrivate(f,\"flushAlgorithm\").@call();@transformStreamDefaultControllerClearAlgorithms(f);const I=@newPromiseCapability(@Promise);return u.@then(()=>{if(@getByIdDirectPrivate(q,\"state\")===@streamErrored){I.@reject.@call(@undefined,@getByIdDirectPrivate(q,\"storedError\"));return}if(@readableStreamDefaultControllerCanCloseOrEnqueue(j))@readableStreamDefaultControllerClose(j);I.@resolve()},(v)=>{@transformStreamError(@getByIdDirectPrivate(f,\"stream\"),v),I.@reject.@call(@undefined,@getByIdDirectPrivate(q,\"storedError\"))}),I.@promise})\n"; +const char* const s_transformStreamInternalsTransformStreamDefaultSinkCloseAlgorithmCode = "(function (f){\"use strict\";const _=@getByIdDirectPrivate(f,\"readable\"),q=@getByIdDirectPrivate(f,\"controller\"),j=@getByIdDirectPrivate(_,\"readableStreamController\"),k=@getByIdDirectPrivate(q,\"flushAlgorithm\");@assert(k!==@undefined);const u=@getByIdDirectPrivate(q,\"flushAlgorithm\").@call();@transformStreamDefaultControllerClearAlgorithms(q);const I=@newPromiseCapability(@Promise);return u.@then(()=>{if(@getByIdDirectPrivate(_,\"state\")===@streamErrored){I.@reject.@call(@undefined,@getByIdDirectPrivate(_,\"storedError\"));return}if(@readableStreamDefaultControllerCanCloseOrEnqueue(j))@readableStreamDefaultControllerClose(j);I.@resolve()},(v)=>{@transformStreamError(@getByIdDirectPrivate(q,\"stream\"),v),I.@reject.@call(@undefined,@getByIdDirectPrivate(_,\"storedError\"))}),I.@promise})\n"; // transformStreamDefaultSourcePullAlgorithm const JSC::ConstructAbility s_transformStreamInternalsTransformStreamDefaultSourcePullAlgorithmCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -674,7 +674,7 @@ const JSC::ConstructorKind s_transformStreamInitializeTransformStreamCodeConstru const JSC::ImplementationVisibility s_transformStreamInitializeTransformStreamCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_transformStreamInitializeTransformStreamCodeLength = 1304; static const JSC::Intrinsic s_transformStreamInitializeTransformStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let u=arguments[1],j=arguments[2];if(_===@undefined)_=null;if(j===@undefined)j={};if(u===@undefined)u={};let q={};if(_!==null){if(\"start\"in _){if(q.start=_.start,typeof q.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(q.transform=_.transform,typeof q.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(q.flush=_.flush,typeof q.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const v=@extractHighWaterMark(j,0),x=@extractSizeAlgorithm(j),B=@extractHighWaterMark(u,1),E=@extractSizeAlgorithm(u),F=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,F.@promise,B,E,v,x),@setUpTransformStreamDefaultControllerFromTransformer(this,_,q),(\"start\"in q)){const G=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,q.start,[G]))().@then(()=>{F.@resolve.@call()},(J)=>{F.@reject.@call(@undefined,J)})}else F.@resolve.@call();return this})\n"; +const char* const s_transformStreamInitializeTransformStreamCode = "(function (){\"use strict\";let _=arguments[0];if(@isObject(_)&&@getByIdDirectPrivate(_,\"TransformStream\"))return this;let j=arguments[1],q=arguments[2];if(_===@undefined)_=null;if(q===@undefined)q={};if(j===@undefined)j={};let u={};if(_!==null){if(\"start\"in _){if(u.start=_.start,typeof u.start!==\"function\")@throwTypeError(\"transformer.start should be a function\")}if(\"transform\"in _){if(u.transform=_.transform,typeof u.transform!==\"function\")@throwTypeError(\"transformer.transform should be a function\")}if(\"flush\"in _){if(u.flush=_.flush,typeof u.flush!==\"function\")@throwTypeError(\"transformer.flush should be a function\")}if(\"readableType\"in _)@throwRangeError(\"TransformStream transformer has a readableType\");if(\"writableType\"in _)@throwRangeError(\"TransformStream transformer has a writableType\")}const x=@extractHighWaterMark(q,0),B=@extractSizeAlgorithm(q),E=@extractHighWaterMark(j,1),F=@extractSizeAlgorithm(j),v=@newPromiseCapability(@Promise);if(@initializeTransformStream(this,v.@promise,E,F,x,B),@setUpTransformStreamDefaultControllerFromTransformer(this,_,u),(\"start\"in u)){const G=@getByIdDirectPrivate(this,\"controller\");(()=>@promiseInvokeOrNoopMethodNoCatch(_,u.start,[G]))().@then(()=>{v.@resolve.@call()},(I)=>{v.@reject.@call(@undefined,I)})}else v.@resolve.@call();return this})\n"; // readable const JSC::ConstructAbility s_transformStreamReadableCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -716,7 +716,7 @@ const JSC::ConstructorKind s_moduleRequireCodeConstructorKind = JSC::Constructor const JSC::ImplementationVisibility s_moduleRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_moduleRequireCodeLength = 1035; static const JSC::Intrinsic s_moduleRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_moduleRequireCode = "(function (M){\"use strict\";const S=@requireMap.@get(M)||@requireMap.@get(M=@resolveSync(M,this.path,!1));if(S)return @evaluateCommonJSModule(S),S.exports;if(M.endsWith(\".json\")||M.endsWith(\".toml\")||M.endsWith(\".node\"))return @internalRequire(M);let f=@Loader.registry.@get(M);if(f\?.evaluated&&(f.state\?\?0)>=@ModuleReady){const b=f.module,r=@Loader.getModuleNamespaceObject(b),_=r\?.[@commonJSSymbol]===0||r\?.default\?.[@commonJSSymbol]===0\?r.default:r.__esModule\?r:Object.create(r,{__esModule:{value:!0}});return @requireMap.@set(M,@createCommonJSModule(M,_,!0)),_}const h=@createCommonJSModule(M,{},!1);@requireMap.@set(M,h);var L=this.@require(M,h);if(L===-1){try{L=@requireESM(M)}catch(b){throw @requireMap.@delete(M),b}if(f=@Loader.registry.@get(M),f\?.evaluated&&(f.state\?\?0)>=@ModuleReady){const b=@Loader.getModuleNamespaceObject(f.module);return h.exports=b\?.[@commonJSSymbol]===0||b\?.default\?.[@commonJSSymbol]===0\?b.default:b.__esModule\?b:Object.create(b,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(h),h.exports})\n"; +const char* const s_moduleRequireCode = "(function (_){\"use strict\";const b=@requireMap.@get(_)||@requireMap.@get(_=@resolveSync(_,this.path,!1));if(b)return @evaluateCommonJSModule(b),b.exports;if(_.endsWith(\".json\")||_.endsWith(\".toml\")||_.endsWith(\".node\"))return @internalRequire(_);let S=@Loader.registry.@get(_);if(S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const M=S.module,f=@Loader.getModuleNamespaceObject(M),r=f\?.[@commonJSSymbol]===0||f\?.default\?.[@commonJSSymbol]===0\?f.default:f.__esModule\?f:Object.create(f,{__esModule:{value:!0}});return @requireMap.@set(_,@createCommonJSModule(_,r,!0)),r}const L=@createCommonJSModule(_,{},!1);@requireMap.@set(_,L);var h=this.@require(_,L);if(h===-1){try{h=@requireESM(_)}catch(M){throw @requireMap.@delete(_),M}if(S=@Loader.registry.@get(_),S\?.evaluated&&(S.state\?\?0)>=@ModuleReady){const M=@Loader.getModuleNamespaceObject(S.module);return L.exports=M\?.[@commonJSSymbol]===0||M\?.default\?.[@commonJSSymbol]===0\?M.default:M.__esModule\?M:Object.create(M,{__esModule:{value:!0}})}}return @evaluateCommonJSModule(L),L.exports})\n"; // requireResolve const JSC::ConstructAbility s_moduleRequireResolveCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -830,7 +830,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntLECodeConstructorKind = JSC 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 (d,r){\"use strict\";const _=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(r){case 1:return _.getInt8(d);case 2:return _.getInt16(d,!0);case 3:{const u=_.getUint16(d,!0)+_.getUint8(d+2)*65536;return u|(u&8388608)*510}case 4:return _.getInt32(d,!0);case 5:{const u=_.getUint8(d+4);return(u|(u&128)*33554430)*4294967296+_.getUint32(d,!0)}case 6:{const u=_.getUint16(d+4,!0);return(u|(u&32768)*131070)*4294967296+_.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntLECode = "(function (d,u){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(u){case 1:return r.getInt8(d);case 2:return r.getInt16(d,!0);case 3:{const _=r.getUint16(d,!0)+r.getUint8(d+2)*65536;return _|(_&8388608)*510}case 4:return r.getInt32(d,!0);case 5:{const _=r.getUint8(d+4);return(_|(_&128)*33554430)*4294967296+r.getUint32(d,!0)}case 6:{const _=r.getUint16(d+4,!0);return(_|(_&32768)*131070)*4294967296+r.getUint32(d,!0)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readIntBE const JSC::ConstructAbility s_jsBufferPrototypeReadIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -838,7 +838,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadIntBECodeConstructorKind = JSC 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 (r,d){\"use strict\";const u=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(d){case 1:return u.getInt8(r);case 2:return u.getInt16(r,!1);case 3:{const c=u.getUint16(r+1,!1)+u.getUint8(r)*65536;return c|(c&8388608)*510}case 4:return u.getInt32(r,!1);case 5:{const c=u.getUint8(r);return(c|(c&128)*33554430)*4294967296+u.getUint32(r+1,!1)}case 6:{const c=u.getUint16(r,!1);return(c|(c&32768)*131070)*4294967296+u.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadIntBECode = "(function (r,c){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:return d.getInt8(r);case 2:return d.getInt16(r,!1);case 3:{const u=d.getUint16(r+1,!1)+d.getUint8(r)*65536;return u|(u&8388608)*510}case 4:return d.getInt32(r,!1);case 5:{const u=d.getUint8(r);return(u|(u&128)*33554430)*4294967296+d.getUint32(r+1,!1)}case 6:{const u=d.getUint16(r,!1);return(u|(u&32768)*131070)*4294967296+d.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readUIntLE const JSC::ConstructAbility s_jsBufferPrototypeReadUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -854,7 +854,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeReadUIntBECodeConstructorKind = JS 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,c){\"use strict\";const p=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:return p.getUint8(r);case 2:return p.getUint16(r,!1);case 3:return p.getUint16(r+1,!1)+p.getUint8(r)*65536;case 4:return p.getUint32(r,!1);case 5:{const d=p.getUint8(r);return(d|(d&128)*33554430)*4294967296+p.getUint32(r+1,!1)}case 6:{const d=p.getUint16(r,!1);return(d|(d&32768)*131070)*4294967296+p.getUint32(r+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; +const char* const s_jsBufferPrototypeReadUIntBECode = "(function (d,p){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(p){case 1:return r.getUint8(d);case 2:return r.getUint16(d,!1);case 3:return r.getUint16(d+1,!1)+r.getUint8(d)*65536;case 4:return r.getUint32(d,!1);case 5:{const c=r.getUint8(d);return(c|(c&128)*33554430)*4294967296+r.getUint32(d+1,!1)}case 6:{const c=r.getUint16(d,!1);return(c|(c&32768)*131070)*4294967296+r.getUint32(d+2,!1)}}@throwRangeError(\"byteLength must be >= 1 and <= 6\")})\n"; // readFloatLE const JSC::ConstructAbility s_jsBufferPrototypeReadFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -926,7 +926,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt8CodeConstructorKind = JSC 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,r){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt8(r,d),r+1})\n"; +const char* const s_jsBufferPrototypeWriteInt8Code = "(function (r,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt8(d,r),d+1})\n"; // writeUInt8 const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt8CodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -934,7 +934,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt8CodeConstructorKind = JS 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint8(d,c),d+1})\n"; +const char* const s_jsBufferPrototypeWriteUInt8Code = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint8(c,d),c+1})\n"; // writeInt16LE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -942,7 +942,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16LECodeConstructorKind = 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(d,c,!0),d+2})\n"; +const char* const s_jsBufferPrototypeWriteInt16LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(c,d,!0),c+2})\n"; // writeInt16BE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -950,7 +950,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt16BECodeConstructorKind = 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(d,c,!1),d+2})\n"; +const char* const s_jsBufferPrototypeWriteInt16BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt16(c,d,!1),c+2})\n"; // writeUInt16LE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -958,7 +958,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16LECodeConstructorKind = 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(d,c,!0),d+2})\n"; +const char* const s_jsBufferPrototypeWriteUInt16LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(c,d,!0),c+2})\n"; // writeUInt16BE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt16BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -966,7 +966,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt16BECodeConstructorKind = 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(d,c,!1),d+2})\n"; +const char* const s_jsBufferPrototypeWriteUInt16BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint16(c,d,!1),c+2})\n"; // writeInt32LE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -974,7 +974,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32LECodeConstructorKind = 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(d,c,!0),d+4})\n"; +const char* const s_jsBufferPrototypeWriteInt32LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(c,d,!0),c+4})\n"; // writeInt32BE const JSC::ConstructAbility s_jsBufferPrototypeWriteInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -982,7 +982,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteInt32BECodeConstructorKind = 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(d,c,!1),d+4})\n"; +const char* const s_jsBufferPrototypeWriteInt32BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setInt32(c,d,!1),c+4})\n"; // writeUInt32LE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -990,7 +990,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32LECodeConstructorKind = 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,c,!0),d+4})\n"; +const char* const s_jsBufferPrototypeWriteUInt32LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(c,d,!0),c+4})\n"; // writeUInt32BE const JSC::ConstructAbility s_jsBufferPrototypeWriteUInt32BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -998,7 +998,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUInt32BECodeConstructorKind = 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(d,c,!1),d+4})\n"; +const char* const s_jsBufferPrototypeWriteUInt32BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setUint32(c,d,!1),c+4})\n"; // writeIntLE const JSC::ConstructAbility s_jsBufferPrototypeWriteIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1006,7 +1006,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteIntLECodeConstructorKind = JS 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,j){\"use strict\";const d=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(j){case 1:{d.setInt8(c,r);break}case 2:{d.setInt16(c,r,!0);break}case 3:{d.setUint16(c,r&65535,!0),d.setInt8(c+2,Math.floor(r*0.0000152587890625));break}case 4:{d.setInt32(c,r,!0);break}case 5:{d.setUint32(c,r|0,!0),d.setInt8(c+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{d.setUint32(c,r|0,!0),d.setInt16(c+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return c+j})\n"; +const char* const s_jsBufferPrototypeWriteIntLECode = "(function (r,d,j){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(j){case 1:{c.setInt8(d,r);break}case 2:{c.setInt16(d,r,!0);break}case 3:{c.setUint16(d,r&65535,!0),c.setInt8(d+2,Math.floor(r*0.0000152587890625));break}case 4:{c.setInt32(d,r,!0);break}case 5:{c.setUint32(d,r|0,!0),c.setInt8(d+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{c.setUint32(d,r|0,!0),c.setInt16(d+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+j})\n"; // writeIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1014,7 +1014,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteIntBECodeConstructorKind = JS 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 (d,r,E){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(E){case 1:{c.setInt8(r,d);break}case 2:{c.setInt16(r,d,!1);break}case 3:{c.setUint16(r+1,d&65535,!1),c.setInt8(r,Math.floor(d*0.0000152587890625));break}case 4:{c.setInt32(r,d,!1);break}case 5:{c.setUint32(r+1,d|0,!1),c.setInt8(r,Math.floor(d*0.00000000023283064365386964));break}case 6:{c.setUint32(r+2,d|0,!1),c.setInt16(r,Math.floor(d*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return r+E})\n"; +const char* const s_jsBufferPrototypeWriteIntBECode = "(function (r,d,c){\"use strict\";const E=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{E.setInt8(d,r);break}case 2:{E.setInt16(d,r,!1);break}case 3:{E.setUint16(d+1,r&65535,!1),E.setInt8(d,Math.floor(r*0.0000152587890625));break}case 4:{E.setInt32(d,r,!1);break}case 5:{E.setUint32(d+1,r|0,!1),E.setInt8(d,Math.floor(r*0.00000000023283064365386964));break}case 6:{E.setUint32(d+2,r|0,!1),E.setInt16(d,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+c})\n"; // writeUIntLE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1022,7 +1022,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntLECodeConstructorKind = J 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,d,E){\"use strict\";const c=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(E){case 1:{c.setUint8(d,r);break}case 2:{c.setUint16(d,r,!0);break}case 3:{c.setUint16(d,r&65535,!0),c.setUint8(d+2,Math.floor(r*0.0000152587890625));break}case 4:{c.setUint32(d,r,!0);break}case 5:{c.setUint32(d,r|0,!0),c.setUint8(d+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{c.setUint32(d,r|0,!0),c.setUint16(d+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+E})\n"; +const char* const s_jsBufferPrototypeWriteUIntLECode = "(function (r,d,c){\"use strict\";const E=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(c){case 1:{E.setUint8(d,r);break}case 2:{E.setUint16(d,r,!0);break}case 3:{E.setUint16(d,r&65535,!0),E.setUint8(d+2,Math.floor(r*0.0000152587890625));break}case 4:{E.setUint32(d,r,!0);break}case 5:{E.setUint32(d,r|0,!0),E.setUint8(d+4,Math.floor(r*0.00000000023283064365386964));break}case 6:{E.setUint32(d,r|0,!0),E.setUint16(d+4,Math.floor(r*0.00000000023283064365386964),!0);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+c})\n"; // writeUIntBE const JSC::ConstructAbility s_jsBufferPrototypeWriteUIntBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1030,7 +1030,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteUIntBECodeConstructorKind = J 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 (d,_,p){\"use strict\";const r=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(p){case 1:{r.setUint8(_,d);break}case 2:{r.setUint16(_,d,!1);break}case 3:{r.setUint16(_+1,d&65535,!1),r.setUint8(_,Math.floor(d*0.0000152587890625));break}case 4:{r.setUint32(_,d,!1);break}case 5:{r.setUint32(_+1,d|0,!1),r.setUint8(_,Math.floor(d*0.00000000023283064365386964));break}case 6:{r.setUint32(_+2,d|0,!1),r.setUint16(_,Math.floor(d*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return _+p})\n"; +const char* const s_jsBufferPrototypeWriteUIntBECode = "(function (r,d,_){\"use strict\";const p=this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength);switch(_){case 1:{p.setUint8(d,r);break}case 2:{p.setUint16(d,r,!1);break}case 3:{p.setUint16(d+1,r&65535,!1),p.setUint8(d,Math.floor(r*0.0000152587890625));break}case 4:{p.setUint32(d,r,!1);break}case 5:{p.setUint32(d+1,r|0,!1),p.setUint8(d,Math.floor(r*0.00000000023283064365386964));break}case 6:{p.setUint32(d+2,r|0,!1),p.setUint16(d,Math.floor(r*0.00000000023283064365386964),!1);break}default:@throwRangeError(\"byteLength must be >= 1 and <= 6\")}return d+_})\n"; // writeFloatLE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1038,7 +1038,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatLECodeConstructorKind = 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!0),d+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatLECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!0),c+4})\n"; // writeFloatBE const JSC::ConstructAbility s_jsBufferPrototypeWriteFloatBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1046,7 +1046,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteFloatBECodeConstructorKind = 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(d,c,!1),d+4})\n"; +const char* const s_jsBufferPrototypeWriteFloatBECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat32(c,d,!1),c+4})\n"; // writeDoubleLE const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleLECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1054,7 +1054,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleLECodeConstructorKind = 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(d,c,!0),d+8})\n"; +const char* const s_jsBufferPrototypeWriteDoubleLECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(c,d,!0),c+8})\n"; // writeDoubleBE const JSC::ConstructAbility s_jsBufferPrototypeWriteDoubleBECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1062,7 +1062,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteDoubleBECodeConstructorKind = 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(d,c,!1),d+8})\n"; +const char* const s_jsBufferPrototypeWriteDoubleBECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setFloat64(c,d,!1),c+8})\n"; // writeBigInt64LE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1070,7 +1070,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64LECodeConstructorKind 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(d,c,!0),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigInt64LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(c,d,!0),c+8})\n"; // writeBigInt64BE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1078,7 +1078,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigInt64BECodeConstructorKind 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(d,c,!1),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigInt64BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigInt64(c,d,!1),c+8})\n"; // writeBigUInt64LE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64LECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1086,7 +1086,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64LECodeConstructorKin 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(d,c,!0),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigUInt64LECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(c,d,!0),c+8})\n"; // writeBigUInt64BE const JSC::ConstructAbility s_jsBufferPrototypeWriteBigUInt64BECodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1094,7 +1094,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeWriteBigUInt64BECodeConstructorKin 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 (c,d){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(d,c,!1),d+8})\n"; +const char* const s_jsBufferPrototypeWriteBigUInt64BECode = "(function (d,c){\"use strict\";return(this.@dataView||=new DataView(this.buffer,this.byteOffset,this.byteLength)).setBigUint64(c,d,!1),c+8})\n"; // utf8Write const JSC::ConstructAbility s_jsBufferPrototypeUtf8WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1134,7 +1134,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeAsciiWriteCodeConstructorKind = JS 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 (c,i,d){\"use strict\";return this.write(c,i,d,\"ascii\")})\n"; +const char* const s_jsBufferPrototypeAsciiWriteCode = "(function (c,d,i){\"use strict\";return this.write(c,d,i,\"ascii\")})\n"; // base64Write const JSC::ConstructAbility s_jsBufferPrototypeBase64WriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1158,7 +1158,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeHexWriteCodeConstructorKind = JSC: 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 (d,a,r){\"use strict\";return this.write(d,a,r,\"hex\")})\n"; +const char* const s_jsBufferPrototypeHexWriteCode = "(function (d,r,a){\"use strict\";return this.write(d,r,a,\"hex\")})\n"; // utf8Slice const JSC::ConstructAbility s_jsBufferPrototypeUtf8SliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1174,7 +1174,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeUcs2SliceCodeConstructorKind = JSC 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 (u,g){\"use strict\";return this.toString(\"ucs2\",u,g)})\n"; +const char* const s_jsBufferPrototypeUcs2SliceCode = "(function (g,u){\"use strict\";return this.toString(\"ucs2\",g,u)})\n"; // utf16leSlice const JSC::ConstructAbility s_jsBufferPrototypeUtf16leSliceCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1238,7 +1238,7 @@ const JSC::ConstructorKind s_jsBufferPrototypeSliceCodeConstructorKind = JSC::Co 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"; +const char* const s_jsBufferPrototypeSliceCode = "(function (w,m){\"use strict\";var{buffer:x,byteOffset:z,byteLength:p}=this;function q(c,k){if(c=@trunc(c),c===0||@isNaN(c))return 0;else if(c<0)return c+=k,c>0\?c:0;else return c<k\?c:k}var i=q(w,p),v=m!==@undefined\?q(m,p):p;return new @Buffer(x,z+i,v>i\?v-i:0)})\n"; // parent const JSC::ConstructAbility s_jsBufferPrototypeParentCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1312,7 +1312,7 @@ const JSC::ConstructorKind s_readableByteStreamControllerByobRequestCodeConstruc 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 _=@getByIdDirectPrivate(this,\"byobRequest\");if(_===@undefined){var a=@getByIdDirectPrivate(this,\"pendingPullIntos\");const l=a.peek();if(l){const m=new @Uint8Array(l.buffer,l.byteOffset+l.bytesFilled,l.byteLength-l.bytesFilled);@putByIdDirectPrivate(this,\"byobRequest\",new @ReadableStreamBYOBRequest(this,m,@isReadableStream))}}return @getByIdDirectPrivate(this,\"byobRequest\")})\n"; +const char* const s_readableByteStreamControllerByobRequestCode = "(function (){\"use strict\";if(!@isReadableByteStreamController(this))throw @makeGetterTypeError(\"ReadableByteStreamController\",\"byobRequest\");var a=@getByIdDirectPrivate(this,\"byobRequest\");if(a===@undefined){var l=@getByIdDirectPrivate(this,\"pendingPullIntos\");const _=l.peek();if(_){const m=new @Uint8Array(_.buffer,_.byteOffset+_.bytesFilled,_.byteLength-_.bytesFilled);@putByIdDirectPrivate(this,\"byobRequest\",new @ReadableStreamBYOBRequest(this,m,@isReadableStream))}}return @getByIdDirectPrivate(this,\"byobRequest\")})\n"; // desiredSize const JSC::ConstructAbility s_readableByteStreamControllerDesiredSizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1338,7 +1338,7 @@ const JSC::ConstructorKind s_consoleObjectAsyncIteratorCodeConstructorKind = JSC 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 w=async function*A(){var D=@Bun.stdin.stream().getReader(),_=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),F,j=@Bun.indexOfLine;try{while(!0){var G,H,m;const M=D.readMany();if(@isPromise(M))({done:G,value:H}=await M);else({done:G,value:H}=M);if(G){if(m)yield _.decode(m);return}var J;for(let q of H){if(J=q,m)J=@Buffer.concat([m,q]),m=null;var K=0,L=j(J,K);while(L!==-1)yield _.decode(J.subarray(K,L)),K=L+1,L=j(J,K);m=J.subarray(K)}}}catch(M){F=M}finally{if(D.releaseLock(),F)throw F}},z=globalThis.Symbol.asyncIterator;return this[z]=w,w()})\n"; +const char* const s_consoleObjectAsyncIteratorCode = "(function (){\"use strict\";const D=async function*L(){var F=@Bun.stdin.stream().getReader(),G=new globalThis.TextDecoder(\"utf-8\",{fatal:!1}),z,H=@Bun.indexOfLine;try{while(!0){var A,B,w;const m=F.readMany();if(@isPromise(m))({done:A,value:B}=await m);else({done:A,value:B}=m);if(A){if(w)yield G.decode(w);return}var _;for(let J of B){if(_=J,w)_=@Buffer.concat([w,J]),w=null;var j=0,q=H(_,j);while(q!==-1)yield G.decode(_.subarray(j,q)),j=q+1,q=H(_,j);w=_.subarray(j)}}}catch(m){z=m}finally{if(F.releaseLock(),z)throw z}},K=globalThis.Symbol.asyncIterator;return this[K]=D,D()})\n"; // write const JSC::ConstructAbility s_consoleObjectWriteCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1346,7 +1346,7 @@ const JSC::ConstructorKind s_consoleObjectWriteCodeConstructorKind = JSC::Constr 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 (a){\"use strict\";var d=@getByIdDirectPrivate(this,\"writer\");if(!d){var _=@toLength(a\?.length\?\?0);d=@Bun.stdout.writer({highWaterMark:_>65536\?_:65536}),@putByIdDirectPrivate(this,\"writer\",d)}var b=d.write(a);const c=@argumentCount();for(var f=1;f<c;f++)b+=d.write(@argument(f));return d.flush(!0),b})\n"; +const char* const s_consoleObjectWriteCode = "(function (_){\"use strict\";var a=@getByIdDirectPrivate(this,\"writer\");if(!a){var b=@toLength(_\?.length\?\?0);a=@Bun.stdout.writer({highWaterMark:b>65536\?b:65536}),@putByIdDirectPrivate(this,\"writer\",a)}var c=a.write(_);const f=@argumentCount();for(var d=1;d<f;d++)c+=a.write(@argument(d));return a.flush(!0),c})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1364,7 +1364,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericI 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 (i,_){\"use strict\";if(@putByIdDirectPrivate(i,\"ownerReadableStream\",_),@putByIdDirectPrivate(_,\"reader\",i),@getByIdDirectPrivate(_,\"state\")===@streamReadable)@putByIdDirectPrivate(i,\"closedPromiseCapability\",@newPromiseCapability(@Promise));else if(@getByIdDirectPrivate(_,\"state\")===@streamClosed)@putByIdDirectPrivate(i,\"closedPromiseCapability\",{@promise:@Promise.@resolve()});else @assert(@getByIdDirectPrivate(_,\"state\")===@streamErrored),@putByIdDirectPrivate(i,\"closedPromiseCapability\",{@promise:@newHandledRejectedPromise(@getByIdDirectPrivate(_,\"storedError\"))})})\n"; +const char* const s_readableStreamInternalsReadableStreamReaderGenericInitializeCode = "(function (_,i){\"use strict\";if(@putByIdDirectPrivate(_,\"ownerReadableStream\",i),@putByIdDirectPrivate(i,\"reader\",_),@getByIdDirectPrivate(i,\"state\")===@streamReadable)@putByIdDirectPrivate(_,\"closedPromiseCapability\",@newPromiseCapability(@Promise));else if(@getByIdDirectPrivate(i,\"state\")===@streamClosed)@putByIdDirectPrivate(_,\"closedPromiseCapability\",{@promise:@Promise.@resolve()});else @assert(@getByIdDirectPrivate(i,\"state\")===@streamErrored),@putByIdDirectPrivate(_,\"closedPromiseCapability\",{@promise:@newHandledRejectedPromise(@getByIdDirectPrivate(i,\"storedError\"))})})\n"; // privateInitializeReadableStreamDefaultController const JSC::ConstructAbility s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1372,7 +1372,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPrivateInitializeReadableStr 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 (d,_,P,b){\"use strict\";if(!@isReadableStream(d))@throwTypeError(\"ReadableStreamDefaultController needs a ReadableStream\");if(@getByIdDirectPrivate(d,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");return @putByIdDirectPrivate(this,\"controlledReadableStream\",d),@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",-1),@putByIdDirectPrivate(this,\"closeRequested\",!1),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@putByIdDirectPrivate(this,\"strategy\",@validateAndNormalizeQueuingStrategy(P,b)),this})\n"; +const char* const s_readableStreamInternalsPrivateInitializeReadableStreamDefaultControllerCode = "(function (d,P,_,b){\"use strict\";if(!@isReadableStream(d))@throwTypeError(\"ReadableStreamDefaultController needs a ReadableStream\");if(@getByIdDirectPrivate(d,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");return @putByIdDirectPrivate(this,\"controlledReadableStream\",d),@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)),this})\n"; // readableStreamDefaultControllerError const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1380,7 +1380,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl 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 (i,u){\"use strict\";const d=@getByIdDirectPrivate(i,\"controlledReadableStream\");if(@getByIdDirectPrivate(d,\"state\")!==@streamReadable)return;@putByIdDirectPrivate(i,\"queue\",@newQueue()),@readableStreamError(d,u)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerErrorCode = "(function (i,d){\"use strict\";const u=@getByIdDirectPrivate(i,\"controlledReadableStream\");if(@getByIdDirectPrivate(u,\"state\")!==@streamReadable)return;@putByIdDirectPrivate(i,\"queue\",@newQueue()),@readableStreamError(u,d)})\n"; // readableStreamPipeTo const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1388,7 +1388,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToCodeCons 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 (c,_){\"use strict\";@assert(@isReadableStream(c));const h=new @ReadableStreamDefaultReader(c);@getByIdDirectPrivate(h,\"closedPromiseCapability\").@promise.@then(()=>{},(g)=>{_.error(g)});function y(){@readableStreamDefaultReaderRead(h).@then(function(g){if(g.done){_.close();return}try{_.enqueue(g.value)}catch(S){_.error(\"ReadableStream chunk enqueueing in the sink failed\");return}y()},function(g){_.error(g)})}y()})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToCode = "(function (g,c){\"use strict\";@assert(@isReadableStream(g));const h=new @ReadableStreamDefaultReader(g);@getByIdDirectPrivate(h,\"closedPromiseCapability\").@promise.@then(()=>{},(_)=>{c.error(_)});function y(){@readableStreamDefaultReaderRead(h).@then(function(_){if(_.done){c.close();return}try{c.enqueue(_.value)}catch(S){c.error(\"ReadableStream chunk enqueueing in the sink failed\");return}y()},function(_){c.error(_)})}y()})\n"; // acquireReadableStreamDefaultReader const JSC::ConstructAbility s_readableStreamInternalsAcquireReadableStreamDefaultReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1402,9 +1402,9 @@ const char* const s_readableStreamInternalsAcquireReadableStreamDefaultReaderCod 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; +const int s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeLength = 726; static const JSC::Intrinsic s_readableStreamInternalsSetupReadableStreamDefaultControllerCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (f,b,j,q,v,w,x){\"use strict\";const B=new @ReadableStreamDefaultController(f,b,j,q,@isReadableStream),C=()=>@promiseInvokeOrNoopMethod(b,w,[B]),D=(_)=>@promiseInvokeOrNoopMethod(b,x,[_]);@putByIdDirectPrivate(B,\"pullAlgorithm\",C),@putByIdDirectPrivate(B,\"cancelAlgorithm\",D),@putByIdDirectPrivate(B,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(B,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(f,\"readableStreamController\",B),@readableStreamDefaultControllerStart(B)})\n"; +const char* const s_readableStreamInternalsSetupReadableStreamDefaultControllerCode = "(function (I,f,w,B,J,D,j){\"use strict\";const _=new @ReadableStreamDefaultController(I,f,w,B,@isReadableStream);var q=I.@asyncContext;const E=()=>@promiseInvokeOrNoopMethod(f,D,[_]),F=q\?(b)=>{var G=@getInternalField(@asyncContext,0);@putInternalField(@asyncContext,0,q);var H=@promiseInvokeOrNoopMethod(f,j,[b]);return @putInternalField(@asyncContext,0,G),H}:(b)=>@promiseInvokeOrNoopMethod(f,j,[b]);@putByIdDirectPrivate(_,\"pullAlgorithm\",E),@putByIdDirectPrivate(_,\"cancelAlgorithm\",F),@putByIdDirectPrivate(_,\"pull\",@readableStreamDefaultControllerPull),@putByIdDirectPrivate(_,\"cancel\",@readableStreamDefaultControllerCancel),@putByIdDirectPrivate(I,\"readableStreamController\",_),@readableStreamDefaultControllerStart(_)})\n"; // createReadableStreamController const JSC::ConstructAbility s_readableStreamInternalsCreateReadableStreamControllerCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1412,7 +1412,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateReadableStreamControll 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 (v,w,f){\"use strict\";const A=w.type,C=@toString(A);if(C===\"bytes\"){if(f.highWaterMark===@undefined)f.highWaterMark=0;if(f.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(v,\"readableStreamController\",new @ReadableByteStreamController(v,w,f.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=f\?.highWaterMark;@initializeArrayBufferStream.@call(v,w,b)}else if(A===@undefined){if(f.highWaterMark===@undefined)f.highWaterMark=1;@setupReadableStreamDefaultController(v,w,f.size,f.highWaterMark,w.start,w.pull,w.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; +const char* const s_readableStreamInternalsCreateReadableStreamControllerCode = "(function (w,v,f){\"use strict\";const A=v.type,C=@toString(A);if(C===\"bytes\"){if(f.highWaterMark===@undefined)f.highWaterMark=0;if(f.size!==@undefined)@throwRangeError(\"Strategy for a ReadableByteStreamController cannot have a size\");@putByIdDirectPrivate(w,\"readableStreamController\",new @ReadableByteStreamController(w,v,f.highWaterMark,@isReadableStream))}else if(C===\"direct\"){var b=f\?.highWaterMark;@initializeArrayBufferStream.@call(w,v,b)}else if(A===@undefined){if(f.highWaterMark===@undefined)f.highWaterMark=1;@setupReadableStreamDefaultController(w,v,f.size,f.highWaterMark,v.start,v.pull,v.cancel)}else @throwRangeError(\"Invalid type for underlying source\")})\n"; // readableStreamDefaultControllerStart const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1420,7 +1420,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl 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 (m){\"use strict\";if(@getByIdDirectPrivate(m,\"started\")!==-1)return;const p=@getByIdDirectPrivate(m,\"underlyingSource\"),B=p.start;@putByIdDirectPrivate(m,\"started\",0),@promiseInvokeOrNoopMethodNoCatch(p,B,[m]).@then(()=>{@putByIdDirectPrivate(m,\"started\",1),@assert(!@getByIdDirectPrivate(m,\"pulling\")),@assert(!@getByIdDirectPrivate(m,\"pullAgain\")),@readableStreamDefaultControllerCallPullIfNeeded(m)},(a)=>{@readableStreamDefaultControllerError(m,a)})})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerStartCode = "(function (m){\"use strict\";if(@getByIdDirectPrivate(m,\"started\")!==-1)return;const B=@getByIdDirectPrivate(m,\"underlyingSource\"),a=B.start;@putByIdDirectPrivate(m,\"started\",0),@promiseInvokeOrNoopMethodNoCatch(B,a,[m]).@then(()=>{@putByIdDirectPrivate(m,\"started\",1),@assert(!@getByIdDirectPrivate(m,\"pulling\")),@assert(!@getByIdDirectPrivate(m,\"pullAgain\")),@readableStreamDefaultControllerCallPullIfNeeded(m)},(p)=>{@readableStreamDefaultControllerError(m,p)})})\n"; // readableStreamPipeToWritableStream const JSC::ConstructAbility s_readableStreamInternalsReadableStreamPipeToWritableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1428,7 +1428,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamPipeToWritable 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 (D,E,T,w,x,z){\"use strict\";if(@assert(@isReadableStream(D)),@assert(@isWritableStream(E)),@assert(!@isReadableStreamLocked(D)),@assert(!@isWritableStreamLocked(E)),@assert(z===@undefined||@isAbortSignal(z)),@getByIdDirectPrivate(D,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let B={source:D,destination:E,preventAbort:w,preventCancel:x,preventClose:T,signal:z};if(B.reader=@acquireReadableStreamDefaultReader(D),B.writer=@acquireWritableStreamDefaultWriter(E),@putByIdDirectPrivate(D,\"disturbed\",!0),B.finalized=!1,B.shuttingDown=!1,B.promiseCapability=@newPromiseCapability(@Promise),B.pendingReadPromiseCapability=@newPromiseCapability(@Promise),B.pendingReadPromiseCapability.@resolve.@call(),B.pendingWritePromise=@Promise.@resolve(),z!==@undefined){const F=(G)=>{if(B.finalized)return;@pipeToShutdownWithAction(B,()=>{const _=!B.preventAbort&&@getByIdDirectPrivate(B.destination,\"state\")===\"writable\"\?@writableStreamAbort(B.destination,G):@Promise.@resolve(),k=!B.preventCancel&&@getByIdDirectPrivate(B.source,\"state\")===@streamReadable\?@readableStreamCancel(B.source,G):@Promise.@resolve();let q=@newPromiseCapability(@Promise),I=!0,J=()=>{if(I){I=!1;return}q.@resolve.@call()},K=(L)=>{q.@reject.@call(@undefined,L)};return _.@then(J,K),k.@then(J,K),q.@promise},G)};if(@whenSignalAborted(z,F))return B.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(B),@pipeToErrorsMustBePropagatedBackward(B),@pipeToClosingMustBePropagatedForward(B),@pipeToClosingMustBePropagatedBackward(B),@pipeToLoop(B),B.promiseCapability.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamPipeToWritableStreamCode = "(function (f,E,z,B,F,D){\"use strict\";if(@assert(@isReadableStream(f)),@assert(@isWritableStream(E)),@assert(!@isReadableStreamLocked(f)),@assert(!@isWritableStreamLocked(E)),@assert(D===@undefined||@isAbortSignal(D)),@getByIdDirectPrivate(f,\"underlyingByteSource\")!==@undefined)return @Promise.@reject(\"Piping to a readable bytestream is not supported\");let _={source:f,destination:E,preventAbort:B,preventCancel:F,preventClose:z,signal:D};if(_.reader=@acquireReadableStreamDefaultReader(f),_.writer=@acquireWritableStreamDefaultWriter(E),@putByIdDirectPrivate(f,\"disturbed\",!0),_.finalized=!1,_.shuttingDown=!1,_.promiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability=@newPromiseCapability(@Promise),_.pendingReadPromiseCapability.@resolve.@call(),_.pendingWritePromise=@Promise.@resolve(),D!==@undefined){const G=(T)=>{if(_.finalized)return;@pipeToShutdownWithAction(_,()=>{const H=!_.preventAbort&&@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"\?@writableStreamAbort(_.destination,T):@Promise.@resolve(),I=!_.preventCancel&&@getByIdDirectPrivate(_.source,\"state\")===@streamReadable\?@readableStreamCancel(_.source,T):@Promise.@resolve();let k=@newPromiseCapability(@Promise),q=!0,w=()=>{if(q){q=!1;return}k.@resolve.@call()},x=(J)=>{k.@reject.@call(@undefined,J)};return H.@then(w,x),I.@then(w,x),k.@promise},T)};if(@whenSignalAborted(D,G))return _.promiseCapability.@promise}return @pipeToErrorsMustBePropagatedForward(_),@pipeToErrorsMustBePropagatedBackward(_),@pipeToClosingMustBePropagatedForward(_),@pipeToClosingMustBePropagatedBackward(_),@pipeToLoop(_),_.promiseCapability.@promise})\n"; // pipeToLoop const JSC::ConstructAbility s_readableStreamInternalsPipeToLoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1444,7 +1444,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToDoReadWriteCodeConstru 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((d)=>{const m=!d.done&&@getByIdDirectPrivate(_.writer,\"stream\")!==@undefined;if(_.pendingReadPromiseCapability.@resolve.@call(@undefined,m),!m)return;_.pendingWritePromise=@writableStreamDefaultWriterWrite(_.writer,d.value)},(d)=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1)})},(d)=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1)}),_.pendingReadPromiseCapability.@promise})\n"; +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((m)=>{const d=!m.done&&@getByIdDirectPrivate(_.writer,\"stream\")!==@undefined;if(_.pendingReadPromiseCapability.@resolve.@call(@undefined,d),!d)return;_.pendingWritePromise=@writableStreamDefaultWriterWrite(_.writer,m.value)},(m)=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1)})},(m)=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1)}),_.pendingReadPromiseCapability.@promise})\n"; // pipeToErrorsMustBePropagatedForward const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1452,7 +1452,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagated 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 (d){\"use strict\";const _=()=>{d.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);const b=@getByIdDirectPrivate(d.source,\"storedError\");if(!d.preventAbort){@pipeToShutdownWithAction(d,()=>@writableStreamAbort(d.destination,b),b);return}@pipeToShutdown(d,b)};if(@getByIdDirectPrivate(d.source,\"state\")===@streamErrored){_();return}@getByIdDirectPrivate(d.reader,\"closedPromiseCapability\").@promise.@then(@undefined,_)})\n"; +const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedForwardCode = "(function (_){\"use strict\";const d=()=>{_.pendingReadPromiseCapability.@resolve.@call(@undefined,!1);const b=@getByIdDirectPrivate(_.source,\"storedError\");if(!_.preventAbort){@pipeToShutdownWithAction(_,()=>@writableStreamAbort(_.destination,b),b);return}@pipeToShutdown(_,b)};if(@getByIdDirectPrivate(_.source,\"state\")===@streamErrored){d();return}@getByIdDirectPrivate(_.reader,\"closedPromiseCapability\").@promise.@then(@undefined,d)})\n"; // pipeToErrorsMustBePropagatedBackward const JSC::ConstructAbility s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1460,7 +1460,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToErrorsMustBePropagated 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 (m){\"use strict\";const h=()=>{const y=@getByIdDirectPrivate(m.destination,\"storedError\");if(!m.preventCancel){@pipeToShutdownWithAction(m,()=>@readableStreamCancel(m.source,y),y);return}@pipeToShutdown(m,y)};if(@getByIdDirectPrivate(m.destination,\"state\")===\"errored\"){h();return}@getByIdDirectPrivate(m.writer,\"closedPromise\").@promise.@then(@undefined,h)})\n"; +const char* const s_readableStreamInternalsPipeToErrorsMustBePropagatedBackwardCode = "(function (m){\"use strict\";const y=()=>{const h=@getByIdDirectPrivate(m.destination,\"storedError\");if(!m.preventCancel){@pipeToShutdownWithAction(m,()=>@readableStreamCancel(m.source,h),h);return}@pipeToShutdown(m,h)};if(@getByIdDirectPrivate(m.destination,\"state\")===\"errored\"){y();return}@getByIdDirectPrivate(m.writer,\"closedPromise\").@promise.@then(@undefined,y)})\n"; // pipeToClosingMustBePropagatedForward const JSC::ConstructAbility s_readableStreamInternalsPipeToClosingMustBePropagatedForwardCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1484,7 +1484,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownWithActionCode 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 (_,h){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const b=arguments.length>2,d=arguments[2],m=()=>{h().@then(()=>{if(b)@pipeToFinalize(_,d);else @pipeToFinalize(_)},(j)=>{@pipeToFinalize(_,j)})};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(m,m)},(g)=>@pipeToFinalize(_,g));return}m()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownWithActionCode = "(function (_,d){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const g=arguments.length>2,h=arguments[2],m=()=>{d().@then(()=>{if(g)@pipeToFinalize(_,h);else @pipeToFinalize(_)},(j)=>{@pipeToFinalize(_,j)})};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(m,m)},(b)=>@pipeToFinalize(_,b));return}m()})\n"; // pipeToShutdown const JSC::ConstructAbility s_readableStreamInternalsPipeToShutdownCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1492,7 +1492,7 @@ const JSC::ConstructorKind s_readableStreamInternalsPipeToShutdownCodeConstructo 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 (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const d=arguments.length>1,m=arguments[1],u=()=>{if(d)@pipeToFinalize(_,m);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(u,u)},(I)=>@pipeToFinalize(_,I));return}u()})\n"; +const char* const s_readableStreamInternalsPipeToShutdownCode = "(function (_){\"use strict\";if(_.shuttingDown)return;_.shuttingDown=!0;const m=arguments.length>1,u=arguments[1],d=()=>{if(m)@pipeToFinalize(_,u);else @pipeToFinalize(_)};if(@getByIdDirectPrivate(_.destination,\"state\")===\"writable\"&&!@writableStreamCloseQueuedOrInFlight(_.destination)){_.pendingReadPromiseCapability.@promise.@then(()=>{_.pendingWritePromise.@then(d,d)},(I)=>@pipeToFinalize(_,I));return}d()})\n"; // pipeToFinalize const JSC::ConstructAbility s_readableStreamInternalsPipeToFinalizeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1508,7 +1508,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeCodeConstru 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 (i,q){\"use strict\";@assert(@isReadableStream(i)),@assert(typeof q===\"boolean\");var v=@getByIdDirectPrivate(i,\"start\");if(v)@putByIdDirectPrivate(i,\"start\",@undefined),v();const k=new @ReadableStreamDefaultReader(i),_={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};_.cancelPromiseCapability=@newPromiseCapability(@Promise);const w=@readableStreamTeePullFunction(_,k,q),f={};@putByIdDirectPrivate(f,\"pull\",w),@putByIdDirectPrivate(f,\"cancel\",@readableStreamTeeBranch1CancelFunction(_,i));const x={};@putByIdDirectPrivate(x,\"pull\",w),@putByIdDirectPrivate(x,\"cancel\",@readableStreamTeeBranch2CancelFunction(_,i));const y=new @ReadableStream(f),g=new @ReadableStream(x);return @getByIdDirectPrivate(k,\"closedPromiseCapability\").@promise.@then(@undefined,function(j){if(_.closedOrErrored)return;if(@readableStreamDefaultControllerError(y.@readableStreamController,j),@readableStreamDefaultControllerError(g.@readableStreamController,j),_.closedOrErrored=!0,!_.canceled1||!_.canceled2)_.cancelPromiseCapability.@resolve.@call()}),_.branch1=y,_.branch2=g,[y,g]})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeCode = "(function (_,q){\"use strict\";@assert(@isReadableStream(_)),@assert(typeof q===\"boolean\");var v=@getByIdDirectPrivate(_,\"start\");if(v)@putByIdDirectPrivate(_,\"start\",@undefined),v();const w=new @ReadableStreamDefaultReader(_),i={closedOrErrored:!1,canceled1:!1,canceled2:!1,reason1:@undefined,reason2:@undefined};i.cancelPromiseCapability=@newPromiseCapability(@Promise);const x=@readableStreamTeePullFunction(i,w,q),f={};@putByIdDirectPrivate(f,\"pull\",x),@putByIdDirectPrivate(f,\"cancel\",@readableStreamTeeBranch1CancelFunction(i,_));const g={};@putByIdDirectPrivate(g,\"pull\",x),@putByIdDirectPrivate(g,\"cancel\",@readableStreamTeeBranch2CancelFunction(i,_));const j=new @ReadableStream(f),k=new @ReadableStream(g);return @getByIdDirectPrivate(w,\"closedPromiseCapability\").@promise.@then(@undefined,function(y){if(i.closedOrErrored)return;if(@readableStreamDefaultControllerError(j.@readableStreamController,y),@readableStreamDefaultControllerError(k.@readableStreamController,y),i.closedOrErrored=!0,!i.canceled1||!i.canceled2)i.cancelPromiseCapability.@resolve.@call()}),i.branch1=j,i.branch2=k,[j,k]})\n"; // readableStreamTeePullFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeePullFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1516,7 +1516,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeePullFunctio 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 (_,m,f){\"use strict\";return function(){@Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(m),function(i){if(@assert(@isObject(i)),@assert(typeof i.done===\"boolean\"),i.done&&!_.closedOrErrored){if(!_.canceled1)@readableStreamDefaultControllerClose(_.branch1.@readableStreamController);if(!_.canceled2)@readableStreamDefaultControllerClose(_.branch2.@readableStreamController);if(_.closedOrErrored=!0,!_.canceled1||!_.canceled2)_.cancelPromiseCapability.@resolve.@call()}if(_.closedOrErrored)return;if(!_.canceled1)@readableStreamDefaultControllerEnqueue(_.branch1.@readableStreamController,i.value);if(!_.canceled2)@readableStreamDefaultControllerEnqueue(_.branch2.@readableStreamController,f\?@structuredCloneForStream(i.value):i.value)})}})\n"; +const char* const s_readableStreamInternalsReadableStreamTeePullFunctionCode = "(function (i,f,m){\"use strict\";return function(){@Promise.prototype.@then.@call(@readableStreamDefaultReaderRead(f),function(_){if(@assert(@isObject(_)),@assert(typeof _.done===\"boolean\"),_.done&&!i.closedOrErrored){if(!i.canceled1)@readableStreamDefaultControllerClose(i.branch1.@readableStreamController);if(!i.canceled2)@readableStreamDefaultControllerClose(i.branch2.@readableStreamController);if(i.closedOrErrored=!0,!i.canceled1||!i.canceled2)i.cancelPromiseCapability.@resolve.@call()}if(i.closedOrErrored)return;if(!i.canceled1)@readableStreamDefaultControllerEnqueue(i.branch1.@readableStreamController,_.value);if(!i.canceled2)@readableStreamDefaultControllerEnqueue(i.branch2.@readableStreamController,m\?@structuredCloneForStream(_.value):_.value)})}})\n"; // readableStreamTeeBranch1CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1524,7 +1524,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch1Canc 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 (c,i){\"use strict\";return function(d){if(c.canceled1=!0,c.reason1=d,c.canceled2)@readableStreamCancel(i,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeBranch1CancelFunctionCode = "(function (c,d){\"use strict\";return function(i){if(c.canceled1=!0,c.reason1=i,c.canceled2)@readableStreamCancel(d,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; // readableStreamTeeBranch2CancelFunction const JSC::ConstructAbility s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1532,7 +1532,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamTeeBranch2Canc 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 (c,i){\"use strict\";return function(d){if(c.canceled2=!0,c.reason2=d,c.canceled1)@readableStreamCancel(i,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; +const char* const s_readableStreamInternalsReadableStreamTeeBranch2CancelFunctionCode = "(function (c,d){\"use strict\";return function(i){if(c.canceled2=!0,c.reason2=i,c.canceled1)@readableStreamCancel(d,[c.reason1,c.reason2]).@then(c.cancelPromiseCapability.@resolve,c.cancelPromiseCapability.@reject);return c.cancelPromiseCapability.@promise}})\n"; // isReadableStream const JSC::ConstructAbility s_readableStreamInternalsIsReadableStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1562,9 +1562,9 @@ const char* const s_readableStreamInternalsIsReadableStreamDefaultControllerCode 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; +const int s_readableStreamInternalsReadDirectStreamCodeLength = 916; static const JSC::Intrinsic s_readableStreamInternalsReadDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (_,f,j){\"use strict\";@putByIdDirectPrivate(_,\"underlyingSource\",@undefined),@putByIdDirectPrivate(_,\"start\",@undefined);function q(x,z){if(z&&j\?.cancel){try{var A=j.cancel(z);@markPromiseAsHandled(A)}catch(B){}j=@undefined}if(x){if(@putByIdDirectPrivate(x,\"readableStreamController\",@undefined),@putByIdDirectPrivate(x,\"reader\",@undefined),z)@putByIdDirectPrivate(x,\"state\",@streamErrored),@putByIdDirectPrivate(x,\"storedError\",z);else @putByIdDirectPrivate(x,\"state\",@streamClosed);x=@undefined}}if(!j.pull){q();return}if(!@isCallable(j.pull)){q(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(_,\"readableStreamController\",f);const v=@getByIdDirectPrivate(_,\"highWaterMark\");f.start({highWaterMark:!v||v<64\?64:v}),@startDirectStream.@call(f,_,j.pull,q),@putByIdDirectPrivate(_,\"reader\",{});var w=j.pull(f);if(f=@undefined,w&&@isPromise(w))return w.@then(()=>{})})\n"; +const char* const s_readableStreamInternalsReadDirectStreamCode = "(function (_,q,f){\"use strict\";@putByIdDirectPrivate(_,\"underlyingSource\",@undefined),@putByIdDirectPrivate(_,\"start\",@undefined);function w(j,v){if(v&&f\?.cancel){try{var A=f.cancel(v);@markPromiseAsHandled(A)}catch(B){}f=@undefined}if(j){if(@putByIdDirectPrivate(j,\"readableStreamController\",@undefined),@putByIdDirectPrivate(j,\"reader\",@undefined),v)@putByIdDirectPrivate(j,\"state\",@streamErrored),@putByIdDirectPrivate(j,\"storedError\",v);else @putByIdDirectPrivate(j,\"state\",@streamClosed);j=@undefined}}if(!f.pull){w();return}if(!@isCallable(f.pull)){w(),@throwTypeError(\"pull is not a function\");return}@putByIdDirectPrivate(_,\"readableStreamController\",q);const x=@getByIdDirectPrivate(_,\"highWaterMark\");q.start({highWaterMark:!x||x<64\?64:x}),@startDirectStream.@call(q,_,f.pull,w,_.@asyncContext),@putByIdDirectPrivate(_,\"reader\",{});var z=f.pull(q);if(q=@undefined,z&&@isPromise(z))return z.@then(()=>{})})\n"; // assignToStream const JSC::ConstructAbility s_readableStreamInternalsAssignToStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1578,9 +1578,9 @@ const char* const s_readableStreamInternalsAssignToStreamCode = "(function (h,_) 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; +const int s_readableStreamInternalsReadStreamIntoSinkCodeLength = 1411; static const JSC::Intrinsic s_readableStreamInternalsReadStreamIntoSinkCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadStreamIntoSinkCode = "(async function (_,D,c){\"use strict\";var f=!1,x=!1;try{var B=_.getReader(),E=B.readMany();if(E&&@isPromise(E))E=await E;if(E.done)return f=!0,D.end();var F=E.value.length;const q=@getByIdDirectPrivate(_,\"highWaterMark\");if(c)@startDirectStream.@call(D,_,@undefined,()=>!x&&@markPromiseAsHandled(_.cancel()));D.start({highWaterMark:q||0});for(var G=0,I=E.value,H=E.value.length;G<H;G++)D.write(I[G]);var J=@getByIdDirectPrivate(_,\"state\");if(J===@streamClosed)return f=!0,D.end();while(!0){var{value:P,done:z}=await B.read();if(z)return f=!0,D.end();D.write(P)}}catch(q){x=!0;try{B=@undefined;const K=_.cancel(q);@markPromiseAsHandled(K)}catch(K){}if(D&&!f){f=!0;try{D.close(q)}catch(K){throw new globalThis.AggregateError([q,K])}}throw q}finally{if(B){try{B.releaseLock()}catch(K){}B=@undefined}D=@undefined;var J=@getByIdDirectPrivate(_,\"state\");if(_){var A=@getByIdDirectPrivate(_,\"readableStreamController\");if(A){if(@getByIdDirectPrivate(A,\"underlyingSource\"))@putByIdDirectPrivate(A,\"underlyingSource\",@undefined);if(@getByIdDirectPrivate(A,\"controlledReadableStream\"))@putByIdDirectPrivate(A,\"controlledReadableStream\",@undefined);if(@putByIdDirectPrivate(_,\"readableStreamController\",null),@getByIdDirectPrivate(_,\"underlyingSource\"))@putByIdDirectPrivate(_,\"underlyingSource\",@undefined);A=@undefined}if(!x&&J!==@streamClosed&&J!==@streamErrored)@readableStreamClose(_);_=@undefined}}})\n"; +const char* const s_readableStreamInternalsReadStreamIntoSinkCode = "(async function (_,c,B){\"use strict\";var j=!1,x=!1;try{var P=_.getReader(),D=P.readMany();if(D&&@isPromise(D))D=await D;if(D.done)return j=!0,c.end();var I=D.value.length;const f=@getByIdDirectPrivate(_,\"highWaterMark\");if(B)@startDirectStream.@call(c,_,@undefined,()=>!x&&@markPromiseAsHandled(_.cancel()),_.@asyncContext);c.start({highWaterMark:f||0});for(var z=0,E=D.value,F=D.value.length;z<F;z++)c.write(E[z]);var q=@getByIdDirectPrivate(_,\"state\");if(q===@streamClosed)return j=!0,c.end();while(!0){var{value:G,done:H}=await P.read();if(H)return j=!0,c.end();c.write(G)}}catch(f){x=!0;try{P=@undefined;const p=_.cancel(f);@markPromiseAsHandled(p)}catch(p){}if(c&&!j){j=!0;try{c.close(f)}catch(p){throw new globalThis.AggregateError([f,p])}}throw f}finally{if(P){try{P.releaseLock()}catch(p){}P=@undefined}c=@undefined;var q=@getByIdDirectPrivate(_,\"state\");if(_){var A=@getByIdDirectPrivate(_,\"readableStreamController\");if(A){if(@getByIdDirectPrivate(A,\"underlyingSource\"))@putByIdDirectPrivate(A,\"underlyingSource\",@undefined);if(@getByIdDirectPrivate(A,\"controlledReadableStream\"))@putByIdDirectPrivate(A,\"controlledReadableStream\",@undefined);if(@putByIdDirectPrivate(_,\"readableStreamController\",null),@getByIdDirectPrivate(_,\"underlyingSource\"))@putByIdDirectPrivate(_,\"underlyingSource\",@undefined);A=@undefined}if(!x&&q!==@streamClosed&&q!==@streamErrored)@readableStreamClose(_);_=@undefined}}})\n"; // handleDirectStreamError const JSC::ConstructAbility s_readableStreamInternalsHandleDirectStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1588,7 +1588,7 @@ const JSC::ConstructorKind s_readableStreamInternalsHandleDirectStreamErrorCodeC 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 (R){\"use strict\";var a=this,h=a.@sink;if(h){@putByIdDirectPrivate(a,\"sink\",@undefined);try{h.close(R)}catch(i){}}if(this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed,typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,R)}catch(i){}try{var _=a._pendingRead;if(_)a._pendingRead=@undefined,@rejectPromise(_,R)}catch(i){}var u=a.@controlledReadableStream;if(u)@readableStreamError(u,R)})\n"; +const char* const s_readableStreamInternalsHandleDirectStreamErrorCode = "(function (u){\"use strict\";var i=this,_=i.@sink;if(_){@putByIdDirectPrivate(i,\"sink\",@undefined);try{_.close(u)}catch(a){}}if(this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed,typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,u)}catch(a){}try{var h=i._pendingRead;if(h)i._pendingRead=@undefined,@rejectPromise(h,u)}catch(a){}var R=i.@controlledReadableStream;if(R)@readableStreamError(R,u)})\n"; // handleDirectStreamErrorReject const JSC::ConstructAbility s_readableStreamInternalsHandleDirectStreamErrorRejectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1602,9 +1602,9 @@ const char* const s_readableStreamInternalsHandleDirectStreamErrorRejectCode = " 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; +const int s_readableStreamInternalsOnPullDirectStreamCodeLength = 929; static const JSC::Intrinsic s_readableStreamInternalsOnPullDirectStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsOnPullDirectStreamCode = "(function (i){\"use strict\";var y=i.@controlledReadableStream;if(!y||@getByIdDirectPrivate(y,\"state\")!==@streamReadable)return;if(i._deferClose===-1)return;i._deferClose=-1,i._deferFlush=-1;var _,g;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(h){return @handleDirectStreamErrorReject.@call(i,h)}finally{_=i._deferClose,g=i._deferFlush,i._deferFlush=i._deferClose=0}var j;if(i._pendingRead===@undefined)i._pendingRead=j=@newPromise();else j=@readableStreamAddReadRequest(y);if(_===1){var k=i._deferCloseReason;return i._deferCloseReason=@undefined,@onCloseDirectStream.@call(i,k),j}if(g===1)@onFlushDirectStream.@call(i);return j})\n"; +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 g,h,S=_.@asyncContext;if(S){var j=@getInternalField(@asyncContext,0);@putInternalField(@asyncContext,0,S)}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(w){return @handleDirectStreamErrorReject.@call(i,w)}finally{if(g=i._deferClose,h=i._deferFlush,i._deferFlush=i._deferClose=0,S)@putInternalField(@asyncContext,0,j)}var k;if(i._pendingRead===@undefined)i._pendingRead=k=@newPromise();else k=@readableStreamAddReadRequest(_);if(g===1){var q=i._deferCloseReason;return i._deferCloseReason=@undefined,@onCloseDirectStream.@call(i,q),k}if(h===1)@onFlushDirectStream.@call(i);return k})\n"; // noopDoneFunction const JSC::ConstructAbility s_readableStreamInternalsNoopDoneFunctionCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1628,7 +1628,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnCloseDirectStreamCodeConst 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 (v){\"use strict\";var b=this.@controlledReadableStream;if(!b||@getByIdDirectPrivate(b,\"state\")!==@streamReadable)return;if(this._deferClose!==0){this._deferClose=1,this._deferCloseReason=v;return}if(@putByIdDirectPrivate(b,\"state\",@streamClosing),typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,v)}catch(j){}var y;try{y=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(j){if(this._pendingRead){var B=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(B,j)}@readableStreamError(b,j);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var C=@getByIdDirectPrivate(b,\"reader\");if(C&&@isReadableStreamDefaultReader(C)){var c=this._pendingRead;if(c&&@isPromise(c)&&y\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(c,{value:y,done:!1}),@readableStreamClose(b);return}}if(y\?.byteLength){var S=@getByIdDirectPrivate(C,\"readRequests\");if(S\?.isNotEmpty()){@readableStreamFulfillReadRequest(b,y,!1),@readableStreamClose(b);return}@putByIdDirectPrivate(b,\"state\",@streamReadable),this.@pull=()=>{var j=@createFulfilledPromise({value:y,done:!1});return y=@undefined,@readableStreamClose(b),b=@undefined,j}}else if(this._pendingRead){var B=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(B,{value:@undefined,done:!0})}@readableStreamClose(b)})\n"; +const char* const s_readableStreamInternalsOnCloseDirectStreamCode = "(function (S){\"use strict\";var c=this.@controlledReadableStream;if(!c||@getByIdDirectPrivate(c,\"state\")!==@streamReadable)return;if(this._deferClose!==0){this._deferClose=1,this._deferCloseReason=S;return}if(@putByIdDirectPrivate(c,\"state\",@streamClosing),typeof this.@underlyingSource.close===\"function\")try{this.@underlyingSource.close.@call(this.@underlyingSource,S)}catch(b){}var v;try{v=this.@sink.end(),@putByIdDirectPrivate(this,\"sink\",@undefined)}catch(b){if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@rejectPromise(y,b)}@readableStreamError(c,b);return}this.error=this.flush=this.write=this.close=this.end=@onReadableStreamDirectControllerClosed;var B=@getByIdDirectPrivate(c,\"reader\");if(B&&@isReadableStreamDefaultReader(B)){var C=this._pendingRead;if(C&&@isPromise(C)&&v\?.byteLength){this._pendingRead=@undefined,@fulfillPromise(C,{value:v,done:!1}),@readableStreamClose(c);return}}if(v\?.byteLength){var j=@getByIdDirectPrivate(B,\"readRequests\");if(j\?.isNotEmpty()){@readableStreamFulfillReadRequest(c,v,!1),@readableStreamClose(c);return}@putByIdDirectPrivate(c,\"state\",@streamReadable),this.@pull=()=>{var b=@createFulfilledPromise({value:v,done:!1});return v=@undefined,@readableStreamClose(c),c=@undefined,b}}else if(this._pendingRead){var y=this._pendingRead;this._pendingRead=@undefined,@putByIdDirectPrivate(this,\"pull\",@noopDoneFunction),@fulfillPromise(y,{value:@undefined,done:!0})}@readableStreamClose(c)})\n"; // onFlushDirectStream const JSC::ConstructAbility s_readableStreamInternalsOnFlushDirectStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1636,7 +1636,7 @@ const JSC::ConstructorKind s_readableStreamInternalsOnFlushDirectStreamCodeConst 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,i=@getByIdDirectPrivate(c,\"reader\");if(!i||!@isReadableStreamDefaultReader(i))return;var B=this._pendingRead;if(this._pendingRead=@undefined,B&&@isPromise(B)){var b=this.@sink.flush();if(b\?.byteLength)this._pendingRead=@getByIdDirectPrivate(c,\"readRequests\")\?.shift(),@fulfillPromise(B,{value:b,done:!1});else this._pendingRead=B}else if(@getByIdDirectPrivate(c,\"readRequests\")\?.isNotEmpty()){var b=this.@sink.flush();if(b\?.byteLength)@readableStreamFulfillReadRequest(c,b,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; +const char* const s_readableStreamInternalsOnFlushDirectStreamCode = "(function (){\"use strict\";var B=this.@controlledReadableStream,i=@getByIdDirectPrivate(B,\"reader\");if(!i||!@isReadableStreamDefaultReader(i))return;var b=this._pendingRead;if(this._pendingRead=@undefined,b&&@isPromise(b)){var c=this.@sink.flush();if(c\?.byteLength)this._pendingRead=@getByIdDirectPrivate(B,\"readRequests\")\?.shift(),@fulfillPromise(b,{value:c,done:!1});else this._pendingRead=b}else if(@getByIdDirectPrivate(B,\"readRequests\")\?.isNotEmpty()){var c=this.@sink.flush();if(c\?.byteLength)@readableStreamFulfillReadRequest(B,c,!1)}else if(this._deferFlush===-1)this._deferFlush=1})\n"; // createTextStream const JSC::ConstructAbility s_readableStreamInternalsCreateTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1644,7 +1644,7 @@ const JSC::ConstructorKind s_readableStreamInternalsCreateTextStreamCodeConstruc 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 (_){\"use strict\";var C,j=[],E=!1,q=!1,F=\"\",v=@toLength(0),G=@newPromiseCapability(@Promise),w=!1;return C={start(){},write(x){if(typeof x===\"string\"){var z=@toLength(x.length);if(z>0)F+=x,E=!0,v+=z;return z}if(!x||!(@ArrayBuffer.@isView(x)||x instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const A=@toLength(x.byteLength);if(A>0)if(q=!0,F.length>0)@arrayPush(j,F,x),F=\"\";else @arrayPush(j,x);return v+=A,A},flush(){return 0},end(){if(w)return\"\";return C.fulfill()},fulfill(){w=!0;const x=C.finishInternal();return @fulfillPromise(G.@promise,x),x},finishInternal(){if(!E&&!q)return\"\";if(E&&!q)return F;if(q&&!E)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(j));var x=new @Bun.ArrayBufferSink;x.start({highWaterMark:v,asUint8Array:!0});for(let z of j)x.write(z);if(j.length=0,F.length>0)x.write(F),F=\"\";return new globalThis.TextDecoder().decode(x.end())},close(){try{if(!w)w=!0,C.fulfill()}catch(x){}}},[C,G]})\n"; +const char* const s_readableStreamInternalsCreateTextStreamCode = "(function (G){\"use strict\";var q,v=[],x=!1,z=!1,j=\"\",C=@toLength(0),F=@newPromiseCapability(@Promise),A=!1;return q={start(){},write(_){if(typeof _===\"string\"){var w=@toLength(_.length);if(w>0)j+=_,x=!0,C+=w;return w}if(!_||!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@throwTypeError(\"Expected text, ArrayBuffer or ArrayBufferView\");const E=@toLength(_.byteLength);if(E>0)if(z=!0,j.length>0)@arrayPush(v,j,_),j=\"\";else @arrayPush(v,_);return C+=E,E},flush(){return 0},end(){if(A)return\"\";return q.fulfill()},fulfill(){A=!0;const _=q.finishInternal();return @fulfillPromise(F.@promise,_),_},finishInternal(){if(!x&&!z)return\"\";if(x&&!z)return j;if(z&&!x)return new globalThis.TextDecoder().decode(@Bun.concatArrayBuffers(v));var _=new @Bun.ArrayBufferSink;_.start({highWaterMark:C,asUint8Array:!0});for(let w of v)_.write(w);if(v.length=0,j.length>0)_.write(j),j=\"\";return new globalThis.TextDecoder().decode(_.end())},close(){try{if(!A)A=!0,q.fulfill()}catch(_){}}},[q,F]})\n"; // initializeTextStream const JSC::ConstructAbility s_readableStreamInternalsInitializeTextStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1652,7 +1652,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeTextStreamCodeCons 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 (_,m){\"use strict\";var[p,b]=@createTextStream(m),f={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:p,close:@onCloseDirectStream,write:p.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; +const char* const s_readableStreamInternalsInitializeTextStreamCode = "(function (m,p){\"use strict\";var[_,b]=@createTextStream(p),f={@underlyingSource:m,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:_,close:@onCloseDirectStream,write:_.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; // initializeArrayStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1660,7 +1660,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayStreamCodeCon 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 b=[],d=@newPromiseCapability(@Promise),j=!1;function p(){return j=!0,d.@resolve.@call(@undefined,b),b}var m={start(){},write(v){return @arrayPush(b,v),v.byteLength||v.length},flush(){return 0},end(){if(j)return[];return p()},close(){if(!j)p()}},q={@underlyingSource:t,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:m,close:@onCloseDirectStream,write:m.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",q),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),d})\n"; +const char* const s_readableStreamInternalsInitializeArrayStreamCode = "(function (m,v){\"use strict\";var _=[],b=@newPromiseCapability(@Promise),t=!1;function d(){return t=!0,b.@resolve.@call(@undefined,_),_}var j={start(){},write(p){return @arrayPush(_,p),p.byteLength||p.length},flush(){return 0},end(){if(t)return[];return d()},close(){if(!t)d()}},q={@underlyingSource:m,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:j,close:@onCloseDirectStream,write:j.write,error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};return @putByIdDirectPrivate(this,\"readableStreamController\",q),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined),b})\n"; // initializeArrayBufferStream const JSC::ConstructAbility s_readableStreamInternalsInitializeArrayBufferStreamCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1668,7 +1668,7 @@ const JSC::ConstructorKind s_readableStreamInternalsInitializeArrayBufferStreamC 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 (_,m){\"use strict\";var w=m&&typeof m===\"number\"\?{highWaterMark:m,stream:!0,asUint8Array:!0}:{stream:!0,asUint8Array:!0},D=new @Bun.ArrayBufferSink;D.start(w);var b={@underlyingSource:_,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:D,close:@onCloseDirectStream,write:D.write.bind(D),error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};@putByIdDirectPrivate(this,\"readableStreamController\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined)})\n"; +const char* const s_readableStreamInternalsInitializeArrayBufferStreamCode = "(function (w,m){\"use strict\";var D=m&&typeof m===\"number\"\?{highWaterMark:m,stream:!0,asUint8Array:!0}:{stream:!0,asUint8Array:!0},_=new @Bun.ArrayBufferSink;_.start(D);var b={@underlyingSource:w,@pull:@onPullDirectStream,@controlledReadableStream:this,@sink:_,close:@onCloseDirectStream,write:_.write.bind(_),error:@handleDirectStreamError,end:@onCloseDirectStream,@close:@onCloseDirectStream,flush:@onFlushDirectStream,_pendingRead:@undefined,_deferClose:0,_deferFlush:0,_deferCloseReason:@undefined,_handleError:@undefined};@putByIdDirectPrivate(this,\"readableStreamController\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"start\",@undefined)})\n"; // readableStreamError const JSC::ConstructAbility s_readableStreamInternalsReadableStreamErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1676,7 +1676,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamErrorCodeConst 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 (i,_){\"use strict\";@assert(@isReadableStream(i)),@assert(@getByIdDirectPrivate(i,\"state\")===@streamReadable),@putByIdDirectPrivate(i,\"state\",@streamErrored),@putByIdDirectPrivate(i,\"storedError\",_);const n=@getByIdDirectPrivate(i,\"reader\");if(!n)return;if(@isReadableStreamDefaultReader(n)){const h=@getByIdDirectPrivate(n,\"readRequests\");@putByIdDirectPrivate(n,\"readRequests\",@createFIFO());for(var f=h.shift();f;f=h.shift())@rejectPromise(f,_)}else{@assert(@isReadableStreamBYOBReader(n));const h=@getByIdDirectPrivate(n,\"readIntoRequests\");@putByIdDirectPrivate(n,\"readIntoRequests\",@createFIFO());for(var f=h.shift();f;f=h.shift())@rejectPromise(f,_)}@getByIdDirectPrivate(n,\"closedPromiseCapability\").@reject.@call(@undefined,_);const c=@getByIdDirectPrivate(n,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(c)})\n"; +const char* const s_readableStreamInternalsReadableStreamErrorCode = "(function (c,f){\"use strict\";@assert(@isReadableStream(c)),@assert(@getByIdDirectPrivate(c,\"state\")===@streamReadable),@putByIdDirectPrivate(c,\"state\",@streamErrored),@putByIdDirectPrivate(c,\"storedError\",f);const _=@getByIdDirectPrivate(c,\"reader\");if(!_)return;if(@isReadableStreamDefaultReader(_)){const n=@getByIdDirectPrivate(_,\"readRequests\");@putByIdDirectPrivate(_,\"readRequests\",@createFIFO());for(var i=n.shift();i;i=n.shift())@rejectPromise(i,f)}else{@assert(@isReadableStreamBYOBReader(_));const n=@getByIdDirectPrivate(_,\"readIntoRequests\");@putByIdDirectPrivate(_,\"readIntoRequests\",@createFIFO());for(var i=n.shift();i;i=n.shift())@rejectPromise(i,f)}@getByIdDirectPrivate(_,\"closedPromiseCapability\").@reject.@call(@undefined,f);const h=@getByIdDirectPrivate(_,\"closedPromiseCapability\").@promise;@markPromiseAsHandled(h)})\n"; // readableStreamDefaultControllerShouldCallPull const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1708,7 +1708,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl 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 (d){\"use strict\";const i=@getByIdDirectPrivate(d,\"controlledReadableStream\"),g=@getByIdDirectPrivate(i,\"state\");if(g===@streamErrored)return null;if(g===@streamClosed)return 0;return @getByIdDirectPrivate(d,\"strategy\").highWaterMark-@getByIdDirectPrivate(d,\"queue\").size})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerGetDesiredSizeCode = "(function (i){\"use strict\";const g=@getByIdDirectPrivate(i,\"controlledReadableStream\"),d=@getByIdDirectPrivate(g,\"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; @@ -1716,7 +1716,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamReaderGenericC 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,h){\"use strict\";const i=@getByIdDirectPrivate(c,\"ownerReadableStream\");return @assert(!!i),@readableStreamCancel(i,h)})\n"; +const char* const s_readableStreamInternalsReadableStreamReaderGenericCancelCode = "(function (h,i){\"use strict\";const c=@getByIdDirectPrivate(h,\"ownerReadableStream\");return @assert(!!c),@readableStreamCancel(c,i)})\n"; // readableStreamCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1724,7 +1724,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamCancelCodeCons 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 (i,p){\"use strict\";@putByIdDirectPrivate(i,\"disturbed\",!0);const u=@getByIdDirectPrivate(i,\"state\");if(u===@streamClosed)return @Promise.@resolve();if(u===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));@readableStreamClose(i);var h=@getByIdDirectPrivate(i,\"readableStreamController\"),_=h.@cancel;if(_)return _(h,p).@then(function(){});var d=h.close;if(d)return @Promise.@resolve(h.close(p));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; +const char* const s_readableStreamInternalsReadableStreamCancelCode = "(function (i,d){\"use strict\";@putByIdDirectPrivate(i,\"disturbed\",!0);const h=@getByIdDirectPrivate(i,\"state\");if(h===@streamClosed)return @Promise.@resolve();if(h===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));@readableStreamClose(i);var _=@getByIdDirectPrivate(i,\"readableStreamController\"),p=_.@cancel;if(p)return p(_,d).@then(function(){});var u=_.close;if(u)return @Promise.@resolve(_.close(d));@throwTypeError(\"ReadableStreamController has no cancel or close method\")})\n"; // readableStreamDefaultControllerCancel const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerCancelCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1764,7 +1764,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamFulfillReadReq 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 (y,_,i){\"use strict\";const p=@getByIdDirectPrivate(@getByIdDirectPrivate(y,\"reader\"),\"readRequests\").shift();@fulfillPromise(p,{value:_,done:i})})\n"; +const char* const s_readableStreamInternalsReadableStreamFulfillReadRequestCode = "(function (i,p,y){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(i,\"reader\"),\"readRequests\").shift();@fulfillPromise(_,{value:p,done:y})})\n"; // readableStreamDefaultControllerEnqueue const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1772,7 +1772,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultControl 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 (_,d){\"use strict\";const D=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(D)&&@getByIdDirectPrivate(@getByIdDirectPrivate(D,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(D,d,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let E=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)E=@getByIdDirectPrivate(_,\"strategy\").size(d);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),d,E)}catch(E){throw @readableStreamDefaultControllerError(_,E),E}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultControllerEnqueueCode = "(function (_,D){\"use strict\";const E=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamDefaultControllerCanCloseOrEnqueue(_)),@isReadableStreamLocked(E)&&@getByIdDirectPrivate(@getByIdDirectPrivate(E,\"reader\"),\"readRequests\")\?.isNotEmpty()){@readableStreamFulfillReadRequest(E,D,!1),@readableStreamDefaultControllerCallPullIfNeeded(_);return}try{let d=1;if(@getByIdDirectPrivate(_,\"strategy\").size!==@undefined)d=@getByIdDirectPrivate(_,\"strategy\").size(D);@enqueueValueWithSize(@getByIdDirectPrivate(_,\"queue\"),D,d)}catch(d){throw @readableStreamDefaultControllerError(_,d),d}@readableStreamDefaultControllerCallPullIfNeeded(_)})\n"; // readableStreamDefaultReaderRead const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1780,7 +1780,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefaultReaderR 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 n=@getByIdDirectPrivate(i,\"ownerReadableStream\");@assert(!!n);const y=@getByIdDirectPrivate(n,\"state\");if(@putByIdDirectPrivate(n,\"disturbed\",!0),y===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(y===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(n,\"storedError\"));return @assert(y===@streamReadable),@getByIdDirectPrivate(n,\"readableStreamController\").@pull(@getByIdDirectPrivate(n,\"readableStreamController\"))})\n"; +const char* const s_readableStreamInternalsReadableStreamDefaultReaderReadCode = "(function (y){\"use strict\";const i=@getByIdDirectPrivate(y,\"ownerReadableStream\");@assert(!!i);const n=@getByIdDirectPrivate(i,\"state\");if(@putByIdDirectPrivate(i,\"disturbed\",!0),n===@streamClosed)return @createFulfilledPromise({value:@undefined,done:!0});if(n===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(i,\"storedError\"));return @assert(n===@streamReadable),@getByIdDirectPrivate(i,\"readableStreamController\").@pull(@getByIdDirectPrivate(i,\"readableStreamController\"))})\n"; // readableStreamAddReadRequest const JSC::ConstructAbility s_readableStreamInternalsReadableStreamAddReadRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1820,7 +1820,7 @@ const JSC::ConstructorKind s_readableStreamInternalsLazyLoadStreamCodeConstructo 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 (U,j){\"use strict\";var N=@getByIdDirectPrivate(U,\"bunNativeType\"),m=@getByIdDirectPrivate(U,\"bunNativePtr\"),q=@lazyStreamPrototypeMap.@get(N);if(q===@undefined){let J=function(Z){var{c:_,v:p}=this;this.c=@undefined,this.v=@undefined,X(Z,_,p)},K=function(Z){try{Z.close()}catch(_){globalThis.reportError(_)}},L=function(Z,_,p,Q){Q[0]=!1;var z;try{z=W(Z,p,Q)}catch(A){return _.error(A)}return X(z,_,p)};var I=J,P=K,H=L,[W,x,y,B,D,b,E]=@lazyLoad(N),O=[!1],X;X=function Z(_,p,Q){if(_&&@isPromise(_))return _.then(J.bind({c:p,v:Q}),(z)=>p.error(z));else if(typeof _===\"number\")if(Q&&Q.byteLength===_&&Q.buffer===p.byobRequest\?.view\?.buffer)p.byobRequest.respondWithNewView(Q);else p.byobRequest.respond(_);else if(_.constructor===@Uint8Array)p.enqueue(_);if(O[0]||_===!1)@enqueueJob(K,p),O[0]=!1};const M=D\?new FinalizationRegistry(D):null;q=class Z{constructor(_,p,Q){if(this.#f=_,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=p,Q!==@undefined)this.start=(z)=>{z.enqueue(Q)};if(M)M.register(this,_,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=x;#j(_){var p=this.#f;if(!p){_.close();return}L(p,_,_.byobRequest.view,O)}#m(_){var p=this.#f;M&&M.unregister(this.#b),b&&b(p,!1),y(p,_)}static deinit=D;static drain=E},@lazyStreamPrototypeMap.@set(N,q)}const Y=q.startSync(m,j);var f;const{drain:F,deinit:G}=q;if(F)f=F(m);if(Y===0){if(D&&m&&@enqueueJob(D,m),(f\?.byteLength\?\?0)>0)return{start(J){J.enqueue(f),J.close()},type:\"bytes\"};return{start(J){J.close()},type:\"bytes\"}}return new q(m,Y,f)})\n"; +const char* const s_readableStreamInternalsLazyLoadStreamCode = "(function (J,P){\"use strict\";var G=@getByIdDirectPrivate(J,\"bunNativeType\"),B=@getByIdDirectPrivate(J,\"bunNativePtr\"),x=@lazyStreamPrototypeMap.@get(G);if(x===@undefined){let q=function(m){var{c:b,v:f}=this;this.c=@undefined,this.v=@undefined,I(m,b,f)},N=function(m){try{m.close()}catch(b){globalThis.reportError(b)}},O=function(m,b,f,j){j[0]=!1;var y;try{y=Q(m,f,j)}catch(Y){return b.error(Y)}return I(y,b,f)};var z=q,A=N,p=O,[Q,U,W,Z,D,K,X]=@lazyLoad(G),H=[!1],I;I=function m(b,f,j){if(b&&@isPromise(b))return b.then(q.bind({c:f,v:j}),(y)=>f.error(y));else if(typeof b===\"number\")if(j&&j.byteLength===b&&j.buffer===f.byobRequest\?.view\?.buffer)f.byobRequest.respondWithNewView(j);else f.byobRequest.respond(b);else if(b.constructor===@Uint8Array)f.enqueue(b);if(H[0]||b===!1)@enqueueJob(N,f),H[0]=!1};const F=D\?new FinalizationRegistry(D):null;x=class m{constructor(b,f,j){if(this.#f=b,this.#b={},this.pull=this.#j.bind(this),this.cancel=this.#m.bind(this),this.autoAllocateChunkSize=f,j!==@undefined)this.start=(y)=>{y.enqueue(j)};if(F)F.register(this,b,this.#b)}#b;pull;cancel;start;#f;type=\"bytes\";autoAllocateChunkSize=0;static startSync=U;#j(b){var f=this.#f;if(!f){b.close();return}O(f,b,b.byobRequest.view,H)}#m(b){var f=this.#f;F&&F.unregister(this.#b),K&&K(f,!1),W(f,b)}static deinit=D;static drain=X},@lazyStreamPrototypeMap.@set(G,x)}const L=x.startSync(B,P);var E;const{drain:M,deinit:_}=x;if(M)E=M(B);if(L===0){if(D&&B&&@enqueueJob(D,B),(E\?.byteLength\?\?0)>0)return{start(q){q.enqueue(E),q.close()},type:\"bytes\"};return{start(q){q.close()},type:\"bytes\"}}return new x(B,L,E)})\n"; // readableStreamIntoArray const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1828,7 +1828,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoArrayCodeC 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 (f){\"use strict\";var g=f.getReader(),j=g.readMany();async function p(q){if(q.done)return[];var _=q.value||[];while(!0){var b=await g.read();if(b.done)break;_=_.concat(b.value)}return _}if(j&&@isPromise(j))return j.@then(p);return p(j)})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoArrayCode = "(function (q){\"use strict\";var b=q.getReader(),f=b.readMany();async function g(j){if(j.done)return[];var _=j.value||[];while(!0){var p=await b.read();if(p.done)break;_=_.concat(p.value)}return _}if(f&&@isPromise(f))return f.@then(g);return g(f)})\n"; // readableStreamIntoText const JSC::ConstructAbility s_readableStreamInternalsReadableStreamIntoTextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1836,7 +1836,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamIntoTextCodeCo 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 (i){\"use strict\";const[_,d]=@createTextStream(@getByIdDirectPrivate(i,\"highWaterMark\")),h=@readStreamIntoSink(i,_,!1);if(h&&@isPromise(h))return @Promise.@resolve(h).@then(d.@promise);return d.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamIntoTextCode = "(function (_){\"use strict\";const[h,d]=@createTextStream(@getByIdDirectPrivate(_,\"highWaterMark\")),i=@readStreamIntoSink(_,h,!1);if(i&&@isPromise(i))return @Promise.@resolve(i).@then(d.@promise);return d.@promise})\n"; // readableStreamToArrayBufferDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayBufferDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1844,7 +1844,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayBufferD 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 (_,A){\"use strict\";var O=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(_,\"underlyingSource\",@undefined);var j=@getByIdDirectPrivate(_,\"highWaterMark\");O.start(j\?{highWaterMark:j}:{});var x=@newPromiseCapability(@Promise),z=!1,B=A.pull,C=A.close,D={start(){},close(F){if(!z){if(z=!0,C)C();@fulfillPromise(x.@promise,O.end())}},end(){if(!z){if(z=!0,C)C();@fulfillPromise(x.@promise,O.end())}},flush(){return 0},write:O.write.bind(O)},q=!1;try{const F=B(D);if(F&&@isObject(F)&&@isPromise(F))return async function(G,v,w){while(!z)await w(G);return await v}(D,promise,B);return x.@promise}catch(F){return q=!0,@readableStreamError(_,F),@Promise.@reject(F)}finally{if(!q&&_)@readableStreamClose(_);D=C=O=B=_=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayBufferDirectCode = "(function (O,A){\"use strict\";var j=new @Bun.ArrayBufferSink;@putByIdDirectPrivate(O,\"underlyingSource\",@undefined);var B=@getByIdDirectPrivate(O,\"highWaterMark\");j.start(B\?{highWaterMark:B}:{});var w=@newPromiseCapability(@Promise),q=!1,x=A.pull,v=A.close,z={start(){},close(_){if(!q){if(q=!0,v)v();@fulfillPromise(w.@promise,j.end())}},end(){if(!q){if(q=!0,v)v();@fulfillPromise(w.@promise,j.end())}},flush(){return 0},write:j.write.bind(j)},C=!1;try{const _=x(z);if(_&&@isObject(_)&&@isPromise(_))return async function(D,F,G){while(!q)await G(D);return await F}(z,promise,x);return w.@promise}catch(_){return C=!0,@readableStreamError(O,_),@Promise.@reject(_)}finally{if(!C&&O)@readableStreamClose(O);z=v=j=x=O=@undefined}})\n"; // readableStreamToTextDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToTextDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1852,7 +1852,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToTextDirectCo 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 (_,j){\"use strict\";const p=@initializeTextStream.@call(_,j,@undefined);var h=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var f=await h.read();if(f.done)break}try{h.releaseLock()}catch(k){}return h=@undefined,_=@undefined,p.@promise})\n"; +const char* const s_readableStreamInternalsReadableStreamToTextDirectCode = "(async function (_,h){\"use strict\";const j=@initializeTextStream.@call(_,h,@undefined);var f=_.getReader();while(@getByIdDirectPrivate(_,\"state\")===@streamReadable){var k=await f.read();if(k.done)break}try{f.releaseLock()}catch(p){}return f=@undefined,_=@undefined,j.@promise})\n"; // readableStreamToArrayDirect const JSC::ConstructAbility s_readableStreamInternalsReadableStreamToArrayDirectCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1860,7 +1860,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamToArrayDirectC const JSC::ImplementationVisibility s_readableStreamInternalsReadableStreamToArrayDirectCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamInternalsReadableStreamToArrayDirectCodeLength = 354; static const JSC::Intrinsic s_readableStreamInternalsReadableStreamToArrayDirectCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (f,k){\"use strict\";const p=@initializeArrayStream.@call(f,k,@undefined);k=@undefined;var j=f.getReader();try{while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var _=await j.read();if(_.done)break}try{j.releaseLock()}catch(q){}return j=@undefined,@Promise.@resolve(p.@promise)}catch(q){throw q}finally{f=@undefined,j=@undefined}})\n"; +const char* const s_readableStreamInternalsReadableStreamToArrayDirectCode = "(async function (f,j){\"use strict\";const p=@initializeArrayStream.@call(f,j,@undefined);j=@undefined;var _=f.getReader();try{while(@getByIdDirectPrivate(f,\"state\")===@streamReadable){var q=await _.read();if(q.done)break}try{_.releaseLock()}catch(k){}return _=@undefined,@Promise.@resolve(p.@promise)}catch(k){throw k}finally{f=@undefined,_=@undefined}})\n"; // readableStreamDefineLazyIterators const JSC::ConstructAbility s_readableStreamInternalsReadableStreamDefineLazyIteratorsCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1868,7 +1868,7 @@ const JSC::ConstructorKind s_readableStreamInternalsReadableStreamDefineLazyIter 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 (h){\"use strict\";var x=globalThis.Symbol.asyncIterator,z=async function*i(B,D){var j=B.getReader(),q;try{while(!0){var w,F;const G=j.readMany();if(@isPromise(G))({done:w,value:F}=await G);else({done:w,value:F}=G);if(w)return;yield*F}}catch(G){q=G}finally{if(j.releaseLock(),!D)B.cancel(q);if(q)throw q}},k=function i(){return z(this,!1)},g=function i({preventCancel:B=!1}={preventCancel:!1}){return z(this,B)};return @Object.@defineProperty(h,x,{value:k}),@Object.@defineProperty(h,\"values\",{value:g}),h})\n"; +const char* const s_readableStreamInternalsReadableStreamDefineLazyIteratorsCode = "(function (i){\"use strict\";var B=globalThis.Symbol.asyncIterator,w=async function*x(k,G){var z=k.getReader(),g;try{while(!0){var j,q;const h=z.readMany();if(@isPromise(h))({done:j,value:q}=await h);else({done:j,value:q}=h);if(j)return;yield*q}}catch(h){g=h}finally{if(z.releaseLock(),!G)k.cancel(g);if(g)throw g}},D=function x(){return w(this,!1)},F=function x({preventCancel:k=!1}={preventCancel:!1}){return w(this,k)};return @Object.@defineProperty(i,B,{value:D}),@Object.@defineProperty(i,\"values\",{value:F}),i})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -1894,7 +1894,7 @@ const JSC::ConstructorKind s_transformStreamDefaultControllerDesiredSizeCodeCons 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 _=@getByIdDirectPrivate(this,\"stream\"),i=@getByIdDirectPrivate(_,\"readable\"),u=@getByIdDirectPrivate(i,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(u)})\n"; +const char* const s_transformStreamDefaultControllerDesiredSizeCode = "(function (){\"use strict\";if(!@isTransformStreamDefaultController(this))throw @makeThisTypeError(\"TransformStreamDefaultController\",\"enqueue\");const _=@getByIdDirectPrivate(this,\"stream\"),u=@getByIdDirectPrivate(_,\"readable\"),i=@getByIdDirectPrivate(u,\"readableStreamController\");return @readableStreamDefaultControllerGetDesiredSize(i)})\n"; // enqueue const JSC::ConstructAbility s_transformStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1929,6 +1929,32 @@ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) #undef DEFINE_BUILTIN_GENERATOR +/* AsyncContext.ts */ +// getAsyncContext +const JSC::ConstructAbility s_asyncContextGetAsyncContextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_asyncContextGetAsyncContextCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_asyncContextGetAsyncContextCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_asyncContextGetAsyncContextCodeLength = 70; +static const JSC::Intrinsic s_asyncContextGetAsyncContextCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_asyncContextGetAsyncContextCode = "(function (){\"use strict\";return @getInternalField(@asyncContext,0)})\n"; + +// setAsyncContext +const JSC::ConstructAbility s_asyncContextSetAsyncContextCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; +const JSC::ConstructorKind s_asyncContextSetAsyncContextCodeConstructorKind = JSC::ConstructorKind::None; +const JSC::ImplementationVisibility s_asyncContextSetAsyncContextCodeImplementationVisibility = JSC::ImplementationVisibility::Public; +const int s_asyncContextSetAsyncContextCodeLength = 73; +static const JSC::Intrinsic s_asyncContextSetAsyncContextCodeIntrinsic = JSC::NoIntrinsic; +const char* const s_asyncContextSetAsyncContextCode = "(function (r){\"use strict\";return @putInternalField(@asyncContext,0,r)})\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().asyncContextBuiltins().codeName##Executable()->link(vm, nullptr, clientData->builtinFunctions().asyncContextBuiltins().codeName##Source(), std::nullopt, s_##codeName##Intrinsic); \ +} +WEBCORE_FOREACH_ASYNCCONTEXT_BUILTIN_CODE(DEFINE_BUILTIN_GENERATOR) +#undef DEFINE_BUILTIN_GENERATOR + /* ReadableStreamBYOBReader.ts */ // initializeReadableStreamBYOBReader const JSC::ConstructAbility s_readableStreamBYOBReaderInitializeReadableStreamBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -1986,7 +2012,7 @@ const JSC::ConstructorKind s_jsBufferConstructorFromCodeConstructorKind = JSC::C 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 (d){\"use strict\";if(@isUndefinedOrNull(d))@throwTypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.\");if(typeof d===\"string\"||typeof d===\"object\"&&(@isTypedArrayView(d)||d instanceof @ArrayBuffer||d instanceof SharedArrayBuffer||d instanceof String))switch(@argumentCount()){case 1:return new @Buffer(d);case 2:return new @Buffer(d,@argument(1));default:return new @Buffer(d,@argument(1),@argument(2))}var f=@toObject(d,\"The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object.\");if(!@isJSArray(f)){const u=@tryGetByIdWithWellKnownSymbol(d,\"toPrimitive\");if(u){const n=u.@call(d,\"string\");if(typeof n===\"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))}}if(!(\"length\"in f)||@isCallable(f))@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(f).buffer)})\n"; +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 d=@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(d)){const u=@tryGetByIdWithWellKnownSymbol(n,\"toPrimitive\");if(u){const f=u.@call(n,\"string\");if(typeof f===\"string\")switch(@argumentCount()){case 1:return new @Buffer(f);case 2:return new @Buffer(f,@argument(1));default:return new @Buffer(f,@argument(1),@argument(2))}}if(!(\"length\"in d)||@isCallable(d))@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(d).buffer)})\n"; // isBuffer const JSC::ConstructAbility s_jsBufferConstructorIsBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2028,7 +2054,7 @@ const JSC::ConstructorKind s_readableStreamDefaultReaderReadManyCodeConstructorK 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 Q=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!Q)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const k=@getByIdDirectPrivate(Q,\"state\");if(@putByIdDirectPrivate(Q,\"disturbed\",!0),k===@streamClosed)return{value:[],size:0,done:!0};else if(k===@streamErrored)throw @getByIdDirectPrivate(Q,\"storedError\");var F=@getByIdDirectPrivate(Q,\"readableStreamController\"),x=@getByIdDirectPrivate(F,\"queue\");if(!x)return F.@pull(F).@then(function({done:J,value:_}){return J\?{done:!0,value:[],size:0}:{value:[_],size:1,done:!1}});const C=x.content;var A=x.size,S=C.toArray(!1),D=S.length;if(D>0){var H=@newArrayWithSize(D);if(@isReadableByteStreamController(F)){{const J=S[0];if(!(@ArrayBuffer.@isView(J)||J instanceof @ArrayBuffer))@putByValDirect(H,0,new @Uint8Array(J.buffer,J.byteOffset,J.byteLength));else @putByValDirect(H,0,J)}for(var I=1;I<D;I++){const J=S[I];if(!(@ArrayBuffer.@isView(J)||J instanceof @ArrayBuffer))@putByValDirect(H,I,new @Uint8Array(J.buffer,J.byteOffset,J.byteLength));else @putByValDirect(H,I,J)}}else{@putByValDirect(H,0,S[0].value);for(var I=1;I<D;I++)@putByValDirect(H,I,S[I].value)}if(@resetQueue(@getByIdDirectPrivate(F,\"queue\")),@getByIdDirectPrivate(F,\"closeRequested\"))@readableStreamClose(@getByIdDirectPrivate(F,\"controlledReadableStream\"));else if(@isReadableStreamDefaultController(F))@readableStreamDefaultControllerCallPullIfNeeded(F);else if(@isReadableByteStreamController(F))@readableByteStreamControllerCallPullIfNeeded(F);return{value:H,size:A,done:!1}}var T=(J)=>{if(J.done)return{value:[],size:0,done:!0};var _=@getByIdDirectPrivate(Q,\"readableStreamController\"),E=@getByIdDirectPrivate(_,\"queue\"),K=[J.value].concat(E.content.toArray(!1)),j=K.length;if(@isReadableByteStreamController(_))for(var G=0;G<j;G++){const B=K[G];if(!(@ArrayBuffer.@isView(B)||B instanceof @ArrayBuffer)){const{buffer:N,byteOffset:d,byteLength:W}=B;@putByValDirect(K,G,new @Uint8Array(N,d,W))}}else for(var G=1;G<j;G++)@putByValDirect(K,G,K[G].value);var w=E.size;if(@resetQueue(E),@getByIdDirectPrivate(_,\"closeRequested\"))@readableStreamClose(@getByIdDirectPrivate(_,\"controlledReadableStream\"));else if(@isReadableStreamDefaultController(_))@readableStreamDefaultControllerCallPullIfNeeded(_);else if(@isReadableByteStreamController(_))@readableByteStreamControllerCallPullIfNeeded(_);return{value:K,size:w,done:!1}},U=F.@pull(F);if(U&&@isPromise(U))return U.@then(T);return T(U)})\n"; +const char* const s_readableStreamDefaultReaderReadManyCode = "(function (){\"use strict\";if(!@isReadableStreamDefaultReader(this))@throwTypeError(\"ReadableStreamDefaultReader.readMany() should not be called directly\");const j=@getByIdDirectPrivate(this,\"ownerReadableStream\");if(!j)@throwTypeError(\"readMany() called on a reader owned by no readable stream\");const I=@getByIdDirectPrivate(j,\"state\");if(@putByIdDirectPrivate(j,\"disturbed\",!0),I===@streamClosed)return{value:[],size:0,done:!0};else if(I===@streamErrored)throw @getByIdDirectPrivate(j,\"storedError\");var B=@getByIdDirectPrivate(j,\"readableStreamController\"),F=@getByIdDirectPrivate(B,\"queue\");if(!F)return B.@pull(B).@then(function({done:_,value:w}){return _\?{done:!0,value:[],size:0}:{value:[w],size:1,done:!1}});const N=F.content;var Q=F.size,x=N.toArray(!1),C=x.length;if(C>0){var D=@newArrayWithSize(C);if(@isReadableByteStreamController(B)){{const _=x[0];if(!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@putByValDirect(D,0,new @Uint8Array(_.buffer,_.byteOffset,_.byteLength));else @putByValDirect(D,0,_)}for(var d=1;d<C;d++){const _=x[d];if(!(@ArrayBuffer.@isView(_)||_ instanceof @ArrayBuffer))@putByValDirect(D,d,new @Uint8Array(_.buffer,_.byteOffset,_.byteLength));else @putByValDirect(D,d,_)}}else{@putByValDirect(D,0,x[0].value);for(var d=1;d<C;d++)@putByValDirect(D,d,x[d].value)}if(@resetQueue(@getByIdDirectPrivate(B,\"queue\")),@getByIdDirectPrivate(B,\"closeRequested\"))@readableStreamClose(@getByIdDirectPrivate(B,\"controlledReadableStream\"));else if(@isReadableStreamDefaultController(B))@readableStreamDefaultControllerCallPullIfNeeded(B);else if(@isReadableByteStreamController(B))@readableByteStreamControllerCallPullIfNeeded(B);return{value:D,size:Q,done:!1}}var J=(_)=>{if(_.done)return{value:[],size:0,done:!0};var w=@getByIdDirectPrivate(j,\"readableStreamController\"),G=@getByIdDirectPrivate(w,\"queue\"),k=[_.value].concat(G.content.toArray(!1)),K=k.length;if(@isReadableByteStreamController(w))for(var A=0;A<K;A++){const H=k[A];if(!(@ArrayBuffer.@isView(H)||H instanceof @ArrayBuffer)){const{buffer:T,byteOffset:U,byteLength:W}=H;@putByValDirect(k,A,new @Uint8Array(T,U,W))}}else for(var A=1;A<K;A++)@putByValDirect(k,A,k[A].value);var S=G.size;if(@resetQueue(G),@getByIdDirectPrivate(w,\"closeRequested\"))@readableStreamClose(@getByIdDirectPrivate(w,\"controlledReadableStream\"));else if(@isReadableStreamDefaultController(w))@readableStreamDefaultControllerCallPullIfNeeded(w);else if(@isReadableByteStreamController(w))@readableByteStreamControllerCallPullIfNeeded(w);return{value:k,size:S,done:!1}},E=B.@pull(B);if(E&&@isPromise(E))return E.@then(J);return J(E)})\n"; // read const JSC::ConstructAbility s_readableStreamDefaultReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2086,7 +2112,7 @@ const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCode 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 (i,n,l){\"use strict\";if(n===@undefined)return @Promise.@resolve();return @shieldingPromiseResolve(n.@apply(i,l))})\n"; +const char* const s_streamInternalsPromiseInvokeOrNoopMethodNoCatchCode = "(function (l,i,n){\"use strict\";if(i===@undefined)return @Promise.@resolve();return @shieldingPromiseResolve(i.@apply(l,n))})\n"; // promiseInvokeOrNoopNoCatch const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2094,7 +2120,7 @@ const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopNoCatchCodeConstr 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,n,l){\"use strict\";return @promiseInvokeOrNoopMethodNoCatch(d,d[n],l)})\n"; +const char* const s_streamInternalsPromiseInvokeOrNoopNoCatchCode = "(function (d,l,n){\"use strict\";return @promiseInvokeOrNoopMethodNoCatch(d,d[l],n)})\n"; // promiseInvokeOrNoopMethod const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrNoopMethodCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2110,7 +2136,7 @@ const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrNoopCodeConstructorKi 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 (l,m,d){\"use strict\";try{return @promiseInvokeOrNoopNoCatch(l,m,d)}catch(n){return @Promise.@reject(n)}})\n"; +const char* const s_streamInternalsPromiseInvokeOrNoopCode = "(function (n,d,l){\"use strict\";try{return @promiseInvokeOrNoopNoCatch(n,d,l)}catch(m){return @Promise.@reject(m)}})\n"; // promiseInvokeOrFallbackOrNoop const JSC::ConstructAbility s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2118,7 +2144,7 @@ const JSC::ConstructorKind s_streamInternalsPromiseInvokeOrFallbackOrNoopCodeCon 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 (n,p,_,l,v){\"use strict\";try{const u=n[p];if(u===@undefined)return @promiseInvokeOrNoopNoCatch(n,l,v);return @shieldingPromiseResolve(u.@apply(n,_))}catch(u){return @Promise.@reject(u)}})\n"; +const char* const s_streamInternalsPromiseInvokeOrFallbackOrNoopCode = "(function (_,l,p,u,v){\"use strict\";try{const n=_[l];if(n===@undefined)return @promiseInvokeOrNoopNoCatch(_,u,v);return @shieldingPromiseResolve(n.@apply(_,p))}catch(n){return @Promise.@reject(n)}})\n"; // validateAndNormalizeQueuingStrategy const JSC::ConstructAbility s_streamInternalsValidateAndNormalizeQueuingStrategyCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2126,7 +2152,7 @@ const JSC::ConstructorKind s_streamInternalsValidateAndNormalizeQueuingStrategyC 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,f){\"use strict\";if(d!==@undefined&&typeof d!==\"function\")@throwTypeError(\"size parameter must be a function\");const l=@toNumber(f);if(@isNaN(l)||l<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return{size:d,highWaterMark:l}})\n"; +const char* const s_streamInternalsValidateAndNormalizeQueuingStrategyCode = "(function (d,l){\"use strict\";if(d!==@undefined&&typeof d!==\"function\")@throwTypeError(\"size parameter must be a function\");const f=@toNumber(l);if(@isNaN(f)||f<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return{size:d,highWaterMark:f}})\n"; // createFIFO const JSC::ConstructAbility s_streamInternalsCreateFIFOCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2134,7 +2160,7 @@ const JSC::ConstructorKind s_streamInternalsCreateFIFOCodeConstructorKind = JSC: const JSC::ImplementationVisibility s_streamInternalsCreateFIFOCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_streamInternalsCreateFIFOCodeLength = 1473; static const JSC::Intrinsic s_streamInternalsCreateFIFOCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var g=@Array.prototype.slice;class M{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:w,_tail:z,_list:B,_capacityMask:E}=this;if(w===z)return @undefined;var b=B[w];if(@putByValDirect(B,w,@undefined),w=this._head=w+1&E,w<2&&z>1e4&&z<=B.length>>>2)this._shrinkArray();return b}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(w){var z=this._tail;if(@putByValDirect(this._list,z,w),this._tail=z+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(w){var z=this._list,B=@toLength(z.length);if(w||this._head>this._tail){var E=@toLength(this._head),b=@toLength(this._tail),F=@toLength(B-E+b),G=@newArrayWithSize(F),v=0;for(var A=E;A<B;A++)@putByValDirect(G,v++,z[A]);for(var A=0;A<b;A++)@putByValDirect(G,v++,z[A]);return G}else return g.@call(z,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 M})\n"; +const char* const s_streamInternalsCreateFIFOCode = "(function (){\"use strict\";var E=@Array.prototype.slice;class A{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:g,_tail:b,_list:x,_capacityMask:M}=this;if(g===b)return @undefined;var w=x[g];if(@putByValDirect(x,g,@undefined),g=this._head=g+1&M,g<2&&b>1e4&&b<=x.length>>>2)this._shrinkArray();return w}peek(){if(this._head===this._tail)return @undefined;return this._list[this._head]}push(g){var b=this._tail;if(@putByValDirect(this._list,b,g),this._tail=b+1&this._capacityMask,this._tail===this._head)this._growArray()}toArray(g){var b=this._list,x=@toLength(b.length);if(g||this._head>this._tail){var M=@toLength(this._head),w=@toLength(this._tail),F=@toLength(x-M+w),z=@newArrayWithSize(F),B=0;for(var v=M;v<x;v++)@putByValDirect(z,B++,b[v]);for(var v=0;v<w;v++)@putByValDirect(z,B++,b[v]);return z}else return E.@call(b,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 A})\n"; // newQueue const JSC::ConstructAbility s_streamInternalsNewQueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2158,7 +2184,7 @@ const JSC::ConstructorKind s_streamInternalsEnqueueValueWithSizeCodeConstructorK 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 (n,d,o){\"use strict\";if(o=@toNumber(o),!@isFinite(o)||o<0)@throwRangeError(\"size has an incorrect value\");n.content.push({value:d,size:o}),n.size+=o})\n"; +const char* const s_streamInternalsEnqueueValueWithSizeCode = "(function (d,o,n){\"use strict\";if(n=@toNumber(n),!@isFinite(n)||n<0)@throwRangeError(\"size has an incorrect value\");d.content.push({value:o,size:n}),d.size+=n})\n"; // peekQueueValue const JSC::ConstructAbility s_streamInternalsPeekQueueValueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2182,7 +2208,7 @@ const JSC::ConstructorKind s_streamInternalsExtractSizeAlgorithmCodeConstructorK 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(w)=>{return p(w)}})\n"; +const char* const s_streamInternalsExtractSizeAlgorithmCode = "(function (p){\"use strict\";const d=p.size;if(d===@undefined)return()=>1;if(typeof d!==\"function\")@throwTypeError(\"strategy.size must be a function\");return(w)=>{return d(w)}})\n"; // extractHighWaterMark const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2190,7 +2216,7 @@ const JSC::ConstructorKind s_streamInternalsExtractHighWaterMarkCodeConstructorK 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 (o,b){\"use strict\";const c=o.highWaterMark;if(c===@undefined)return b;if(@isNaN(c)||c<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return @toNumber(c)})\n"; +const char* const s_streamInternalsExtractHighWaterMarkCode = "(function (b,c){\"use strict\";const o=b.highWaterMark;if(o===@undefined)return c;if(@isNaN(o)||o<0)@throwRangeError(\"highWaterMark value is negative or not a number\");return @toNumber(o)})\n"; // extractHighWaterMarkFromQueuingStrategyInit const JSC::ConstructAbility s_streamInternalsExtractHighWaterMarkFromQueuingStrategyInitCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2206,7 +2232,7 @@ const JSC::ConstructorKind s_streamInternalsCreateFulfilledPromiseCodeConstructo 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 (d){\"use strict\";const n=@newPromise();return @fulfillPromise(n,d),n})\n"; +const char* const s_streamInternalsCreateFulfilledPromiseCode = "(function (n){\"use strict\";const d=@newPromise();return @fulfillPromise(d,n),d})\n"; // toDictionary const JSC::ConstructAbility s_streamInternalsToDictionaryCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2214,7 +2240,7 @@ const JSC::ConstructorKind s_streamInternalsToDictionaryCodeConstructorKind = JS 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 (c,p,n){\"use strict\";if(c===@undefined||c===null)return p;if(!@isObject(c))@throwTypeError(n);return c})\n"; +const char* const s_streamInternalsToDictionaryCode = "(function (c,n,p){\"use strict\";if(c===@undefined||c===null)return n;if(!@isObject(c))@throwTypeError(p);return c})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2232,7 +2258,7 @@ const JSC::ConstructorKind s_importMetaObjectLoadCJS2ESMCodeConstructorKind = JS const JSC::ImplementationVisibility s_importMetaObjectLoadCJS2ESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectLoadCJS2ESMCodeLength = 1387; static const JSC::Intrinsic s_importMetaObjectLoadCJS2ESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (J){\"use strict\";var Q=@Loader,T=@createFIFO(),H=J;while(H){var x=Q.registry.@get(H);if((x\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(H),x=Q.registry.@get(H);var z=@getPromiseInternalField(x.fetch,@promiseFieldReactionsOrResult),_=Q.parseModule(H,z),I=x.module;if(_&&@isPromise(_)){var B=@getPromiseInternalField(_,@promiseFieldReactionsOrResult),U=@getPromiseInternalField(_,@promiseFieldFlags),F=U&@promiseStateMask;if(F===@promiseStatePending||B&&@isPromise(B))@throwTypeError(`require() async module \"${H}\" is unsupported. use \"await import()\" instead.`);else if(F===@promiseStateRejected){if(!B\?.message)@throwTypeError(`${B+\"\"\?B:\"An error occurred\"} occurred while parsing module \\\"${H}\\\"`);throw B}x.module=I=B}else if(_&&!I)x.module=I=_;@setStateToMax(x,@ModuleLink);var V=I.dependenciesMap,w=Q.requestedModules(I),L=@newArrayWithSize(w.length);for(var D=0,W=w.length;D<W;++D){var X=w[D],G=X[0]===\"/\"\?X:Q.resolve(X,H),Y=Q.ensureRegistered(G);if(Y.state<@ModuleLink)T.push(G);@putByValDirect(L,D,Y),V.@set(X,Y)}x.dependencies=L,x.instantiate=@Promise.resolve(x),x.satisfy=@Promise.resolve(x),H=T.shift();while(H&&(Q.registry.@get(H)\?.state\?\?@ModuleFetch)>=@ModuleLink)H=T.shift()}var Z=Q.linkAndEvaluateModule(J,@undefined);if(Z&&@isPromise(Z))@throwTypeError(`require() async module \\\"${J}\\\" is unsupported. use \"await import()\" instead.`);return Q.registry.@get(J)})\n"; +const char* const s_importMetaObjectLoadCJS2ESMCode = "(function (B){\"use strict\";var D=@Loader,H=@createFIFO(),_=B;while(_){var w=D.registry.@get(_);if((w\?.state\?\?0)<=@ModuleFetch)@fulfillModuleSync(_),w=D.registry.@get(_);var W=@getPromiseInternalField(w.fetch,@promiseFieldReactionsOrResult),x=D.parseModule(_,W),z=w.module;if(x&&@isPromise(x)){var J=@getPromiseInternalField(x,@promiseFieldReactionsOrResult),X=@getPromiseInternalField(x,@promiseFieldFlags),Q=X&@promiseStateMask;if(Q===@promiseStatePending||J&&@isPromise(J))@throwTypeError(`require() async module \"${_}\" is unsupported. use \"await import()\" instead.`);else if(Q===@promiseStateRejected){if(!J\?.message)@throwTypeError(`${J+\"\"\?J:\"An error occurred\"} occurred while parsing module \\\"${_}\\\"`);throw J}w.module=z=J}else if(x&&!z)w.module=z=x;@setStateToMax(w,@ModuleLink);var Y=z.dependenciesMap,I=D.requestedModules(z),T=@newArrayWithSize(I.length);for(var F=0,Z=I.length;F<Z;++F){var G=I[F],U=G[0]===\"/\"\?G:D.resolve(G,_),L=D.ensureRegistered(U);if(L.state<@ModuleLink)H.push(U);@putByValDirect(T,F,L),Y.@set(G,L)}w.dependencies=T,w.instantiate=@Promise.resolve(w),w.satisfy=@Promise.resolve(w),_=H.shift();while(_&&(D.registry.@get(_)\?.state\?\?@ModuleFetch)>=@ModuleLink)_=H.shift()}var V=D.linkAndEvaluateModule(B,@undefined);if(V&&@isPromise(V))@throwTypeError(`require() async module \\\"${B}\\\" is unsupported. use \"await import()\" instead.`);return D.registry.@get(B)})\n"; // requireESM const JSC::ConstructAbility s_importMetaObjectRequireESMCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2240,7 +2266,7 @@ const JSC::ConstructorKind s_importMetaObjectRequireESMCodeConstructorKind = JSC const JSC::ImplementationVisibility s_importMetaObjectRequireESMCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectRequireESMCodeLength = 325; static const JSC::Intrinsic s_importMetaObjectRequireESMCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectRequireESMCode = "(function (a){\"use strict\";var c=@Loader.registry.@get(a);if(!c||!c.evaluated)c=@loadCJS2ESM(a);if(!c||!c.evaluated||!c.module)@throwTypeError(`require() failed to evaluate module \"${a}\". This is an internal consistentency error.`);var _=@Loader.getModuleNamespaceObject(c.module);if(_[@commonJSSymbol]===0)return;return _})\n"; +const char* const s_importMetaObjectRequireESMCode = "(function (c){\"use strict\";var a=@Loader.registry.@get(c);if(!a||!a.evaluated)a=@loadCJS2ESM(c);if(!a||!a.evaluated||!a.module)@throwTypeError(`require() failed to evaluate module \"${c}\". This is an internal consistentency error.`);var _=@Loader.getModuleNamespaceObject(a.module);if(_[@commonJSSymbol]===0)return;return _})\n"; // internalRequire const JSC::ConstructAbility s_importMetaObjectInternalRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2248,7 +2274,7 @@ const JSC::ConstructorKind s_importMetaObjectInternalRequireCodeConstructorKind const JSC::ImplementationVisibility s_importMetaObjectInternalRequireCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectInternalRequireCodeLength = 747; static const JSC::Intrinsic s_importMetaObjectInternalRequireCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectInternalRequireCode = "(function (b){\"use strict\";var _=@requireMap.@get(b);const j=b.substring(b.length-5);if(_)return _.exports;if(j===\".json\"){var n=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),g=JSON.parse(n.readFileSync(b,\"utf8\"));return @requireMap.@set(b,@createCommonJSModule(b,g,!0)),g}else if(j===\".node\"){const k=@createCommonJSModule(b,{},!0);return process.dlopen(k,b),@requireMap.@set(b,k),k.exports}else if(j===\".toml\"){var n=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),g=@Bun.TOML.parse(n.readFileSync(b,\"utf8\"));return @requireMap.@set(b,@createCommonJSModule(b,g,!0)),g}else{var g=@requireESM(b);const q=@requireMap.@get(b);if(q)return q.exports;var v=g\?.default;if(v\?.[@commonJSSymbol]===0)g=v;return @requireMap.@set(b,@createCommonJSModule(b,g,!0)),g}})\n"; +const char* const s_importMetaObjectInternalRequireCode = "(function (_){\"use strict\";var n=@requireMap.@get(_);const g=_.substring(_.length-5);if(n)return n.exports;if(g===\".json\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),b=JSON.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}else if(g===\".node\"){const k=@createCommonJSModule(_,{},!0);return process.dlopen(k,_),@requireMap.@set(_,k),k.exports}else if(g===\".toml\"){var j=globalThis[Symbol.for(\"_fs\")]||=@Bun.fs(),b=@Bun.TOML.parse(j.readFileSync(_,\"utf8\"));return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}else{var b=@requireESM(_);const v=@requireMap.@get(_);if(v)return v.exports;var q=b\?.default;if(q\?.[@commonJSSymbol]===0)b=q;return @requireMap.@set(_,@createCommonJSModule(_,b,!0)),b}})\n"; // createRequireCache const JSC::ConstructAbility s_importMetaObjectCreateRequireCacheCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2256,7 +2282,7 @@ const JSC::ConstructorKind s_importMetaObjectCreateRequireCacheCodeConstructorKi const JSC::ImplementationVisibility s_importMetaObjectCreateRequireCacheCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_importMetaObjectCreateRequireCacheCodeLength = 854; static const JSC::Intrinsic s_importMetaObjectCreateRequireCacheCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var f=new Map,h={};return new Proxy(h,{get(t,_){const u=@requireMap.@get(_);if(u)return u;const L=@Loader.registry.@get(_);if(L\?.evaluated){const b=@Loader.getModuleNamespaceObject(L.module),c=b[@commonJSSymbol]===0||b.default\?.[@commonJSSymbol]\?b.default:b,g=@createCommonJSModule(_,c,!0);return @requireMap.@set(_,g),g}return h[_]},set(t,_,u){return @requireMap.@set(_,u),!0},has(t,_){return @requireMap.@has(_)||@Loader.registry.@has(_)},deleteProperty(t,_){return f.@delete(_),@requireMap.@delete(_),@Loader.registry.@delete(_),!0},ownKeys(t){var _=[...@requireMap.@keys()];const u=[...@Loader.registry.@keys()];for(let L of u)if(!_.includes(L))@arrayPush(_,L);return _},getPrototypeOf(t){return null},getOwnPropertyDescriptor(t,_){if(@requireMap.@has(_)||@Loader.registry.@has(_))return{configurable:!0,enumerable:!0}}})})\n"; +const char* const s_importMetaObjectCreateRequireCacheCode = "(function (){\"use strict\";var c=new Map,L={};return new Proxy(L,{get(f,_){const h=@requireMap.@get(_);if(h)return h;const t=@Loader.registry.@get(_);if(t\?.evaluated){const u=@Loader.getModuleNamespaceObject(t.module),g=u[@commonJSSymbol]===0||u.default\?.[@commonJSSymbol]\?u.default:u,b=@createCommonJSModule(_,g,!0);return @requireMap.@set(_,b),b}return L[_]},set(f,_,h){return @requireMap.@set(_,h),!0},has(f,_){return @requireMap.@has(_)||@Loader.registry.@has(_)},deleteProperty(f,_){return c.@delete(_),@requireMap.@delete(_),@Loader.registry.@delete(_),!0},ownKeys(f){var _=[...@requireMap.@keys()];const h=[...@Loader.registry.@keys()];for(let t of h)if(!_.includes(t))@arrayPush(_,t);return _},getPrototypeOf(f){return null},getOwnPropertyDescriptor(f,_){if(@requireMap.@has(_)||@Loader.registry.@has(_))return{configurable:!0,enumerable:!0}}})})\n"; // require const JSC::ConstructAbility s_importMetaObjectRequireCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2438,9 +2464,9 @@ WEBCORE_FOREACH_WRITABLESTREAMDEFAULTWRITER_BUILTIN_CODE(DEFINE_BUILTIN_GENERATO 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; +const int s_readableStreamInitializeReadableStreamCodeLength = 2143; static const JSC::Intrinsic s_readableStreamInitializeReadableStreamCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,B){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(B===@undefined)B={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(B!==@undefined&&!@isObject(B))@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\",f=!!_.@lazy,m=I||f;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!m){const v=@getByIdDirectPrivate(B,\"size\"),b=@getByIdDirectPrivate(B,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",b),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,v,b!==@undefined\?b:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(I)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(B,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,B));else if(m){const v=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",v||@getByIdDirectPrivate(B,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const b=@lazyLoadStream(this,v);if(b)@createReadableStreamController(this,b,B)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(B,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,B);return this})\n"; +const char* const s_readableStreamInitializeReadableStreamCode = "(function (_,v){\"use strict\";if(_===@undefined)_={@bunNativeType:0,@bunNativePtr:0,@lazy:!1};if(v===@undefined)v={};if(!@isObject(_))@throwTypeError(\"ReadableStream constructor takes an object as first argument\");if(v!==@undefined&&!@isObject(v))@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),@putByIdDirectPrivate(this,\"asyncContext\",@getInternalField(@asyncContext,0));const B=_.type===\"direct\",R=!!_.@lazy,P=B||R;if(@getByIdDirectPrivate(_,\"pull\")!==@undefined&&!P){const m=@getByIdDirectPrivate(v,\"size\"),f=@getByIdDirectPrivate(v,\"highWaterMark\");return @putByIdDirectPrivate(this,\"highWaterMark\",f),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@setupReadableStreamDefaultController(this,_,m,f!==@undefined\?f:1,@getByIdDirectPrivate(_,\"start\"),@getByIdDirectPrivate(_,\"pull\"),@getByIdDirectPrivate(_,\"cancel\")),this}if(B)@putByIdDirectPrivate(this,\"underlyingSource\",_),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(v,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>@createReadableStreamController(this,_,v));else if(P){const m=_.autoAllocateChunkSize;@putByIdDirectPrivate(this,\"highWaterMark\",@undefined),@putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",m||@getByIdDirectPrivate(v,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",()=>{const f=@lazyLoadStream(this,m);if(f)@createReadableStreamController(this,f,v)})}else @putByIdDirectPrivate(this,\"underlyingSource\",@undefined),@putByIdDirectPrivate(this,\"highWaterMark\",@getByIdDirectPrivate(v,\"highWaterMark\")),@putByIdDirectPrivate(this,\"start\",@undefined),@createReadableStreamController(this,_,v);return this})\n"; // readableStreamToArray const JSC::ConstructAbility s_readableStreamReadableStreamToArrayCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2456,7 +2482,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToTextCodeConstructorKi 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"; +const char* const s_readableStreamReadableStreamToTextCode = "(function (p){\"use strict\";var _=@getByIdDirectPrivate(p,\"underlyingSource\");if(_!==@undefined)return @readableStreamToTextDirect(p,_);return @readableStreamIntoText(p)})\n"; // readableStreamToArrayBuffer const JSC::ConstructAbility s_readableStreamReadableStreamToArrayBufferCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2464,7 +2490,7 @@ const JSC::ConstructorKind s_readableStreamReadableStreamToArrayBufferCodeConstr const JSC::ImplementationVisibility s_readableStreamReadableStreamToArrayBufferCodeImplementationVisibility = JSC::ImplementationVisibility::Private; const int s_readableStreamReadableStreamToArrayBufferCodeLength = 270; static const JSC::Intrinsic s_readableStreamReadableStreamToArrayBufferCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var b=@getByIdDirectPrivate(_,\"underlyingSource\");if(b!==@undefined)return @readableStreamToArrayBufferDirect(_,b);var p=@Bun.readableStreamToArray(_);if(@isPromise(p))return p.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(p)})\n"; +const char* const s_readableStreamReadableStreamToArrayBufferCode = "(function (_){\"use strict\";var p=@getByIdDirectPrivate(_,\"underlyingSource\");if(p!==@undefined)return @readableStreamToArrayBufferDirect(_,p);var b=@Bun.readableStreamToArray(_);if(@isPromise(b))return b.then(@Bun.concatArrayBuffers);return @Bun.concatArrayBuffers(b)})\n"; // readableStreamToJSON const JSC::ConstructAbility s_readableStreamReadableStreamToJSONCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2520,7 +2546,7 @@ const JSC::ConstructorKind s_readableStreamGetReaderCodeConstructorKind = JSC::C 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 (e){\"use strict\";if(!@isReadableStream(this))throw @makeThisTypeError(\"ReadableStream\",\"getReader\");const n=@toDictionary(e,{},\"ReadableStream.getReader takes an object as first argument\").mode;if(n===@undefined){var b=@getByIdDirectPrivate(this,\"start\");if(b)@putByIdDirectPrivate(this,\"start\",@undefined),b();return new @ReadableStreamDefaultReader(this)}if(n==\"byob\")return new @ReadableStreamBYOBReader(this);@throwTypeError(\"Invalid mode is specified\")})\n"; +const char* const s_readableStreamGetReaderCode = "(function (b){\"use strict\";if(!@isReadableStream(this))throw @makeThisTypeError(\"ReadableStream\",\"getReader\");const e=@toDictionary(b,{},\"ReadableStream.getReader takes an object as first argument\").mode;if(e===@undefined){var n=@getByIdDirectPrivate(this,\"start\");if(n)@putByIdDirectPrivate(this,\"start\",@undefined),n();return new @ReadableStreamDefaultReader(this)}if(e==\"byob\")return new @ReadableStreamBYOBReader(this);@throwTypeError(\"Invalid mode is specified\")})\n"; // pipeThrough const JSC::ConstructAbility s_readableStreamPipeThroughCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2528,7 +2554,7 @@ const JSC::ConstructorKind s_readableStreamPipeThroughCodeConstructorKind = JSC: const JSC::ImplementationVisibility s_readableStreamPipeThroughCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamPipeThroughCodeLength = 859; static const JSC::Intrinsic s_readableStreamPipeThroughCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamPipeThroughCode = "(function (_,d){\"use strict\";const u=_,y=u.readable;if(!@isReadableStream(y))throw @makeTypeError(\"readable should be ReadableStream\");const c=u.writable,h=@getInternalWritableStream(c);if(!@isWritableStream(h))throw @makeTypeError(\"writable should be WritableStream\");let j=!1,k=!1,q=!1,x;if(!@isUndefinedOrNull(d)){if(!@isObject(d))throw @makeTypeError(\"options must be an object\");if(k=!!d.preventAbort,q=!!d.preventCancel,j=!!d.preventClose,x=d.signal,x!==@undefined&&!@isAbortSignal(x))throw @makeTypeError(\"options.signal must be AbortSignal\")}if(!@isReadableStream(this))throw @makeThisTypeError(\"ReadableStream\",\"pipeThrough\");if(@isReadableStreamLocked(this))throw @makeTypeError(\"ReadableStream is locked\");if(@isWritableStreamLocked(h))throw @makeTypeError(\"WritableStream is locked\");return @readableStreamPipeToWritableStream(this,h,j,k,q,x),y})\n"; +const char* const s_readableStreamPipeThroughCode = "(function (q,_){\"use strict\";const y=q,c=y.readable;if(!@isReadableStream(c))throw @makeTypeError(\"readable should be ReadableStream\");const x=y.writable,u=@getInternalWritableStream(x);if(!@isWritableStream(u))throw @makeTypeError(\"writable should be WritableStream\");let h=!1,j=!1,k=!1,d;if(!@isUndefinedOrNull(_)){if(!@isObject(_))throw @makeTypeError(\"options must be an object\");if(j=!!_.preventAbort,k=!!_.preventCancel,h=!!_.preventClose,d=_.signal,d!==@undefined&&!@isAbortSignal(d))throw @makeTypeError(\"options.signal must be AbortSignal\")}if(!@isReadableStream(this))throw @makeThisTypeError(\"ReadableStream\",\"pipeThrough\");if(@isReadableStreamLocked(this))throw @makeTypeError(\"ReadableStream is locked\");if(@isWritableStreamLocked(u))throw @makeTypeError(\"WritableStream is locked\");return @readableStreamPipeToWritableStream(this,u,h,j,k,d),c})\n"; // pipeTo const JSC::ConstructAbility s_readableStreamPipeToCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2536,7 +2562,7 @@ const JSC::ConstructorKind s_readableStreamPipeToCodeConstructorKind = JSC::Cons const JSC::ImplementationVisibility s_readableStreamPipeToCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_readableStreamPipeToCodeLength = 914; static const JSC::Intrinsic s_readableStreamPipeToCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_readableStreamPipeToCode = "(function (m){\"use strict\";if(!@isReadableStream(this))return @Promise.@reject(@makeThisTypeError(\"ReadableStream\",\"pipeTo\"));if(@isReadableStreamLocked(this))return @Promise.@reject(@makeTypeError(\"ReadableStream is locked\"));let j=@argument(1),u=!1,_=!1,E=!1,R;if(!@isUndefinedOrNull(j)){if(!@isObject(j))return @Promise.@reject(@makeTypeError(\"options must be an object\"));try{_=!!j.preventAbort,E=!!j.preventCancel,u=!!j.preventClose,R=j.signal}catch(b){return @Promise.@reject(b)}if(R!==@undefined&&!@isAbortSignal(R))return @Promise.@reject(@makeTypeError(\"options.signal must be AbortSignal\"))}const S=@getInternalWritableStream(m);if(!@isWritableStream(S))return @Promise.@reject(@makeTypeError(\"ReadableStream pipeTo requires a WritableStream\"));if(@isWritableStreamLocked(S))return @Promise.@reject(@makeTypeError(\"WritableStream is locked\"));return @readableStreamPipeToWritableStream(this,S,u,_,E,R)})\n"; +const char* const s_readableStreamPipeToCode = "(function (S){\"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),j=!1,E=!1,R=!1,u;if(!@isUndefinedOrNull(m)){if(!@isObject(m))return @Promise.@reject(@makeTypeError(\"options must be an object\"));try{E=!!m.preventAbort,R=!!m.preventCancel,j=!!m.preventClose,u=m.signal}catch(b){return @Promise.@reject(b)}if(u!==@undefined&&!@isAbortSignal(u))return @Promise.@reject(@makeTypeError(\"options.signal must be AbortSignal\"))}const _=@getInternalWritableStream(S);if(!@isWritableStream(_))return @Promise.@reject(@makeTypeError(\"ReadableStream pipeTo requires a WritableStream\"));if(@isWritableStreamLocked(_))return @Promise.@reject(@makeTypeError(\"WritableStream is locked\"));return @readableStreamPipeToWritableStream(this,_,j,E,R,u)})\n"; // tee const JSC::ConstructAbility s_readableStreamTeeCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2560,7 +2586,7 @@ const JSC::ConstructorKind s_readableStreamValuesCodeConstructorKind = JSC::Cons 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 (r){\"use strict\";var _=@ReadableStream.prototype;return @readableStreamDefineLazyIterators(_),_.values.@call(this,r)})\n"; +const char* const s_readableStreamValuesCode = "(function (_){\"use strict\";var r=@ReadableStream.prototype;return @readableStreamDefineLazyIterators(r),r.values.@call(this,_)})\n"; // lazyAsyncIterator const JSC::ConstructAbility s_readableStreamLazyAsyncIteratorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2586,7 +2612,7 @@ const JSC::ConstructorKind s_readableStreamDefaultControllerInitializeReadableSt 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 (_,R,C,p){\"use strict\";if(arguments.length!==5&&arguments[4]!==@isReadableStream)@throwTypeError(\"ReadableStreamDefaultController constructor should not be called directly\");return @privateInitializeReadableStreamDefaultController.@call(this,_,R,C,p)})\n"; +const char* const s_readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCode = "(function (_,p,C,R){\"use strict\";if(arguments.length!==5&&arguments[4]!==@isReadableStream)@throwTypeError(\"ReadableStreamDefaultController constructor should not be called directly\");return @privateInitializeReadableStreamDefaultController.@call(this,_,p,C,R)})\n"; // enqueue const JSC::ConstructAbility s_readableStreamDefaultControllerEnqueueCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2636,7 +2662,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsPrivateInitializeReadabl 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 (_,b,p){\"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\",b),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let v=@toNumber(p);if(@isNaN(v)||v<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",v);let R=b.autoAllocateChunkSize;if(R!==@undefined){if(R=@toNumber(R),R<=0||R===@Infinity||R===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",R),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const f=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(f,\"underlyingByteSource\"),\"start\",[f]).@then(()=>{@putByIdDirectPrivate(f,\"started\",1),@assert(!@getByIdDirectPrivate(f,\"pulling\")),@assert(!@getByIdDirectPrivate(f,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(f)},(d)=>{if(@getByIdDirectPrivate(_,\"state\")===@streamReadable)@readableByteStreamControllerError(f,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; +const char* const s_readableByteStreamInternalsPrivateInitializeReadableByteStreamControllerCode = "(function (b,p,R){\"use strict\";if(!@isReadableStream(b))@throwTypeError(\"ReadableByteStreamController needs a ReadableStream\");if(@getByIdDirectPrivate(b,\"readableStreamController\")!==null)@throwTypeError(\"ReadableStream already has a controller\");@putByIdDirectPrivate(this,\"controlledReadableStream\",b),@putByIdDirectPrivate(this,\"underlyingByteSource\",p),@putByIdDirectPrivate(this,\"pullAgain\",!1),@putByIdDirectPrivate(this,\"pulling\",!1),@readableByteStreamControllerClearPendingPullIntos(this),@putByIdDirectPrivate(this,\"queue\",@newQueue()),@putByIdDirectPrivate(this,\"started\",0),@putByIdDirectPrivate(this,\"closeRequested\",!1);let f=@toNumber(R);if(@isNaN(f)||f<0)@throwRangeError(\"highWaterMark value is negative or not a number\");@putByIdDirectPrivate(this,\"strategyHWM\",f);let _=p.autoAllocateChunkSize;if(_!==@undefined){if(_=@toNumber(_),_<=0||_===@Infinity||_===-@Infinity)@throwRangeError(\"autoAllocateChunkSize value is negative or equal to positive or negative infinity\")}@putByIdDirectPrivate(this,\"autoAllocateChunkSize\",_),@putByIdDirectPrivate(this,\"pendingPullIntos\",@createFIFO());const v=this;return @promiseInvokeOrNoopNoCatch(@getByIdDirectPrivate(v,\"underlyingByteSource\"),\"start\",[v]).@then(()=>{@putByIdDirectPrivate(v,\"started\",1),@assert(!@getByIdDirectPrivate(v,\"pulling\")),@assert(!@getByIdDirectPrivate(v,\"pullAgain\")),@readableByteStreamControllerCallPullIfNeeded(v)},(d)=>{if(@getByIdDirectPrivate(b,\"state\")===@streamReadable)@readableByteStreamControllerError(v,d)}),@putByIdDirectPrivate(this,\"cancel\",@readableByteStreamControllerCancel),@putByIdDirectPrivate(this,\"pull\",@readableByteStreamControllerPull),this})\n"; // readableStreamByteStreamControllerStart const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamByteStreamControllerStartCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2684,7 +2710,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 (p,u){\"use strict\";var _=@getByIdDirectPrivate(p,\"pendingPullIntos\"),a=_.peek();if(a)a.bytesFilled=0;return @putByIdDirectPrivate(p,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(p,\"underlyingByteSource\"),\"cancel\",[u])})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCancelCode = "(function (a,u){\"use strict\";var _=@getByIdDirectPrivate(a,\"pendingPullIntos\"),p=_.peek();if(p)p.bytesFilled=0;return @putByIdDirectPrivate(a,\"queue\",@newQueue()),@promiseInvokeOrNoop(@getByIdDirectPrivate(a,\"underlyingByteSource\"),\"cancel\",[u])})\n"; // readableByteStreamControllerError const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerErrorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2700,7 +2726,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 (u){\"use strict\";if(@assert(!@getByIdDirectPrivate(u,\"closeRequested\")),@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(u,\"controlledReadableStream\"),\"state\")===@streamReadable),@getByIdDirectPrivate(u,\"queue\").size>0){@putByIdDirectPrivate(u,\"closeRequested\",!0);return}var d=@getByIdDirectPrivate(u,\"pendingPullIntos\")\?.peek();if(d){if(d.bytesFilled>0){const a=@makeTypeError(\"Close requested while there remain pending bytes\");throw @readableByteStreamControllerError(u,a),a}}@readableStreamClose(@getByIdDirectPrivate(u,\"controlledReadableStream\"))})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerCloseCode = "(function (d){\"use strict\";if(@assert(!@getByIdDirectPrivate(d,\"closeRequested\")),@assert(@getByIdDirectPrivate(@getByIdDirectPrivate(d,\"controlledReadableStream\"),\"state\")===@streamReadable),@getByIdDirectPrivate(d,\"queue\").size>0){@putByIdDirectPrivate(d,\"closeRequested\",!0);return}var a=@getByIdDirectPrivate(d,\"pendingPullIntos\")\?.peek();if(a){if(a.bytesFilled>0){const u=@makeTypeError(\"Close requested while there remain pending bytes\");throw @readableByteStreamControllerError(d,u),u}}@readableStreamClose(@getByIdDirectPrivate(d,\"controlledReadableStream\"))})\n"; // readableByteStreamControllerClearPendingPullIntos const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerClearPendingPullIntosCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2716,7 +2742,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 (_){\"use strict\";const u=@getByIdDirectPrivate(_,\"controlledReadableStream\"),d=@getByIdDirectPrivate(u,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(_,\"strategyHWM\")-@getByIdDirectPrivate(_,\"queue\").size})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerGetDesiredSizeCode = "(function (u){\"use strict\";const _=@getByIdDirectPrivate(u,\"controlledReadableStream\"),d=@getByIdDirectPrivate(_,\"state\");if(d===@streamErrored)return null;if(d===@streamClosed)return 0;return @getByIdDirectPrivate(u,\"strategyHWM\")-@getByIdDirectPrivate(u,\"queue\").size})\n"; // readableStreamHasBYOBReader const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamHasBYOBReaderCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2732,7 +2758,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamHasDefault 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 (l){\"use strict\";const n=@getByIdDirectPrivate(l,\"reader\");return n!==@undefined&&@isReadableStreamDefaultReader(n)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamHasDefaultReaderCode = "(function (n){\"use strict\";const l=@getByIdDirectPrivate(n,\"reader\");return l!==@undefined&&@isReadableStreamDefaultReader(l)})\n"; // readableByteStreamControllerHandleQueueDrain const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerHandleQueueDrainCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2748,7 +2774,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 F=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(F)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const P=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=P.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let R;try{R=new @Uint8Array(P.buffer,P.byteOffset,P.byteLength)}catch(h){return @Promise.@reject(h)}return @createFulfilledPromise({value:R,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let P;try{P=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(h){return @Promise.@reject(h)}const R={buffer:P,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(R)}const d=@readableStreamAddReadRequest(F);return @readableByteStreamControllerCallPullIfNeeded(_),d})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullCode = "(function (_){\"use strict\";const P=@getByIdDirectPrivate(_,\"controlledReadableStream\");if(@assert(@readableStreamHasDefaultReader(P)),@getByIdDirectPrivate(_,\"queue\").content\?.isNotEmpty()){const d=@getByIdDirectPrivate(_,\"queue\").content.shift();@getByIdDirectPrivate(_,\"queue\").size-=d.byteLength,@readableByteStreamControllerHandleQueueDrain(_);let h;try{h=new @Uint8Array(d.buffer,d.byteOffset,d.byteLength)}catch(F){return @Promise.@reject(F)}return @createFulfilledPromise({value:h,done:!1})}if(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\")!==@undefined){let d;try{d=@createUninitializedArrayBuffer(@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"))}catch(F){return @Promise.@reject(F)}const h={buffer:d,byteOffset:0,byteLength:@getByIdDirectPrivate(_,\"autoAllocateChunkSize\"),bytesFilled:0,elementSize:1,ctor:@Uint8Array,readerType:\"default\"};@getByIdDirectPrivate(_,\"pendingPullIntos\").push(h)}const R=@readableStreamAddReadRequest(P);return @readableByteStreamControllerCallPullIfNeeded(_),R})\n"; // readableByteStreamControllerShouldCallPull const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2756,7 +2782,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 (b){\"use strict\";const P=@getByIdDirectPrivate(b,\"controlledReadableStream\");if(@getByIdDirectPrivate(P,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(b,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(b,\"started\")>0))return!1;const u=@getByIdDirectPrivate(P,\"reader\");if(u&&(@getByIdDirectPrivate(u,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(u,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(P)&&@getByIdDirectPrivate(@getByIdDirectPrivate(P,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(b)>0)return!0;return!1})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerShouldCallPullCode = "(function (u){\"use strict\";const P=@getByIdDirectPrivate(u,\"controlledReadableStream\");if(@getByIdDirectPrivate(P,\"state\")!==@streamReadable)return!1;if(@getByIdDirectPrivate(u,\"closeRequested\"))return!1;if(!(@getByIdDirectPrivate(u,\"started\")>0))return!1;const b=@getByIdDirectPrivate(P,\"reader\");if(b&&(@getByIdDirectPrivate(b,\"readRequests\")\?.isNotEmpty()||!!@getByIdDirectPrivate(b,\"bunNativePtr\")))return!0;if(@readableStreamHasBYOBReader(P)&&@getByIdDirectPrivate(@getByIdDirectPrivate(P,\"reader\"),\"readIntoRequests\")\?.isNotEmpty())return!0;if(@readableByteStreamControllerGetDesiredSize(u)>0)return!0;return!1})\n"; // readableByteStreamControllerCallPullIfNeeded const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerCallPullIfNeededCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2788,7 +2814,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 (i,_){\"use strict\";const d=@getByIdDirectPrivate(i,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(i,\"closeRequested\")),@assert(@getByIdDirectPrivate(d,\"state\")===@streamReadable),@getByIdDirectPrivate(d,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(d,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(d,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(_.buffer),_.byteOffset,_.byteLength);else{@assert(!@getByIdDirectPrivate(i,\"queue\").content.size());const f=_.constructor===@Uint8Array\?_:new @Uint8Array(_.buffer,_.byteOffset,_.byteLength);@readableStreamFulfillReadRequest(d,f,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(_.buffer),_.byteOffset,_.byteLength),@readableByteStreamControllerProcessPullDescriptors(i);break}case 3:break;default:{@assert(!@isReadableStreamLocked(d)),@readableByteStreamControllerEnqueueChunk(i,@transferBufferToCurrentRealm(_.buffer),_.byteOffset,_.byteLength);break}}})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueCode = "(function (d,i){\"use strict\";const _=@getByIdDirectPrivate(d,\"controlledReadableStream\");switch(@assert(!@getByIdDirectPrivate(d,\"closeRequested\")),@assert(@getByIdDirectPrivate(_,\"state\")===@streamReadable),@getByIdDirectPrivate(_,\"reader\")\?@readableStreamReaderKind(@getByIdDirectPrivate(_,\"reader\")):0){case 1:{if(!@getByIdDirectPrivate(@getByIdDirectPrivate(_,\"reader\"),\"readRequests\")\?.isNotEmpty())@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength);else{@assert(!@getByIdDirectPrivate(d,\"queue\").content.size());const f=i.constructor===@Uint8Array\?i:new @Uint8Array(i.buffer,i.byteOffset,i.byteLength);@readableStreamFulfillReadRequest(_,f,!1)}break}case 2:{@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength),@readableByteStreamControllerProcessPullDescriptors(d);break}case 3:break;default:{@assert(!@isReadableStreamLocked(_)),@readableByteStreamControllerEnqueueChunk(d,@transferBufferToCurrentRealm(i.buffer),i.byteOffset,i.byteLength);break}}})\n"; // readableByteStreamControllerEnqueueChunk const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2796,7 +2822,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 (_,a,d,p){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:a,byteOffset:d,byteLength:p}),@getByIdDirectPrivate(_,\"queue\").size+=p})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerEnqueueChunkCode = "(function (_,d,p,a){\"use strict\";@getByIdDirectPrivate(_,\"queue\").content.push({buffer:d,byteOffset:p,byteLength:a}),@getByIdDirectPrivate(_,\"queue\").size+=a})\n"; // readableByteStreamControllerRespondWithNewView const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2804,7 +2830,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 (a,u){\"use strict\";@assert(@getByIdDirectPrivate(a,\"pendingPullIntos\").isNotEmpty());let d=@getByIdDirectPrivate(a,\"pendingPullIntos\").peek();if(d.byteOffset+d.bytesFilled!==u.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(d.byteLength!==u.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");d.buffer=u.buffer,@readableByteStreamControllerRespondInternal(a,u.byteLength)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondWithNewViewCode = "(function (d,u){\"use strict\";@assert(@getByIdDirectPrivate(d,\"pendingPullIntos\").isNotEmpty());let a=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek();if(a.byteOffset+a.bytesFilled!==u.byteOffset)@throwRangeError(\"Invalid value for view.byteOffset\");if(a.byteLength!==u.byteLength)@throwRangeError(\"Invalid value for view.byteLength\");a.buffer=u.buffer,@readableByteStreamControllerRespondInternal(d,u.byteLength)})\n"; // readableByteStreamControllerRespond const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2812,7 +2838,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 (u,I){\"use strict\";if(I=@toNumber(I),@isNaN(I)||I===@Infinity||I<0)@throwRangeError(\"bytesWritten has an incorrect value\");@assert(@getByIdDirectPrivate(u,\"pendingPullIntos\").isNotEmpty()),@readableByteStreamControllerRespondInternal(u,I)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondCode = "(function (I,u){\"use strict\";if(u=@toNumber(u),@isNaN(u)||u===@Infinity||u<0)@throwRangeError(\"bytesWritten has an incorrect value\");@assert(@getByIdDirectPrivate(I,\"pendingPullIntos\").isNotEmpty()),@readableByteStreamControllerRespondInternal(I,u)})\n"; // readableByteStreamControllerRespondInternal const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2820,7 +2846,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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(d,\"pendingPullIntos\").peek(),k=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@getByIdDirectPrivate(k,\"state\")===@streamClosed){if(_!==0)@throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");@readableByteStreamControllerRespondInClosedState(d,u)}else @assert(@getByIdDirectPrivate(k,\"state\")===@streamReadable),@readableByteStreamControllerRespondInReadableState(d,_,u)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInternalCode = "(function (d,u){\"use strict\";let _=@getByIdDirectPrivate(d,\"pendingPullIntos\").peek(),k=@getByIdDirectPrivate(d,\"controlledReadableStream\");if(@getByIdDirectPrivate(k,\"state\")===@streamClosed){if(u!==0)@throwTypeError(\"bytesWritten is different from 0 even though stream is closed\");@readableByteStreamControllerRespondInClosedState(d,_)}else @assert(@getByIdDirectPrivate(k,\"state\")===@streamReadable),@readableByteStreamControllerRespondInReadableState(d,u,_)})\n"; // readableByteStreamControllerRespondInReadableState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2828,7 +2854,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 (w,g,R){\"use strict\";if(R.bytesFilled+g>R.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(w,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(w,\"pendingPullIntos\").peek()===R),@readableByteStreamControllerInvalidateBYOBRequest(w),R.bytesFilled+=g,R.bytesFilled<R.elementSize)return;@readableByteStreamControllerShiftPendingDescriptor(w);const _=R.bytesFilled%R.elementSize;if(_>0){const h=R.byteOffset+R.bytesFilled,f=@cloneArrayBuffer(R.buffer,h-_,_);@readableByteStreamControllerEnqueueChunk(w,f,0,f.byteLength)}R.buffer=@transferBufferToCurrentRealm(R.buffer),R.bytesFilled-=_,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(w,\"controlledReadableStream\"),R),@readableByteStreamControllerProcessPullDescriptors(w)})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInReadableStateCode = "(function (w,_,f){\"use strict\";if(f.bytesFilled+_>f.byteLength)@throwRangeError(\"bytesWritten value is too great\");if(@assert(@getByIdDirectPrivate(w,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(w,\"pendingPullIntos\").peek()===f),@readableByteStreamControllerInvalidateBYOBRequest(w),f.bytesFilled+=_,f.bytesFilled<f.elementSize)return;@readableByteStreamControllerShiftPendingDescriptor(w);const R=f.bytesFilled%f.elementSize;if(R>0){const h=f.byteOffset+f.bytesFilled,g=@cloneArrayBuffer(f.buffer,h-R,R);@readableByteStreamControllerEnqueueChunk(w,g,0,g.byteLength)}f.buffer=@transferBufferToCurrentRealm(f.buffer),f.bytesFilled-=R,@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(w,\"controlledReadableStream\"),f),@readableByteStreamControllerProcessPullDescriptors(w)})\n"; // readableByteStreamControllerRespondInClosedState const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2836,7 +2862,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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,d){\"use strict\";if(d.buffer=@transferBufferToCurrentRealm(d.buffer),@assert(d.bytesFilled===0),@readableStreamHasBYOBReader(@getByIdDirectPrivate(a,\"controlledReadableStream\")))while(@getByIdDirectPrivate(@getByIdDirectPrivate(@getByIdDirectPrivate(a,\"controlledReadableStream\"),\"reader\"),\"readIntoRequests\")\?.isNotEmpty()){let _=@readableByteStreamControllerShiftPendingDescriptor(a);@readableByteStreamControllerCommitDescriptor(@getByIdDirectPrivate(a,\"controlledReadableStream\"),_)}})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerRespondInClosedStateCode = "(function (a,_){\"use strict\";if(_.buffer=@transferBufferToCurrentRealm(_.buffer),@assert(_.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; @@ -2852,7 +2878,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 (_,q){\"use strict\";const v=q.bytesFilled-q.bytesFilled%q.elementSize,w=@getByIdDirectPrivate(_,\"queue\").size<q.byteLength-q.bytesFilled\?@getByIdDirectPrivate(_,\"queue\").size:q.byteLength-q.bytesFilled,j=q.bytesFilled+w,z=j-j%q.elementSize;let G=w,H=!1;if(z>v)G=z-q.bytesFilled,H=!0;while(G>0){let k=@getByIdDirectPrivate(_,\"queue\").content.peek();const J=G<k.byteLength\?G:k.byteLength,E=q.byteOffset+q.bytesFilled;if(new @Uint8Array(q.buffer).set(new @Uint8Array(k.buffer,k.byteOffset,J),E),k.byteLength===J)@getByIdDirectPrivate(_,\"queue\").content.shift();else k.byteOffset+=J,k.byteLength-=J;@getByIdDirectPrivate(_,\"queue\").size-=J,@assert(@getByIdDirectPrivate(_,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(_,\"pendingPullIntos\").peek()===q),@readableByteStreamControllerInvalidateBYOBRequest(_),q.bytesFilled+=J,G-=J}if(!H)@assert(@getByIdDirectPrivate(_,\"queue\").size===0),@assert(q.bytesFilled>0),@assert(q.bytesFilled<q.elementSize);return H})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerFillDescriptorFromQueueCode = "(function (q,_){\"use strict\";const H=_.bytesFilled-_.bytesFilled%_.elementSize,z=@getByIdDirectPrivate(q,\"queue\").size<_.byteLength-_.bytesFilled\?@getByIdDirectPrivate(q,\"queue\").size:_.byteLength-_.bytesFilled,E=_.bytesFilled+z,G=E-E%_.elementSize;let v=z,w=!1;if(G>H)v=G-_.bytesFilled,w=!0;while(v>0){let j=@getByIdDirectPrivate(q,\"queue\").content.peek();const k=v<j.byteLength\?v:j.byteLength,J=_.byteOffset+_.bytesFilled;if(new @Uint8Array(_.buffer).set(new @Uint8Array(j.buffer,j.byteOffset,k),J),j.byteLength===k)@getByIdDirectPrivate(q,\"queue\").content.shift();else j.byteOffset+=k,j.byteLength-=k;@getByIdDirectPrivate(q,\"queue\").size-=k,@assert(@getByIdDirectPrivate(q,\"pendingPullIntos\").isEmpty()||@getByIdDirectPrivate(q,\"pendingPullIntos\").peek()===_),@readableByteStreamControllerInvalidateBYOBRequest(q),_.bytesFilled+=k,v-=k}if(!w)@assert(@getByIdDirectPrivate(q,\"queue\").size===0),@assert(_.bytesFilled>0),@assert(_.bytesFilled<_.elementSize);return w})\n"; // readableByteStreamControllerShiftPendingDescriptor const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerShiftPendingDescriptorCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2876,7 +2902,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 (h,g){\"use strict\";@assert(@getByIdDirectPrivate(h,\"state\")!==@streamErrored);let _=!1;if(@getByIdDirectPrivate(h,\"state\")===@streamClosed)@assert(!g.bytesFilled),_=!0;let b=@readableByteStreamControllerConvertDescriptor(g);if(g.readerType===\"default\")@readableStreamFulfillReadRequest(h,b,_);else @assert(g.readerType===\"byob\"),@readableStreamFulfillReadIntoRequest(h,b,_)})\n"; +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; @@ -2892,7 +2918,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamFulfillRea 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 (l,_,i){\"use strict\";const p=@getByIdDirectPrivate(@getByIdDirectPrivate(l,\"reader\"),\"readIntoRequests\").shift();@fulfillPromise(p,{value:_,done:i})})\n"; +const char* const s_readableByteStreamInternalsReadableStreamFulfillReadIntoRequestCode = "(function (l,i,p){\"use strict\";const _=@getByIdDirectPrivate(@getByIdDirectPrivate(l,\"reader\"),\"readIntoRequests\").shift();@fulfillPromise(_,{value:i,done:p})})\n"; // readableStreamBYOBReaderRead const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamBYOBReaderReadCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2900,7 +2926,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableStreamBYOBReader 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 (o,c){\"use strict\";const l=@getByIdDirectPrivate(o,\"ownerReadableStream\");if(@assert(!!l),@putByIdDirectPrivate(l,\"disturbed\",!0),@getByIdDirectPrivate(l,\"state\")===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(l,\"storedError\"));return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(l,\"readableStreamController\"),c)})\n"; +const char* const s_readableByteStreamInternalsReadableStreamBYOBReaderReadCode = "(function (c,l){\"use strict\";const o=@getByIdDirectPrivate(c,\"ownerReadableStream\");if(@assert(!!o),@putByIdDirectPrivate(o,\"disturbed\",!0),@getByIdDirectPrivate(o,\"state\")===@streamErrored)return @Promise.@reject(@getByIdDirectPrivate(o,\"storedError\"));return @readableByteStreamControllerPullInto(@getByIdDirectPrivate(o,\"readableStreamController\"),l)})\n"; // readableByteStreamControllerPullInto const JSC::ConstructAbility s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2908,7 +2934,7 @@ const JSC::ConstructorKind s_readableByteStreamInternalsReadableByteStreamContro 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 (_,E){\"use strict\";const k=@getByIdDirectPrivate(_,\"controlledReadableStream\");let L=1;if(E.BYTES_PER_ELEMENT!==@undefined)L=E.BYTES_PER_ELEMENT;const b=E.constructor,N={buffer:E.buffer,byteOffset:E.byteOffset,byteLength:E.byteLength,bytesFilled:0,elementSize:L,ctor:b,readerType:\"byob\"};var d=@getByIdDirectPrivate(_,\"pendingPullIntos\");if(d\?.isNotEmpty())return N.buffer=@transferBufferToCurrentRealm(N.buffer),d.push(N),@readableStreamAddReadIntoRequest(k);if(@getByIdDirectPrivate(k,\"state\")===@streamClosed){const A=new b(N.buffer,N.byteOffset,0);return @createFulfilledPromise({value:A,done:!0})}if(@getByIdDirectPrivate(_,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(_,N)){const A=@readableByteStreamControllerConvertDescriptor(N);return @readableByteStreamControllerHandleQueueDrain(_),@createFulfilledPromise({value:A,done:!1})}if(@getByIdDirectPrivate(_,\"closeRequested\")){const A=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(_,A),@Promise.@reject(A)}}N.buffer=@transferBufferToCurrentRealm(N.buffer),@getByIdDirectPrivate(_,\"pendingPullIntos\").push(N);const R=@readableStreamAddReadIntoRequest(k);return @readableByteStreamControllerCallPullIfNeeded(_),R})\n"; +const char* const s_readableByteStreamInternalsReadableByteStreamControllerPullIntoCode = "(function (b,d){\"use strict\";const A=@getByIdDirectPrivate(b,\"controlledReadableStream\");let E=1;if(d.BYTES_PER_ELEMENT!==@undefined)E=d.BYTES_PER_ELEMENT;const L=d.constructor,_={buffer:d.buffer,byteOffset:d.byteOffset,byteLength:d.byteLength,bytesFilled:0,elementSize:E,ctor:L,readerType:\"byob\"};var N=@getByIdDirectPrivate(b,\"pendingPullIntos\");if(N\?.isNotEmpty())return _.buffer=@transferBufferToCurrentRealm(_.buffer),N.push(_),@readableStreamAddReadIntoRequest(A);if(@getByIdDirectPrivate(A,\"state\")===@streamClosed){const k=new L(_.buffer,_.byteOffset,0);return @createFulfilledPromise({value:k,done:!0})}if(@getByIdDirectPrivate(b,\"queue\").size>0){if(@readableByteStreamControllerFillDescriptorFromQueue(b,_)){const k=@readableByteStreamControllerConvertDescriptor(_);return @readableByteStreamControllerHandleQueueDrain(b),@createFulfilledPromise({value:k,done:!1})}if(@getByIdDirectPrivate(b,\"closeRequested\")){const k=@makeTypeError(\"Closing stream has been requested\");return @readableByteStreamControllerError(b,k),@Promise.@reject(k)}}_.buffer=@transferBufferToCurrentRealm(_.buffer),@getByIdDirectPrivate(b,\"pendingPullIntos\").push(_);const R=@readableStreamAddReadIntoRequest(A);return @readableByteStreamControllerCallPullIfNeeded(b),R})\n"; // readableStreamAddReadIntoRequest const JSC::ConstructAbility s_readableByteStreamInternalsReadableStreamAddReadIntoRequestCodeConstructAbility = JSC::ConstructAbility::CannotConstruct; @@ -2942,7 +2968,7 @@ const JSC::ConstructorKind s_writableStreamDefaultControllerErrorCodeConstructor 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 (t){\"use strict\";if(@getByIdDirectPrivate(this,\"abortSteps\")===@undefined)throw @makeThisTypeError(\"WritableStreamDefaultController\",\"error\");const r=@getByIdDirectPrivate(this,\"stream\");if(@getByIdDirectPrivate(r,\"state\")!==\"writable\")return;@writableStreamDefaultControllerError(this,t)})\n"; +const char* const s_writableStreamDefaultControllerErrorCode = "(function (r){\"use strict\";if(@getByIdDirectPrivate(this,\"abortSteps\")===@undefined)throw @makeThisTypeError(\"WritableStreamDefaultController\",\"error\");const t=@getByIdDirectPrivate(this,\"stream\");if(@getByIdDirectPrivate(t,\"state\")!==\"writable\")return;@writableStreamDefaultControllerError(this,r)})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ @@ -2960,7 +2986,7 @@ const JSC::ConstructorKind s_eventSourceGetEventSourceCodeConstructorKind = JSC: const JSC::ImplementationVisibility s_eventSourceGetEventSourceCodeImplementationVisibility = JSC::ImplementationVisibility::Public; const int s_eventSourceGetEventSourceCodeLength = 5477; static const JSC::Intrinsic s_eventSourceGetEventSourceCodeIntrinsic = JSC::NoIntrinsic; -const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class B extends EventTarget{#$;#j;#w;#A;#B;#F=!1;#G=null;#J=\"\";#K=\"\";#L=\"\";#M=!0;#O=0;#Q=0;#U=0;#V=null;static#W(V){V.#H()}static#X(V,j){const w=V.data,F=w.#L\?`Last-Event-ID: ${w.#L}\\r\\n`:\"\",G=`GET ${j.pathname}${j.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${F}\\r\\n`,W=V.write(G);if(W!==G.length)w.#K=G.substring(W)}static#Y(V,j,w){for(;;){if(w>=j.length)return;let F=-1,G=j.indexOf(\"\\r\\n\",w);const W=G+2;if(G>0)if(V.#O===0){const Z=parseInt(j.substring(w,G),16);if(Z===0){V.#j=2,V.#G\?.end();return}F=W+Z}else F=j.length;else{if(V.#J.length===0){V.#J+=j.substring(w);return}F=j.length}let X=j.substring(W,F);w=F+2;let J=0,Y=X.indexOf(\"\\n\\n\");if(Y==-1){V.#J+=j.substring(W);return}if(V.#J.length)V.#J+=X,X=V.#J,V.#J=\"\";let K=!0;while(K){const Z=X.substring(J,Y);let L,z=\"\",A,H=0,M=-1;for(;;){let Q=Z.indexOf(\"\\n\",H);if(Q===-1){if(H>=Z.length)break;Q=Z.length}const U=Z.substring(H,Q);if(U.startsWith(\"data:\"))if(z.length)z+=`\\n${U.substring(5).trim()}`;else z=U.substring(5).trim();else if(U.startsWith(\"event:\"))L=U.substring(6).trim();else if(U.startsWith(\"id:\"))A=U.substring(3).trim();else if(U.startsWith(\"retry:\")){if(M=parseInt(U.substring(6).trim(),10),@isNaN(M))M=-1}H=Q+1}if(V.#L=A||\"\",M>=0)V.#U=M;if(z||A||L)V.dispatchEvent(new MessageEvent(L||\"message\",{data:z||\"\",origin:V.#$.origin,source:V,lastEventId:A}));if(X.length===Y+2){K=!1;break}const O=X.indexOf(\"\\n\\n\",Y+1);if(O===-1)break;J=Y,Y=O}}}static#Z={open(V){const j=V.data;if(j.#G=V,!j.#F)B.#X(V,j.#$)},handshake(V,j,w){const F=V.data;if(j)B.#X(V,F.#$);else F.#j=2,F.dispatchEvent(new ErrorEvent(\"error\",{error:w})),V.end()},data(V,j){const w=V.data;switch(w.#j){case 0:{let F=j.toString();const G=F.indexOf(\"\\r\\n\\r\\n\");if(G===-1){w.#J+=F;return}if(w.#J.length)w.#J+=F,F=w.#J,w.#J=\"\";const W=F.substring(0,G),X=W.indexOf(\"\\r\\n\");if(X===-1){w.#j=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),V.end();return}const J=W.substring(0,X);if(J!==\"HTTP/1.1 200 OK\"){w.#j=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(J)})),V.end();return}let Y=X+1,K=!1,Z=-1;for(;;){let z=W.indexOf(\"\\r\\n\",Y);if(z===-1){if(Y>=W.length){if(!K)w.#j=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),V.end();return}z=W.length}const A=W.substring(Y+1,z),H=A.indexOf(\":\"),M=A.substring(0,H),O=M.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(Y=z+1,O)if(A.endsWith(\" text/event-stream\"))K=!0;else{w.#j=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),V.end();return}else if(M.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(Z=parseInt(A.substring(H+1).trim(),10),@isNaN(Z)||Z<=0){w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),V.end();return}if(K)break}else if(M.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(A.substring(H+1).trim()!==\"chunked\"){w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),V.end();return}if(Z=0,K)break}}w.#O=Z,w.#j=1,w.dispatchEvent(new Event(\"open\"));const L=F.substring(G+4);if(B.#Y(w,L,0),w.#O>0){if(w.#Q+=L.length,w.#Q>=w.#O)w.#j=2,V.end()}return}case 1:if(B.#Y(w,j.toString(),2),w.#O>0){if(w.#Q+=j.byteLength,w.#Q>=w.#O)w.#j=2,V.end()}return;default:break}},drain(V){const j=V.data;if(j.#j===0){const w=j.#J;if(w.length){const F=V.write(w);if(F!==w.length)V.data.#K=w.substring(F);else V.data.#K=\"\"}}},close:B.#z,end(V){B.#z(V).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(V){B.#z(V).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#z(V){const j=V.data;if(j.#G=null,j.#Q=0,j.#j=2,j.#M){if(j.#V)clearTimeout(j.#V);j.#V=setTimeout(B.#W,j.#U,j)}return j}constructor(V,j=@undefined){super();const w=new URL(V);this.#F=w.protocol===\"https:\",this.#$=w,this.#j=2,process.nextTick(B.#W,this)}ref(){this.#V\?.ref(),this.#G\?.ref()}unref(){this.#V\?.unref(),this.#G\?.unref()}#H(){if(this.#j!==2)return;const V=this.#$,j=this.#F;this.#j=0,@Bun.connect({data:this,socket:B.#Z,hostname:V.hostname,port:parseInt(V.port||(j\?\"443\":\"80\"),10),tls:j\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((w)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:w})),this.#M){if(this.#V)this.#V.unref\?.();this.#V=setTimeout(B.#W,1000,this)}})}get url(){return this.#$.href}get readyState(){return this.#j}close(){this.#M=!1,this.#j=2,this.#G\?.unref(),this.#G\?.end()}get onopen(){return this.#B}get onerror(){return this.#w}get onmessage(){return this.#A}set onopen(V){if(this.#B)super.removeEventListener(\"close\",this.#B);super.addEventListener(\"open\",V),this.#B=V}set onerror(V){if(this.#w)super.removeEventListener(\"error\",this.#w);super.addEventListener(\"error\",V),this.#w=V}set onmessage(V){if(this.#A)super.removeEventListener(\"message\",this.#A);super.addEventListener(\"message\",V),this.#A=V}}return Object.defineProperty(B.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(B.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(B.prototype,\"CLOSED\",{enumerable:!0,value:2}),B[Symbol.for(\"CommonJS\")]=0,B})\n"; +const char* const s_eventSourceGetEventSourceCode = "(function (){\"use strict\";class F extends EventTarget{#B;#$;#J;#K;#L;#M=!1;#A=null;#j=\"\";#O=\"\";#Q=\"\";#U=!0;#F=0;#G=0;#X=0;#w=null;static#V(j){j.#H()}static#Y(j,A){const w=j.data,B=w.#Q\?`Last-Event-ID: ${w.#Q}\\r\\n`:\"\",K=`GET ${A.pathname}${A.search} HTTP/1.1\\r\\nHost: bun\\r\\nContent-type: text/event-stream\\r\\nContent-length: 0\\r\\n${B}\\r\\n`,G=j.write(K);if(G!==K.length)w.#O=K.substring(G)}static#Z(j,A,w){for(;;){if(w>=A.length)return;let B=-1,K=A.indexOf(\"\\r\\n\",w);const G=K+2;if(K>0)if(j.#F===0){const J=parseInt(A.substring(w,K),16);if(J===0){j.#$=2,j.#A\?.end();return}B=G+J}else B=A.length;else{if(j.#j.length===0){j.#j+=A.substring(w);return}B=A.length}let M=A.substring(G,B);w=B+2;let Z=0,L=M.indexOf(\"\\n\\n\");if(L==-1){j.#j+=A.substring(G);return}if(j.#j.length)j.#j+=M,M=j.#j,j.#j=\"\";let X=!0;while(X){const J=M.substring(Z,L);let Y,O=\"\",Q,W=0,V=-1;for(;;){let z=J.indexOf(\"\\n\",W);if(z===-1){if(W>=J.length)break;z=J.length}const U=J.substring(W,z);if(U.startsWith(\"data:\"))if(O.length)O+=`\\n${U.substring(5).trim()}`;else O=U.substring(5).trim();else if(U.startsWith(\"event:\"))Y=U.substring(6).trim();else if(U.startsWith(\"id:\"))Q=U.substring(3).trim();else if(U.startsWith(\"retry:\")){if(V=parseInt(U.substring(6).trim(),10),@isNaN(V))V=-1}W=z+1}if(j.#Q=Q||\"\",V>=0)j.#X=V;if(O||Q||Y)j.dispatchEvent(new MessageEvent(Y||\"message\",{data:O||\"\",origin:j.#B.origin,source:j,lastEventId:Q}));if(M.length===L+2){X=!1;break}const H=M.indexOf(\"\\n\\n\",L+1);if(H===-1)break;Z=L,L=H}}}static#z={open(j){const A=j.data;if(A.#A=j,!A.#M)F.#Y(j,A.#B)},handshake(j,A,w){const B=j.data;if(A)F.#Y(j,B.#B);else B.#$=2,B.dispatchEvent(new ErrorEvent(\"error\",{error:w})),j.end()},data(j,A){const w=j.data;switch(w.#$){case 0:{let B=A.toString();const K=B.indexOf(\"\\r\\n\\r\\n\");if(K===-1){w.#j+=B;return}if(w.#j.length)w.#j+=B,B=w.#j,w.#j=\"\";const G=B.substring(0,K),M=G.indexOf(\"\\r\\n\");if(M===-1){w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Invalid HTTP request\")})),j.end();return}const Z=G.substring(0,M);if(Z!==\"HTTP/1.1 200 OK\"){w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(Z)})),j.end();return}let L=M+1,X=!1,J=-1;for(;;){let O=G.indexOf(\"\\r\\n\",L);if(O===-1){if(L>=G.length){if(!X)w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has no MIME type and \"text/event-stream\" is required. Aborting the connection.`)})),j.end();return}O=G.length}const Q=G.substring(L+1,O),W=Q.indexOf(\":\"),V=Q.substring(0,W),H=V.localeCompare(\"content-type\",@undefined,{sensitivity:\"accent\"})===0;if(L=O+1,H)if(Q.endsWith(\" text/event-stream\"))X=!0;else{w.#$=2,w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's response has a MIME type that is not \"text/event-stream\". Aborting the connection.`)})),j.end();return}else if(V.localeCompare(\"content-length\",@undefined,{sensitivity:\"accent\"})===0){if(J=parseInt(Q.substring(W+1).trim(),10),@isNaN(J)||J<=0){w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Content-Length is invalid. Aborting the connection.`)})),j.end();return}if(X)break}else if(V.localeCompare(\"transfer-encoding\",@undefined,{sensitivity:\"accent\"})===0){if(Q.substring(W+1).trim()!==\"chunked\"){w.dispatchEvent(new ErrorEvent(\"error\",{error:new Error(`EventSource's Transfer-Encoding is invalid. Aborting the connection.`)})),j.end();return}if(J=0,X)break}}w.#F=J,w.#$=1,w.dispatchEvent(new Event(\"open\"));const Y=B.substring(K+4);if(F.#Z(w,Y,0),w.#F>0){if(w.#G+=Y.length,w.#G>=w.#F)w.#$=2,j.end()}return}case 1:if(F.#Z(w,A.toString(),2),w.#F>0){if(w.#G+=A.byteLength,w.#G>=w.#F)w.#$=2,j.end()}return;default:break}},drain(j){const A=j.data;if(A.#$===0){const w=A.#j;if(w.length){const B=j.write(w);if(B!==w.length)j.data.#O=w.substring(B);else j.data.#O=\"\"}}},close:F.#W,end(j){F.#W(j).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Connection closed by server\")}))},timeout(j){F.#W(j).dispatchEvent(new ErrorEvent(\"error\",{error:new Error(\"Timeout\")}))},binaryType:\"buffer\"};static#W(j){const A=j.data;if(A.#A=null,A.#G=0,A.#$=2,A.#U){if(A.#w)clearTimeout(A.#w);A.#w=setTimeout(F.#V,A.#X,A)}return A}constructor(j,A=@undefined){super();const w=new URL(j);this.#M=w.protocol===\"https:\",this.#B=w,this.#$=2,process.nextTick(F.#V,this)}ref(){this.#w\?.ref(),this.#A\?.ref()}unref(){this.#w\?.unref(),this.#A\?.unref()}#H(){if(this.#$!==2)return;const j=this.#B,A=this.#M;this.#$=0,@Bun.connect({data:this,socket:F.#z,hostname:j.hostname,port:parseInt(j.port||(A\?\"443\":\"80\"),10),tls:A\?{requestCert:!0,rejectUnauthorized:!1}:!1}).catch((w)=>{if(super.dispatchEvent(new ErrorEvent(\"error\",{error:w})),this.#U){if(this.#w)this.#w.unref\?.();this.#w=setTimeout(F.#V,1000,this)}})}get url(){return this.#B.href}get readyState(){return this.#$}close(){this.#U=!1,this.#$=2,this.#A\?.unref(),this.#A\?.end()}get onopen(){return this.#L}get onerror(){return this.#J}get onmessage(){return this.#K}set onopen(j){if(this.#L)super.removeEventListener(\"close\",this.#L);super.addEventListener(\"open\",j),this.#L=j}set onerror(j){if(this.#J)super.removeEventListener(\"error\",this.#J);super.addEventListener(\"error\",j),this.#J=j}set onmessage(j){if(this.#K)super.removeEventListener(\"message\",this.#K);super.addEventListener(\"message\",j),this.#K=j}}return Object.defineProperty(F.prototype,\"CONNECTING\",{enumerable:!0,value:0}),Object.defineProperty(F.prototype,\"OPEN\",{enumerable:!0,value:1}),Object.defineProperty(F.prototype,\"CLOSED\",{enumerable:!0,value:2}),F[Symbol.for(\"CommonJS\")]=0,F})\n"; #define DEFINE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ JSC::FunctionExecutable* codeName##Generator(JSC::VM& vm) \ diff --git a/src/js/out/WebCoreJSBuiltins.h b/src/js/out/WebCoreJSBuiltins.h index 26c2fdee7..db4b19316 100644 --- a/src/js/out/WebCoreJSBuiltins.h +++ b/src/js/out/WebCoreJSBuiltins.h @@ -3396,6 +3396,95 @@ inline void TransformStreamDefaultControllerBuiltinsWrapper::exportNames() WEBCORE_FOREACH_TRANSFORMSTREAMDEFAULTCONTROLLER_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) #undef EXPORT_FUNCTION_NAME } +/* AsyncContext.ts */ +// getAsyncContext +#define WEBCORE_BUILTIN_ASYNCCONTEXT_GETASYNCCONTEXT 1 +extern const char* const s_asyncContextGetAsyncContextCode; +extern const int s_asyncContextGetAsyncContextCodeLength; +extern const JSC::ConstructAbility s_asyncContextGetAsyncContextCodeConstructAbility; +extern const JSC::ConstructorKind s_asyncContextGetAsyncContextCodeConstructorKind; +extern const JSC::ImplementationVisibility s_asyncContextGetAsyncContextCodeImplementationVisibility; + +// setAsyncContext +#define WEBCORE_BUILTIN_ASYNCCONTEXT_SETASYNCCONTEXT 1 +extern const char* const s_asyncContextSetAsyncContextCode; +extern const int s_asyncContextSetAsyncContextCodeLength; +extern const JSC::ConstructAbility s_asyncContextSetAsyncContextCodeConstructAbility; +extern const JSC::ConstructorKind s_asyncContextSetAsyncContextCodeConstructorKind; +extern const JSC::ImplementationVisibility s_asyncContextSetAsyncContextCodeImplementationVisibility; + +#define WEBCORE_FOREACH_ASYNCCONTEXT_BUILTIN_DATA(macro) \ + macro(getAsyncContext, asyncContextGetAsyncContext, 0) \ + macro(setAsyncContext, asyncContextSetAsyncContext, 1) \ + +#define WEBCORE_FOREACH_ASYNCCONTEXT_BUILTIN_CODE(macro) \ + macro(asyncContextGetAsyncContextCode, getAsyncContext, ASCIILiteral(), s_asyncContextGetAsyncContextCodeLength) \ + macro(asyncContextSetAsyncContextCode, setAsyncContext, ASCIILiteral(), s_asyncContextSetAsyncContextCodeLength) \ + +#define WEBCORE_FOREACH_ASYNCCONTEXT_BUILTIN_FUNCTION_NAME(macro) \ + macro(getAsyncContext) \ + macro(setAsyncContext) \ + +#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \ + JSC::FunctionExecutable* codeName##Generator(JSC::VM&); + +WEBCORE_FOREACH_ASYNCCONTEXT_BUILTIN_CODE(DECLARE_BUILTIN_GENERATOR) +#undef DECLARE_BUILTIN_GENERATOR + +class AsyncContextBuiltinsWrapper : private JSC::WeakHandleOwner { +public: + explicit AsyncContextBuiltinsWrapper(JSC::VM& vm) + : m_vm(vm) + WEBCORE_FOREACH_ASYNCCONTEXT_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_ASYNCCONTEXT_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_ASYNCCONTEXT_BUILTIN_CODE(EXPOSE_BUILTIN_EXECUTABLES) +#undef EXPOSE_BUILTIN_EXECUTABLES + + WEBCORE_FOREACH_ASYNCCONTEXT_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) + + void exportNames(); + +private: + JSC::VM& m_vm; + + WEBCORE_FOREACH_ASYNCCONTEXT_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_ASYNCCONTEXT_BUILTIN_CODE(DECLARE_BUILTIN_SOURCE_MEMBERS) +#undef DECLARE_BUILTIN_SOURCE_MEMBERS + +}; + +#define DEFINE_BUILTIN_EXECUTABLES(name, functionName, overriddenName, length) \ +inline JSC::UnlinkedFunctionExecutable* AsyncContextBuiltinsWrapper::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_ASYNCCONTEXT_BUILTIN_CODE(DEFINE_BUILTIN_EXECUTABLES) +#undef DEFINE_BUILTIN_EXECUTABLES + +inline void AsyncContextBuiltinsWrapper::exportNames() +{ +#define EXPORT_FUNCTION_NAME(name) m_vm.propertyNames->appendExternalName(name##PublicName(), name##PrivateName()); + WEBCORE_FOREACH_ASYNCCONTEXT_BUILTIN_FUNCTION_NAME(EXPORT_FUNCTION_NAME) +#undef EXPORT_FUNCTION_NAME +} /* ReadableStreamBYOBReader.ts */ // initializeReadableStreamBYOBReader #define WEBCORE_BUILTIN_READABLESTREAMBYOBREADER_INITIALIZEREADABLESTREAMBYOBREADER 1 @@ -4687,7 +4776,7 @@ extern const JSC::ConstructorKind s_readableStreamLazyAsyncIteratorCodeConstruct extern const JSC::ImplementationVisibility s_readableStreamLazyAsyncIteratorCodeImplementationVisibility; #define WEBCORE_FOREACH_READABLESTREAM_BUILTIN_DATA(macro) \ - macro(initializeReadableStream, readableStreamInitializeReadableStream, 2) \ + macro(initializeReadableStream, readableStreamInitializeReadableStream, 3) \ macro(readableStreamToArray, readableStreamReadableStreamToArray, 1) \ macro(readableStreamToText, readableStreamReadableStreamToText, 1) \ macro(readableStreamToArrayBuffer, readableStreamReadableStreamToArrayBuffer, 1) \ @@ -5605,6 +5694,7 @@ public: , m_consoleObjectBuiltins(m_vm) , m_readableStreamInternalsBuiltins(m_vm) , m_transformStreamDefaultControllerBuiltins(m_vm) + , m_asyncContextBuiltins(m_vm) , m_readableStreamBYOBReaderBuiltins(m_vm) , m_jsBufferConstructorBuiltins(m_vm) , m_readableStreamDefaultReaderBuiltins(m_vm) @@ -5638,6 +5728,7 @@ public: ConsoleObjectBuiltinsWrapper& consoleObjectBuiltins() { return m_consoleObjectBuiltins; } ReadableStreamInternalsBuiltinsWrapper& readableStreamInternalsBuiltins() { return m_readableStreamInternalsBuiltins; } TransformStreamDefaultControllerBuiltinsWrapper& transformStreamDefaultControllerBuiltins() { return m_transformStreamDefaultControllerBuiltins; } + AsyncContextBuiltinsWrapper& asyncContextBuiltins() { return m_asyncContextBuiltins; } ReadableStreamBYOBReaderBuiltinsWrapper& readableStreamBYOBReaderBuiltins() { return m_readableStreamBYOBReaderBuiltins; } JSBufferConstructorBuiltinsWrapper& jsBufferConstructorBuiltins() { return m_jsBufferConstructorBuiltins; } ReadableStreamDefaultReaderBuiltinsWrapper& readableStreamDefaultReaderBuiltins() { return m_readableStreamDefaultReaderBuiltins; } @@ -5666,6 +5757,7 @@ private: ConsoleObjectBuiltinsWrapper m_consoleObjectBuiltins; ReadableStreamInternalsBuiltinsWrapper m_readableStreamInternalsBuiltins; TransformStreamDefaultControllerBuiltinsWrapper m_transformStreamDefaultControllerBuiltins; + AsyncContextBuiltinsWrapper m_asyncContextBuiltins; ReadableStreamBYOBReaderBuiltinsWrapper m_readableStreamBYOBReaderBuiltins; JSBufferConstructorBuiltinsWrapper m_jsBufferConstructorBuiltins; ReadableStreamDefaultReaderBuiltinsWrapper m_readableStreamDefaultReaderBuiltins; diff --git a/src/js/out/modules/node/async_hooks.js b/src/js/out/modules/node/async_hooks.js index 60a1fa0a8..d2659dbcf 100644 --- a/src/js/out/modules/node/async_hooks.js +++ b/src/js/out/modules/node/async_hooks.js @@ -1,59 +1,153 @@ -import {drainMicrotasks} from "bun:jsc"; -var createHook = function() { +var createWarning = function(message) { + let warned = !1; + var wrapped = function() { + if (warned) + return; + if (new Error().stack.includes("zx/build/core.js")) + return; + warned = !0, console.warn("[bun] Warning:", message); + }; + return wrapped; +}, createHook = function(callbacks) { return { - enable() { - notImplemented(); - }, - disable() { - notImplemented(); - } + enable: createHookNotImpl, + disable: createHookNotImpl }; }, executionAsyncId = function() { - return 0; + return executionAsyncIdNotImpl(), 0; }, triggerAsyncId = function() { return 0; }, executionAsyncResource = function() { - return null; -}, notImplemented = () => { - console.warn("[bun] Warning: async_hooks has not been implemented yet. See https://github.com/oven-sh/bun/issues/1832"), notImplemented = () => { - }; -}; + return executionAsyncResourceWarning(), process.stdin; +}, { get, set, cleanupLater } = globalThis[Symbol.for("Bun.lazy")]("async_hooks"); class AsyncLocalStorage { - #store; - _enabled; + #disableCalled = !1; constructor() { - this._enabled = !1, this.#store = null; + } + static bind(fn, ...args) { + return this.snapshot().bind(null, fn, ...args); + } + static snapshot() { + var context = get(); + return (fn, ...args) => { + var prev = get(); + set(context); + try { + return fn(...args); + } catch (error) { + throw error; + } finally { + set(prev); + } + }; } enterWith(store) { - return this.#store = store, notImplemented(), this; + cleanupLater(); + var context = get(); + if (!context) { + set([this, store]); + return; + } + var { length } = context; + for (var i = 0;i < length; i += 2) + if (context[i] === this) { + const clone = context.slice(); + clone[i + 1] = store, set(clone); + return; + } + set(context.concat(this, store)); } exit(cb, ...args) { - this.#store = null, notImplemented(), typeof cb === "function" && cb(...args); + return this.run(void 0, cb, ...args); } run(store, callback, ...args) { - if (typeof callback !== "function") - throw new TypeError("ERR_INVALID_CALLBACK"); - var result, err; - if (process.nextTick((store2) => { - const prev = this.#store; - this.enterWith(store2); - try { - result = callback(...args); - } catch (e) { - err = e; - } finally { - this.#store = prev; + var context = get(), hasPrevious = !1, previous, i = 0, contextWasInit = !context; + if (contextWasInit) + set(context = [this, store]); + else { + if (context = context.slice(), i = context.indexOf(this), i > -1) + hasPrevious = !0, previous = context[i + 1], context[i + 1] = store; + else + context.push(this, store); + set(context); + } + try { + return callback(...args); + } catch (e) { + throw e; + } finally { + if (!this.#disableCalled) { + var context2 = get(); + if (context2 === context && contextWasInit) + set(void 0); + else if (context2 = context2.slice(), hasPrevious) + context2[i + 1] = previous, set(context2); + else + context2.splice(i, 2), set(context2.length ? context2 : void 0); } - }, store), drainMicrotasks(), typeof err !== "undefined") - throw err; - return result; + } + } + disable() { + if (!this.#disableCalled) { + var context = get(); + if (context) { + var { length } = context; + for (var i = 0;i < length; i += 2) + if (context[i] === this) { + context.splice(i, 2), set(context.length ? context : void 0); + break; + } + } + this.#disableCalled = !0; + } } getStore() { - return this.#store; + var context = get(); + if (!context) + return; + var { length } = context; + for (var i = 0;i < length; i += 2) + if (context[i] === this) + return context[i + 1]; + } +} + +class AsyncResource { + type; + #snapshot; + constructor(type, options) { + if (typeof type !== "string") + throw new TypeError('The "type" argument must be of type string. Received type ' + typeof type); + this.type = type, this.#snapshot = get(); + } + emitBefore() { + return !0; + } + emitAfter() { + return !0; + } + asyncId() { + return 0; + } + triggerAsyncId() { + return 0; + } + emitDestroy() { + } + runInAsyncScope(fn, thisArg, ...args) { + var prev = get(); + set(this.#snapshot); + try { + return fn.apply(thisArg, args); + } catch (error) { + throw error; + } finally { + set(prev); + } } } -var asyncWrapProviders = { +var createHookNotImpl = createWarning("async_hooks.createHook is not implemented in Bun. Hooks can still be created but will never be called."), executionAsyncIdNotImpl = createWarning("async_hooks.executionAsyncId/triggerAsyncId are not implemented in Bun. It will return 0 every time."), executionAsyncResourceWarning = createWarning("async_hooks.executionAsyncResource is not implemented in Bun. It returns a reference to process.stdin every time."), asyncWrapProviders = { NONE: 0, DIRHANDLE: 1, DNSCHANNEL: 2, @@ -113,40 +207,6 @@ var asyncWrapProviders = { VERIFYREQUEST: 56, INSPECTORJSBINDING: 57 }; - -class AsyncResource { - constructor(type, triggerAsyncId2) { - if (this.type = type, this.triggerAsyncId = triggerAsyncId2, AsyncResource.allowedRunInAsyncScope.has(type)) - this.runInAsyncScope = this.#runInAsyncScope; - } - static allowedRunInAsyncScope = new Set(["prisma-client-request"]); - type; - triggerAsyncId; - emitBefore() { - return !0; - } - emitAfter() { - return !0; - } - emitDestroy() { - } - runInAsyncScope; - #runInAsyncScope(fn, ...args) { - var result, err; - if (process.nextTick((fn2) => { - try { - result = fn2(...args); - } catch (err2) { - err = err2; - } - }, fn), drainMicrotasks(), err) - throw err; - return result; - } - asyncId() { - return 0; - } -} var async_hooks_default = { AsyncLocalStorage, createHook, @@ -155,7 +215,6 @@ var async_hooks_default = { executionAsyncResource, asyncWrapProviders, AsyncResource, - [Symbol.toStringTag]: "Module (not implemented yet)", [Symbol.for("CommonJS")]: 0 }; export { diff --git a/src/js/out/modules/node/events.js b/src/js/out/modules/node/events.js index 23adee4cc..21704b36d 100644 --- a/src/js/out/modules/node/events.js +++ b/src/js/out/modules/node/events.js @@ -327,10 +327,23 @@ class AbortError extends Error { this.code = "ABORT_ERR", this.name = "AbortError"; } } +var AsyncResource = null; class EventEmitterAsyncResource extends EventEmitter { - constructor(options = void 0) { - throwNotImplemented("EventEmitterAsyncResource", 1832); + triggerAsyncId; + asyncResource; + constructor(options) { + if (!AsyncResource) + AsyncResource = import.meta.require("async_hooks").AsyncResource; + var { captureRejections = !1, triggerAsyncId, name = new.target.name, requireManualDestroy } = options || {}; + super({ captureRejections }); + this.triggerAsyncId = triggerAsyncId ?? 0, this.asyncResource = new AsyncResource(name, { triggerAsyncId, requireManualDestroy }); + } + emit(...args) { + this.asyncResource.runInAsyncScope(() => super.emit(...args)); + } + emitDestroy() { + this.asyncResource.emitDestroy(); } } var usingDomains = !1; diff --git a/src/js/private.d.ts b/src/js/private.d.ts index 244187703..9ca25935d 100644 --- a/src/js/private.d.ts +++ b/src/js/private.d.ts @@ -187,6 +187,11 @@ interface BunLazyModules { functionRegular: any; callback: any; }; + "async_hooks": { + get: typeof import("./builtins/AsyncContext").getAsyncContext; + set: typeof import("./builtins/AsyncContext").setAsyncContext; + cleanupLater: () => void; + }; // ReadableStream related [1]: any; diff --git a/test/js/node/async_hooks/AsyncLocalStorage.test.ts b/test/js/node/async_hooks/AsyncLocalStorage.test.ts new file mode 100644 index 000000000..1a7aad050 --- /dev/null +++ b/test/js/node/async_hooks/AsyncLocalStorage.test.ts @@ -0,0 +1,568 @@ +import { AsyncLocalStorage, AsyncResource } from "async_hooks"; +import { beforeEach, describe, expect, test } from "bun:test"; + +describe("AsyncLocalStorage", () => { + test("throw inside of AsyncLocalStorage.run() will be passed out", () => { + const s = new AsyncLocalStorage(); + expect(() => { + s.run(1, () => { + throw new Error("error"); + }); + }).toThrow("error"); + }); +}); + +test("AsyncResource", () => { + const resource = new AsyncResource("prisma-client-request"); + var called = false; + resource.runInAsyncScope( + () => { + called = true; + }, + null, + "foo", + "bar", + ); + expect(called).toBe(true); +}); + +describe("async context passes through", () => { + beforeEach(() => { + /* @ts-ignore */ + const { set } = globalThis[Symbol.for("Bun.lazy")]("async_hooks"); + // just in case + set(undefined); + }); + test("syncronously", () => { + const s = new AsyncLocalStorage(); + s.run("value", () => { + expect(s.getStore()).toBe("value"); + }); + expect(s.getStore()).toBe(undefined); + s.run("value", () => { + s.run("second", () => { + expect(s.getStore()).toBe("second"); + }); + expect(s.getStore()).toBe("value"); + }); + expect(s.getStore()).toBe(undefined); + }); + test("promise.then", async () => { + const s = new AsyncLocalStorage<string>(); + let resolve!: () => void; + const promise = new Promise<void>(r => (resolve = r)); + let v!: string; + s.run("value", () => { + promise.then(() => { + v = s.getStore()!; + }); + }); + resolve(); + await promise; + expect(v).toBe("value"); + expect(s.getStore()).toBe(undefined); + }); + test("nested promises", async () => { + const s = new AsyncLocalStorage<string>(); + let resolve!: () => void; + let resolve2!: () => void; + const promise = new Promise<void>(r => (resolve = r)); + const promise2 = new Promise<void>(r => (resolve2 = r)); + let v!: string; + const resolved = Promise.resolve(5); + // console.log(1); + s.run("value", () => { + // console.log(2); + promise.then(() => { + // console.log(3); + new Promise<void>(resolve => { + // console.log(4); + setTimeout(() => { + // console.log(5); + resolve(); + }, 1); + }).then(() => { + // console.log(6); + resolved.then(() => { + // console.log(7); + v = s.getStore()!; + resolve2(); + }); + }); + }); + }); + resolve(); + await promise2; + expect(v).toBe("value"); + expect(s.getStore()).toBe(undefined); + }); + test("await 1", async () => { + const s = new AsyncLocalStorage<string>(); + await s.run("value", async () => { + expect(s.getStore()).toBe("value"); + await 1; + expect(s.getStore()).toBe("value"); + }); + expect(s.getStore()).toBe(undefined); + }); + test("await an actual promise", async () => { + const s = new AsyncLocalStorage<string>(); + await s.run("value", async () => { + expect(s.getStore()).toBe("value"); + await Promise.resolve(1); + expect(s.getStore()).toBe("value"); + await Bun.sleep(2); + expect(s.getStore()).toBe("value"); + }); + expect(s.getStore()).toBe(undefined); + }); + test("setTimeout", async () => { + let resolve: (x: string) => void; + const promise = new Promise<string>(r => (resolve = r)); + const s = new AsyncLocalStorage<string>(); + s.run("value", () => { + expect(s.getStore()).toBe("value"); + setTimeout(() => { + resolve(s.getStore()!); + }, 2); + }); + expect(s.getStore()).toBe(undefined); + expect(await promise).toBe("value"); + }); + test("setInterval", async () => { + let resolve: (x: string[]) => void; + const promise = new Promise<string[]>(r => (resolve = r)); + const s = new AsyncLocalStorage<string>(); + await s.run("value", () => { + expect(s.getStore()).toBe("value"); + const array: string[] = []; + const interval = setInterval(() => { + array.push(s.getStore()!); + if (array.length === 3) { + clearInterval(interval); + resolve(array); + } + }, 5); + }); + expect(s.getStore()).toBe(undefined); + expect(await promise).toEqual(["value", "value", "value"]); + }); + test("setImmediate", async () => { + let resolve: (x: string) => void; + const promise = new Promise<string>(r => (resolve = r)); + const s = new AsyncLocalStorage<string>(); + await s.run("value", () => { + expect(s.getStore()).toBe("value"); + setImmediate(() => { + resolve(s.getStore()!); + }); + }); + expect(s.getStore()).toBe(undefined); + expect(await promise).toBe("value"); + }); + test("process.nextTick", async () => { + let resolve: (x: string) => void; + const promise = new Promise<string>(r => (resolve = r)); + const s = new AsyncLocalStorage<string>(); + await s.run("value", () => { + expect(s.getStore()).toBe("value"); + process.nextTick(() => { + resolve(s.getStore()!); + }); + }); + expect(s.getStore()).toBe(undefined); + expect(await promise).toBe("value"); + }); + test("queueMicrotask", async () => { + let resolve: (x: string) => void; + const promise = new Promise<string>(r => (resolve = r)); + const s = new AsyncLocalStorage<string>(); + await s.run("value", () => { + expect(s.getStore()).toBe("value"); + queueMicrotask(() => { + resolve(s.getStore()!); + }); + }); + expect(s.getStore()).toBe(undefined); + expect(await promise).toBe("value"); + }); + test("promise catch", async () => { + const s = new AsyncLocalStorage<string>(); + let reject!: () => void; + let promise = new Promise<void>((_, r) => (reject = r)); + let v!: string; + s.run("value", () => { + promise = promise.catch(() => { + v = s.getStore()!; + }); + }); + reject(); + await promise; + expect(v).toBe("value"); + expect(s.getStore()).toBe(undefined); + }); + test("promise finally", async () => { + const s = new AsyncLocalStorage<string>(); + let resolve!: () => void; + let promise = new Promise<void>(r => (resolve = r)); + let v!: string; + s.run("value", () => { + promise = promise.finally(() => { + v = s.getStore()!; + }); + }); + resolve(); + await promise; + expect(v).toBe("value"); + expect(s.getStore()).toBe(undefined); + }); + test("fetch", async () => { + const s = new AsyncLocalStorage<string>(); + await s.run("value", async () => { + expect(s.getStore()).toBe("value"); + const response = await fetch("https://bun.sh") // + .then(r => { + expect(s.getStore()).toBe("value"); + return true; + }); + expect(s.getStore()).toBe("value"); + expect(response).toBe(true); + }); + expect(s.getStore()).toBe(undefined); + }); + test("Bun.spawn() onExit", async () => { + const s = new AsyncLocalStorage<string>(); + let value: string | undefined; + let resolve!: () => void; + const promise = new Promise<void>(r => (resolve = r)); + await s.run("value", () => { + expect(s.getStore()).toBe("value"); + + const x = Bun.spawn({ + cmd: ["echo", "hello"], + onExit(subprocess, exitCode, signalCode, error) { + value = s.getStore()!; + resolve(); + }, + }); + + expect(s.getStore()).toBe("value"); + }); + expect(s.getStore()).toBe(undefined); + await promise; + expect(value).toBe("value"); + }); + test("Bun.serve", async () => { + const s = new AsyncLocalStorage<string>(); + await s.run("value", async () => { + expect(s.getStore()).toBe("value"); + + const server = Bun.serve({ + port: 0, + fetch(request, server) { + return new Response(s.getStore()!); + }, + }); + + const response = await fetch(server.hostname + ":" + server.port); + expect(await response.text()).toBe("value"); + + expect(s.getStore()).toBe("value"); + }); + expect(s.getStore()).toBe(undefined); + }); + test("readable stream .start", async () => { + const s = new AsyncLocalStorage<string>(); + let stream!: ReadableStream; + s.run("value", async () => { + stream = new ReadableStream({ + start(controller) { + controller.enqueue(s.getStore()!); + controller.close(); + }, + }); + }); + const reader = stream.getReader(); + const result = await reader.read(); + expect(result.value).toBe("value"); + const result2 = await reader.read(); + expect(result2.done).toBe(true); + expect(s.getStore()).toBe(undefined); + }); + test("readable stream .pull", async () => { + const s = new AsyncLocalStorage<string>(); + let stream!: ReadableStream; + s.run("value", async () => { + stream = new ReadableStream( + { + start(controller) { + controller.enqueue(new Uint8Array(500)); + }, + pull(controller) { + controller.enqueue(s.getStore()!); + controller.close(); + }, + }, + { + highWaterMark: 1, + size() { + return 500; + }, + }, + ); + }); + const reader = stream.getReader(); + const result = await reader.read(); + const result2 = await reader.read(); + expect(result2.value).toBe("value"); + const result3 = await reader.read(); + expect(result3.done).toBe(true); + expect(s.getStore()).toBe(undefined); + }); + test("readable stream .pull 2", async () => { + const s = new AsyncLocalStorage<string>(); + let stream!: ReadableStream; + let n = 0; + s.run("value", async () => { + stream = new ReadableStream( + { + start(controller) { + controller.enqueue(new Uint8Array(500)); + }, + async pull(controller) { + controller.enqueue(s.getStore()!); + n++; + if (n < 5) { + await new Promise(r => setTimeout(r, 1)); + } else { + controller.close(); + } + }, + }, + { + highWaterMark: 1, + size() { + return 500; + }, + }, + ); + }); + expect(s.getStore()).toBe(undefined); + const reader = stream.getReader(); + const result = await reader.read(); + const result2 = await reader.read(); + expect(result2.value).toBe("value"); + const result3 = await reader.read(); + expect(result3.value).toBe("value"); + const result4 = await reader.read(); + expect(result4.value).toBe("value"); + const result5 = await reader.read(); + expect(result5.value).toBe("value"); + const result6 = await reader.read(); + expect(result6.value).toBe("value"); + const result7 = await reader.read(); + expect(result7.done).toBe(true); + expect(s.getStore()).toBe(undefined); + }); + test("readable stream .cancel", async () => { + const s = new AsyncLocalStorage<string>(); + let stream!: ReadableStream; + let value: string | undefined; + let resolve!: () => void; + let promise = new Promise<void>(r => (resolve = r)); + s.run("value", async () => { + stream = new ReadableStream({ + start(controller) {}, + cancel(reason) { + value = s.getStore(); + resolve(); + }, + }); + }); + expect(s.getStore()).toBe(undefined); + const reader = stream.getReader(); + reader.cancel(); + await promise; + expect(value).toBe("value"); + }); + test("readable stream direct .pull", async () => { + const s = new AsyncLocalStorage<string>(); + let stream!: ReadableStream; + let value: string | undefined; + let value2: string | undefined; + let resolve!: () => void; + let promise = new Promise<void>(r => (resolve = r)); + s.run("value", async () => { + stream = new ReadableStream({ + type: "direct", + pull(controller) { + value = s.getStore(); + controller.write("hello"); + controller.close(); + resolve(); + }, + cancel(reason) {}, + }); + }); + expect(s.getStore()).toBe(undefined); + const reader = stream.getReader(); + await reader.read(); + await promise; + expect(value).toBe("value"); + }); + // blocked by a bug with .cancel + test.todo("readable stream direct .cancel", async () => { + const s = new AsyncLocalStorage<string>(); + let stream!: ReadableStream; + let value: string | undefined; + let value2: string | undefined; + let resolve!: () => void; + let promise = new Promise<void>(r => (resolve = r)); + s.run("value", async () => { + stream = new ReadableStream({ + type: "direct", + pull(controller) { + value = s.getStore(); + controller.write("hello"); + }, + cancel(reason) { + console.log("1"); + value2 = s.getStore(); + resolve(); + }, + }); + }); + expect(s.getStore()).toBe(undefined); + const reader = stream.getReader(); + await reader.read(); + await reader.cancel(); + await stream.cancel(); + await promise; + expect(value).toBe("value"); + expect(value2).toBe("value"); + }); + test("Websocket Server", async () => { + const s = new AsyncLocalStorage<string>(); + let values_server: string[] = []; + let resolve: () => void; + const promise = new Promise<void>(r => (resolve = r)); + await s.run("value", async () => { + expect(s.getStore()).toBe("value"); + + const server = Bun.serve({ + port: 0, + fetch(request, server) { + if (server.upgrade(request)) return null as any; + return new Response(s.getStore()!); + }, + websocket: { + open(ws) { + values_server.push("open:" + s.getStore()); + }, + message(ws, message) { + values_server.push("message:" + s.getStore()); + ws.close(); + }, + close(ws, code, message) { + values_server.push("close:" + s.getStore()); + }, + }, + }); + + const ws = new WebSocket("ws://" + server.hostname + ":" + server.port); + ws.addEventListener("open", () => { + ws.send("hello"); + }); + ws.addEventListener("close", () => { + resolve(); + }); + }); + expect(s.getStore()).toBe(undefined); + await promise; + expect(values_server).toEqual(["open:value", "message:value", "close:value"]); + }); + test.todo("WebSocket client", async () => { + const s = new AsyncLocalStorage<string>(); + let values_client: string[] = []; + let resolve: () => void; + const promise = new Promise<void>(r => (resolve = r)); + await s.run("value", async () => { + expect(s.getStore()).toBe("value"); + + const server = Bun.serve({ + port: 0, + fetch(request, server) { + if (server.upgrade(request)) return null as any; + return new Response(s.getStore()!); + }, + websocket: { + open(ws) {}, + message(ws, message) { + ws.close(); + }, + close(ws, code, message) {}, + }, + }); + + const ws = new WebSocket("ws://" + server.hostname + ":" + server.port); + ws.addEventListener("open", () => { + ws.send("hello"); + values_client.push("open:" + s.getStore()); + }); + ws.addEventListener("close", () => { + resolve(); + values_client.push("close:" + s.getStore()); + }); + }); + expect(s.getStore()).toBe(undefined); + await promise; + expect(values_client).toEqual(["open:value", "close:value"]); + }); + test("node:fs callback", async () => { + const fs = require("fs"); + const s = new AsyncLocalStorage<string>(); + let resolve: (x: string) => void; + const promise = new Promise<string>(r => (resolve = r)); + await s.run("value", async () => { + expect(s.getStore()).toBe("value"); + fs.readFile(import.meta.path, () => { + resolve(s.getStore()!); + }); + expect(s.getStore()).toBe("value"); + }); + expect(s.getStore()).toBe(undefined); + expect(await promise).toBe("value"); + }); + test("node:fs/promises", async () => { + const fs = require("fs").promises; + const s = new AsyncLocalStorage<string>(); + let v!: string; + await s.run("value", async () => { + expect(s.getStore()).toBe("value"); + await fs.readFile(import.meta.path).then(() => { + v = s.getStore()!; + }); + expect(s.getStore()).toBe("value"); + }); + expect(s.getStore()).toBe(undefined); + expect(v).toBe("value"); + }); + test("Bun.build plugin", async () => { + const s = new AsyncLocalStorage<string>(); + let a = undefined; + await s.run("value", async () => { + Bun.build({ + entrypoints: [import.meta.path], + plugins: [ + { + name: "test", + setup(build) { + a = s.getStore(); + }, + }, + ], + }); + }); + expect(a).toBe("value"); + }); +}); diff --git a/test/js/node/async_hooks/EventEmitterAsyncResource.test.ts b/test/js/node/async_hooks/EventEmitterAsyncResource.test.ts new file mode 100644 index 000000000..bbcadf9bf --- /dev/null +++ b/test/js/node/async_hooks/EventEmitterAsyncResource.test.ts @@ -0,0 +1,29 @@ +import EventEmitter, { EventEmitterAsyncResource } from "events"; +import { AsyncLocalStorage } from "async_hooks"; +import { describe, test, expect } from "bun:test"; + +describe("EventEmitterAsyncResource", () => { + test("is an EventEmitter", () => { + const ee = new EventEmitterAsyncResource("test"); + expect(ee).toBeInstanceOf(EventEmitterAsyncResource); + expect(ee).toBeInstanceOf(EventEmitter); + }); + test("has context tracking", () => { + let ee; + const asl = new AsyncLocalStorage(); + asl.run(123, () => { + ee = new EventEmitterAsyncResource("test"); + }); + + let val; + ee.on("test", () => { + val = asl.getStore(); + }); + + asl.run(456, () => { + ee.emit("test"); + }); + + expect(val).toBe(123); + }); +}); diff --git a/test/js/node/async_hooks/async_hooks.node.test.ts b/test/js/node/async_hooks/async_hooks.node.test.ts new file mode 100644 index 000000000..107c58a8c --- /dev/null +++ b/test/js/node/async_hooks/async_hooks.node.test.ts @@ -0,0 +1,34 @@ +import { AsyncLocalStorage } from "async_hooks"; +import assert from "assert"; + +test("node async_hooks.AsyncLocalStorage enable disable", async () => { + const asyncLocalStorage = new AsyncLocalStorage(); + + asyncLocalStorage.run(new Map(), () => { + asyncLocalStorage.getStore().set("foo", "bar"); + process.nextTick(() => { + assert.strictEqual(asyncLocalStorage.getStore().get("foo"), "bar"); + process.nextTick(() => { + assert.strictEqual(asyncLocalStorage.getStore(), undefined); + }); + + asyncLocalStorage.disable(); + assert.strictEqual(asyncLocalStorage.getStore(), undefined); + + // Calls to exit() should not mess with enabled status + asyncLocalStorage.exit(() => { + assert.strictEqual(asyncLocalStorage.getStore(), undefined); + }); + assert.strictEqual(asyncLocalStorage.getStore(), undefined); + + process.nextTick(() => { + assert.strictEqual(asyncLocalStorage.getStore(), undefined); + asyncLocalStorage.run(new Map().set("bar", "foo"), () => { + assert.strictEqual(asyncLocalStorage.getStore().get("bar"), "foo"); + + done(); + }); + }); + }); + }); +}); diff --git a/test/js/node/disabled-module.test.js b/test/js/node/disabled-module.test.js index bb707a122..7333a0f1f 100644 --- a/test/js/node/disabled-module.test.js +++ b/test/js/node/disabled-module.test.js @@ -1,5 +1,4 @@ import { expect, test } from "bun:test"; -import { AsyncResource, AsyncLocalStorage } from "async_hooks"; import * as worker_threads from "worker_threads"; import worker_threads_default from "worker_threads"; @@ -10,32 +9,6 @@ test("not implemented yet module masquerades as undefined and throws an error", expect(typeof worker_threads_default.getEnvironmentData).toBe("undefined"); }); -test("AsyncLocalStorage polyfill", () => { - const store = new AsyncLocalStorage(); - var called = false; - expect(store.getStore()).toBe(null); - store.run({ foo: "bar" }, () => { - expect(store.getStore()).toEqual({ foo: "bar" }); - called = true; - }); - expect(store.getStore()).toBe(null); - expect(called).toBe(true); -}); - -test("AsyncResource polyfill", () => { - const resource = new AsyncResource("prisma-client-request"); - var called = false; - resource.runInAsyncScope( - () => { - called = true; - }, - null, - "foo", - "bar", - ); - expect(called).toBe(true); -}); - test("esbuild functions with worker_threads stub", async () => { const esbuild = await import("esbuild"); const result = await esbuild.transform('console . log( "hello world" )', { minify: true }); |