Bug 839376 (part 13) - Fix ten easy rooting hazards in vm/Debugger.cpp. r=terrence.

--HG--
extra : rebase_source : 0cc515f0f423d8794dd42eff70b6056cf8d6919f
This commit is contained in:
Nicholas Nethercote 2013-02-14 18:55:24 -08:00
parent 02bd075401
commit a3a8daff7a

View File

@ -760,9 +760,9 @@ Debugger::handleUncaughtExceptionHelper(Maybe<AutoCompartment> &ac,
if (callHook && uncaughtExceptionHook) {
Value fval = ObjectValue(*uncaughtExceptionHook);
Value exc = cx->getPendingException();
Value rv;
RootedValue rv(cx);
cx->clearPendingException();
if (Invoke(cx, ObjectValue(*object), fval, 1, &exc, &rv))
if (Invoke(cx, ObjectValue(*object), fval, 1, &exc, rv.address()))
return vp ? parseResumptionValue(ac, true, rv, *vp, false) : JSTRAP_CONTINUE;
}
@ -947,8 +947,8 @@ Debugger::fireDebuggerStatement(JSContext *cx, MutableHandleValue vp)
if (!getScriptFrame(cx, iter, &argv))
return handleUncaughtException(ac, vp, false);
Value rv;
bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv.address(), &rv);
RootedValue rv(cx);
bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv.address(), rv.address());
return parseResumptionValue(ac, ok, rv, vp);
}
@ -974,8 +974,8 @@ Debugger::fireExceptionUnwind(JSContext *cx, MutableHandleValue vp)
if (!getScriptFrame(cx, iter, avr.handleAt(0)) || !wrapDebuggeeValue(cx, avr.handleAt(1)))
return handleUncaughtException(ac, vp, false);
Value rv;
bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 2, argv, &rv);
RootedValue rv(cx);
bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 2, argv, rv.address());
JSTrapStatus st = parseResumptionValue(ac, ok, rv, vp);
if (st == JSTRAP_CONTINUE)
cx->setPendingException(exc);
@ -997,8 +997,8 @@ Debugger::fireEnterFrame(JSContext *cx, MutableHandleValue vp)
if (!getScriptFrame(cx, iter, &argv))
return handleUncaughtException(ac, vp, false);
Value rv;
bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv.address(), &rv);
RootedValue rv(cx);
bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv.address(), rv.address());
return parseResumptionValue(ac, ok, rv, vp);
}
@ -1169,9 +1169,9 @@ Debugger::onTrap(JSContext *cx, MutableHandleValue vp)
AutoValueArray ava(cx, argv, 1);
if (!dbg->getScriptFrame(cx, iter, ava.handleAt(0)))
return dbg->handleUncaughtException(ac, vp, false);
Value rv;
RootedValue rv(cx);
Rooted<JSObject*> handler(cx, bp->handler);
bool ok = CallMethodIfPresent(cx, handler, "hit", 1, argv, &rv);
bool ok = CallMethodIfPresent(cx, handler, "hit", 1, argv, rv.address());
JSTrapStatus st = dbg->parseResumptionValue(ac, ok, rv, vp, true);
if (st != JSTRAP_CONTINUE)
return st;
@ -1284,8 +1284,8 @@ Debugger::onSingleStep(JSContext *cx, MutableHandleValue vp)
ac.construct(cx, dbg->object);
const Value &handler = frame->getReservedSlot(JSSLOT_DEBUGFRAME_ONSTEP_HANDLER);
Value rval;
bool ok = Invoke(cx, ObjectValue(*frame), handler, 0, NULL, &rval);
RootedValue rval(cx);
bool ok = Invoke(cx, ObjectValue(*frame), handler, 0, NULL, rval.address());
JSTrapStatus st = dbg->parseResumptionValue(ac, ok, rval, vp);
if (st != JSTRAP_CONTINUE)
return st;
@ -1313,8 +1313,8 @@ Debugger::fireNewGlobalObject(JSContext *cx, Handle<GlobalObject *> global, Muta
if (!wrapDebuggeeValue(cx, argvRooter.handleAt(0)))
return handleUncaughtException(ac, NULL, false);
Value rv;
bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv, &rv);
RootedValue rv(cx);
bool ok = Invoke(cx, ObjectValue(*object), ObjectValue(*hook), 1, argv, rv.address());
return parseResumptionValue(ac, ok, rv, vp);
}
@ -1798,7 +1798,7 @@ JSBool
Debugger::setOnNewGlobalObject(JSContext *cx, unsigned argc, Value *vp)
{
THIS_DEBUGGER(cx, argc, vp, "setOnNewGlobalObject", args, dbg);
JSObject *oldHook = dbg->getHook(OnNewGlobalObject);
RootedObject oldHook(cx, dbg->getHook(OnNewGlobalObject));
if (!setHookImpl(cx, argc, vp, OnNewGlobalObject))
return false;
@ -3811,11 +3811,11 @@ DebuggerGenericEval(JSContext *cx, const char *fullMethodName,
}
/* Run the code and produce the completion value. */
Value rval;
RootedValue rval(cx);
JS::Anchor<JSString *> anchor(stable);
AbstractFramePtr frame = iter ? iter->abstractFramePtr() : NullFramePtr();
bool ok = EvaluateInEnv(cx, env, thisv, frame, stable->chars(), stable->length(),
"debugger eval code", 1, &rval);
"debugger eval code", 1, rval.address());
return dbg->receiveCompletionValue(ac, ok, rval, vp);
}
@ -4514,8 +4514,8 @@ ApplyOrCall(JSContext *cx, unsigned argc, Value *vp, ApplyOrCallMode mode)
* Call the function. Use receiveCompletionValue to return to the debugger
* compartment and populate args.rval().
*/
Value rval;
bool ok = Invoke(cx, thisv, calleev, callArgc, callArgv, &rval);
RootedValue rval(cx);
bool ok = Invoke(cx, thisv, calleev, callArgc, callArgv, rval.address());
return dbg->receiveCompletionValue(ac, ok, rval, args.rval());
}