Backed out changeset af649bce14da. Trying to fix performance regressions.

This commit is contained in:
Blake Kaplan 2009-09-17 15:23:58 -07:00
parent 231c6c273f
commit 5e4fdf8802
2 changed files with 18 additions and 4 deletions

View File

@ -17,7 +17,7 @@ static JSClass CounterClass = {
JSCLASS_NO_OPTIONAL_MEMBERS
};
BEGIN_TEST(testPropCache_bug505523)
BEGIN_TEST(testPropCache_bug505798)
{
g_counter = 0;
EXEC("var x = {};");
@ -25,7 +25,8 @@ BEGIN_TEST(testPropCache_bug505523)
EXEC("var arr = [x, y];\n"
"for (var i = 0; i < arr.length; i++)\n"
" arr[i].p = 1;\n");
knownFail = true;
CHECK(g_counter == 1);
return true;
}
END_TEST(testPropCache_bug505523)
END_TEST(testPropCache_bug505798)

View File

@ -949,19 +949,32 @@ js_GetterOnlyPropertyStub(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
/*
* If an object is "similar" to its prototype, it can share OBJ_SCOPE(proto)->emptyScope.
* Similar objects have the same JSObjectOps and the same JSClass.
* Similar objects have the same JSObjectOps and the same private and reserved slots.
*
* We assume that if prototype and object are of the same class, they always
* have the same number of computed reserved slots (returned via
* clasp->reserveSlots). This is true for builtin classes (except Block, and
* for this reason among others Blocks must never be exposed to scripts).
*
* Otherwise, prototype and object classes must have the same (null or not)
* reserveSlots hook.
*
* FIXME: This fails to distinguish between objects with different addProperty
* hooks. See bug 505523.
*/
static inline bool
js_ObjectIsSimilarToProto(JSContext *cx, JSObject *obj, JSObjectOps *ops, JSClass *clasp,
JSObject *proto)
{
JS_ASSERT(proto == OBJ_GET_PROTO(cx, obj));
return (proto->map->ops == ops && OBJ_GET_CLASS(cx, proto) == clasp);
JSClass *protoclasp;
return (proto->map->ops == ops &&
((protoclasp = OBJ_GET_CLASS(cx, proto)) == clasp ||
(!((protoclasp->flags ^ clasp->flags) &
(JSCLASS_HAS_PRIVATE |
(JSCLASS_RESERVED_SLOTS_MASK << JSCLASS_RESERVED_SLOTS_SHIFT))) &&
protoclasp->reserveSlots == clasp->reserveSlots)));
}
#ifdef DEBUG