Bug 1260984 (part 2) - Reduce ObjectOps exposure. r=jorendorff.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 31 Mar 2016 19:24:29 +1100
changeset 291498 0ed129db55485ccd748f44b4d0b02de607dd290c
parent 291497 fb1734c047af5bbfa2ee1ec4844dd16764b184e9
child 291499 c2bfc27e083f8bf6659b54345086b6275f60e1b9
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1260984
milestone48.0a1
Bug 1260984 (part 2) - Reduce ObjectOps exposure. r=jorendorff. A number of ObjectOps instances are more exposed than they need to be. This patch converts several to be either private (within a class) or static (within a file).
js/src/vm/ScopeObject.cpp
js/src/vm/ScopeObject.h
js/src/vm/UnboxedObject.cpp
js/src/vm/UnboxedObject.h
--- a/js/src/vm/ScopeObject.cpp
+++ b/js/src/vm/ScopeObject.cpp
@@ -863,17 +863,17 @@ with_GetOwnPropertyDescriptor(JSContext*
 static bool
 with_DeleteProperty(JSContext* cx, HandleObject obj, HandleId id, ObjectOpResult& result)
 {
     MOZ_ASSERT(!JSID_IS_ATOM(id, cx->names().dotThis));
     RootedObject actual(cx, &obj->as<DynamicWithObject>().object());
     return DeleteProperty(cx, actual, id, result);
 }
 
-const ObjectOps DynamicWithObject::objectOps_ = {
+static const ObjectOps DynamicWithObjectObjectOps = {
     with_LookupProperty,
     with_DefineProperty,
     with_HasProperty,
     with_GetProperty,
     with_SetProperty,
     with_GetOwnPropertyDescriptor,
     with_DeleteProperty,
     nullptr, nullptr,    /* watch/unwatch */
@@ -895,17 +895,17 @@ const Class DynamicWithObject::class_ = 
     nullptr, /* mayResolve */
     nullptr, /* finalize */
     nullptr, /* call */
     nullptr, /* hasInstance */
     nullptr, /* construct */
     nullptr, /* trace */
     JS_NULL_CLASS_SPEC,
     JS_NULL_CLASS_EXT,
-    &DynamicWithObject::objectOps_
+    &DynamicWithObjectObjectOps
 };
 
 /* static */ StaticEvalScope*
 StaticEvalScope::create(JSContext* cx, HandleObject enclosing)
 {
     StaticEvalScope* obj =
         NewObjectWithNullTaggedProto<StaticEvalScope>(cx, TenuredObject, BaseShape::DELEGATE);
     if (!obj)
@@ -1378,17 +1378,17 @@ lexicalError_GetOwnPropertyDescriptor(JS
 
 static bool
 lexicalError_DeleteProperty(JSContext* cx, HandleObject obj, HandleId id, ObjectOpResult& result)
 {
     ReportRuntimeLexicalErrorId(cx, obj->as<RuntimeLexicalErrorObject>().errorNumber(), id);
     return false;
 }
 
-const ObjectOps RuntimeLexicalErrorObject::objectOps_ = {
+static const ObjectOps RuntimeLexicalErrorObjectObjectOps = {
     lexicalError_LookupProperty,
     nullptr,             /* defineProperty */
     lexicalError_HasProperty,
     lexicalError_GetProperty,
     lexicalError_SetProperty,
     lexicalError_GetOwnPropertyDescriptor,
     lexicalError_DeleteProperty,
     nullptr, nullptr,    /* watch/unwatch */
@@ -1410,17 +1410,17 @@ const Class RuntimeLexicalErrorObject::c
     nullptr, /* mayResolve */
     nullptr, /* finalize */
     nullptr, /* call */
     nullptr, /* hasInstance */
     nullptr, /* construct */
     nullptr, /* trace */
     JS_NULL_CLASS_SPEC,
     JS_NULL_CLASS_EXT,
-    &RuntimeLexicalErrorObject::objectOps_
+    &RuntimeLexicalErrorObjectObjectOps
 };
 
 /*****************************************************************************/
 
 // Any name atom for a function which will be added as a DeclEnv object to the
 // scope chain above call objects for fun.
 static inline JSAtom*
 CallObjectLambdaName(JSFunction& fun)
--- a/js/src/vm/ScopeObject.h
+++ b/js/src/vm/ScopeObject.h
@@ -811,18 +811,19 @@ class CallObject : public LexicalScopeBa
         return CALLEE_SLOT;
     }
 };
 
 class ModuleEnvironmentObject : public LexicalScopeBase
 {
     static const uint32_t MODULE_SLOT = 1;
 
+    static const ObjectOps objectOps_;
+
   public:
-    static const ObjectOps objectOps_;
     static const Class class_;
 
     static const uint32_t RESERVED_SLOTS = 2;
 
     static ModuleEnvironmentObject* create(ExclusiveContext* cx, HandleModuleObject module);
     ModuleObject& module();
     IndirectBindingMap& importBindings();
 
@@ -907,17 +908,16 @@ class NestedScopeObject : public ScopeOb
 class DynamicWithObject : public NestedScopeObject
 {
     static const unsigned OBJECT_SLOT = 1;
     static const unsigned THIS_SLOT = 2;
     static const unsigned KIND_SLOT = 3;
 
   public:
     static const unsigned RESERVED_SLOTS = 4;
-    static const ObjectOps objectOps_;
     static const Class class_;
 
     enum WithKind {
         SyntacticWith,
         NonSyntacticWith
     };
 
     static DynamicWithObject*
@@ -1070,17 +1070,16 @@ class ClonedBlockObject : public NestedS
 // ES6 'const' bindings induce a runtime error when assigned to outside
 // of initialization, regardless of strictness.
 class RuntimeLexicalErrorObject : public ScopeObject
 {
     static const unsigned ERROR_SLOT = 1;
 
   public:
     static const unsigned RESERVED_SLOTS = 2;
-    static const ObjectOps objectOps_;
     static const Class class_;
 
     static RuntimeLexicalErrorObject* create(JSContext* cx, HandleObject enclosing,
                                              unsigned errorNumber);
 
     unsigned errorNumber() {
         return getReservedSlot(ERROR_SLOT).toInt32();
     }
--- a/js/src/vm/UnboxedObject.cpp
+++ b/js/src/vm/UnboxedObject.cpp
@@ -900,17 +900,17 @@ UnboxedPlainObject::obj_enumerate(JSCont
     return true;
 }
 
 const Class UnboxedExpandoObject::class_ = {
     "UnboxedExpandoObject",
     0
 };
 
-const ObjectOps UnboxedPlainObject::objectOps_ = {
+static const ObjectOps UnboxedPlainObjectObjectOps = {
     UnboxedPlainObject::obj_lookupProperty,
     UnboxedPlainObject::obj_defineProperty,
     UnboxedPlainObject::obj_hasProperty,
     UnboxedPlainObject::obj_getProperty,
     UnboxedPlainObject::obj_setProperty,
     UnboxedPlainObject::obj_getOwnPropertyDescriptor,
     UnboxedPlainObject::obj_deleteProperty,
     UnboxedPlainObject::obj_watch,
@@ -934,17 +934,17 @@ const Class UnboxedPlainObject::class_ =
     nullptr,        /* mayResolve  */
     nullptr,        /* finalize    */
     nullptr,        /* call        */
     nullptr,        /* hasInstance */
     nullptr,        /* construct   */
     UnboxedPlainObject::trace,
     JS_NULL_CLASS_SPEC,
     JS_NULL_CLASS_EXT,
-    &UnboxedPlainObject::objectOps_
+    &UnboxedPlainObjectObjectOps
 };
 
 /////////////////////////////////////////////////////////////////////
 // UnboxedArrayObject
 /////////////////////////////////////////////////////////////////////
 
 template <JSValueType Type>
 DenseElementResult
@@ -1586,17 +1586,17 @@ UnboxedArrayObject::obj_enumerate(JSCont
     }
 
     if (!enumerableOnly && !properties.append(NameToId(cx->names().length)))
         return false;
 
     return true;
 }
 
-const ObjectOps UnboxedArrayObject::objectOps_ = {
+static const ObjectOps UnboxedArrayObjectObjectOps = {
     UnboxedArrayObject::obj_lookupProperty,
     UnboxedArrayObject::obj_defineProperty,
     UnboxedArrayObject::obj_hasProperty,
     UnboxedArrayObject::obj_getProperty,
     UnboxedArrayObject::obj_setProperty,
     UnboxedArrayObject::obj_getOwnPropertyDescriptor,
     UnboxedArrayObject::obj_deleteProperty,
     UnboxedArrayObject::obj_watch,
@@ -1624,17 +1624,17 @@ const Class UnboxedArrayObject::class_ =
     nullptr,        /* construct   */
     UnboxedArrayObject::trace,
     JS_NULL_CLASS_SPEC,
     {
         false,      /* isWrappedNative */
         nullptr,    /* weakmapKeyDelegateOp */
         UnboxedArrayObject::objectMoved
     },
-    &UnboxedArrayObject::objectOps_
+    &UnboxedArrayObjectObjectOps
 };
 
 /////////////////////////////////////////////////////////////////////
 // API
 /////////////////////////////////////////////////////////////////////
 
 static bool
 UnboxedTypeIncludes(JSValueType supertype, JSValueType subtype)
--- a/js/src/vm/UnboxedObject.h
+++ b/js/src/vm/UnboxedObject.h
@@ -233,17 +233,16 @@ class UnboxedPlainObject : public JSObje
     // not automatically barriered to avoid problems if the object is converted
     // to a native. See ensureExpando().
     UnboxedExpandoObject* expando_;
 
     // Start of the inline data, which immediately follows the group and extra properties.
     uint8_t data_[1];
 
   public:
-    static const ObjectOps objectOps_;
     static const Class class_;
 
     static bool obj_lookupProperty(JSContext* cx, HandleObject obj,
                                    HandleId id, MutableHandleObject objp,
                                    MutableHandleShape propp);
 
     static bool obj_defineProperty(JSContext* cx, HandleObject obj, HandleId id,
                                    Handle<PropertyDescriptor> desc,
@@ -370,17 +369,16 @@ class UnboxedArrayObject : public JSObje
             return length;
         return CapacityArray[index];
     }
 
     static uint32_t chooseCapacityIndex(uint32_t capacity, uint32_t length);
     static uint32_t exactCapacityIndex(uint32_t capacity);
 
   public:
-    static const ObjectOps objectOps_;
     static const Class class_;
 
     static bool obj_lookupProperty(JSContext* cx, HandleObject obj,
                                    HandleId id, MutableHandleObject objp,
                                    MutableHandleShape propp);
 
     static bool obj_defineProperty(JSContext* cx, HandleObject obj, HandleId id,
                                    Handle<PropertyDescriptor> desc,