Bug 765956 - Set Bindings' parent eagerly (r=bhackett)

--HG--
extra : rebase_source : 198757535745ab10f4bba192b163d38768e7260b
This commit is contained in:
Luke Wagner 2012-06-20 08:57:29 -07:00
Родитель de8ea2a8cc
Коммит 45f9d72da4
6 изменённых файлов: 4 добавлений и 39 удалений

Просмотреть файл

@ -128,7 +128,7 @@ struct JSCompartment
//
// In contrast, JSObject::global() is infallible because marking a JSObject
// always marks its global as well.
// TODO: add infallible JSScript::global() and JSContext::global()
// TODO: add infallible JSScript::global()
//
js::GlobalObject *maybeGlobal() const {
JS_ASSERT_IF(global_, global_->compartment() == this);

Просмотреть файл

@ -5040,14 +5040,6 @@ TypeScript::SetScope(JSContext *cx, JSScript *script_, JSObject *scope_)
JS_ASSERT_IF(fun && scope, fun->global() == scope->global());
script->types->global = fun ? &fun->global() : &scope->global();
/*
* Update the parent in the script's bindings. The bindings are created
* with a NULL parent, and fixing the parent now avoids the need to reshape
* every time a call object is created from the bindings.
*/
if (!script->bindings.setParent(cx, script->types->global))
return false;
if (!cx->typeInferenceEnabled())
return true;

Просмотреть файл

@ -1207,31 +1207,6 @@ Bindings::setExtensibleParents(JSContext *cx)
return true;
}
bool
Bindings::setParent(JSContext *cx, JSObject *obj_)
{
RootedObject obj(cx, obj_);
/*
* This may be invoked on GC heap allocated bindings, in which case this
* is pointing to an internal value of a JSScript that can't itself be
* relocated. The script itself will be rooted, and will not be moved, so
* mark the stack value as non-relocatable for the stack root analysis.
*/
Bindings *self = this;
SkipRoot root(cx, &self);
if (!ensureShape(cx))
return false;
/* This is only used for Block objects, which have a NULL proto. */
Shape *newShape = Shape::setObjectParent(cx, obj, NULL, self->lastBinding);
if (!newShape)
return false;
self->lastBinding = newShape;
return true;
}
inline
InitialShapeEntry::InitialShapeEntry() : shape(NULL), proto(NULL)
{

Просмотреть файл

@ -124,7 +124,7 @@ Bindings::add(JSContext *cx, HandleAtom name, BindingKind kind)
id = AtomToId(name);
}
StackBaseShape base(&CallClass, NULL, BaseShape::VAROBJ);
StackBaseShape base(&CallClass, cx->global(), BaseShape::VAROBJ);
base.updateGetterSetter(attrs, getter, setter);
UnownedBaseShape *nbase = BaseShape::getUnowned(cx, base);

Просмотреть файл

@ -128,8 +128,6 @@ class Bindings
inline bool extensibleParents();
bool setExtensibleParents(JSContext *cx);
bool setParent(JSContext *cx, JSObject *obj);
enum {
/* A script may have no more than this many arguments or variables. */
BINDING_COUNT_LIMIT = 0xFFFF

Просмотреть файл

@ -55,8 +55,8 @@ Bindings::initialShape(JSContext *cx) const
gc::AllocKind kind = gc::FINALIZE_OBJECT2_BACKGROUND;
JS_ASSERT(gc::GetGCKindSlots(kind) == CallObject::RESERVED_SLOTS);
return EmptyShape::getInitialShape(cx, &CallClass, NULL, NULL, kind,
BaseShape::VAROBJ);
return EmptyShape::getInitialShape(cx, &CallClass, NULL, cx->global(),
kind, BaseShape::VAROBJ);
}
bool