Reviewers: Toon Verwaest,

Message:
PTAL

Description:
Unify monomorphic and polymorphic cases in IC::PatchCache.

BUG=

Please review this at https://codereview.chromium.org/171683007/

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

Affected files (+18, -24 lines):
  M src/ic.cc


Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index bd06cb6f9617d5bcf435673cbf507ae91eeedc97..2c0c59031c508d86c8e5d8af3aa5f9b52910af96 100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -605,27 +605,34 @@ bool IC::UpdatePolymorphicIC(Handle<HeapType> type,
                              Handle<String> name,
                              Handle<Code> code) {
   if (!code->is_handler()) return false;
-  int number_of_valid_types;
-  int handler_to_overwrite = -1;

   int number_of_types = types()->length();
-  number_of_valid_types = number_of_types;
+
+  int deprecated_types = 0;
+  int handler_to_overwrite = -1;

   for (int i = 0; i < number_of_types; i++) {
     Handle<HeapType> current_type = types()->at(i);
-    // Filter out deprecated maps to ensure their instances get migrated.
if (current_type->IsClass() && current_type->AsClass()->is_deprecated()) {
-      number_of_valid_types--;
- // If the receiver type is already in the polymorphic IC, this indicates - // there was a prototoype chain failure. In that case, just overwrite the
-    // handler.
+      // Filter out deprecated maps to ensure their instances get migrated.
+      ++deprecated_types;
     } else if (type->IsCurrently(current_type)) {
-      ASSERT(handler_to_overwrite == -1);
-      number_of_valid_types--;
+ // If the receiver type is already in the polymorphic IC, this indicates + // there was a prototoype chain failure. In that case, just overwrite the
+      // handler.
+      handler_to_overwrite = i;
+    } else if (handler_to_overwrite == -1 &&
+               current_type->IsClass() &&
+               type->IsClass() &&
+               IsTransitionOfMonomorphicTarget(*current_type->AsClass(),
+                                               *type->AsClass())) {
       handler_to_overwrite = i;
     }
   }

+  int number_of_valid_types =
+      number_of_types - deprecated_types - (handler_to_overwrite != -1);
+
   if (number_of_valid_types >= 4) return false;
   if (number_of_types == 0) return false;
   if (handlers()->length() < types()->length()) return false;
@@ -727,20 +734,7 @@ void IC::PatchCache(Handle<HeapType> type,
     case MONOMORPHIC_PROTOTYPE_FAILURE:
       UpdateMonomorphicIC(type, code, name);
       break;
-    case MONOMORPHIC: {
-      // For now, call stubs are allowed to rewrite to the same stub. This
-      // happens e.g., when the field does not contain a function.
-      ASSERT(!target().is_identical_to(code));
-      Map* old_map = first_map();
-      Code* old_handler = first_handler();
-      Map* map = type->IsClass() ? *type->AsClass() : NULL;
-      if (old_handler == *code &&
-          IsTransitionOfMonomorphicTarget(old_map, map)) {
-        UpdateMonomorphicIC(type, code, name);
-        break;
-      }
-      // Fall through.
-    }
+    case MONOMORPHIC:  // Fall through.
     case POLYMORPHIC:
       if (!target()->is_keyed_stub()) {
         if (UpdatePolymorphicIC(type, name, code)) break;


--
--
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