Bug 530489: don't (incorrectly) trace custom equality ops, r=jorendorff

This commit is contained in:
David Mandelin 2009-12-03 13:02:36 -08:00
parent ab4554e731
commit 90477b6487
3 changed files with 51 additions and 0 deletions

View File

@ -51,6 +51,7 @@ CPPSRCS = \
testContexts.cpp \
testDebugger.cpp \
testDefineGetterSetterNonEnumerable.cpp \
testExtendedEq.cpp \
testIntString.cpp \
testLookup.cpp \
testPropCache.cpp \

View File

@ -0,0 +1,45 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=4 sw=4 et tw=99:
*
* This tests user-specified (via JSExtendedClass) equality operations on
* trace.
*/
#include "tests.h"
static JSBool
my_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
{
*bp = JS_TRUE;
return JS_TRUE;
}
JSExtendedClass TestExtendedEq_JSClass = {
{ "TestExtendedEq",
JSCLASS_IS_EXTENDED,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
JS_EnumerateStub, JS_ResolveStub, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL
},
// JSExtendedClass initialization
my_Equality,
NULL, NULL, NULL, NULL, JSCLASS_NO_RESERVED_MEMBERS
};
BEGIN_TEST(testExtendedEq_bug530489)
{
JSClass *clasp = (JSClass *) &TestExtendedEq_JSClass;
JSObject *global = JS_GetGlobalObject(cx);
JS_InitClass(cx, global, global, clasp, NULL, 0, NULL, NULL, NULL, NULL);
JS_DefineObject(cx, global, "obj1", clasp, NULL, 0);
JS_DefineObject(cx, global, "obj2", clasp, NULL, 0);
jsval v;
EVAL("(function() { var r; for (var i = 0; i < 10; ++i) r = obj1 == obj2; return r; })()", &v);
CHECK_SAME(v, JSVAL_TRUE);
return true;
}
END_TEST(testExtendedEq_bug530489)

View File

@ -8637,6 +8637,11 @@ TraceRecorder::equalityHelper(jsval l, jsval r, LIns* l_ins, LIns* r_ins,
if (GetPromotedType(l) == GetPromotedType(r)) {
if (JSVAL_TAG(l) == JSVAL_OBJECT || JSVAL_IS_SPECIAL(l)) {
if (JSVAL_TAG(l) == JSVAL_OBJECT && l) {
JSClass *clasp = OBJ_GET_CLASS(cx, JSVAL_TO_OBJECT(l));
if ((clasp->flags & JSCLASS_IS_EXTENDED) && ((JSExtendedClass*) clasp)->equality)
RETURN_STOP_A("Can't trace extended class equality operator");
}
if (JSVAL_TAG(l) == JSVAL_OBJECT)
op = LIR_peq;
cond = (l == r);