Keep the inline caches for the builtins object monomorphic when
authorager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 16 Sep 2008 09:21:22 +0000 (09:21 +0000)
committerager@chromium.org <ager@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 16 Sep 2008 09:21:22 +0000 (09:21 +0000)
libraries are loaded lazily.

Review URL: http://codereview.chromium.org/2885

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@313 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/ic.cc

index df1e120..be90d80 100644 (file)
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -160,6 +160,19 @@ IC::State IC::StateFrom(Code* target, Object* receiver) {
 
     return MONOMORPHIC_PROTOTYPE_FAILURE;
   }
+
+  // The builtins object is special.  It only changes when JavaScript
+  // builtins are loaded lazily.  It is important to keep inline
+  // caches for the builtins object monomorphic.  Therefore, if we get
+  // an inline cache miss for the builtins object after lazily loading
+  // JavaScript builtins, we clear the code cache and return
+  // uninitialized as the state to force the inline cache back to
+  // monomorphic state.
+  if (receiver->IsJSBuiltinsObject()) {
+    map->ClearCodeCache();
+    return UNINITIALIZED;
+  }
+
   return MONOMORPHIC;
 }