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

Unified Diff: src/runtime.js

Issue 118553003: Upgrade Symbol implementation to match current ES6 behavior. (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: Created 6 years, 12 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
Index: src/runtime.js
diff --git a/src/runtime.js b/src/runtime.js
index 35bc07a10e8c26f37ccb96dc5ce5dc2d6cbac625..e59075ca1ab56db77cb00cf02e8c76feccf28efc 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -81,6 +81,8 @@ function EQUALS(y) {
if (!IS_SPEC_OBJECT(y)) return 1; // not equal
y = %ToPrimitive(y, NO_HINT);
}
+ } else if (IS_SYMBOL_WRAPPER(x) && IS_SYMBOL_WRAPPER(y)) {
+ return %_ObjectEquals(x, y) ? 0 : 1;
} else if (IS_BOOLEAN(x)) {
if (IS_BOOLEAN(y)) return %_ObjectEquals(x, y) ? 0 : 1;
if (IS_NULL_OR_UNDEFINED(y)) return 1;
@@ -502,7 +504,7 @@ function ToPrimitive(x, hint) {
if (IS_STRING(x)) return x;
// Normal behavior.
if (!IS_SPEC_OBJECT(x)) return x;
- if (IS_SYMBOL_WRAPPER(x)) return %_ValueOf(x);
+ if (IS_SYMBOL_WRAPPER(x)) throw MakeTypeError('symbol_to_primitive', []);
if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT;
return (hint == NUMBER_HINT) ? %DefaultNumber(x) : %DefaultString(x);
}
@@ -549,6 +551,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('symbol_to_string', []);
return (IS_NULL(x)) ? 'null' : %ToString(%DefaultString(x));
}
@@ -569,7 +572,7 @@ function ToName(x) {
// ECMA-262, section 9.9, page 36.
function ToObject(x) {
if (IS_STRING(x)) return new $String(x);
- if (IS_SYMBOL(x)) return new $Symbol(x);
+ if (IS_SYMBOL(x)) return new $SymbolWrapper(x);
if (IS_NUMBER(x)) return new $Number(x);
if (IS_BOOLEAN(x)) return new $Boolean(x);
if (IS_NULL_OR_UNDEFINED(x) && !IS_UNDETECTABLE(x)) {
« no previous file with comments | « src/runtime.cc ('k') | src/symbol.js » ('j') | test/mjsunit/harmony/symbols.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698