From 14422a698fced1f7b9e85547dd9f9d4c93d22b1d Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Tue, 1 Oct 2013 09:44:35 +0000 Subject: [PATCH] Cleanup in IC patching. BUG= R=ulan@chromium.org Review URL: https://chromiumcodereview.appspot.com/25001005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17036 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/ic.cc | 54 ++++++++++++++++++++++------------------------- src/objects-inl.h | 5 +++++ src/objects.h | 1 + 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/ic.cc b/src/ic.cc index e88c74a364..68fc4c2f66 100644 --- a/src/ic.cc +++ b/src/ic.cc @@ -182,9 +182,7 @@ Address IC::OriginalCodeAddress() const { static bool TryRemoveInvalidPrototypeDependentStub(Code* target, Object* receiver, Object* name) { - if (target->is_keyed_load_stub() || - target->is_keyed_call_stub() || - target->is_keyed_store_stub()) { + if (target->is_keyed_stub()) { // Determine whether the failure is due to a name failure. if (!name->IsName()) return false; Name* stub_name = target->FindFirstName(); @@ -1102,46 +1100,44 @@ void IC::PatchCache(State state, UpdateMonomorphicIC(receiver, code, name); break; case MONOMORPHIC: - // Only move to megamorphic if the target changes. - if (target() != *code) { - if (target()->is_load_stub() || target()->is_store_stub()) { - bool is_same_handler = false; - { - DisallowHeapAllocation no_allocation; - Code* old_handler = target()->FindFirstHandler(); - is_same_handler = old_handler == *code; - } - if (is_same_handler - && IsTransitionedMapOfMonomorphicTarget(receiver->map())) { - UpdateMonomorphicIC(receiver, code, name); - break; - } - if (UpdatePolymorphicIC(state, receiver, name, code)) { - break; - } - - CopyICToMegamorphicCache(name); + ASSERT(target() != *code); + if (!target()->is_keyed_stub()) { + bool is_same_handler = false; + { + DisallowHeapAllocation no_allocation; + Code* old_handler = target()->FindFirstHandler(); + is_same_handler = old_handler == *code; + } + if (is_same_handler + && IsTransitionedMapOfMonomorphicTarget(receiver->map())) { + UpdateMonomorphicIC(receiver, code, name); + break; + } + if (UpdatePolymorphicIC(state, receiver, name, code)) { + break; } - UpdateMegamorphicCache(receiver->map(), *name, *code); - set_target(*megamorphic_stub()); + CopyICToMegamorphicCache(name); } + + UpdateMegamorphicCache(receiver->map(), *name, *code); + set_target(*megamorphic_stub()); break; case MEGAMORPHIC: UpdateMegamorphicCache(receiver->map(), *name, *code); break; case POLYMORPHIC: - if (target()->is_load_stub() || target()->is_store_stub()) { + if (target()->is_keyed_stub()) { + // When trying to patch a polymorphic keyed stub with anything other + // than another polymorphic stub, go generic. + set_target(*generic_stub()); + } else { if (UpdatePolymorphicIC(state, receiver, name, code)) { break; } CopyICToMegamorphicCache(name); UpdateMegamorphicCache(receiver->map(), *name, *code); set_target(*megamorphic_stub()); - } else { - // When trying to patch a polymorphic keyed load/store element stub - // with anything other than another polymorphic stub, go generic. - set_target(*generic_stub()); } break; case DEBUG_STUB: diff --git a/src/objects-inl.h b/src/objects-inl.h index 7293f11094..785257c6ba 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -4028,6 +4028,11 @@ bool Code::is_inline_cache_stub() { } +bool Code::is_keyed_stub() { + return is_keyed_load_stub() || is_keyed_store_stub() || is_keyed_call_stub(); +} + + bool Code::is_debug_stub() { return ic_state() == DEBUG_STUB; } diff --git a/src/objects.h b/src/objects.h index 5fba15c37a..209f1bb3ab 100644 --- a/src/objects.h +++ b/src/objects.h @@ -4895,6 +4895,7 @@ class Code: public HeapObject { inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; } inline bool is_compare_nil_ic_stub() { return kind() == COMPARE_NIL_IC; } inline bool is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; } + inline bool is_keyed_stub(); // [major_key]: For kind STUB or BINARY_OP_IC, the major key. inline int major_key();