Reviewers: Jakob,

Message:
Committed patchset #1 manually as 22939 (presubmit successful).

Description:
Only allocate a handler compiler when necessary

BUG=
[email protected]

Committed: https://code.google.com/p/v8/source/detail?r=22939

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

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

Affected files (+21, -5 lines):
  M src/ic.cc


Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index 02d66b34ac6acc0325f6f2603fa081c4a82845ce..9007e9338f907210fc8746f667926175a8ac6e7e 100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -998,12 +998,11 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
   Handle<HeapType> type = receiver_type();
   Handle<JSObject> holder = lookup->GetHolder<JSObject>();
   bool receiver_is_holder = object.is_identical_to(holder);
-  NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
-                                    cache_holder);
-
   // -------------- Interceptors --------------
   if (lookup->state() == LookupIterator::INTERCEPTOR) {
     DCHECK(!holder->GetNamedInterceptor()->getter()->IsUndefined());
+    NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
+                                      cache_holder);
     return compiler.CompileLoadInterceptor(name);
   }
   DCHECK(lookup->state() == LookupIterator::PROPERTY);
@@ -1033,6 +1032,8 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
         return slow_stub();
       }
       if (!holder->HasFastProperties()) return slow_stub();
+      NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
+                                        cache_holder);
       return compiler.CompileLoadCallback(name, info);
     }
     if (accessors->IsAccessorPair()) {
@@ -1048,6 +1049,8 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
         return slow_stub();
       }
       CallOptimization call_optimization(function);
+      NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
+                                        cache_holder);
       if (call_optimization.is_simple_api_call() &&
           call_optimization.IsCompatibleReceiver(object, holder)) {
         return compiler.CompileLoadCallback(name, call_optimization);
@@ -1064,6 +1067,8 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
   if (lookup->property_encoding() == LookupIterator::DICTIONARY) {
     if (kind() != Code::LOAD_IC) return slow_stub();
     if (holder->IsGlobalObject()) {
+      NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
+                                        cache_holder);
       Handle<PropertyCell> cell = lookup->GetPropertyCell();
       Handle<Code> code =
           compiler.CompileLoadGlobal(cell, name, lookup->IsConfigurable());
@@ -1089,6 +1094,8 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
     if (receiver_is_holder) {
       return SimpleFieldLoad(field);
     }
+    NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
+                                      cache_holder);
     return compiler.CompileLoadField(name, field);
   }

@@ -1098,6 +1105,8 @@ Handle<Code> LoadIC::CompileHandler(LookupIterator* lookup,
     LoadConstantStub stub(isolate(), lookup->GetConstantIndex());
     return stub.GetCode();
   }
+  NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder,
+                                    cache_holder);
   return compiler.CompileLoadConstant(name, lookup->GetConstantIndex());
 }

@@ -1459,7 +1468,6 @@ Handle<Code> StoreIC::CompileStoreHandler(LookupResult* lookup,
   Handle<JSObject> receiver = Handle<JSObject>::cast(object);

   Handle<JSObject> holder(lookup->holder());
-  NamedStoreHandlerCompiler compiler(isolate(), receiver_type(), holder);

   if (lookup->IsTransition()) {
     // Explicitly pass in the receiver map since LookupForWrite may have
@@ -1469,6 +1477,7 @@ Handle<Code> StoreIC::CompileStoreHandler(LookupResult* lookup,

     if (details.type() != CALLBACKS && details.attributes() == NONE &&
         holder->HasFastProperties()) {
+ NamedStoreHandlerCompiler compiler(isolate(), receiver_type(), holder);
       return compiler.CompileStoreTransition(transition, name);
     }
   } else {
@@ -1486,6 +1495,7 @@ Handle<Code> StoreIC::CompileStoreHandler(LookupResult* lookup,
                               lookup->representation());
           return stub.GetCode();
         }
+ NamedStoreHandlerCompiler compiler(isolate(), receiver_type(), holder);
         return compiler.CompileStoreField(lookup, name);
       }
       case NORMAL:
@@ -1521,6 +1531,8 @@ Handle<Code> StoreIC::CompileStoreHandler(LookupResult* lookup,
                   isolate(), info, receiver_type())) {
             break;
           }
+          NamedStoreHandlerCompiler compiler(isolate(), receiver_type(),
+                                             holder);
           return compiler.CompileStoreCallback(receiver, name, info);
         } else if (callback->IsAccessorPair()) {
           Handle<Object> setter(
@@ -1530,6 +1542,8 @@ Handle<Code> StoreIC::CompileStoreHandler(LookupResult* lookup,
           if (!holder->HasFastProperties()) break;
           Handle<JSFunction> function = Handle<JSFunction>::cast(setter);
           CallOptimization call_optimization(function);
+          NamedStoreHandlerCompiler compiler(isolate(), receiver_type(),
+                                             holder);
           if (call_optimization.is_simple_api_call() &&
               call_optimization.IsCompatibleReceiver(receiver, holder)) {
             return compiler.CompileStoreCallback(receiver, name,
@@ -1542,9 +1556,11 @@ Handle<Code> StoreIC::CompileStoreHandler(LookupResult* lookup,
         DCHECK(callback->IsDeclaredAccessorInfo());
         break;
       }
-      case INTERCEPTOR:
+      case INTERCEPTOR: {
         DCHECK(HasInterceptorSetter(*holder));
+ NamedStoreHandlerCompiler compiler(isolate(), receiver_type(), holder);
         return compiler.CompileStoreInterceptor(name);
+      }
       case CONSTANT:
         break;
       case NONEXISTENT:


--
--
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/d/optout.

Reply via email to