mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Objects of different JSClass can share scopes (505523, r=jorendorff).
This commit is contained in:
parent
12b7a6e203
commit
231c6c273f
@ -17,7 +17,7 @@ static JSClass CounterClass = {
|
||||
JSCLASS_NO_OPTIONAL_MEMBERS
|
||||
};
|
||||
|
||||
BEGIN_TEST(testPropCache_bug505798)
|
||||
BEGIN_TEST(testPropCache_bug505523)
|
||||
{
|
||||
g_counter = 0;
|
||||
EXEC("var x = {};");
|
||||
@ -25,8 +25,7 @@ BEGIN_TEST(testPropCache_bug505798)
|
||||
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_bug505798)
|
||||
END_TEST(testPropCache_bug505523)
|
||||
|
@ -949,32 +949,19 @@ 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 private and reserved slots.
|
||||
* Similar objects have the same JSObjectOps and the same JSClass.
|
||||
*
|
||||
* 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));
|
||||
|
||||
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)));
|
||||
return (proto->map->ops == ops && OBJ_GET_CLASS(cx, proto) == clasp);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user