Bug 1268034 - Part 2: Call setConstructor and initBuiltinConstructor after defining properties in all init function. r=till
authorTooru Fujisawa <arai_a@mac.com>
Fri, 29 Apr 2016 18:24:21 +0900
changeset 295409 05c1151be7a7821136263bb46d887bf8e99ce64d
parent 295408 d31171af48e4fe4e0e35e6e96b4c76504a7ee091
child 295410 b10abfa0ce4861480b80c58f9232753f586fd23f
push id75908
push userarai_a@mac.com
push dateFri, 29 Apr 2016 09:25:03 +0000
treeherdermozilla-inbound@05c1151be7a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs1268034
milestone49.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 1268034 - Part 2: Call setConstructor and initBuiltinConstructor after defining properties in all init function. r=till
js/src/builtin/TypedObject.cpp
js/src/vm/ArrayBufferObject.cpp
js/src/vm/SharedArrayObject.cpp
--- a/js/src/builtin/TypedObject.cpp
+++ b/js/src/builtin/TypedObject.cpp
@@ -1297,23 +1297,24 @@ GlobalObject::initTypedObjectModule(JSCo
     if (!DefineProperty(cx, module, cx->names().StructType, structTypeValue,
                         nullptr, nullptr, JSPROP_READONLY | JSPROP_PERMANENT))
     {
         return false;
     }
 
     // Everything is setup, install module on the global object:
     RootedValue moduleValue(cx, ObjectValue(*module));
-    global->setConstructor(JSProto_TypedObject, moduleValue);
     if (!DefineProperty(cx, global, cx->names().TypedObject, moduleValue, nullptr, nullptr,
                         JSPROP_RESOLVING))
     {
         return false;
     }
 
+    global->setConstructor(JSProto_TypedObject, moduleValue);
+
     return module;
 }
 
 JSObject*
 js::InitTypedObjectModuleObject(JSContext* cx, HandleObject obj)
 {
     MOZ_ASSERT(obj->is<GlobalObject>());
     Rooted<GlobalObject*> global(cx, &obj->as<GlobalObject>());
--- a/js/src/vm/ArrayBufferObject.cpp
+++ b/js/src/vm/ArrayBufferObject.cpp
@@ -1423,22 +1423,16 @@ js::InitArrayBufferClass(JSContext* cx, 
     if (!arrayBufferProto)
         return nullptr;
 
     RootedFunction ctor(cx, global->createConstructor(cx, ArrayBufferObject::class_constructor,
                                                       cx->names().ArrayBuffer, 1));
     if (!ctor)
         return nullptr;
 
-    if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_ArrayBuffer,
-                                              ctor, arrayBufferProto))
-    {
-        return nullptr;
-    }
-
     if (!LinkConstructorAndPrototype(cx, ctor, arrayBufferProto))
         return nullptr;
 
     RootedId byteLengthId(cx, NameToId(cx->names().byteLength));
     RootedAtom atom(cx, IdToFunctionName(cx, byteLengthId, "get"));
     if (!atom)
         return nullptr;
     unsigned attrs = JSPROP_SHARED | JSPROP_GETTER;
@@ -1455,11 +1449,17 @@ js::InitArrayBufferClass(JSContext* cx, 
         return nullptr;
 
     if (!JS_DefineProperties(cx, ctor, ArrayBufferObject::jsstaticprops))
         return nullptr;
 
     if (!JS_DefineFunctions(cx, arrayBufferProto, ArrayBufferObject::jsfuncs))
         return nullptr;
 
+    if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_ArrayBuffer,
+                                              ctor, arrayBufferProto))
+    {
+        return nullptr;
+    }
+
     return arrayBufferProto;
 }
 
--- a/js/src/vm/SharedArrayObject.cpp
+++ b/js/src/vm/SharedArrayObject.cpp
@@ -380,19 +380,16 @@ js::InitSharedArrayBufferClass(JSContext
     if (!proto)
         return nullptr;
 
     RootedFunction ctor(cx, global->createConstructor(cx, SharedArrayBufferObject::class_constructor,
                                                       cx->names().SharedArrayBuffer, 1));
     if (!ctor)
         return nullptr;
 
-    if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_SharedArrayBuffer, ctor, proto))
-        return nullptr;
-
     if (!LinkConstructorAndPrototype(cx, ctor, proto))
         return nullptr;
 
     RootedId byteLengthId(cx, NameToId(cx->names().byteLength));
     unsigned attrs = JSPROP_SHARED | JSPROP_GETTER | JSPROP_PERMANENT;
     JSObject* getter =
         NewNativeFunction(cx, SharedArrayBufferObject::byteLengthGetter, 0, nullptr);
     if (!getter)
@@ -403,16 +400,19 @@ js::InitSharedArrayBufferClass(JSContext
         return nullptr;
 
     if (!JS_DefineFunctions(cx, ctor, SharedArrayBufferObject::jsstaticfuncs))
         return nullptr;
 
     if (!JS_DefineFunctions(cx, proto, SharedArrayBufferObject::jsfuncs))
         return nullptr;
 
+    if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_SharedArrayBuffer, ctor, proto))
+        return nullptr;
+
     return proto;
 }
 
 bool
 js::IsSharedArrayBuffer(HandleValue v)
 {
     return v.isObject() && v.toObject().is<SharedArrayBufferObject>();
 }