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) {
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());
}
}
......
......@@ -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;
......
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