mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 20:30:41 +00:00
Bug 1101602 - Add --gc-zeal option to JS shell r=sfink
This commit is contained in:
parent
099d9f90d0
commit
365b464e2e
@ -324,6 +324,7 @@ class GCRuntime
|
||||
#ifdef JS_GC_ZEAL
|
||||
const void *addressOfZealMode() { return &zealMode; }
|
||||
void setZeal(uint8_t zeal, uint32_t frequency);
|
||||
bool parseAndSetZeal(const char *str);
|
||||
void setNextScheduled(uint32_t count);
|
||||
void verifyPreBarriers();
|
||||
void verifyPostBarriers();
|
||||
@ -532,7 +533,6 @@ class GCRuntime
|
||||
inline bool wantBackgroundAllocation(const AutoLockGC &lock) const;
|
||||
void startBackgroundAllocTaskIfIdle();
|
||||
|
||||
bool initZeal();
|
||||
void requestMajorGC(JS::gcreason::Reason reason);
|
||||
void collect(bool incremental, SliceBudget &budget, JSGCInvocationKind gckind,
|
||||
JS::gcreason::Reason reason);
|
||||
|
@ -189,6 +189,7 @@
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/Move.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#ifndef XP_WIN
|
||||
# include <sys/mman.h>
|
||||
@ -1285,22 +1286,22 @@ GCRuntime::setNextScheduled(uint32_t count)
|
||||
}
|
||||
|
||||
bool
|
||||
GCRuntime::initZeal()
|
||||
GCRuntime::parseAndSetZeal(const char *str)
|
||||
{
|
||||
const char *env = getenv("JS_GC_ZEAL");
|
||||
if (!env)
|
||||
return true;
|
||||
|
||||
int zeal = -1;
|
||||
int frequency = JS_DEFAULT_ZEAL_FREQ;
|
||||
if (strcmp(env, "help") != 0) {
|
||||
zeal = atoi(env);
|
||||
const char *p = strchr(env, ',');
|
||||
if (p)
|
||||
int frequency = -1;
|
||||
|
||||
if (isdigit(str[0])) {
|
||||
zeal = atoi(str);
|
||||
|
||||
const char *p = strchr(str, ',');
|
||||
if (!p)
|
||||
frequency = JS_DEFAULT_ZEAL_FREQ;
|
||||
else
|
||||
frequency = atoi(p + 1);
|
||||
}
|
||||
|
||||
if (zeal < 0 || zeal > ZealLimit || frequency < 0) {
|
||||
if (zeal < 0 || zeal > ZealLimit || frequency <= 0) {
|
||||
fprintf(stderr, "Format: JS_GC_ZEAL=level[,N]\n");
|
||||
fputs(ZealModeHelpText, stderr);
|
||||
return false;
|
||||
@ -1360,7 +1361,8 @@ GCRuntime::init(uint32_t maxbytes, uint32_t maxNurseryBytes)
|
||||
#endif
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
if (!initZeal())
|
||||
const char *zealSpec = getenv("JS_GC_ZEAL");
|
||||
if (zealSpec && zealSpec[0] && !parseAndSetZeal(zealSpec))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
|
@ -5612,6 +5612,12 @@ SetRuntimeOptions(JSRuntime *rt, const OptionParser &op)
|
||||
dumpEntrainedVariables = op.getBoolOption("dump-entrained-variables");
|
||||
#endif
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
const char *zealStr = op.getStringOption("gc-zeal");
|
||||
if (zealStr && !rt->gc.parseAndSetZeal(zealStr))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -5843,6 +5849,11 @@ main(int argc, char **argv, char **envp)
|
||||
#endif
|
||||
#ifdef JSGC_GENERATIONAL
|
||||
|| !op.addIntOption('\0', "nursery-size", "SIZE-MB", "Set the maximum nursery size in MB", 16)
|
||||
#endif
|
||||
#ifdef JS_GC_ZEAL
|
||||
|| !op.addStringOption('z', "gc-zeal", "LEVEL[,N]",
|
||||
"Specifies zealous garbage collection, overriding the environement "
|
||||
"variable JS_GC_ZEAL.")
|
||||
#endif
|
||||
)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user