Bug 1454592 part 2 - Use constexpr for protoTable static array. r=jonco
☠☠ backed out by 3d0c62242c48 ☠ ☠
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 20 Apr 2018 13:07:14 +0200
changeset 468285 82821ff143e3db57f6d87acd650cb4e60f5099e4
parent 468284 89504aa6f1b32e195ce4e12584fb5594fc328ea2
child 468286 3d0c62242c483a022e08a262794b071dea58376d
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjonco
bugs1454592
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1454592 part 2 - Use constexpr for protoTable static array. r=jonco
js/public/ProtoKey.h
js/public/Proxy.h
js/public/Wrapper.h
js/src/proxy/Proxy.cpp
js/src/proxy/Wrapper.cpp
js/src/vm/GlobalObject.cpp
js/src/vm/ProxyObject.h
--- a/js/public/ProtoKey.h
+++ b/js/public/ProtoKey.h
@@ -90,17 +90,17 @@
     real(Uint8Array,            InitViaClassSpec,       TYPED_ARRAY_CLASP(Uint8)) \
     real(Int16Array,            InitViaClassSpec,       TYPED_ARRAY_CLASP(Int16)) \
     real(Uint16Array,           InitViaClassSpec,       TYPED_ARRAY_CLASP(Uint16)) \
     real(Int32Array,            InitViaClassSpec,       TYPED_ARRAY_CLASP(Int32)) \
     real(Uint32Array,           InitViaClassSpec,       TYPED_ARRAY_CLASP(Uint32)) \
     real(Float32Array,          InitViaClassSpec,       TYPED_ARRAY_CLASP(Float32)) \
     real(Float64Array,          InitViaClassSpec,       TYPED_ARRAY_CLASP(Float64)) \
     real(Uint8ClampedArray,     InitViaClassSpec,       TYPED_ARRAY_CLASP(Uint8Clamped)) \
-    real(Proxy,                 InitProxyClass,         js::ProxyClassPtr) \
+    real(Proxy,                 InitProxyClass,         &js::ProxyClass) \
     real(WeakMap,               InitWeakMapClass,       OCLASP(WeakMap)) \
     real(Map,                   InitViaClassSpec,       OCLASP(Map)) \
     real(Set,                   InitViaClassSpec,       OCLASP(Set)) \
     real(DataView,              InitViaClassSpec,       OCLASP(DataView)) \
     real(Symbol,                InitSymbolClass,        OCLASP(Symbol)) \
 IF_SAB(real,imaginary)(SharedArrayBuffer,       InitViaClassSpec, OCLASP(SharedArrayBuffer)) \
 IF_INTL(real,imaginary) (Intl,                  InitIntlClass,          CLASP(Intl)) \
 IF_BDATA(real,imaginary)(TypedObject,           InitTypedObjectModuleObject,   OCLASP(TypedObjectModule)) \
--- a/js/public/Proxy.h
+++ b/js/public/Proxy.h
@@ -347,17 +347,17 @@ class JS_FRIEND_API(BaseProxyHandler)
     virtual bool getElements(JSContext* cx, HandleObject proxy, uint32_t begin, uint32_t end,
                              ElementAdder* adder) const;
 
     /* See comment for weakmapKeyDelegateOp in js/Class.h. */
     virtual JSObject* weakmapKeyDelegate(JSObject* proxy) const;
     virtual bool isScripted() const { return false; }
 };
 
-extern JS_FRIEND_DATA(const js::Class* const) ProxyClassPtr;
+extern JS_FRIEND_DATA(const js::Class) ProxyClass;
 
 inline bool IsProxy(const JSObject* obj)
 {
     return GetObjectClass(obj)->isProxy();
 }
 
 namespace detail {
 
@@ -542,23 +542,23 @@ IsScriptedProxy(const JSObject* obj)
 }
 
 class MOZ_STACK_CLASS ProxyOptions {
   protected:
     /* protected constructor for subclass */
     explicit ProxyOptions(bool singletonArg, bool lazyProtoArg = false)
       : singleton_(singletonArg),
         lazyProto_(lazyProtoArg),
-        clasp_(ProxyClassPtr)
+        clasp_(&ProxyClass)
     {}
 
   public:
     ProxyOptions() : singleton_(false),
                      lazyProto_(false),
-                     clasp_(ProxyClassPtr)
+                     clasp_(&ProxyClass)
     {}
 
     bool singleton() const { return singleton_; }
     ProxyOptions& setSingleton(bool flag) {
         singleton_ = flag;
         return *this;
     }
 
--- a/js/public/Wrapper.h
+++ b/js/public/Wrapper.h
@@ -150,17 +150,17 @@ class JS_FRIEND_API(Wrapper) : public Fo
     unsigned flags() const {
         return mFlags;
     }
 
     static const char family;
     static const Wrapper singleton;
     static const Wrapper singletonWithPrototype;
 
-    static JSObject* defaultProto;
+    static JSObject* const defaultProto;
 };
 
 inline JSObject*
 WrapperOptions::proto() const
 {
     return proto_ ? *proto_ : Wrapper::defaultProto;
 }
 
