Bug 1038274 - Add max heap size constants to pass to JS_NewRuntime() r=terrence

This commit is contained in:
Jon Coppeard 2014-07-16 10:01:20 +01:00
Родитель 8b4f6eb2b3
Коммит 948a1ddf13
3 изменённых файлов: 8 добавлений и 11 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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<JS::AutoDisableGenerationalGC> noggc;
if (op.getBoolOption("no-ggc"))

Просмотреть файл

@ -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