static bool ValidateConstant(JSContext *cx, AsmJSModule::Global &global, HandleValue globalVal) { RootedPropertyName field(cx, global.constantName()); RootedValue v(cx, globalVal); if (global.constantKind() == AsmJSModule::Global::MathConstant) { if (!GetDataProperty(cx, v, cx->names().Math, &v)) return false; } if (!GetDataProperty(cx, v, field, &v)) return false; if (!v.isNumber()) return LinkFail(cx, "math / global constant value needs to be a number"); // NaN != NaN if (IsNaN(global.constantValue())) { if (!IsNaN(v.toNumber())) return LinkFail(cx, "global constant value needs to be NaN"); } else { if (v.toNumber() != global.constantValue()) return LinkFail(cx, "global constant value mismatch"); } return true; }
static bool ValidateGlobalConstant(JSContext *cx, AsmJSModule::Global global, HandleValue globalVal) { RootedPropertyName field(cx, global.constantName()); RootedValue v(cx); if (!GetProperty(cx, globalVal, field, &v)) return false; if (!v.isNumber()) return LinkFail(cx, "global constant value needs to be a number"); // NaN != NaN if (MOZ_DOUBLE_IS_NaN(global.constantValue())) { if (!MOZ_DOUBLE_IS_NaN(v.toNumber())) return LinkFail(cx, "global constant value needs to be NaN"); } else { if (v.toNumber() != global.constantValue()) return LinkFail(cx, "global constant value mismatch"); } return true; }