Merge TM -> JM

This commit is contained in:
Brian Hackett
2011-05-09 09:49:48 -07:00
967 changed files with 15871 additions and 19401 deletions

View File

@@ -408,8 +408,7 @@ ParseIntStringHelper(JSContext *cx, const jschar *ws, const jschar *end, int may
static jsdouble
ParseIntDoubleHelper(jsdouble d)
{
if (!JSDOUBLE_IS_FINITE(d))
return js_NaN;
JS_ASSERT(-1e21 < d && d < 1e21);
if (d > 0)
return floor(d);
if (d < 0)
@@ -433,10 +432,19 @@ num_parseInt(JSContext *cx, uintN argc, Value *vp)
*vp = vp[2];
return true;
}
if (vp[2].isDouble()) {
vp->setNumber(ParseIntDoubleHelper(vp[2].toDouble()));
if (!vp->isInt32())
cx->markTypeCallerOverflow();
/*
* Step 1 is |inputString = ToString(string)|. When string >=
* 1e21, ToString(string) is in the form "NeM". 'e' marks the end of
* the word, which would mean the result of parseInt(string) should be |N|.
*
* To preserve this behaviour, we can't use the fast-path when string >
* 1e21, or else the result would be |NeM|.
*/
if (vp[2].isDouble() &&
vp[2].toDouble() > -1.0e21 &&
vp[2].toDouble() < 1.0e21) {
vp->setDouble(ParseIntDoubleHelper(vp[2].toDouble()));
cx->markTypeCallerOverflow();
return true;
}
}
@@ -503,9 +511,21 @@ ParseInt(JSContext* cx, JSString* str)
}
static jsdouble FASTCALL
ParseIntDouble(jsdouble d)
ParseIntDouble(JSContext* cx, jsdouble d)
{
return ParseIntDoubleHelper(d);
/* Fast path - see comment in numParseInt. */
if (-1.0e21 < d && d < 1.0e21)
return ParseIntDoubleHelper(d);
/* Slow path - convert to a string and parse normally. */
JSString *inputString = js_NumberToString(cx, d);
if (!inputString) {
TraceMonitor *tm = JS_TRACE_MONITOR_ON_TRACE(cx);
SetBuiltinError(tm);
return js_NaN;
}
return ParseInt(cx, inputString);
}
#endif
@@ -520,7 +540,7 @@ const char js_parseInt_str[] = "parseInt";
JS_DEFINE_TRCINFO_2(num_parseInt,
(2, (static, DOUBLE_FAIL, ParseInt, CONTEXT, STRING,1, nanojit::ACCSET_NONE)),
(1, (static, DOUBLE, ParseIntDouble, DOUBLE, 1, nanojit::ACCSET_NONE)))
(2, (static, DOUBLE_FAIL, ParseIntDouble, CONTEXT, DOUBLE,1, nanojit::ACCSET_NONE)))
JS_DEFINE_TRCINFO_1(num_parseFloat,
(2, (static, DOUBLE_FAIL, ParseFloat, CONTEXT, STRING, 1, nanojit::ACCSET_NONE)))