[builtins] Fix ToString in Array.prototype.join.
authorbmeurer <bmeurer@chromium.org>
Mon, 28 Sep 2015 05:03:29 +0000 (22:03 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 28 Sep 2015 05:03:42 +0000 (05:03 +0000)
The internal ConvertToString helper was using the wrong ToPrimitive,
actually the old ES5 like DefaultString, and it also prematurely
optimized for no real benefit.

BUG=v8:4307
LOG=n

Review URL: https://codereview.chromium.org/1370943002

Cr-Commit-Position: refs/heads/master@{#30956}

src/array.js
src/runtime.js

index 721121e..b2b038d 100644 (file)
@@ -209,10 +209,11 @@ function Join(array, length, separator, convert) {
 
 
 function ConvertToString(x) {
-  // Assumes x is a non-string.
-  if (IS_NUMBER(x)) return %_NumberToString(x);
-  if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
-  return (IS_NULL_OR_UNDEFINED(x)) ? '' : ToString($defaultString(x));
+  if (IS_NULL_OR_UNDEFINED(x)) {
+    return '';
+  } else {
+    return TO_STRING(x);
+  }
 }
 
 
@@ -224,7 +225,7 @@ function ConvertToLocaleString(e) {
     // must throw a TypeError if ToObject(e).toLocaleString isn't
     // callable.
     var e_obj = TO_OBJECT(e);
-    return ToString(e_obj.toLocaleString());
+    return TO_STRING(e_obj.toLocaleString());
   }
 }
 
index f0bc133..c3b8ed2 100644 (file)
@@ -11,7 +11,6 @@
 
 // The following declarations are shared with other native JS files.
 // They are all declared at this one spot to avoid redeclaration errors.
-var $defaultString;
 var $NaN;
 var $nonNumberToNumber;
 var $sameValue;
@@ -345,7 +344,6 @@ function ToPositiveInteger(x, rangeErrorIndex) {
 // ----------------------------------------------------------------------------
 // Exports
 
-$defaultString = DefaultString;
 $NaN = %GetRootNaN();
 $nonNumberToNumber = NonNumberToNumber;
 $sameValue = SameValue;