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

Unified Diff: src/v8natives.js

Issue 1072083002: [es6] don't "replace" Object.prototype.toString for --harmony-tostring (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Final fixup... Created 5 years, 8 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/runtime/runtime-internal.cc ('k') | test/mjsunit/es6/prototype-ordinary-objects.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index 56e8c2d69d035f49da62b2b2b7d25e7355a60979..51168d9156e47603f6bba4e3a20bf4260a53b03e 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -216,7 +216,7 @@ SetUpGlobal();
// ----------------------------------------------------------------------------
// Object
-var DefaultObjectToString = NoSideEffectsObjectToString;
+var DefaultObjectToString = ObjectToString;
// ECMA-262 - 15.2.4.2
function NoSideEffectsObjectToString() {
if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
@@ -225,6 +225,27 @@ function NoSideEffectsObjectToString() {
}
+function ObjectToString() {
+ if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]";
+ if (IS_NULL(this)) return "[object Null]";
+ var O = TO_OBJECT_INLINE(this);
+ var builtinTag = %_ClassOf(O);
+ var tag;
+
+ // TODO(caitp): cannot wait to get rid of this flag :>
+ if (harmony_tostring) {
+ var tag = O[symbolToStringTag];
+ if (!IS_STRING(tag)) {
+ tag = builtinTag;
+ }
+ } else {
+ tag = builtinTag;
+ }
+
+ return `[object ${tag}]`;
+}
+
+
// ECMA-262 - 15.2.4.3
function ObjectToLocaleString() {
CHECK_OBJECT_COERCIBLE(this, "Object.prototype.toLocaleString");
@@ -1410,7 +1431,7 @@ function SetUpObject() {
// Set up non-enumerable functions on the Object.prototype object.
InstallFunctions($Object.prototype, DONT_ENUM, $Array(
- "toString", NoSideEffectsObjectToString,
+ "toString", ObjectToString,
"toLocaleString", ObjectToLocaleString,
"valueOf", ObjectValueOf,
"hasOwnProperty", ObjectHasOwnProperty,
« no previous file with comments | « src/runtime/runtime-internal.cc ('k') | test/mjsunit/es6/prototype-ordinary-objects.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698