Bug 918350 - SpiderMonkey: Initialize JSRuntime's NaN and Infinity members right away instead of waiting. r=waldo

This commit is contained in:
Dan Gohman 2013-09-19 18:47:52 -07:00
parent dfbc494859
commit 99f9b78a3c
3 changed files with 15 additions and 19 deletions

View File

@ -47,6 +47,7 @@
using namespace js;
using namespace js::types;
using mozilla::MinDoubleValue;
using mozilla::NegativeInfinity;
using mozilla::PodCopy;
using mozilla::PositiveInfinity;
@ -1143,25 +1144,16 @@ js::InitRuntimeNumberState(JSRuntime *rt)
{
FIX_FPU();
double d;
/*
* Our NaN must be one particular canonical value, because we rely on NaN
* encoding for our value representation. See Value.h.
*/
d = GenericNaN();
number_constants[NC_NaN].dval = d;
rt->NaNValue.setDouble(d);
number_constants[NC_NaN].dval = GenericNaN();
d = mozilla::PositiveInfinity();
number_constants[NC_POSITIVE_INFINITY].dval = d;
rt->positiveInfinityValue.setDouble(d);
number_constants[NC_POSITIVE_INFINITY].dval = mozilla::PositiveInfinity();
number_constants[NC_NEGATIVE_INFINITY].dval = mozilla::NegativeInfinity();
d = mozilla::NegativeInfinity();
number_constants[NC_NEGATIVE_INFINITY].dval = d;
rt->negativeInfinityValue.setDouble(d);
number_constants[NC_MIN_VALUE].dval = mozilla::MinDoubleValue();
number_constants[NC_MIN_VALUE].dval = MinDoubleValue();
// XXX If EXPOSE_INTL_API becomes true all the time at some point,
// js::InitRuntimeNumberState is no longer fallible, and we should

View File

@ -39,9 +39,13 @@ using namespace js::gc;
using mozilla::Atomic;
using mozilla::DebugOnly;
using mozilla::NegativeInfinity;
using mozilla::PodZero;
using mozilla::PodArrayZero;
using mozilla::PositiveInfinity;
using mozilla::ThreadLocal;
using JS::GenericNaN;
using JS::DoubleNaNValue;
/* static */ ThreadLocal<PerThreadData*> js::TlsPerThreadData;
@ -226,9 +230,9 @@ JSRuntime::JSRuntime(JSUseHelperThreads useHelperThreads)
gcFinalizeCallback(NULL),
gcMallocBytes(0),
scriptAndCountsVector(NULL),
NaNValue(UndefinedValue()),
negativeInfinityValue(UndefinedValue()),
positiveInfinityValue(UndefinedValue()),
NaNValue(DoubleNaNValue()),
negativeInfinityValue(DoubleValue(NegativeInfinity())),
positiveInfinityValue(DoubleValue(PositiveInfinity())),
emptyString(NULL),
sourceHook(NULL),
debugMode(false),

View File

@ -1262,9 +1262,9 @@ struct JSRuntime : public JS::shadow::Runtime,
js::ScriptAndCountsVector *scriptAndCountsVector;
/* Well-known numbers held for use by this runtime's contexts. */
js::Value NaNValue;
js::Value negativeInfinityValue;
js::Value positiveInfinityValue;
const js::Value NaNValue;
const js::Value negativeInfinityValue;
const js::Value positiveInfinityValue;
js::PropertyName *emptyString;