Commit e174e26b authored by verwaest@chromium.org's avatar verwaest@chromium.org

Only allocate a handler compiler when necessary

BUG=
R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/443993002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22939 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c29b0a96
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment