Reviewers: ulan,

Message:
PTAL

Description:
Cleanup in IC patching.

BUG=

Please review this at https://chromiumcodereview.appspot.com/25001005/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+31, -29 lines):
  M src/ic.cc
  M src/objects-inl.h
  M src/objects.h


Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index b8c45d1ec683906e653764e439c25b8204f6ead0..3216dfe4f4e849583fb1092cd58397bae6088b96 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:
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 7b51f0d99ae0d32f93cccde47300548566562593..9af70f9f2606fdf595747e7b8088d0d29989ebad 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -4027,6 +4027,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;
 }
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index b4edb8484bcc83c365e4f4c5426db611431d86c1..7f96bf5891fe489bf30aef0ca0b2d96a0a71579f 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -4905,6 +4905,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();


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to