Bug 853461 - GC: A couple more rooting hazards r=terrence

--HG--
extra : rebase_source : da4c0acc97603cf3eb8b263d9c99166660bc1524
This commit is contained in:
Jon Coppeard 2013-03-22 14:05:10 +00:00
parent b4b90f8459
commit cb8d86e34d
4 changed files with 30 additions and 27 deletions

View File

@ -492,8 +492,7 @@ AutoGCRooter::trace(JSTracer *trc)
case SCRIPTVECTOR: {
AutoScriptVector::VectorImpl &vector = static_cast<AutoScriptVector *>(this)->vector;
for (size_t i = 0; i < vector.length(); i++)
MarkScriptRoot(trc, &vector[i], "AutoScriptVector element");
MarkScriptRootRange(trc, vector.length(), vector.begin(), "js::AutoScriptVector.vector");
return;
}

View File

@ -878,7 +878,7 @@ Debugger::parseResumptionValue(Maybe<AutoCompartment> &ac, bool ok, const Value
JSContext *cx = ac.ref().context();
Rooted<JSObject*> obj(cx);
RootedShape shape(cx);
jsid returnId = NameToId(cx->names().return_);
RootedId returnId(cx, NameToId(cx->names().return_));
jsid throwId = NameToId(cx->names().throw_);
bool okResumption = rv.isObject();
if (okResumption) {
@ -4435,10 +4435,12 @@ DebuggerObject_defineProperties(JSContext *cx, unsigned argc, Value *vp)
Maybe<AutoCompartment> ac;
ac.construct(cx, obj);
RootedId id(cx);
for (size_t i = 0; i < n; i++) {
if (!rewrappedIds.append(jsid()) || !rewrappedDescs.append())
return false;
if (!unwrappedDescs[i].wrapInto(cx, obj, ids[i], &rewrappedIds[i], &rewrappedDescs[i]))
id = ids[i];
if (!unwrappedDescs[i].wrapInto(cx, obj, id, &rewrappedIds[i], &rewrappedDescs[i]))
return false;
}
@ -4970,14 +4972,15 @@ DebuggerEnv_names(JSContext *cx, unsigned argc, Value *vp)
RootedObject arr(cx, NewDenseEmptyArray(cx));
if (!arr)
return false;
RootedId id(cx);
for (size_t i = 0, len = keys.length(); i < len; i++) {
jsid id = keys[i];
if (JSID_IS_ATOM(id) && IsIdentifier(JSID_TO_ATOM(id))) {
if (!cx->compartment->wrapId(cx, &id))
return false;
if (!js_NewbornArrayPush(cx, arr, StringValue(JSID_TO_STRING(id))))
return false;
}
id = keys[i];
if (JSID_IS_ATOM(id) && IsIdentifier(JSID_TO_ATOM(id))) {
if (!cx->compartment->wrapId(cx, id.address()))
return false;
if (!js_NewbornArrayPush(cx, arr, StringValue(JSID_TO_STRING(id))))
return false;
}
}
args.rval().setObject(*arr);
return true;

View File

@ -403,9 +403,9 @@ class ParallelIonInvoke
calleeToken_ = CalleeToToken(callee);
}
bool invoke() {
Value result;
enter_(jitcode_, argc_ + 1, argv_ + 1, NULL, calleeToken_, &result);
bool invoke(JSContext *cx) {
RootedValue result(cx);
enter_(jitcode_, argc_ + 1, argv_ + 1, NULL, calleeToken_, result.address());
return !result.isMagic();
}
};
@ -414,17 +414,17 @@ class ParallelIonInvoke
class ParallelDo : public ForkJoinOp
{
JSContext *cx_;
HeapPtrObject fun_;
RootedObject fun_;
public:
// For tests, make sure to keep this in sync with minItemsTestingThreshold.
const static uint32_t MAX_BAILOUTS = 3;
uint32_t bailouts;
Vector<JSScript *> pendingInvalidations;
AutoScriptVector pendingInvalidations;
ParallelDo(JSContext *cx, HandleObject fun)
: cx_(cx),
fun_(fun),
fun_(cx, fun),
bailouts(0),
pendingInvalidations(cx)
{ }
@ -593,10 +593,8 @@ class ParallelDo : public ForkJoinOp
JS_ASSERT(pendingInvalidations[slice.sliceId] == NULL);
js::PerThreadData *pt = slice.perThreadData;
RootedObject fun(pt, fun_);
JS_ASSERT(fun->isFunction());
RootedFunction callee(cx_, fun->toFunction());
JS_ASSERT(fun_->isFunction());
RootedFunction callee(cx_, fun_->toFunction());
if (!callee->nonLazyScript()->hasParallelIonScript()) {
// Sometimes, particularly with GCZeal, the parallel ion
// script can be collected between starting the parallel
@ -612,7 +610,7 @@ class ParallelDo : public ForkJoinOp
fii.args[1] = Int32Value(slice.numSlices);
fii.args[2] = BooleanValue(false);
bool ok = fii.invoke();
bool ok = fii.invoke(cx_);
JS_ASSERT(ok == !slice.abortedScript);
if (!ok) {
JSScript *script = slice.abortedScript;

View File

@ -21,6 +21,8 @@
using namespace js;
using namespace js::types;
typedef Rooted<ArgumentsObject *> RootedArgumentsObject;
/*****************************************************************************/
StaticScopeIter::StaticScopeIter(JSContext *cx, HandleObject objArg)
@ -1317,8 +1319,8 @@ class DebugScopeProxy : public BaseProxyHandler
Rooted<DebugScopeObject*> debugScope(cx, &proxy->asDebugScope());
Rooted<ScopeObject*> scope(cx, &debugScope->scope());
ArgumentsObject *maybeArgsObj;
if (!checkForMissingArguments(cx, id, *scope, &maybeArgsObj))
RootedArgumentsObject maybeArgsObj(cx);
if (!checkForMissingArguments(cx, id, *scope, maybeArgsObj.address()))
return false;
if (maybeArgsObj) {
@ -1347,8 +1349,8 @@ class DebugScopeProxy : public BaseProxyHandler
Rooted<DebugScopeObject*> debugScope(cx, &proxy->asDebugScope());
Rooted<ScopeObject*> scope(cx, &proxy->asDebugScope().scope());
ArgumentsObject *maybeArgsObj;
if (!checkForMissingArguments(cx, id, *scope, &maybeArgsObj))
RootedArgumentsObject maybeArgsObj(cx);
if (!checkForMissingArguments(cx, id, *scope, maybeArgsObj.address()))
return false;
if (maybeArgsObj) {
@ -1425,8 +1427,9 @@ class DebugScopeProxy : public BaseProxyHandler
return getScopePropertyNames(cx, proxy, props, 0);
}
bool has(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) MOZ_OVERRIDE
bool has(JSContext *cx, HandleObject proxy, HandleId id_, bool *bp) MOZ_OVERRIDE
{
RootedId id(cx, id_);
ScopeObject &scopeObj = proxy->asDebugScope().scope();
if (isArguments(cx, id) && isFunctionScope(scopeObj)) {