Bug 958598 - Reorder some code in SIMDObject::initClass to handle OOM. r=nmatsakis
authorChristian Holler <choller@mozilla.com>
Mon, 13 Jan 2014 16:39:21 +0100
changeset 163145 2ba9e57f56783179df8e1e9abf290748ad1d1c53
parent 163144 bf8de5ab6d041719e8bbba9788990d9f465f5cb5
child 163146 d86046660b1f0431247d584216163173b5ab9331
push id38407
push usercholler@mozilla.com
push dateMon, 13 Jan 2014 17:53:45 +0000
treeherdermozilla-inbound@d86046660b1f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnmatsakis
bugs958598
milestone29.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 958598 - Reorder some code in SIMDObject::initClass to handle OOM. r=nmatsakis
js/src/builtin/SIMD.cpp
--- a/js/src/builtin/SIMD.cpp
+++ b/js/src/builtin/SIMD.cpp
@@ -353,52 +353,55 @@ SIMDObject::initClass(JSContext *cx, Han
         return nullptr;
 
     // float32x4
 
     RootedObject float32x4Object(cx, CreateX4Class<Float32x4Defn>(cx, global));
     if (!float32x4Object)
         return nullptr;
 
-    // Define float32x4 functions and install as a property of the SIMD object.
-    global->setFloat32x4TypeObject(*float32x4Object);
     RootedValue float32x4Value(cx, ObjectValue(*float32x4Object));
     if (!JS_DefineFunctions(cx, float32x4Object, Float32x4Methods) ||
         !JSObject::defineProperty(cx, SIMD, cx->names().float32x4,
                                   float32x4Value, nullptr, nullptr,
                                   JSPROP_READONLY | JSPROP_PERMANENT))
     {
         return nullptr;
     }
 
     // int32x4
 
     RootedObject int32x4Object(cx, CreateX4Class<Int32x4Defn>(cx, global));
     if (!int32x4Object)
         return nullptr;
 
-    // Define int32x4 functions and install as a property of the SIMD object.
-    global->setInt32x4TypeObject(*int32x4Object);
     RootedValue int32x4Value(cx, ObjectValue(*int32x4Object));
     if (!JS_DefineFunctions(cx, int32x4Object, Int32x4Methods) ||
         !JSObject::defineProperty(cx, SIMD, cx->names().int32x4,
                                   int32x4Value, nullptr, nullptr,
                                   JSPROP_READONLY | JSPROP_PERMANENT))
     {
         return nullptr;
     }
 
     RootedValue SIMDValue(cx, ObjectValue(*SIMD));
-    global->setConstructor(JSProto_SIMD, SIMDValue);
 
     // Everything is set up, install SIMD on the global object.
     if (!JSObject::defineProperty(cx, global, cx->names().SIMD,  SIMDValue, nullptr, nullptr, 0)) {
         return nullptr;
     }
 
+    global->setConstructor(JSProto_SIMD, SIMDValue);
+
+    // Define float32x4 functions and install as a property of the SIMD object.
+    global->setFloat32x4TypeObject(*float32x4Object);
+
+    // Define int32x4 functions and install as a property of the SIMD object.
+    global->setInt32x4TypeObject(*int32x4Object);
+
     return SIMD;
 }
 
 JSObject *
 js_InitSIMDClass(JSContext *cx, HandleObject obj)
 {
     JS_ASSERT(obj->is<GlobalObject>());
     Rooted<GlobalObject *> global(cx, &obj->as<GlobalObject>());