aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/ZigGlobalObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bun.js/bindings/ZigGlobalObject.cpp')
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp18
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();
}
}