--- a/js/src/proxy/Proxy.cpp
+++ b/js/src/proxy/Proxy.cpp
@@ -804,23 +804,21 @@ const ObjectOps js::ProxyObjectOps = {
     Proxy::get,
     Proxy::set,
     Proxy::getOwnPropertyDescriptor,
     proxy_DeleteProperty,
     Proxy::getElements,
     Proxy::fun_toString
 };
 
-const Class js::ProxyObject::proxyClass =
+const Class js::ProxyClass =
     PROXY_CLASS_DEF("Proxy",
                     JSCLASS_HAS_CACHED_PROTO(JSProto_Proxy) |
                     JSCLASS_HAS_RESERVED_SLOTS(2));
 
-const Class* const js::ProxyClassPtr = &js::ProxyObject::proxyClass;
-
 JS_FRIEND_API(JSObject*)
 js::NewProxyObject(JSContext* cx, const BaseProxyHandler* handler, HandleValue priv, JSObject* proto_,
                    const ProxyOptions& options)
 {
     if (options.lazyProto()) {
         MOZ_ASSERT(!proto_);
         proto_ = TaggedProto::LazyProto;
     }
@@ -828,17 +826,17 @@ js::NewProxyObject(JSContext* cx, const 
     return ProxyObject::New(cx, handler, priv, TaggedProto(proto_), options);
 }
 
 void
 ProxyObject::renew(const BaseProxyHandler* handler, const Value& priv)
 {
     MOZ_ASSERT(!IsInsideNursery(this));
     MOZ_ASSERT_IF(IsCrossCompartmentWrapper(this), IsDeadProxyObject(this));
-    MOZ_ASSERT(getClass() == &ProxyObject::proxyClass);
+    MOZ_ASSERT(getClass() == &ProxyClass);
     MOZ_ASSERT(!IsWindowProxy(this));
     MOZ_ASSERT(hasDynamicPrototype());
 
     setHandler(handler);
     setCrossCompartmentPrivate(priv);
     for (size_t i = 0; i < numReservedSlots(); i++)
         setReservedSlot(i, UndefinedValue());
 }
--- a/js/src/proxy/Wrapper.cpp
+++ b/js/src/proxy/Wrapper.cpp
@@ -424,17 +424,17 @@ void
 js::ReportAccessDenied(JSContext* cx)
 {
     JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_OBJECT_ACCESS_DENIED);
 }
 
 const char Wrapper::family = 0;
 const Wrapper Wrapper::singleton((unsigned)0);
 const Wrapper Wrapper::singletonWithPrototype((unsigned)0, true);
-JSObject* Wrapper::defaultProto = TaggedProto::LazyProto;
+JSObject* const Wrapper::defaultProto = TaggedProto::LazyProto;
 
 /* Compartments. */
 
 JSObject*
 js::TransparentObjectWrapper(JSContext* cx, HandleObject existing, HandleObject obj)
 {
     // Allow wrapping outer window proxies.
     MOZ_ASSERT(!obj->is<WrapperObject>() || IsWindowProxy(obj));
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -61,17 +61,17 @@ JS_FOR_EACH_PROTOTYPE(DECLARE_PROTOTYPE_
 } // namespace js
 
 JSObject*
 js::InitViaClassSpec(JSContext* cx, Handle<GlobalObject*> global)
 {
     MOZ_CRASH("InitViaClassSpec() should not be called.");
 }
 
-static const ProtoTableEntry protoTable[JSProto_LIMIT] = {
+static constexpr ProtoTableEntry protoTable[JSProto_LIMIT] = {
 #define INIT_FUNC(name,init,clasp) { clasp, init },
 #define INIT_FUNC_DUMMY(name,init,clasp) { nullptr, nullptr },
     JS_FOR_PROTOTYPES(INIT_FUNC, INIT_FUNC_DUMMY)
 #undef INIT_FUNC_DUMMY
 #undef INIT_FUNC
 };
 
 JS_FRIEND_API(const js::Class*)
--- a/js/src/vm/ProxyObject.h
+++ b/js/src/vm/ProxyObject.h
@@ -13,16 +13,20 @@
 namespace js {
 
 /**
  * This is the base class for the various kinds of proxy objects.  It's never
  * instantiated.
  *
  * Proxy objects use ShapedObject::shape_ primarily to record flags.  Property
  * information, &c. is all dynamically computed.
+ *
+ * There is no class_ member to force specialization of JSObject::is<T>().
+ * The implementation in JSObject is incorrect for proxies since it doesn't
+ * take account of the handler type.
  */
 class ProxyObject : public ShapedObject
 {
     // GetProxyDataLayout computes the address of this field.
     detail::ProxyDataLayout data;
 
     void static_asserts() {
         static_assert(sizeof(ProxyObject) == sizeof(JSObject_Slots0),
@@ -122,21 +126,16 @@ class ProxyObject : public ShapedObject
 
     void renew(const BaseProxyHandler* handler, const Value& priv);
 
     static void trace(JSTracer* trc, JSObject* obj);
 
     static void traceEdgeToTarget(JSTracer* trc, ProxyObject* obj);
 
     void nuke();
-
-    // There is no class_ member to force specialization of JSObject::is<T>().
-    // The implementation in JSObject is incorrect for proxies since it doesn't
-    // take account of the handler type.
-    static const Class proxyClass;
 };
 
 inline bool
 IsProxyClass(const Class* clasp)
 {
     return clasp->isProxy();
 }