mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-19 07:26:26 +00:00
bug 716512 - make sure that gcparam in shell cannot set MAX_GC_BYTES to a value les than the current GC_BYTES. r=anygregor
This commit is contained in:
parent
a0183e60b6
commit
2343df4eb3
@ -1254,7 +1254,7 @@ GCParameter(JSContext *cx, uintN argc, jsval *vp)
|
||||
|
||||
JSFlatString *flatStr = JS_FlattenString(cx, str);
|
||||
if (!flatStr)
|
||||
return JS_FALSE;
|
||||
return false;
|
||||
|
||||
size_t paramIndex = 0;
|
||||
for (;; paramIndex++) {
|
||||
@ -1263,7 +1263,7 @@ GCParameter(JSContext *cx, uintN argc, jsval *vp)
|
||||
"the first argument argument must be maxBytes, "
|
||||
"maxMallocBytes, gcStackpoolLifespan, gcBytes or "
|
||||
"gcNumber");
|
||||
return JS_FALSE;
|
||||
return false;
|
||||
}
|
||||
if (JS_FlatStringEqualsAscii(flatStr, paramMap[paramIndex].name))
|
||||
break;
|
||||
@ -1279,7 +1279,7 @@ GCParameter(JSContext *cx, uintN argc, jsval *vp)
|
||||
param == JSGC_BYTES) {
|
||||
JS_ReportError(cx, "Attempt to change read-only parameter %s",
|
||||
paramMap[paramIndex].name);
|
||||
return JS_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t value;
|
||||
@ -1287,11 +1287,23 @@ GCParameter(JSContext *cx, uintN argc, jsval *vp)
|
||||
JS_ReportError(cx,
|
||||
"the second argument must be convertable to uint32_t "
|
||||
"with non-zero value");
|
||||
return JS_FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (param == JSGC_MAX_BYTES) {
|
||||
uint32_t gcBytes = JS_GetGCParameter(cx->runtime, JSGC_BYTES);
|
||||
if (value < gcBytes) {
|
||||
JS_ReportError(cx,
|
||||
"attempt to set maxBytes to the value less than the current "
|
||||
"gcBytes (%u)",
|
||||
gcBytes);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
JS_SetGCParameter(cx->runtime, param, value);
|
||||
*vp = JSVAL_VOID;
|
||||
return JS_TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
@ -2013,31 +2025,31 @@ DisassembleScript(JSContext *cx, JSScript *script, JSFunction *fun, bool lines,
|
||||
if (fun && (fun->flags & ~7U)) {
|
||||
uint16_t flags = fun->flags;
|
||||
Sprint(sp, "flags:");
|
||||
|
||||
|
||||
#define SHOW_FLAG(flag) if (flags & JSFUN_##flag) Sprint(sp, " " #flag);
|
||||
|
||||
|
||||
SHOW_FLAG(LAMBDA);
|
||||
SHOW_FLAG(HEAVYWEIGHT);
|
||||
SHOW_FLAG(EXPR_CLOSURE);
|
||||
|
||||
|
||||
#undef SHOW_FLAG
|
||||
|
||||
|
||||
if (fun->isNullClosure())
|
||||
Sprint(sp, " NULL_CLOSURE");
|
||||
else if (fun->isFlatClosure())
|
||||
Sprint(sp, " FLAT_CLOSURE");
|
||||
|
||||
|
||||
JSScript *script = fun->script();
|
||||
if (script->bindings.hasUpvars()) {
|
||||
Sprint(sp, "\nupvars: {\n");
|
||||
|
||||
|
||||
Vector<JSAtom *> localNames(cx);
|
||||
if (!script->bindings.getLocalNameArray(cx, &localNames))
|
||||
return false;
|
||||
|
||||
|
||||
JSUpvarArray *uva = script->upvars();
|
||||
uintN upvar_base = script->bindings.countArgsAndVars();
|
||||
|
||||
|
||||
for (uint32_t i = 0, n = uva->length; i < n; i++) {
|
||||
JSAtom *atom = localNames[upvar_base + i];
|
||||
UpvarCookie cookie = uva->vector[i];
|
||||
@ -2047,7 +2059,7 @@ DisassembleScript(JSContext *cx, JSScript *script, JSFunction *fun, bool lines,
|
||||
printable.ptr(), cookie.level(), cookie.slot());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Sprint(sp, "}");
|
||||
}
|
||||
Sprint(sp, "\n");
|
||||
@ -2190,7 +2202,7 @@ DisassFile(JSContext *cx, uintN argc, jsval *vp)
|
||||
DisassembleOptionParser p(argc, JS_ARGV(cx, vp));
|
||||
if (!p.parse(cx))
|
||||
return false;
|
||||
|
||||
|
||||
if (!p.argc) {
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return JS_TRUE;
|
||||
@ -2222,7 +2234,7 @@ DisassFile(JSContext *cx, uintN argc, jsval *vp)
|
||||
fprintf(stdout, "%s\n", sprinter.base);
|
||||
if (!ok)
|
||||
return false;
|
||||
|
||||
|
||||
JS_SET_RVAL(cx, vp, JSVAL_VOID);
|
||||
return true;
|
||||
}
|
||||
@ -5033,7 +5045,7 @@ BindScriptArgs(JSContext *cx, JSObject *obj, OptionParser *op)
|
||||
if (!scriptArgs)
|
||||
return false;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Script arguments are bound as a normal |arguments| property on the
|
||||
* global object. It has no special significance, like |arguments| in
|
||||
* function scope does -- this identifier is used de-facto across shell
|
||||
@ -5222,7 +5234,7 @@ Shell(JSContext *cx, OptionParser *op, char **envp)
|
||||
|
||||
if (enableDisassemblyDumps)
|
||||
JS_DumpCompartmentPCCounts(cx);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -5375,7 +5387,7 @@ main(int argc, char **argv, char **envp)
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
/*
|
||||
* Process OOM options as early as possible so that we can observe as many
|
||||
* allocations as possible.
|
||||
*/
|
||||
|
@ -56,7 +56,9 @@ function test()
|
||||
|
||||
if (typeof gcparam != 'undefined')
|
||||
{
|
||||
gcparam("maxBytes", 22000);
|
||||
gc();
|
||||
gc();
|
||||
gcparam("maxBytes", gcparam("gcBytes") + 4*1024);
|
||||
expectExitCode(5);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user