Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: src/runtime.js

Issue 1256323004: Optimize ToString and NonStringToString. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix messages test. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/messages.h ('k') | test/mjsunit/messages.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.js
diff --git a/src/runtime.js b/src/runtime.js
index dd776dbc8c354722c692c3580914398e5de26d30..e70666817321d2d60c7b7256ae9d20953663d8cc 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -766,7 +766,6 @@ function ToPrimitive(x, hint) {
if (IS_STRING(x)) return x;
// Normal behavior.
if (!IS_SPEC_OBJECT(x)) return x;
- if (IS_SYMBOL_WRAPPER(x)) throw MakeTypeError(kSymbolToPrimitive);
bbudge 2015/07/28 19:07:30 Is this error part of the Spec? If so, we have to
rossberg 2015/07/29 11:49:11 No, the spec doesn't even recognise the existence
if (IS_FLOAT32X4(x)) return x;
if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT;
return (hint == NUMBER_HINT) ? DefaultNumber(x) : DefaultString(x);
@@ -816,7 +815,7 @@ function ToString(x) {
if (IS_NUMBER(x)) return %_NumberToString(x);
if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
if (IS_UNDEFINED(x)) return 'undefined';
- if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToString);
+ // Types that can't be converted to string are caught in DefaultString.
return (IS_NULL(x)) ? 'null' : ToString(DefaultString(x));
}
@@ -824,7 +823,7 @@ function NonStringToString(x) {
if (IS_NUMBER(x)) return %_NumberToString(x);
if (IS_BOOLEAN(x)) return x ? 'true' : 'false';
if (IS_UNDEFINED(x)) return 'undefined';
- if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToString);
+ // Types that can't be converted to string are caught in DefaultString.
return (IS_NULL(x)) ? 'null' : ToString(DefaultString(x));
}
@@ -963,6 +962,7 @@ function DefaultNumber(x) {
// ECMA-262, section 8.6.2.6, page 28.
function DefaultString(x) {
if (!IS_SYMBOL_WRAPPER(x)) {
+ if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToString);
var toString = x.toString;
if (IS_SPEC_FUNCTION(toString)) {
var s = %_CallFunction(x, toString);
« no previous file with comments | « src/messages.h ('k') | test/mjsunit/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698