[runtime] Minor cleanup of inferred-name handling

Bug: 
Change-Id: Iccc0241859970ad4e04b9a6e5f206491aa7c442e
Reviewed-on: https://chromium-review.googlesource.com/781939
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49541}
This commit is contained in:
Toon Verwaest 2017-11-21 14:15:37 +01:00 committed by Commit Bot
parent 742b6d1b96
commit 572210e731
2 changed files with 7 additions and 10 deletions

View File

@ -3707,8 +3707,7 @@ Handle<String> JSReceiver::GetConstructorName(Handle<JSReceiver> receiver) {
Object* maybe_constructor = receiver->map()->GetConstructor(); Object* maybe_constructor = receiver->map()->GetConstructor();
if (maybe_constructor->IsJSFunction()) { if (maybe_constructor->IsJSFunction()) {
JSFunction* constructor = JSFunction::cast(maybe_constructor); JSFunction* constructor = JSFunction::cast(maybe_constructor);
String* name = constructor->shared()->name(); String* name = constructor->shared()->DebugName();
if (name->length() == 0) name = constructor->shared()->inferred_name();
if (name->length() != 0 && if (name->length() != 0 &&
!name->Equals(isolate->heap()->Object_string())) { !name->Equals(isolate->heap()->Object_string())) {
return handle(name, isolate); return handle(name, isolate);
@ -3735,8 +3734,7 @@ Handle<String> JSReceiver::GetConstructorName(Handle<JSReceiver> receiver) {
Handle<String> result = isolate->factory()->Object_string(); Handle<String> result = isolate->factory()->Object_string();
if (maybe_constructor->IsJSFunction()) { if (maybe_constructor->IsJSFunction()) {
JSFunction* constructor = JSFunction::cast(*maybe_constructor); JSFunction* constructor = JSFunction::cast(*maybe_constructor);
String* name = constructor->shared()->name(); String* name = constructor->shared()->DebugName();
if (name->length() == 0) name = constructor->shared()->inferred_name();
if (name->length() > 0) result = handle(name, isolate); if (name->length() > 0) result = handle(name, isolate);
} }
@ -13572,9 +13570,8 @@ void SharedFunctionInfo::set_debugger_hints(int value) {
} }
String* SharedFunctionInfo::DebugName() { String* SharedFunctionInfo::DebugName() {
String* n = name(); if (name()->length() == 0) return inferred_name();
if (String::cast(n)->length() == 0) return inferred_name(); return name();
return String::cast(n);
} }
bool SharedFunctionInfo::HasNoSideEffect() { bool SharedFunctionInfo::HasNoSideEffect() {

View File

@ -362,9 +362,9 @@ String* SharedFunctionInfo::inferred_name() {
if (HasInferredName()) { if (HasInferredName()) {
return String::cast(function_identifier()); return String::cast(function_identifier());
} }
Isolate* isolate = GetIsolate(); DCHECK(function_identifier()->IsUndefined(GetIsolate()) ||
DCHECK(function_identifier()->IsUndefined(isolate) || HasBuiltinFunctionId()); HasBuiltinFunctionId());
return isolate->heap()->empty_string(); return GetHeap()->empty_string();
} }
void SharedFunctionInfo::set_inferred_name(String* inferred_name) { void SharedFunctionInfo::set_inferred_name(String* inferred_name) {