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}
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);
+ }
}
// 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());
}
}
// 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;
// ----------------------------------------------------------------------------
// Exports
-$defaultString = DefaultString;
$NaN = %GetRootNaN();
$nonNumberToNumber = NonNumberToNumber;
$sameValue = SameValue;