Fix test failures.

This commit is contained in:
Brian Hackett 2011-10-19 08:12:44 -07:00
parent ed28c77902
commit 4deff4dab5
7 changed files with 30 additions and 9 deletions

View File

@ -2335,7 +2335,7 @@ js_NewFunction(JSContext *cx, JSObject *funobj, Native native, uintN nargs,
JS_ASSERT(funobj->isFunction());
JS_ASSERT(funobj->getParent() == parent);
} else {
funobj = NewFunction(cx, parent ? parent->getGlobal() : NULL);
funobj = NewFunction(cx, SkipScopeParent(parent));
if (!funobj)
return NULL;
if (native && !funobj->setSingletonType(cx))
@ -2381,7 +2381,7 @@ js_CloneFunctionObject(JSContext *cx, JSFunction *fun, JSObject *parent,
JS_ASSERT(parent);
JS_ASSERT(proto);
JSFunction *clone = NewFunction(cx, parent->getGlobal());
JSFunction *clone = NewFunction(cx, SkipScopeParent(parent));
if (!clone)
return NULL;

View File

@ -237,6 +237,16 @@ IsBuiltinFunctionConstructor(JSFunction *fun);
const Shape *
LookupInterpretedFunctionPrototype(JSContext *cx, JSObject *funobj);
static inline JSObject *
SkipScopeParent(JSObject *parent)
{
if (!parent)
return NULL;
while (parent->isScope())
parent = parent->getParentMaybeScope();
return parent;
}
inline JSFunction *
CloneFunctionObject(JSContext *cx, JSFunction *fun, JSObject *parent,
bool ignoreSingletonClone = false)
@ -255,6 +265,8 @@ CloneFunctionObject(JSContext *cx, JSFunction *fun, JSObject *parent,
*/
if (ignoreSingletonClone && fun->hasSingletonType()) {
JS_ASSERT(fun->getProto() == proto);
if (!fun->setParent(cx, SkipScopeParent(parent)))
return NULL;
fun->setCallScope(parent);
return fun;
}

View File

@ -4067,7 +4067,7 @@ js_XDRBlockObject(JSXDRState *xdr, JSObject **objp)
if (xdr->mode == JSXDR_ENCODE) {
obj = *objp;
parent = obj->scopeChain();
parent = obj->getStaticBlockScopeChain();
parentId = JSScript::isValidOffset(xdr->script->objectsOffset)
? FindObjectIndex(xdr->script->objects(), parent)
: NO_PARENT_INDEX;
@ -4094,11 +4094,10 @@ js_XDRBlockObject(JSXDRState *xdr, JSObject **objp)
* object array. We know that we XDR block object in outer-to-inner
* order, which means that getting the parent now will work.
*/
if (parentId == NO_PARENT_INDEX)
parent = NULL;
else
if (parentId != NO_PARENT_INDEX) {
parent = xdr->script->getObject(parentId);
obj->setScopeChain(parent);
obj->setScopeChain(parent);
}
}
AutoObjectRooter tvr(cx, obj);

View File

@ -1950,6 +1950,7 @@ Parser::newFunction(JSTreeContext *tc, JSAtom *atom, FunctionSyntaxKind kind)
return NULL;
if (!fun->clearType(context))
return NULL;
fun->setCallScope(NULL);
}
return fun;
}

View File

@ -741,7 +741,7 @@ inline bool
JSObject::initRegExp(JSContext *cx, js::RegExp *re)
{
JS_ASSERT(isRegExp());
JS_ASSERT(getAllocKind() == js::gc::FINALIZE_OBJECT8);
JS_ASSERT(js::gc::GetGCKindSlots(getAllocKind()) == 8);
/*
* It's currently possible to swap RegExp guts. In that case this object

View File

@ -1150,6 +1150,9 @@ JSObject::setParent(JSContext *cx, JSObject *parent)
/* static */ bool
Shape::setObjectParent(JSContext *cx, JSObject *parent, Shape **listp)
{
if ((*listp)->getObjectParent() == parent)
return true;
BaseShape base(*(*listp)->base()->unowned());
base.setParent(parent);
BaseShape *nbase = BaseShape::lookup(cx, base);
@ -1190,6 +1193,9 @@ JSObject::setFlag(JSContext *cx, /*BaseShape::Flag*/ uint32 flag_, GenerateShape
{
BaseShape::Flag flag = (BaseShape::Flag) flag_;
if (lastProperty()->getObjectFlags() & flag)
return true;
if (inDictionaryMode()) {
if (generateShape == GENERATE_SHAPE && !generateOwnShape(cx))
return false;
@ -1203,6 +1209,9 @@ JSObject::setFlag(JSContext *cx, /*BaseShape::Flag*/ uint32 flag_, GenerateShape
/* static */ bool
Shape::setObjectFlag(JSContext *cx, BaseShape::Flag flag, Shape **listp)
{
if ((*listp)->getObjectFlags() & flag)
return true;
BaseShape base(*(*listp)->base()->unowned());
base.flags |= flag;
BaseShape *nbase = BaseShape::lookup(cx, base);

View File

@ -132,7 +132,7 @@ inline bool
StringObject::init(JSContext *cx, JSString *str)
{
JS_ASSERT(nativeEmpty());
JS_ASSERT(getAllocKind() == gc::FINALIZE_OBJECT2);
JS_ASSERT(gc::GetGCKindSlots(getAllocKind()) == 2);
if (isDelegate()) {
if (!assignInitialShape(cx))