static bool ValidateSimdType(JSContext *cx, AsmJSModule::Global &global, HandleValue globalVal, MutableHandleValue out) { RootedValue v(cx); if (!GetDataProperty(cx, globalVal, cx->names().SIMD, &v)) return false; AsmJSSimdType type; if (global.which() == AsmJSModule::Global::SimdCtor) type = global.simdCtorType(); else type = global.simdOperationType(); RootedPropertyName simdTypeName(cx, SimdTypeToName(cx, type)); if (!GetDataProperty(cx, v, simdTypeName, &v)) return false; if (!v.isObject()) return LinkFail(cx, "bad SIMD type"); RootedObject simdDesc(cx, &v.toObject()); if (!simdDesc->is<SimdTypeDescr>()) return LinkFail(cx, "bad SIMD type"); if (AsmJSSimdTypeToTypeDescrType(type) != simdDesc->as<SimdTypeDescr>().type()) return LinkFail(cx, "bad SIMD type"); out.set(v); return true; }