Bug 782818 - Temporarily enable compartment assertions (r=luke)

This commit is contained in:
Bill McCloskey 2012-12-12 12:59:51 -08:00
parent a706708a78
commit 14b9689032
4 changed files with 25 additions and 17 deletions

View File

@ -184,7 +184,7 @@ class AutoPtr
T *get() { return value; }
};
#ifdef DEBUG
#ifdef JS_CRASH_DIAGNOSTICS
class CompartmentChecker
{
JSContext *context;
@ -201,7 +201,7 @@ class CompartmentChecker
*/
static void fail(JSCompartment *c1, JSCompartment *c2) {
printf("*** Compartment mismatch %p vs. %p\n", (void *) c1, (void *) c2);
JS_NOT_REACHED("compartment mismatched");
MOZ_CRASH();
}
/* Note: should only be used when neither c1 nor c2 may be the default compartment. */
@ -282,8 +282,7 @@ class CompartmentChecker
check(fp->scopeChain());
}
};
#endif
#endif /* JS_CRASH_DIAGNOSTICS */
/*
* Don't perform these checks when called from a finalizer. The checking
@ -297,6 +296,15 @@ class CompartmentChecker
template <class T1> inline void
assertSameCompartment(JSContext *cx, const T1 &t1)
{
#ifdef JS_CRASH_DIAGNOSTICS
START_ASSERT_SAME_COMPARTMENT();
c.check(t1);
#endif
}
template <class T1> inline void
assertSameCompartmentDebugOnly(JSContext *cx, const T1 &t1)
{
#ifdef DEBUG
START_ASSERT_SAME_COMPARTMENT();
c.check(t1);
@ -306,7 +314,7 @@ assertSameCompartment(JSContext *cx, const T1 &t1)
template <class T1, class T2> inline void
assertSameCompartment(JSContext *cx, const T1 &t1, const T2 &t2)
{
#ifdef DEBUG
#ifdef JS_CRASH_DIAGNOSTICS
START_ASSERT_SAME_COMPARTMENT();
c.check(t1);
c.check(t2);
@ -316,7 +324,7 @@ assertSameCompartment(JSContext *cx, const T1 &t1, const T2 &t2)
template <class T1, class T2, class T3> inline void
assertSameCompartment(JSContext *cx, const T1 &t1, const T2 &t2, const T3 &t3)
{
#ifdef DEBUG
#ifdef JS_CRASH_DIAGNOSTICS
START_ASSERT_SAME_COMPARTMENT();
c.check(t1);
c.check(t2);
@ -327,7 +335,7 @@ assertSameCompartment(JSContext *cx, const T1 &t1, const T2 &t2, const T3 &t3)
template <class T1, class T2, class T3, class T4> inline void
assertSameCompartment(JSContext *cx, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4)
{
#ifdef DEBUG
#ifdef JS_CRASH_DIAGNOSTICS
START_ASSERT_SAME_COMPARTMENT();
c.check(t1);
c.check(t2);
@ -339,7 +347,7 @@ assertSameCompartment(JSContext *cx, const T1 &t1, const T2 &t2, const T3 &t3, c
template <class T1, class T2, class T3, class T4, class T5> inline void
assertSameCompartment(JSContext *cx, const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5)
{
#ifdef DEBUG
#ifdef JS_CRASH_DIAGNOSTICS
START_ASSERT_SAME_COMPARTMENT();
c.check(t1);
c.check(t2);

View File

@ -887,16 +887,16 @@ TryNoteIter::settle()
}
}
#define PUSH_COPY(v) do { *regs.sp++ = v; assertSameCompartment(cx, regs.sp[-1]); } while (0)
#define PUSH_COPY(v) do { *regs.sp++ = v; assertSameCompartmentDebugOnly(cx, regs.sp[-1]); } while (0)
#define PUSH_COPY_SKIP_CHECK(v) *regs.sp++ = v
#define PUSH_NULL() regs.sp++->setNull()
#define PUSH_UNDEFINED() regs.sp++->setUndefined()
#define PUSH_BOOLEAN(b) regs.sp++->setBoolean(b)
#define PUSH_DOUBLE(d) regs.sp++->setDouble(d)
#define PUSH_INT32(i) regs.sp++->setInt32(i)
#define PUSH_STRING(s) do { regs.sp++->setString(s); assertSameCompartment(cx, regs.sp[-1]); } while (0)
#define PUSH_OBJECT(obj) do { regs.sp++->setObject(obj); assertSameCompartment(cx, regs.sp[-1]); } while (0)
#define PUSH_OBJECT_OR_NULL(obj) do { regs.sp++->setObjectOrNull(obj); assertSameCompartment(cx, regs.sp[-1]); } while (0)
#define PUSH_STRING(s) do { regs.sp++->setString(s); assertSameCompartmentDebugOnly(cx, regs.sp[-1]); } while (0)
#define PUSH_OBJECT(obj) do { regs.sp++->setObject(obj); assertSameCompartmentDebugOnly(cx, regs.sp[-1]); } while (0)
#define PUSH_OBJECT_OR_NULL(obj) do { regs.sp++->setObjectOrNull(obj); assertSameCompartmentDebugOnly(cx, regs.sp[-1]); } while (0)
#define PUSH_HOLE() regs.sp++->setMagic(JS_ARRAY_HOLE)
#define POP_COPY_TO(v) v = *--regs.sp
#define POP_RETURN_VALUE() regs.fp()->setReturnValue(*--regs.sp)
@ -2230,7 +2230,7 @@ BEGIN_CASE(JSOP_CALLPROP)
TypeScript::Monitor(cx, script, regs.pc, rval);
regs.sp[-1] = rval;
assertSameCompartment(cx, regs.sp[-1]);
assertSameCompartmentDebugOnly(cx, regs.sp[-1]);
}
END_CASE(JSOP_GETPROP)
@ -2732,7 +2732,7 @@ BEGIN_CASE(JSOP_CALLLOCAL)
* a use of the variable.
*/
if (regs.pc[JSOP_GETLOCAL_LENGTH] != JSOP_POP)
assertSameCompartment(cx, regs.sp[-1]);
assertSameCompartmentDebugOnly(cx, regs.sp[-1]);
}
END_CASE(JSOP_GETLOCAL)
@ -2975,7 +2975,7 @@ BEGIN_CASE(JSOP_SETTER)
if (js_CodeSpec[op2].ndefs > js_CodeSpec[op2].nuses) {
JS_ASSERT(js_CodeSpec[op2].ndefs == js_CodeSpec[op2].nuses + 1);
regs.sp[-1] = rval;
assertSameCompartment(cx, regs.sp[-1]);
assertSameCompartmentDebugOnly(cx, regs.sp[-1]);
}
len = js_CodeSpec[op2].length;
DO_NEXT_OP(len);

View File

@ -779,7 +779,7 @@ GetObjectElementOperation(JSContext *cx, JSOp op, HandleObject obj, const Value
}
}
assertSameCompartment(cx, res);
assertSameCompartmentDebugOnly(cx, res);
return true;
}

View File

@ -77,7 +77,7 @@ ShapeTable::init(JSRuntime *rt, Shape *lastProp)
Shape::makeOwnBaseShape(JSContext *cx, HandleShape shape)
{
JS_ASSERT(!shape->base()->isOwned());
assertSameCompartment(cx, shape->compartment());
assertSameCompartmentDebugOnly(cx, shape->compartment());
UnrootedBaseShape nbase = js_NewGCBaseShape(cx);
if (!nbase)