Revision: 8504
Author:   [email protected]
Date:     Fri Jul  1 00:58:58 2011
Log: Cleanup polymorphic IC code to make use of ElementsKind information in maps.

Review URL: http://codereview.chromium.org/7283044
http://code.google.com/p/v8/source/detail?r=8504

Modified:
 /branches/bleeding_edge/src/ic.cc
 /branches/bleeding_edge/src/ic.h

=======================================
--- /branches/bleeding_edge/src/ic.cc   Fri Jul  1 00:50:46 2011
+++ /branches/bleeding_edge/src/ic.cc   Fri Jul  1 00:58:58 2011
@@ -1095,16 +1095,6 @@
   TraceIC("LoadIC", name, state, target());
 #endif
 }
-
-
-String* KeyedLoadIC::GetStubNameForCache(IC::State ic_state) {
-  if (ic_state == MONOMORPHIC) {
-    return isolate()->heap()->KeyedLoadElementMonomorphic_symbol();
-  } else {
-    ASSERT(ic_state == MEGAMORPHIC);
-    return isolate()->heap()->KeyedLoadElementPolymorphic_symbol();
-  }
-}


 MaybeObject* KeyedLoadIC::GetFastElementStubWithoutMapCheck(
@@ -1634,18 +1624,14 @@
                                   StrictModeFlag strict_mode,
                                   Code* generic_stub) {
   State ic_state = target()->ic_state();
-  Code* monomorphic_stub;
- // Always compute the MONOMORPHIC stub, even if the MEGAMORPHIC stub ends up - // being used. This is necessary because the megamorphic stub needs to have - // access to more information than what is stored in the receiver map in some
-  // cases (external arrays need the array type from the MONOMORPHIC stub).
-  MaybeObject* maybe_stub = ComputeMonomorphicStub(receiver,
-                                                   is_store,
-                                                   strict_mode,
-                                                   generic_stub);
-  if (!maybe_stub->To(&monomorphic_stub)) return maybe_stub;
-
   if (ic_state == UNINITIALIZED || ic_state == PREMONOMORPHIC) {
+    Code* monomorphic_stub;
+    MaybeObject* maybe_stub = ComputeMonomorphicStub(receiver,
+                                                     is_store,
+                                                     strict_mode,
+                                                     generic_stub);
+    if (!maybe_stub->To(&monomorphic_stub)) return maybe_stub;
+
     return monomorphic_stub;
   }
   ASSERT(target() != generic_stub);
@@ -1696,9 +1682,9 @@
   }
   // Build the MEGAMORPHIC stub.
   Code* stub;
-  maybe_stub = ConstructMegamorphicStub(&target_receiver_maps,
-                                        &handler_ics,
-                                        strict_mode);
+  MaybeObject* maybe_stub = ConstructMegamorphicStub(&target_receiver_maps,
+                                                     &handler_ics,
+                                                     strict_mode);
   if (!maybe_stub->To(&stub)) return maybe_stub;
MaybeObject* maybe_update = cache->Update(&target_receiver_maps, flags, stub);
   if (maybe_update->IsFailure()) return maybe_update;
@@ -1714,22 +1700,7 @@
     ASSERT(string_stub() != NULL);
     return string_stub();
   } else if (receiver_map->has_external_array_elements()) {
- // Determine the array type from the default MONOMORPHIC already generated - // stub. There is no other way to determine the type of the external array
-    // directly from the receiver type.
-    Code::Kind kind = this->kind();
-    Code::Flags flags = Code::ComputeMonomorphicFlags(kind,
-                                                      NORMAL,
-                                                      strict_mode);
-    String* monomorphic_name = GetStubNameForCache(MONOMORPHIC);
- Object* maybe_default_stub = receiver_map->FindInCodeCache(monomorphic_name,
-                                                               flags);
-    if (maybe_default_stub->IsUndefined()) {
-      return generic_stub;
-    }
-    Code* default_stub = Code::cast(maybe_default_stub);
-    Map* first_map = default_stub->FindFirstMap();
-    return GetExternalArrayStubWithoutMapCheck(first_map->elements_kind());
+ return GetExternalArrayStubWithoutMapCheck(receiver_map->elements_kind());
   } else if (receiver_map->has_fast_elements()) {
     bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
     return GetFastElementStubWithoutMapCheck(is_js_array);
@@ -1756,16 +1727,6 @@
   }
   return result;
 }
-
-
-String* KeyedStoreIC::GetStubNameForCache(IC::State ic_state) {
-  if (ic_state == MONOMORPHIC) {
-    return isolate()->heap()->KeyedStoreElementMonomorphic_symbol();
-  } else {
-    ASSERT(ic_state == MEGAMORPHIC);
-    return isolate()->heap()->KeyedStoreElementPolymorphic_symbol();
-  }
-}


 MaybeObject* KeyedStoreIC::GetFastElementStubWithoutMapCheck(
=======================================
--- /branches/bleeding_edge/src/ic.h    Mon Jun 20 03:19:00 2011
+++ /branches/bleeding_edge/src/ic.h    Fri Jul  1 00:58:58 2011
@@ -358,8 +358,6 @@

   virtual Code::Kind kind() const = 0;

-  virtual String* GetStubNameForCache(IC::State ic_state) = 0;
-
   MaybeObject* ComputeStub(JSObject* receiver,
                            bool is_store,
                            StrictModeFlag strict_mode,
@@ -425,8 +423,6 @@

  protected:
   virtual Code::Kind kind() const { return Code::KEYED_LOAD_IC; }
-
-  virtual String* GetStubNameForCache(IC::State ic_state);

   virtual MaybeObject* ConstructMegamorphicStub(
       MapList* receiver_maps,
@@ -580,8 +576,6 @@

  protected:
   virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; }
-
-  virtual String* GetStubNameForCache(IC::State ic_state);

   virtual MaybeObject* ConstructMegamorphicStub(
       MapList* receiver_maps,

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to