Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/jsc/bindings/ZigGlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,14 @@ extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(c
continue;
}

if (!JSC::Options::setOption(env + 8)) [[unlikely]] {
// Options::initialize runs notifyOptionsChanged once after this callback, and
// that pass applies jitPolicyScale. Verifying each option here would apply the
// scale once per BUN_JSC_ variable.
Comment thread
robobun marked this conversation as resolved.
Resolved
if (!JSC::Options::setOption(env + 8, /* verify */ false)) [[unlikely]] {
onCrash(env, strlen(env));
}
}
}
JSC::Options::assertOptionsAreCoherent();
}); // end JSC::initialize lambda

#if OS(WINDOWS) && (CPU(X86_64) || CPU(ARM64))
Expand Down
19 changes: 19 additions & 0 deletions test/cli/run/env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1277,4 +1277,23 @@ describe("JSC option environment variables", () => {
expect(stderr).not.toContain("thresholdForJITAfterWarmUp=77");
expect(exitCode).toBe(0);
});
test.concurrent("BUN_JSC_jitPolicyScale is applied once, whatever else is set", async () => {
// JSC multiplies the tier-up thresholds by the scale every time it verifies an option change.
// The options are set without verification and verified once at the end, so the other
// BUN_JSC_ variables do not compound the scale: 1000 * 0.5 is 500, not 500 * 0.5 * 0.5.
const { stderr, exitCode } = await dumpOptions({
BUN_JSC_dumpOptions: "2",
BUN_JSC_jitPolicyScale: "0.5",
BUN_JSC_useConcurrentJIT: "0",
});
expect(stderr).toMatch(/^\s*thresholdForOptimizeAfterWarmUp=500$/m);
expect(exitCode).toBe(0);
});
test.concurrent("an option that needs the verification pass starts up", async () => {
// useProfiler=1 is only coherent once notifyOptionsChanged has turned on disassembly support,
// so the options must not be checked for coherence before that pass.
const { stderr, exitCode } = await dumpOptions({ BUN_JSC_useProfiler: "1" });
expect(stderr).toBe("");
expect(exitCode).toBe(0);
});
Comment thread
robobun marked this conversation as resolved.
Resolved
});
Loading