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

Unified Diff: src/objects.cc

Issue 1526023002: [proxies] Recognize arraylike proxies in Object.prototype.toString. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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/objects.h ('k') | test/mjsunit/es6/object-tostring.js » ('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 65b1524b981933a6a829a4fe084918bddd0e16ff..a7243f7a17b4cd0339ccaa03372af878f72e475f 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -1,4 +1,4 @@
-// Copyright 2013 the V8 project authors. All rights reserved.
+// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -2319,6 +2319,18 @@ String* JSReceiver::class_name() {
}
+MaybeHandle<String> JSReceiver::BuiltinStringTag(Handle<JSReceiver> object) {
+ Maybe<bool> is_array = Object::IsArray(object);
+ MAYBE_RETURN(is_array, MaybeHandle<String>());
+ if (is_array.FromJust()) {
+ return object->GetIsolate()->factory()->Array_string();
+ }
+ // TODO(adamk): class_name() is expensive, replace with instance type
+ // checks where possible.
+ return handle(object->class_name());
+}
+
+
// static
Handle<String> JSReceiver::GetConstructorName(Handle<JSReceiver> receiver) {
Isolate* isolate = receiver->GetIsolate();
@@ -16237,8 +16249,8 @@ int JSObject::GetOwnElementKeys(FixedArray* storage, PropertyFilter filter) {
}
-MaybeHandle<String> JSObject::ObjectProtoToString(Isolate* isolate,
- Handle<Object> object) {
+MaybeHandle<String> Object::ObjectProtoToString(Isolate* isolate,
+ Handle<Object> object) {
if (object->IsUndefined()) return isolate->factory()->undefined_to_string();
if (object->IsNull()) return isolate->factory()->null_to_string();
@@ -16258,9 +16270,8 @@ MaybeHandle<String> JSObject::ObjectProtoToString(Isolate* isolate,
}
if (tag.is_null()) {
- // TODO(adamk): class_name() is expensive, replace with instance type
- // checks where possible.
- tag = handle(receiver->class_name(), isolate);
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, tag,
+ JSReceiver::BuiltinStringTag(receiver), String);
}
IncrementalStringBuilder builder(isolate);
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/es6/object-tostring.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698