Commit 1ce20687 authored by bmeurer's avatar bmeurer Committed by Commit bot

[builtins] Fix ToString in Array.prototype.join.

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}
parent 6266a9d6
...@@ -209,10 +209,11 @@ function Join(array, length, separator, convert) { ...@@ -209,10 +209,11 @@ function Join(array, length, separator, convert) {
function ConvertToString(x) { function ConvertToString(x) {
// Assumes x is a non-string. if (IS_NULL_OR_UNDEFINED(x)) {
if (IS_NUMBER(x)) return %_NumberToString(x); return '';
if (IS_BOOLEAN(x)) return x ? 'true' : 'false'; } else {
return (IS_NULL_OR_UNDEFINED(x)) ? '' : ToString($defaultString(x)); return TO_STRING(x);
}
} }
...@@ -224,7 +225,7 @@ function ConvertToLocaleString(e) { ...@@ -224,7 +225,7 @@ function ConvertToLocaleString(e) {
// must throw a TypeError if ToObject(e).toLocaleString isn't // must throw a TypeError if ToObject(e).toLocaleString isn't
// callable. // callable.
var e_obj = TO_OBJECT(e); var e_obj = TO_OBJECT(e);
return ToString(e_obj.toLocaleString()); return TO_STRING(e_obj.toLocaleString());
} }
} }
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
// The following declarations are shared with other native JS files. // The following declarations are shared with other native JS files.
// They are all declared at this one spot to avoid redeclaration errors. // They are all declared at this one spot to avoid redeclaration errors.
var $defaultString;
var $NaN; var $NaN;
var $nonNumberToNumber; var $nonNumberToNumber;
var $sameValue; var $sameValue;
...@@ -345,7 +344,6 @@ function ToPositiveInteger(x, rangeErrorIndex) { ...@@ -345,7 +344,6 @@ function ToPositiveInteger(x, rangeErrorIndex) {
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Exports // Exports
$defaultString = DefaultString;
$NaN = %GetRootNaN(); $NaN = %GetRootNaN();
$nonNumberToNumber = NonNumberToNumber; $nonNumberToNumber = NonNumberToNumber;
$sameValue = SameValue; $sameValue = SameValue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment