This commit is contained in:
Robert Sayre 2009-03-11 04:19:20 -04:00
commit 8f77fb9b9e
2 changed files with 29 additions and 8 deletions

View File

@ -4944,9 +4944,15 @@ TraceRecorder::stringify(jsval& v)
} else if (JSVAL_TAG(v) == JSVAL_BOOLEAN) {
ci = &js_BooleanOrUndefinedToString_ci;
} else {
/* We can't stringify objects here (use imacros instead), just return NULL. */
return NULL;
/*
* Callers must deal with non-primitive (non-null object) values by
* calling an imacro. We don't try to guess about which imacro, with
* what valueOf hint, here.
*/
JS_ASSERT(JSVAL_IS_NULL(v));
return INS_CONSTPTR(cx->runtime->atomState.nullAtom);
}
v_ins = lir->insCall(ci, args);
guard(false, lir->ins_eq0(v_ins), OOM_EXIT);
return v_ins;
@ -6398,8 +6404,6 @@ TraceRecorder::record_JSOP_ADD()
if (JSVAL_IS_STRING(l) || JSVAL_IS_STRING(r)) {
LIns* args[] = { stringify(r), stringify(l), cx_ins };
if (!args[0] || !args[1])
ABORT_TRACE("can't stringify objects");
LIns* concat = lir->insCall(&js_ConcatStrings_ci, args);
guard(false, lir->ins_eq0(concat), OOM_EXIT);
set(&l, concat);
@ -6707,10 +6711,7 @@ TraceRecorder::functionCall(bool constructing, uintN argc)
jsval& v = stackval(0 - argc);
if (!JSVAL_IS_PRIMITIVE(v))
return call_imacro(call_imacros.String);
LIns *i = stringify(v);
if (!i)
ABORT_TRACE("can't stringify value");
set(&fval, i);
set(&fval, stringify(v));
return true;
}
}

View File

@ -4503,6 +4503,26 @@ testToStringBeforeValueOf.jitstats = {
};
test(testToStringBeforeValueOf);
function testNullToString()
{
var a = [];
for (var i = 0; i < 10; i++)
a.push(String(null));
for (i = 0; i < 10; i++) {
var t = typeof a[i];
if (t != "string")
a.push(t);
}
return a.join(",");
}
testNullToString.expected = "null,null,null,null,null,null,null,null,null,null";
testNullToString.jitstats = {
recorderStarted: 2,
sideExitIntoInterpreter: 2,
recorderAborted: 0
};
test(testNullToString);
/*****************************************************************************
* *