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, |