Bug 611432: assert that compartments stay the same before and after a JM activation, r=gal

This commit is contained in:
David Mandelin 2011-01-05 17:21:31 -08:00
parent b3dcdca182
commit ed486e4069
2 changed files with 22 additions and 2 deletions

View File

@ -388,6 +388,22 @@ class SwitchToCompartment : public PreserveCompartment {
}
};
class AssertCompartmentUnchanged {
protected:
JSContext * const cx;
JSCompartment * const oldCompartment;
JS_DECL_USE_GUARD_OBJECT_NOTIFIER
public:
AssertCompartmentUnchanged(JSContext *cx JS_GUARD_OBJECT_NOTIFIER_PARAM)
: cx(cx), oldCompartment(cx->compartment) {
JS_GUARD_OBJECT_NOTIFIER_INIT;
}
~AssertCompartmentUnchanged() {
JS_ASSERT(cx->compartment == oldCompartment);
}
};
}
#endif /* jscompartment_h___ */

View File

@ -741,8 +741,12 @@ mjit::EnterMethodJIT(JSContext *cx, JSStackFrame *fp, void *code, Value *stackLi
JS_ASSERT(cx->regs->fp == fp);
JSFrameRegs *oldRegs = cx->regs;
JSAutoResolveFlags rf(cx, JSRESOLVE_INFER);
JSBool ok = JaegerTrampoline(cx, fp, code, stackLimit);
JSBool ok;
{
AssertCompartmentUnchanged pcc(cx);
JSAutoResolveFlags rf(cx, JSRESOLVE_INFER);
ok = JaegerTrampoline(cx, fp, code, stackLimit);
}
cx->setCurrentRegs(oldRegs);
JS_ASSERT(fp == cx->fp());