diff options
author | 2023-02-28 21:56:09 -0800 | |
---|---|---|
committer | 2023-02-28 21:56:28 -0800 | |
commit | 45704a55dcee86c2b0f623dce55215ad21737d68 (patch) | |
tree | 55c5baa64407cc2a408bbd1bceca319b3771639b /src/bun.js/bindings/ZigGlobalObject.cpp | |
parent | 714b8d10e021a03ed75738459f02ab25239d7dcd (diff) | |
download | bun-45704a55dcee86c2b0f623dce55215ad21737d68.tar.gz bun-45704a55dcee86c2b0f623dce55215ad21737d68.tar.zst bun-45704a55dcee86c2b0f623dce55215ad21737d68.zip |
Expose JSC::Options via `BUN_JSC_` prefix
Example usage:
BUN_JSC_logGC=1 bun file.js
Diffstat (limited to 'src/bun.js/bindings/ZigGlobalObject.cpp')
-rw-r--r-- | src/bun.js/bindings/ZigGlobalObject.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index c4b63869e..7878b96a7 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -181,7 +181,7 @@ constexpr size_t DEFAULT_ERROR_STACK_TRACE_LIMIT = 10; // #include <iostream> static bool has_loaded_jsc = false; -extern "C" void JSCInitialize() +extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(const char* ptr, size_t length)) { if (has_loaded_jsc) return; @@ -208,6 +208,22 @@ extern "C" void JSCInitialize() JSC::Options::useResizableArrayBuffer() = true; JSC::Options::showPrivateScriptsInStackTraces() = true; JSC::Options::useSetMethods() = true; + + if (LIKELY(envc > 0)) { + while (envc--) { + const char* env = (const char*)envp[envc]; + // need to check for \0 so we might as well make this single pass + // strlen would check the end of the string + if (LIKELY(!(env[0] == 'B' && env[1] == 'U' && env[2] == 'N' && env[3] == '_' && env[4] == 'J' && env[5] == 'S' && env[6] == 'C' && env[7] == '_'))) { + continue; + } + + if (UNLIKELY(!JSC::Options::setOption(env + 8))) { + onCrash(env, strlen(env)); + } + } + } + JSC::Options::assertOptionsAreCoherent(); } } |