Bug 958598 - Reorder some code in SIMDObject::initClass to handle OOM. r=nmatsakis

--HG--
extra : rebase_source : d1c043ee7c2fcf5fa0a5fd032a0bc65c0a54a123
This commit is contained in:
Christian Holler 2014-01-13 16:39:21 +01:00
parent fe1d4c04ca
commit 1668e25520

View File

@ -358,8 +358,6 @@ SIMDObject::initClass(JSContext *cx, Handle<GlobalObject *> 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,
@ -375,8 +373,6 @@ SIMDObject::initClass(JSContext *cx, Handle<GlobalObject *> 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,
@ -387,13 +383,20 @@ SIMDObject::initClass(JSContext *cx, Handle<GlobalObject *> global)
}
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;
}