Skip to content

Commit ae4a68e

Browse files
Jake ChampionJakeChampion
authored andcommitted
add --enable-experimental-byob-streams flag to turn the feature on
1 parent 11eac9a commit ae4a68e

File tree

6 files changed

+19
-8
lines changed

6 files changed

+19
-8
lines changed

c-dependencies/js-compute-runtime/js-compute-runtime.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@ bool init_js() {
115115
if (!js::UseInternalJobQueues(cx) || !JS::InitSelfHostedCode(cx))
116116
return false;
117117

118+
bool ENABLE_EXPERIMENTAL_BYOB_STREAMS = std::string(std::getenv("ENABLE_EXPERIMENTAL_BYOB_STREAMS")) == "1";
119+
118120
// TODO: check if we should set a different creation zone.
119121
JS::RealmOptions options;
120122
options.creationOptions()
121123
.setStreamsEnabled(true)
122-
.setReadableByteStreamsEnabled(true)
123-
.setBYOBStreamReadersEnabled(true)
124+
.setReadableByteStreamsEnabled(ENABLE_EXPERIMENTAL_BYOB_STREAMS)
125+
.setBYOBStreamReadersEnabled(ENABLE_EXPERIMENTAL_BYOB_STREAMS)
124126
.setReadableStreamPipeToEnabled(true)
125127
.setWritableStreamsEnabled(true)
126128
.setWeakRefsEnabled(JS::WeakRefSpecifier::EnabledWithoutCleanupSome);

c-dependencies/spidermonkey

integration-tests/js-compute/fixtures/byob/fastly.toml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ name = "byob"
99
service_id = ""
1010

1111
[scripts]
12-
build = "node ../../../../js-compute-runtime-cli.js"
12+
build = "node ../../../../js-compute-runtime-cli.js --enable-experimental-byob-streams"

js-compute-runtime-cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { printVersion } from "./src/printVersion.js";
55
import { printHelp } from "./src/printHelp.js";
66
import { addSdkMetadataField } from "./src/addSdkMetadataField.js";
77

8-
const {wasmEngine, input, component, output, version, help} = await parseInputs(process.argv.slice(2))
8+
const {enableExperimentalByobStreams, wasmEngine, input, component, output, version, help} = await parseInputs(process.argv.slice(2))
99

1010
if (version) {
1111
await printVersion();
@@ -19,7 +19,7 @@ if (version) {
1919
// it could be that the user is using an older version of js-compute-runtime
2020
// and a newer version does support the platform they are using.
2121
const {compileApplicationToWasm} = await import('./src/compileApplicationToWasm.js')
22-
await compileApplicationToWasm(input, output, wasmEngine);
22+
await compileApplicationToWasm(input, output, wasmEngine, enableExperimentalByobStreams);
2323
if (component) {
2424
const {compileComponent} = await import('./src/component.js');
2525
await compileComponent(output);

src/compileApplicationToWasm.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { precompile } from "./precompile.js";
88
import { bundle } from "./bundle.js";
99
import { containsSyntaxErrors } from "./containsSyntaxErrors.js";
1010

11-
export async function compileApplicationToWasm(input, output, wasmEngine) {
11+
export async function compileApplicationToWasm(input, output, wasmEngine, enableExperimentalByobStreams = false) {
1212
try {
1313
if (!(await isFile(input))) {
1414
console.error(
@@ -85,6 +85,7 @@ export async function compileApplicationToWasm(input, output, wasmEngine) {
8585
let wizerProcess = spawnSync(
8686
wizer,
8787
[
88+
"--inherit-env=true",
8889
"--allow-wasi",
8990
`--dir=.`,
9091
`--wasm-bulk-memory=true`,
@@ -97,6 +98,9 @@ export async function compileApplicationToWasm(input, output, wasmEngine) {
9798
input: application,
9899
shell: true,
99100
encoding: "utf-8",
101+
env: {
102+
ENABLE_EXPERIMENTAL_BYOB_STREAMS: enableExperimentalByobStreams ? 1 : 0
103+
}
100104
}
101105
);
102106
process.exitCode = wizerProcess.status;

src/parseInputs.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export async function parseInputs(cliInputs) {
77
const __dirname = dirname(fileURLToPath(import.meta.url));
88

99
let component = false;
10+
let enableExperimentalByobStreams = false;
1011
let customEngineSet = false;
1112
let wasmEngine = join(__dirname, "../js-compute-runtime.wasm");
1213
let customInputSet = false;
@@ -20,6 +21,10 @@ export async function parseInputs(cliInputs) {
2021
case "--": {
2122
break loop;
2223
}
24+
case "--enable-experimental-byob-streams": {
25+
enableExperimentalByobStreams = true;
26+
break;
27+
}
2328
case "-V":
2429
case "--version": {
2530
return { version: true };
@@ -88,5 +93,5 @@ export async function parseInputs(cliInputs) {
8893
}
8994
}
9095
}
91-
return { wasmEngine, component, input, output };
96+
return { wasmEngine, component, input, output, enableExperimentalByobStreams };
9297
}

0 commit comments

Comments
 (0)