From 2010ac0c7d13d3211f071bacd1a5a7ba5c6abc41 Mon Sep 17 00:00:00 2001 From: ishell Date: Thu, 3 Nov 2016 10:52:16 -0700 Subject: [PATCH] [ic] Avoid extra prototype chain iteration when creating a load IC data handler. Since all possible data-encoded prototype chain checks are supported by LoadIC we can remove this extra iteration. LoadGlobalIC does not support data handlers yet. BUG=v8:5561 Review-Url: https://codereview.chromium.org/2479523002 Cr-Commit-Position: refs/heads/master@{#40738} --- src/ic/ic.cc | 24 +++++++++++------------- src/ic/ic.h | 11 +++++------ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/ic/ic.cc b/src/ic/ic.cc index 9900f87289..27a3228c9f 100644 --- a/src/ic/ic.cc +++ b/src/ic/ic.cc @@ -915,10 +915,10 @@ int LoadIC::GetPrototypeCheckCount(Handle receiver_map, Handle(), Handle()); } -Handle LoadIC::SimpleLoadFromPrototype(Handle receiver_map, - Handle holder, - Handle name, - Handle smi_handler) { +Handle LoadIC::LoadFromPrototype(Handle receiver_map, + Handle holder, + Handle name, + Handle smi_handler) { int checks_count = GetPrototypeCheckCount(receiver_map, holder); DCHECK_LE(0, checks_count); @@ -950,8 +950,8 @@ Handle LoadIC::SimpleLoadFromPrototype(Handle receiver_map, return handler_array; } -Handle LoadIC::SimpleLoadNonExistent(Handle receiver_map, - Handle name) { +Handle LoadIC::LoadNonExistent(Handle receiver_map, + Handle name) { Handle holder; // null handle int checks_count = GetPrototypeCheckCount(receiver_map, holder); DCHECK_LE(0, checks_count); @@ -1041,7 +1041,7 @@ void LoadIC::UpdateCaches(LookupIterator* lookup) { } else if (!lookup->IsFound()) { if (kind() == Code::LOAD_IC) { TRACE_HANDLER_STATS(isolate(), LoadIC_LoadNonexistentDH); - code = SimpleLoadNonExistent(receiver_map(), lookup->name()); + code = LoadNonExistent(receiver_map(), lookup->name()); } else if (kind() == Code::LOAD_GLOBAL_IC) { code = NamedLoadHandlerCompiler::ComputeLoadNonexistent(lookup->name(), receiver_map()); @@ -1387,10 +1387,9 @@ Handle LoadIC::GetMapIndependentHandler(LookupIterator* lookup) { if (receiver_is_holder) { return smi_handler; } - if (FLAG_tf_load_ic_stub && GetPrototypeCheckCount(map, holder) >= 0) { + if (FLAG_tf_load_ic_stub && kind() != Code::LOAD_GLOBAL_IC) { TRACE_HANDLER_STATS(isolate(), LoadIC_LoadFieldFromPrototypeDH); - return SimpleLoadFromPrototype(map, holder, lookup->name(), - smi_handler); + return LoadFromPrototype(map, holder, lookup->name(), smi_handler); } break; // Custom-compiled handler. } @@ -1404,10 +1403,9 @@ Handle LoadIC::GetMapIndependentHandler(LookupIterator* lookup) { TRACE_HANDLER_STATS(isolate(), LoadIC_LoadConstantDH); return smi_handler; } - if (GetPrototypeCheckCount(map, holder) >= 0) { + if (kind() != Code::LOAD_GLOBAL_IC) { TRACE_HANDLER_STATS(isolate(), LoadIC_LoadConstantFromPrototypeDH); - return SimpleLoadFromPrototype(map, holder, lookup->name(), - smi_handler); + return LoadFromPrototype(map, holder, lookup->name(), smi_handler); } } else { if (receiver_is_holder) { diff --git a/src/ic/ic.h b/src/ic/ic.h index 39036c42d6..47cc54257c 100644 --- a/src/ic/ic.h +++ b/src/ic/ic.h @@ -325,14 +325,13 @@ class LoadIC : public IC { // Creates a data handler that represents a prototype chain check followed // by given Smi-handler that encoded a load from the holder. // Can be used only if GetPrototypeCheckCount() returns non negative value. - Handle SimpleLoadFromPrototype(Handle receiver_map, - Handle holder, - Handle name, - Handle smi_handler); + Handle LoadFromPrototype(Handle receiver_map, + Handle holder, Handle name, + Handle smi_handler); // Creates a data handler that represents a load of a non-existent property. - Handle SimpleLoadNonExistent(Handle receiver_map, - Handle name); + Handle LoadNonExistent(Handle receiver_map, Handle name); + friend class IC; };