aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-06-19 00:33:14 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-06-19 00:33:14 -0700
commitcbd6d24d34b78de2b28fad75df2be1b728561d93 (patch)
tree0d0fd24cf7f7bbdbe0b33bdc7a0ced69cb583f80 /src
parentb951c1f89e90aeb4507d4402b4f1f5e5520b4923 (diff)
downloadbun-cbd6d24d34b78de2b28fad75df2be1b728561d93.tar.gz
bun-cbd6d24d34b78de2b28fad75df2be1b728561d93.tar.zst
bun-cbd6d24d34b78de2b28fad75df2be1b728561d93.zip
Move this code up a bit
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp41
1 files changed, 17 insertions, 24 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index 6b58c241f..ec4976bc4 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -222,25 +222,6 @@ extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(c
JSC::Options::showPrivateScriptsInStackTraces() = true;
JSC::Options::useSetMethods() = true;
- bool didSetForceRAMSize = false;
-
- 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));
- }
-
- didSetForceRAMSize = didSetForceRAMSize || strcmp(env + 8, "forceRAMSize") == 0;
- }
- }
-
/*
* The Magic "Use Less RAM" button
*/
@@ -298,13 +279,25 @@ extern "C" void JSCInitialize(const char* envp[], size_t envc, void (*onCrash)(c
// crypto.createHash("sha256") 964 ns/iter (946.02 ns … 1.1 µs) 962.95 ns 1.1 µs 1.1 µs
// crypto.createHash("sha1") 985.26 ns/iter (956.7 ns … 1.12 µs) 1 µs 1.12 µs 1.12 µs
// Peak memory usage: 56 MB
+ size_t ramSize = WTF::ramSize();
+ ramSize /= 1024;
- if (!didSetForceRAMSize) {
- size_t ramSize = WTF::ramSize();
- ramSize /= 1024;
+ if (ramSize > 0) {
+ JSC::Options::forceRAMSize() = ramSize;
+ }
- if (ramSize > 0) {
- JSC::Options::forceRAMSize() = ramSize;
+ 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));
+ }
}
}