From 1668e255205a25e50d6e890d00f253f08f50e635 Mon Sep 17 00:00:00 2001 From: Christian Holler Date: Mon, 13 Jan 2014 16:39:21 +0100 Subject: [PATCH] Bug 958598 - Reorder some code in SIMDObject::initClass to handle OOM. r=nmatsakis --HG-- extra : rebase_source : d1c043ee7c2fcf5fa0a5fd032a0bc65c0a54a123 --- js/src/builtin/SIMD.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/src/builtin/SIMD.cpp b/js/src/builtin/SIMD.cpp index 60d67f9a2db..3d5845f990f 100644 --- a/js/src/builtin/SIMD.cpp +++ b/js/src/builtin/SIMD.cpp @@ -358,8 +358,6 @@ SIMDObject::initClass(JSContext *cx, Handle 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 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 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; }