Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 5c1e9aa653684776f9a1cf4d307b941f8dbacc35..839b9670fe6d638b2e273d5c69a768612972d22d 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -730,7 +730,7 @@ Handle<Object> JSReceiver::GetDataProperty(LookupIterator* it) { |
| case LookupIterator::TRANSITION: |
| UNREACHABLE(); |
| case LookupIterator::ACCESS_CHECK: |
| - if (it->HasAccess()) continue; |
| + if (it->isolate()->context() != nullptr && it->HasAccess()) continue; |
|
Camillo Bruni
2015/11/12 12:43:08
nit: maybe add a comment that you check for the mi
|
| // Fall through. |
| case LookupIterator::JSPROXY: |
| it->NotFound(); |
| @@ -1745,9 +1745,7 @@ MaybeHandle<JSFunction> Map::GetConstructorFunction( |
| void Map::PrintReconfiguration(FILE* file, int modify_index, PropertyKind kind, |
| PropertyAttributes attributes) { |
| OFStream os(file); |
| - os << "[reconfiguring "; |
| - constructor_name()->PrintOn(file); |
| - os << "] "; |
| + os << "[reconfiguring]"; |
| Name* name = instance_descriptors()->GetKey(modify_index); |
| if (name->IsString()) { |
| String::cast(name)->PrintOn(file); |
| @@ -1772,9 +1770,7 @@ void Map::PrintGeneralization(FILE* file, |
| HeapType* old_field_type, |
| HeapType* new_field_type) { |
| OFStream os(file); |
| - os << "[generalizing "; |
| - constructor_name()->PrintOn(file); |
| - os << "] "; |
| + os << "[generalizing]"; |
| Name* name = instance_descriptors()->GetKey(modify_index); |
| if (name->IsString()) { |
| String::cast(name)->PrintOn(file); |
| @@ -1806,9 +1802,7 @@ void Map::PrintGeneralization(FILE* file, |
| void JSObject::PrintInstanceMigration(FILE* file, |
| Map* original_map, |
| Map* new_map) { |
| - PrintF(file, "[migrating "); |
| - map()->constructor_name()->PrintOn(file); |
| - PrintF(file, "] "); |
| + PrintF(file, "[migrating]"); |
| DescriptorArray* o = original_map->instance_descriptors(); |
| DescriptorArray* n = new_map->instance_descriptors(); |
| for (int i = 0; i < original_map->NumberOfOwnDescriptors(); i++) { |
| @@ -2139,31 +2133,38 @@ String* JSReceiver::class_name() { |
| } |
| -String* Map::constructor_name() { |
| - if (is_prototype_map() && prototype_info()->IsPrototypeInfo()) { |
| - PrototypeInfo* proto_info = PrototypeInfo::cast(prototype_info()); |
| - if (proto_info->constructor_name()->IsString()) { |
| - return String::cast(proto_info->constructor_name()); |
| - } |
| +// static |
| +Handle<String> JSReceiver::GetConstructorName(Handle<JSReceiver> receiver) { |
| + Isolate* isolate = receiver->GetIsolate(); |
| + if (FLAG_harmony_tostring) { |
| + Handle<Object> maybe_tag = JSReceiver::GetDataProperty( |
| + receiver, isolate->factory()->to_string_tag_symbol()); |
| + if (maybe_tag->IsString()) return Handle<String>::cast(maybe_tag); |
| } |
| - Object* maybe_constructor = GetConstructor(); |
| + |
| + PrototypeIterator iter(isolate, receiver); |
| + if (iter.IsAtEnd()) return handle(receiver->class_name()); |
| + Handle<JSReceiver> start = PrototypeIterator::GetCurrent<JSReceiver>(iter); |
| + LookupIterator it(receiver, isolate->factory()->constructor_string(), start, |
| + LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR); |
| + Handle<Object> maybe_constructor = JSReceiver::GetDataProperty(&it); |
| + Handle<String> result = isolate->factory()->Object_string(); |
| if (maybe_constructor->IsJSFunction()) { |
| - JSFunction* constructor = JSFunction::cast(maybe_constructor); |
| + JSFunction* constructor = JSFunction::cast(*maybe_constructor); |
| String* name = String::cast(constructor->shared()->name()); |
| - if (name->length() > 0) return name; |
| - String* inferred_name = constructor->shared()->inferred_name(); |
| - if (inferred_name->length() > 0) return inferred_name; |
| - Object* proto = prototype(); |
| - if (proto->IsJSObject()) return JSObject::cast(proto)->constructor_name(); |
| + if (name->length() > 0) { |
| + result = handle(name, isolate); |
| + } else { |
| + String* inferred_name = constructor->shared()->inferred_name(); |
|
Camillo Bruni
2015/11/12 12:43:08
I would have expected to check for the inferred_na
|
| + if (inferred_name->length() > 0) { |
| + result = handle(inferred_name, isolate); |
| + } |
| + } |
| } |
| - // TODO(rossberg): what about proxies? |
| - // If the constructor is not present, return "Object". |
| - return GetHeap()->Object_string(); |
| -} |
| - |
| -String* JSReceiver::constructor_name() { |
| - return map()->constructor_name(); |
| + return result.is_identical_to(isolate->factory()->Object_string()) |
| + ? handle(receiver->class_name()) |
| + : result; |
| } |
| @@ -11304,13 +11305,9 @@ void JSObject::OptimizeAsPrototype(Handle<JSObject> object, |
| Isolate* isolate = object->GetIsolate(); |
| if (!constructor->shared()->IsApiFunction() && |
| object->class_name() == isolate->heap()->Object_string()) { |
| - Handle<String> constructor_name(object->constructor_name(), isolate); |
| Context* context = constructor->context()->native_context(); |
| JSFunction* object_function = context->object_function(); |
| object->map()->SetConstructor(object_function); |
| - Handle<PrototypeInfo> proto_info = |
| - Map::GetOrCreatePrototypeInfo(object, isolate); |
| - proto_info->set_constructor_name(*constructor_name); |
| } |
| } |
| } |