From fd99ea95643914bfd629ed5396eeda513748fdd2 Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Tue, 3 Apr 2012 11:41:56 -0700 Subject: [PATCH] Bug 742570 - Remove the compartment option for gczeal (r=igor) --- dom/base/nsJSEnvironment.cpp | 4 +--- dom/workers/RuntimeService.cpp | 2 +- dom/workers/WorkerPrivate.cpp | 2 +- ipc/testshell/XPCShellEnvironment.cpp | 2 +- js/src/builtin/TestingFunctions.cpp | 21 +++++++-------------- js/src/jsapi.cpp | 8 ++------ js/src/jsapi.h | 4 ++-- js/src/jscntxt.h | 1 - js/src/jsgc.cpp | 11 +---------- js/src/shell/js.cpp | 24 ------------------------ js/xpconnect/shell/xpcshell.cpp | 2 +- js/xpconnect/src/XPCComponents.cpp | 2 +- 12 files changed, 18 insertions(+), 65 deletions(-) diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index bca98a20f46..efd0ac542dd 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -915,7 +915,6 @@ static const char js_relimit_option_str[]= JS_OPTIONS_DOT_STR "relimit"; #ifdef JS_GC_ZEAL static const char js_zeal_option_str[] = JS_OPTIONS_DOT_STR "gczeal"; static const char js_zeal_frequency_str[] = JS_OPTIONS_DOT_STR "gczeal.frequency"; -static const char js_zeal_compartment_str[] = JS_OPTIONS_DOT_STR "gczeal.compartment_gc"; #endif static const char js_methodjit_content_str[] = JS_OPTIONS_DOT_STR "methodjit.content"; static const char js_methodjit_chrome_str[] = JS_OPTIONS_DOT_STR "methodjit.chrome"; @@ -1022,9 +1021,8 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data) #ifdef JS_GC_ZEAL PRInt32 zeal = Preferences::GetInt(js_zeal_option_str, -1); PRInt32 frequency = Preferences::GetInt(js_zeal_frequency_str, JS_DEFAULT_ZEAL_FREQ); - bool compartment = Preferences::GetBool(js_zeal_compartment_str, false); if (zeal >= 0) - ::JS_SetGCZeal(context->mContext, (PRUint8)zeal, frequency, compartment); + ::JS_SetGCZeal(context->mContext, (PRUint8)zeal, frequency); #endif return 0; diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index d4b9e125b59..07c154325af 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -320,7 +320,7 @@ CreateJSContextForWorker(WorkerPrivate* aWorkerPrivate) NS_ASSERTION(zeal <= 3, "Bad zeal value!"); PRUint32 frequency = zeal <= 2 ? JS_DEFAULT_ZEAL_FREQ : 1; - JS_SetGCZeal(workerCx, zeal, frequency, false); + JS_SetGCZeal(workerCx, zeal, frequency); } #endif diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 4963b3c35fb..1dbf218281a 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -3877,7 +3877,7 @@ WorkerPrivate::UpdateGCZealInternal(JSContext* aCx, PRUint8 aGCZeal) AssertIsOnWorkerThread(); PRUint32 frequency = aGCZeal <= 2 ? JS_DEFAULT_ZEAL_FREQ : 1; - JS_SetGCZeal(aCx, aGCZeal, frequency, false); + JS_SetGCZeal(aCx, aGCZeal, frequency); for (PRUint32 index = 0; index < mChildWorkers.Length(); index++) { mChildWorkers[index]->UpdateGCZeal(aCx, aGCZeal); diff --git a/ipc/testshell/XPCShellEnvironment.cpp b/ipc/testshell/XPCShellEnvironment.cpp index c985744f7d8..4f6e1c620a6 100644 --- a/ipc/testshell/XPCShellEnvironment.cpp +++ b/ipc/testshell/XPCShellEnvironment.cpp @@ -430,7 +430,7 @@ GCZeal(JSContext *cx, if (!JS_ValueToECMAUint32(cx, argv[0], &zeal)) return JS_FALSE; - JS_SetGCZeal(cx, PRUint8(zeal), JS_DEFAULT_ZEAL_FREQ, JS_FALSE); + JS_SetGCZeal(cx, PRUint8(zeal), JS_DEFAULT_ZEAL_FREQ); return JS_TRUE; } #endif diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 07085e41b65..fa5f0428113 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -154,9 +154,8 @@ static JSBool GCZeal(JSContext *cx, unsigned argc, jsval *vp) { uint32_t zeal, frequency = JS_DEFAULT_ZEAL_FREQ; - JSBool compartment = JS_FALSE; - if (argc > 3) { + if (argc > 2) { ReportUsageError(cx, &JS_CALLEE(cx, vp).toObject(), "Too many arguments"); return JS_FALSE; } @@ -165,10 +164,8 @@ GCZeal(JSContext *cx, unsigned argc, jsval *vp) if (argc >= 2) if (!JS_ValueToECMAUint32(cx, vp[3], &frequency)) return JS_FALSE; - if (argc >= 3) - compartment = js_ValueToBoolean(vp[3]); - JS_SetGCZeal(cx, (uint8_t)zeal, frequency, compartment); + JS_SetGCZeal(cx, (uint8_t)zeal, frequency); *vp = JSVAL_VOID; return JS_TRUE; } @@ -177,18 +174,15 @@ static JSBool ScheduleGC(JSContext *cx, unsigned argc, jsval *vp) { uint32_t count; - bool compartment = false; - if (argc != 1 && argc != 2) { + if (argc != 1) { ReportUsageError(cx, &JS_CALLEE(cx, vp).toObject(), "Wrong number of arguments"); return JS_FALSE; } if (!JS_ValueToECMAUint32(cx, vp[2], &count)) return JS_FALSE; - if (argc == 2) - compartment = js_ValueToBoolean(vp[3]); - JS_ScheduleGC(cx, count, compartment); + JS_ScheduleGC(cx, count); *vp = JSVAL_VOID; return JS_TRUE; } @@ -502,7 +496,7 @@ static JSFunctionSpecWithHelp TestingFunctions[] = { #ifdef JS_GC_ZEAL JS_FN_HELP("gczeal", GCZeal, 2, 0, -"gczeal(level, [period], [compartmentGC?])", +"gczeal(level, [period])", " Specifies how zealous the garbage collector should be. Values for level:\n" " 0: Normal amount of collection\n" " 1: Collect when roots are added or removed\n" @@ -510,11 +504,10 @@ static JSFunctionSpecWithHelp TestingFunctions[] = { " 3: Collect when the window paints (browser only)\n" " 4: Verify write barriers between instructions\n" " 5: Verify write barriers between paints\n" -" Period specifies that collection happens every n allocations.\n" -" If compartmentGC is true, the collections will be compartmental."), +" Period specifies that collection happens every n allocations.\n"), JS_FN_HELP("schedulegc", ScheduleGC, 1, 0, -"schedulegc(num, [compartmentGC?])", +"schedulegc(num)", " Schedule a GC to happen after num allocations."), JS_FN_HELP("verifybarriers", VerifyBarriers, 0, 0, diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 97ff629e550..d1e5dbaf4c1 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -747,7 +747,6 @@ JSRuntime::JSRuntime() gcZeal_(0), gcZealFrequency(0), gcNextScheduled(0), - gcDebugCompartmentGC(false), gcDeterministicOnly(false), #endif gcCallback(NULL), @@ -6565,14 +6564,13 @@ JS_AbortIfWrongThread(JSRuntime *rt) #ifdef JS_GC_ZEAL JS_PUBLIC_API(void) -JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency, JSBool compartment) +JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency) { #ifdef JS_GC_ZEAL const char *env = getenv("JS_GC_ZEAL"); if (env) { zeal = atoi(env); frequency = 1; - compartment = false; } #endif @@ -6580,14 +6578,12 @@ JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency, JSBool compartment cx->runtime->gcZeal_ = zeal; cx->runtime->gcZealFrequency = frequency; cx->runtime->gcNextScheduled = schedule ? frequency : 0; - cx->runtime->gcDebugCompartmentGC = !!compartment; } JS_PUBLIC_API(void) -JS_ScheduleGC(JSContext *cx, uint32_t count, JSBool compartment) +JS_ScheduleGC(JSContext *cx, uint32_t count) { cx->runtime->gcNextScheduled = count; - cx->runtime->gcDebugCompartmentGC = !!compartment; } #endif diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 644116f99df..70d61a73499 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -5531,10 +5531,10 @@ JS_NewObjectForConstructor(JSContext *cx, JSClass *clasp, const jsval *vp); #define JS_DEFAULT_ZEAL_FREQ 100 extern JS_PUBLIC_API(void) -JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency, JSBool compartment); +JS_SetGCZeal(JSContext *cx, uint8_t zeal, uint32_t frequency); extern JS_PUBLIC_API(void) -JS_ScheduleGC(JSContext *cx, uint32_t count, JSBool compartment); +JS_ScheduleGC(JSContext *cx, uint32_t count); #endif /* diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h index 88fe18360ae..60f095a9776 100644 --- a/js/src/jscntxt.h +++ b/js/src/jscntxt.h @@ -445,7 +445,6 @@ struct JSRuntime : js::RuntimeFriendFields int gcZeal_; int gcZealFrequency; int gcNextScheduled; - bool gcDebugCompartmentGC; bool gcDeterministicOnly; int gcZeal() { return gcZeal_; } diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 16965cc2d53..88955da435d 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -3932,16 +3932,7 @@ void RunDebugGC(JSContext *cx) { #ifdef JS_GC_ZEAL - JSRuntime *rt = cx->runtime; - - /* - * If rt->gcDebugCompartmentGC is true, only GC the current - * compartment. But don't GC the atoms compartment. - */ - if (rt->gcDebugCompartmentGC) - PrepareCompartmentForGC(cx->compartment); - else - PrepareForFullGC(cx->runtime); + PrepareForFullGC(cx->runtime); RunLastDitchGC(cx, gcreason::DEBUG_GC); #endif } diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index c634d3ef804..bb799f6442a 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -652,25 +652,6 @@ MapContextOptionNameToFlag(JSContext* cx, const char* name) extern JSClass global_class; -#ifdef JS_GC_ZEAL -static void -ParseZealArg(JSContext *cx, const char *arg) -{ - int zeal, freq = 1, compartment = 0; - const char *p = strchr(arg, ','); - - zeal = atoi(arg); - if (p) { - freq = atoi(p + 1); - p = strchr(p + 1, ','); - if (p) - compartment = atoi(p + 1); - } - - JS_SetGCZeal(cx, (uint8_t)zeal, freq, !!compartment); -} -#endif - static JSBool Version(JSContext *cx, unsigned argc, jsval *vp) { @@ -4674,11 +4655,6 @@ ProcessArgs(JSContext *cx, JSObject *obj, OptionParser *op) JS_ToggleOptions(cx, JSOPTION_METHODJIT); } -#ifdef JS_GC_ZEAL - if (const char *zeal = op->getStringOption('Z')) - ParseZealArg(cx, zeal); -#endif - if (op->getBoolOption('d')) { JS_SetRuntimeDebugMode(JS_GetRuntime(cx), true); JS_SetDebugMode(cx, true); diff --git a/js/xpconnect/shell/xpcshell.cpp b/js/xpconnect/shell/xpcshell.cpp index c94f2cb7591..4e03bd5a875 100644 --- a/js/xpconnect/shell/xpcshell.cpp +++ b/js/xpconnect/shell/xpcshell.cpp @@ -568,7 +568,7 @@ GCZeal(JSContext *cx, unsigned argc, jsval *vp) if (!JS_ValueToECMAUint32(cx, argc ? JS_ARGV(cx, vp)[0] : JSVAL_VOID, &zeal)) return false; - JS_SetGCZeal(cx, uint8_t(zeal), JS_DEFAULT_ZEAL_FREQ, false); + JS_SetGCZeal(cx, uint8_t(zeal), JS_DEFAULT_ZEAL_FREQ); JS_SET_RVAL(cx, vp, JSVAL_VOID); return true; } diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 236676056ba..97ac9ae50bf 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -3929,7 +3929,7 @@ NS_IMETHODIMP nsXPCComponents_Utils::SetGCZeal(PRInt32 aValue, JSContext* cx) { #ifdef JS_GC_ZEAL - JS_SetGCZeal(cx, PRUint8(aValue), JS_DEFAULT_ZEAL_FREQ, false); + JS_SetGCZeal(cx, PRUint8(aValue), JS_DEFAULT_ZEAL_FREQ); #endif return NS_OK; }