From 99f9b78a3c50cb5f1f21fe5a99e028617ef3f2cf Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 19 Sep 2013 18:47:52 -0700 Subject: [PATCH] Bug 918350 - SpiderMonkey: Initialize JSRuntime's NaN and Infinity members right away instead of waiting. r=waldo --- js/src/jsnum.cpp | 18 +++++------------- js/src/vm/Runtime.cpp | 10 +++++++--- js/src/vm/Runtime.h | 6 +++--- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp index a9a0adcc5823..201d289513db 100644 --- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -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 diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index 0dcfe0f4c6b8..19cf9c9fcd54 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -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 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), diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index ca9007317c9d..138271312886 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -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;