diff --git a/js/public/HeapAPI.h b/js/public/HeapAPI.h index d9fcb99c032e..bccc4925d287 100644 --- a/js/public/HeapAPI.h +++ b/js/public/HeapAPI.h @@ -100,6 +100,12 @@ struct Zone; /* Default size for the generational nursery in bytes. */ const uint32_t DefaultNurseryBytes = 16 * 1024 * 1024; +/* Default maximum heap size in bytes to pass to JS_NewRuntime(). */ +const uint32_t DefaultHeapMaxBytes = 32 * 1024 * 1024; + +/* Value indicating no maximum heap size to pass to JS_NewRuntime(). */ +const uint32_t UnlimitedHeapMaxBytes = 0xffffffff; + /* * We cannot expose the class hierarchy: the implementation is hidden. Instead * we provide cast functions with strong debug-mode assertions. diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 76f1fb706461..46a798292685 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -6419,7 +6419,7 @@ main(int argc, char **argv, char **envp) #endif /* Use the same parameters as the browser in xpcjsruntime.cpp. */ - rt = JS_NewRuntime(32L * 1024L * 1024L, nurseryBytes); + rt = JS_NewRuntime(JS::UnlimitedHeapMaxBytes, nurseryBytes); if (!rt) return 1; @@ -6429,7 +6429,6 @@ main(int argc, char **argv, char **envp) gInterruptFunc.construct(rt, NullValue()); - JS_SetGCParameter(rt, JSGC_MAX_BYTES, 0xffffffff); #ifdef JSGC_GENERATIONAL Maybe noggc; if (op.getBoolOption("no-ggc")) diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index f25db8e86c1c..ae244224d75d 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -3069,7 +3069,7 @@ static const JSWrapObjectCallbacks WrapObjectCallbacks = { }; XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect) - : CycleCollectedJSRuntime(nullptr, 32L * 1024L * 1024L), + : CycleCollectedJSRuntime(nullptr, JS::UnlimitedHeapMaxBytes), mJSContextStack(new XPCJSContextStack(MOZ_THIS_IN_INITIALIZER_LIST())), mCallContext(nullptr), mAutoRoots(nullptr), @@ -3108,14 +3108,6 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect) memset(rtPrivate, 0, sizeof(PerThreadAtomCache)); JS_SetRuntimePrivate(runtime, rtPrivate); - // Unconstrain the runtime's threshold on nominal heap size, to avoid - // triggering GC too often if operating continuously near an arbitrary - // finite threshold (0xffffffff is infinity for uint32_t parameters). - // This leaves the maximum-JS_malloc-bytes threshold still in effect - // to cause period, and we hope hygienic, last-ditch GCs from within - // the GC's allocator. - JS_SetGCParameter(runtime, JSGC_MAX_BYTES, 0xffffffff); - // The JS engine permits us to set different stack limits for system code, // trusted script, and untrusted script. We have tests that ensure that // we can always execute 10 "heavy" (eval+with) stack frames deeper in