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

Unified Diff: src/objects.cc

Issue 2071343002: Fix Object.prototype.toString() when @@toStringTag is not a string. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add test for global object Created 4 years, 6 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/d8.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 3b1c24f0dd3283102e837c9692edb3e8f6858c62..1653247d9b653a2c839b883608ac4b6c8bb56eed 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2537,6 +2537,7 @@ MaybeHandle<String> JSReceiver::BuiltinStringTag(Handle<JSReceiver> object) {
if (is_array.FromJust()) {
return isolate->factory()->Array_string();
}
+
// TODO(adamk): According to ES2015, we should return "Function" when
// object has a [[Call]] internal method (corresponds to IsCallable).
// But this is well cemented in layout tests and might cause webbreakage.
@@ -2545,7 +2546,23 @@ MaybeHandle<String> JSReceiver::BuiltinStringTag(Handle<JSReceiver> object) {
// }
// TODO(adamk): class_name() is expensive, replace with instance type
// checks where possible.
- return handle(object->class_name(), isolate);
+
+ InstanceType instance_type = object->map()->instance_type();
+ switch (instance_type) {
+ case JS_PROXY_TYPE:
+ case JS_SPECIAL_API_OBJECT_TYPE:
+ case JS_API_OBJECT_TYPE:
+ case JS_VALUE_TYPE:
+ case JS_DATE_TYPE:
+ // Arguments and Error objects have type JS_OBJECT_TYPE
+ case JS_OBJECT_TYPE:
+ case JS_REGEXP_TYPE:
+ case JS_BOUND_FUNCTION_TYPE:
+ case JS_FUNCTION_TYPE:
+ return handle(object->class_name(), isolate);
+ default:
+ return isolate->factory()->Object_string();
+ }
}
« no previous file with comments | « src/d8.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698