Bug 1271854 - Part 3: Avoid saving the GC zeal string inside the JS shell; r=terrence

This will ensure that the GC zeal argument won't get truncated needlessly.
This commit is contained in:
Ehsan Akhgari 2016-05-12 10:20:37 -04:00
parent 7345ba362b
commit 73f2ed803a

View File

@ -186,7 +186,8 @@ static bool enableNativeRegExp = false;
static bool enableUnboxedArrays = false;
static bool enableSharedMemory = SHARED_MEMORY_DEFAULT;
#ifdef JS_GC_ZEAL
static char gZealStr[128];
static uint32_t gZealBits = 0;
static uint32_t gZealFrequency = 0;
#endif
static bool printTiming = false;
static const char* jsCacheDir = nullptr;
@ -7013,12 +7014,11 @@ SetRuntimeOptions(JSRuntime* rt, const OptionParser& op)
#ifdef JS_GC_ZEAL
const char* zealStr = op.getStringOption("gc-zeal");
gZealStr[0] = 0;
if (zealStr) {
if (!rt->gc.parseAndSetZeal(zealStr))
return false;
strncpy(gZealStr, zealStr, sizeof(gZealStr));
gZealStr[sizeof(gZealStr)-1] = 0;
uint32_t nextScheduled;
rt->gc.getZealBits(&gZealBits, &gZealFrequency, &nextScheduled);
}
#endif
@ -7039,8 +7039,13 @@ SetWorkerRuntimeOptions(JSRuntime* rt)
rt->profilingScripts = enableCodeCoverage || enableDisassemblyDumps;
#ifdef JS_GC_ZEAL
if (*gZealStr)
rt->gc.parseAndSetZeal(gZealStr);
if (gZealBits && gZealFrequency) {
#define ZEAL_MODE(_, value) \
if (gZealBits & (1 << value)) \
rt->gc.setZeal(value, gZealFrequency);
JS_FOR_EACH_ZEAL_MODE(ZEAL_MODE)
#undef ZEAL_MODE
}
#endif
JS_SetNativeStackQuota(rt, gMaxStackSize);