From 45f9d72da465d4c5b374c9524216cb1df98c5444 Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Wed, 20 Jun 2012 08:57:29 -0700 Subject: [PATCH] Bug 765956 - Set Bindings' parent eagerly (r=bhackett) --HG-- extra : rebase_source : 198757535745ab10f4bba192b163d38768e7260b --- js/src/jscompartment.h | 2 +- js/src/jsinfer.cpp | 8 -------- js/src/jsscope.cpp | 25 ------------------------- js/src/jsscript.cpp | 2 +- js/src/jsscript.h | 2 -- js/src/jsscriptinlines.h | 4 ++-- 6 files changed, 4 insertions(+), 39 deletions(-) diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h index db9e9b4b22fc..f1ea9c3196ee 100644 --- a/js/src/jscompartment.h +++ b/js/src/jscompartment.h @@ -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); diff --git a/js/src/jsinfer.cpp b/js/src/jsinfer.cpp index 6e49dc0656bd..4a7dcfee57eb 100644 --- a/js/src/jsinfer.cpp +++ b/js/src/jsinfer.cpp @@ -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; diff --git a/js/src/jsscope.cpp b/js/src/jsscope.cpp index 961c0bfbbfc5..faaa28dc1b80 100644 --- a/js/src/jsscope.cpp +++ b/js/src/jsscope.cpp @@ -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) { diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 1bdccb44c514..4b4c52ff0017 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -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); diff --git a/js/src/jsscript.h b/js/src/jsscript.h index 6516c11a51c8..0c9482083051 100644 --- a/js/src/jsscript.h +++ b/js/src/jsscript.h @@ -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 diff --git a/js/src/jsscriptinlines.h b/js/src/jsscriptinlines.h index 59408880fb14..dd09858387a4 100644 --- a/js/src/jsscriptinlines.h +++ b/js/src/jsscriptinlines.h @@ -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