Merge.
authorRobert Sayre <sayrer@gmail.com>
Wed, 11 Mar 2009 04:19:20 -0400
changeset 26037 11e02710ebfa15ea0a7fd2038d869084b5757dc2
parent 26035 44cd744842422ca215443df7c86c7490686773ef (current diff)
parent 26036 89b61367af4cd5b31acf041eddfee7b34dba42da (diff)
child 26038 ae7ce7e47f5adddd65d9b3b83516c19d14cf37a3
child 26058 e0a0a14fd1d362b6a1f138996960cfab1c7a21fa
push id5861
push userrsayre@mozilla.com
push dateWed, 11 Mar 2009 08:21:19 +0000
treeherdermozilla-central@11e02710ebfa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.2a1pre
Merge.
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -4939,19 +4939,25 @@ TraceRecorder::stringify(jsval& v)
 
     LIns* args[] = { v_ins, cx_ins };
     const CallInfo* ci;
     if (JSVAL_IS_NUMBER(v)) {
         ci = &js_NumberToString_ci;
     } 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;
 }
 
 JS_REQUIRES_STACK bool
 TraceRecorder::call_imacro(jsbytecode* imacro)
 {
@@ -6393,18 +6399,16 @@ TraceRecorder::record_JSOP_ADD()
             return call_imacro(add_imacros.obj_obj);
         return call_imacro(add_imacros.obj_any);
     }
     if (!JSVAL_IS_PRIMITIVE(r))
         return call_imacro(add_imacros.any_obj);
 
     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);
         return true;
     }
 
     return binary(LIR_fadd);
 }
@@ -6702,20 +6706,17 @@ TraceRecorder::functionCall(bool constru
     if (FUN_SLOW_NATIVE(fun)) {
         JSNative native = fun->u.n.native;
         if (native == js_Array)
             return newArray(FUN_OBJECT(fun), argc, &tval + 1, &fval);
         if (native == js_String && argc == 1 && !constructing) {
             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;
         }
     }
 
     if (!(fun->flags & JSFUN_TRACEABLE))
         ABORT_TRACE("untraceable native");
 
     JSTraceableNative* known = FUN_TRCINFO(fun);
--- a/js/src/trace-test.js
+++ b/js/src/trace-test.js
@@ -4498,16 +4498,36 @@ function testToStringBeforeValueOf()
 }
 testToStringBeforeValueOf.expected = "s,s,s,s,s,s,s,s,s,s";
 testToStringBeforeValueOf.jitstats = {
   recorderStarted: 1,
   sideExitIntoInterpreter: 1
 };
 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);
+
 
 /*****************************************************************************
  *                                                                           *
  *  _____ _   _  _____ ______ _____ _______                                  *
  * |_   _| \ | |/ ____|  ____|  __ \__   __|                                 *
  *   | | |  \| | (___ | |__  | |__) | | |                                    *
  *   | | | . ` |\___ \|  __| |  _  /  | |                                    *
  *  _| |_| |\  |____) | |____| | \ \  | |                                    *