Detect global object wrapping at recording time and on trace (495699, r=mrbkap).

This commit is contained in:
Andreas Gal 2009-06-01 18:52:08 -07:00
parent bde1aa7cf1
commit 5283063eab

View File

@ -6742,18 +6742,26 @@ TraceRecorder::getThis(LIns*& this_ins)
}
this_ins = get(&thisv);
/*
* mrbkap says its not necessary to ever call the thisObject hook if obj is not the global
* object, because the only implicit way to obtain a reference to an object that must be
* wrapped is via the global object. All other sources (API, explicit references) already
* are wrapped as we obtain them through XPConnect. The only exception are With objects,
* which have to call the getThis object hook. We don't trace those cases.
*/
JS_ASSERT(original == thisv);
if (guardClass(JSVAL_TO_OBJECT(thisv), this_ins, &js_WithClass, snapshot(MISMATCH_EXIT)))
ABORT_TRACE("can't trace getThis on With object");
/*
* The only unwrapped object that needs to be wrapped that we can get here is the
* global object obtained throught the scope chain.
*/
JS_ASSERT(JSVAL_IS_OBJECT(thisv));
JSObject* obj = js_GetWrappedObject(cx, JSVAL_TO_OBJECT(thisv));
OBJ_TO_INNER_OBJECT(cx, obj);
if (!obj)
return JSRS_ERROR;
JS_ASSERT(original == thisv || original == OBJECT_TO_JSVAL(obj));
this_ins = lir->ins_choose(lir->ins2(LIR_eq,
this_ins,
INS_CONSTPTR(obj)),
INS_CONSTPTR(JSVAL_TO_OBJECT(thisv)),
this_ins);
return JSRS_CONTINUE;
}