Backed out changeset 6534f8b9aa74 (bug 491013, assert on startup).

This commit is contained in:
Andreas Gal
2009-05-04 15:07:53 -07:00
parent 5ef9af3875
commit 079d3cd7df
14 changed files with 126 additions and 76 deletions

View File

@@ -2411,14 +2411,24 @@ js_NewWithObject(JSContext *cx, JSObject *proto, JSObject *parent, jsint depth)
JSObject *
js_NewBlockObject(JSContext *cx)
{
JSObject *obj;
JSBool ok;
/*
* Null obj's proto slot so that Object.prototype.* does not pollute block
* scopes and to give the block object its own scope.
* scopes. Make sure obj has its own scope too, since clearing proto does
* not affect OBJ_SCOPE(obj).
*/
JSObject *blockObj = js_NewObjectWithGivenProto(cx, &js_BlockClass,
NULL, NULL, 0);
JS_ASSERT_IF(blockObj, !OBJ_IS_CLONED_BLOCK(blockObj));
return blockObj;
obj = js_NewObject(cx, &js_BlockClass, NULL, NULL, 0);
if (!obj)
return NULL;
JS_LOCK_OBJ(cx, obj);
ok = js_GetMutableScope(cx, obj) != NULL;
JS_UNLOCK_OBJ(cx, obj);
if (!ok)
return NULL;
OBJ_CLEAR_PROTO(cx, obj);
return obj;
}
JSObject *
@@ -2436,7 +2446,6 @@ js_CloneBlockObject(JSContext *cx, JSObject *proto, JSObject *parent,
STOBJ_SET_SLOT(clone, JSSLOT_BLOCK_DEPTH,
OBJ_GET_SLOT(cx, proto, JSSLOT_BLOCK_DEPTH));
JS_ASSERT(OBJ_IS_CLONED_BLOCK(clone));
JS_ASSERT(OBJ_SCOPE(clone)->object == proto);
return clone;
}
@@ -2564,8 +2573,8 @@ FindObjectIndex(JSObjectArray *array, JSObject *obj)
return NO_PARENT_INDEX;
}
JSBool
js_XDRBlockObject(JSXDRState *xdr, JSObject **objp)
static JSBool
block_xdrObject(JSXDRState *xdr, JSObject **objp)
{
JSContext *cx;
uint32 parentId;
@@ -2678,6 +2687,8 @@ js_XDRBlockObject(JSXDRState *xdr, JSObject **objp)
return ok;
}
#else
# define block_xdrObject NULL
#endif
static uint32
@@ -2688,12 +2699,27 @@ block_reserveSlots(JSContext *cx, JSObject *obj)
JSClass js_BlockClass = {
"Block",
JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_IS_ANONYMOUS,
JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(1) |
JSCLASS_IS_ANONYMOUS | JSCLASS_HAS_CACHED_PROTO(JSProto_Block),
JS_PropertyStub, JS_PropertyStub, block_getProperty, block_setProperty,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, block_reserveSlots
NULL, NULL, NULL, NULL, block_xdrObject, NULL, NULL, block_reserveSlots
};
JSObject*
js_InitBlockClass(JSContext *cx, JSObject* obj)
{
JSObject *proto;
proto = JS_InitClass(cx, obj, NULL, &js_BlockClass, NULL, 0, NULL,
NULL, NULL, NULL);
if (!proto)
return NULL;
OBJ_CLEAR_PROTO(cx, proto);
return proto;
}
JSObject *
js_InitEval(JSContext *cx, JSObject *obj)
{
@@ -4251,7 +4277,7 @@ js_NativeSet(JSContext *cx, JSObject *obj, JSScopeProperty *sprop, jsval *vp)
JS_ASSERT(OBJ_IS_NATIVE(obj));
JS_ASSERT(JS_IS_OBJ_LOCKED(cx, obj));
scope = OBJ_SCOPE(obj);
JS_ASSERT(scope->object == obj || (sprop->attrs & JSPROP_SHARED));
JS_ASSERT(scope->object == obj);
slot = sprop->slot;
if (slot != SPROP_INVALID_SLOT) {
@@ -4285,7 +4311,7 @@ js_NativeSet(JSContext *cx, JSObject *obj, JSScopeProperty *sprop, jsval *vp)
return JS_FALSE;
JS_LOCK_SCOPE(cx, scope);
JS_ASSERT(scope->object == obj || (sprop->attrs & JSPROP_SHARED));
JS_ASSERT(scope->object == obj);
if (SLOT_IN_SCOPE(slot, scope) &&
(JS_LIKELY(cx->runtime->propertyRemovals == sample) ||
SCOPE_GET_PROPERTY(scope, sprop->id) == sprop)) {