Commit 8c9958e5 authored by ager@chromium.org's avatar ager@chromium.org

Only update the stub cache tables with monomorphic stubs used by

megamorphic call sites. This removes a lot of contention in the
tables.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4853 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 74cbb6ca
......@@ -387,6 +387,7 @@ Object* CallICBase::TryCallAsFunction(Object* object) {
return *delegate;
}
void CallICBase::ReceiverToObject(Handle<Object> object) {
HandleScope scope;
Handle<Object> receiver(object);
......@@ -588,6 +589,9 @@ void CallICBase::UpdateCaches(LookupResult* lookup,
state == MONOMORPHIC ||
state == MONOMORPHIC_PROTOTYPE_FAILURE) {
set_target(Code::cast(code));
} else if (state == MEGAMORPHIC) {
// Update the stub cache.
StubCache::Set(*name, GetCodeCacheMapForObject(*object), Code::cast(code));
}
#ifdef DEBUG
......@@ -664,7 +668,6 @@ Object* LoadIC::Load(State state, Handle<Object> object, Handle<String> name) {
Code* target = NULL;
target = Builtins::builtin(Builtins::LoadIC_StringLength);
set_target(target);
StubCache::Set(*name, map, target);
return Smi::FromInt(String::cast(*object)->length());
}
......@@ -679,7 +682,6 @@ Object* LoadIC::Load(State state, Handle<Object> object, Handle<String> name) {
Code* target = Builtins::builtin(Builtins::LoadIC_ArrayLength);
set_target(target);
StubCache::Set(*name, map, target);
return JSArray::cast(*object)->length();
}
......@@ -691,7 +693,6 @@ Object* LoadIC::Load(State state, Handle<Object> object, Handle<String> name) {
#endif
Code* target = Builtins::builtin(Builtins::LoadIC_FunctionPrototype);
set_target(target);
StubCache::Set(*name, HeapObject::cast(*object)->map(), target);
return Accessors::FunctionGetPrototype(*object, 0);
}
}
......@@ -847,6 +848,9 @@ void LoadIC::UpdateCaches(LookupResult* lookup,
set_target(Code::cast(code));
} else if (state == MONOMORPHIC) {
set_target(megamorphic_stub());
} else if (state == MEGAMORPHIC) {
// Update the stub cache.
StubCache::Set(*name, GetCodeCacheMapForObject(*object), Code::cast(code));
}
#ifdef DEBUG
......@@ -1110,7 +1114,6 @@ Object* StoreIC::Store(State state,
return *value;
}
// Use specialized code for setting the length of arrays.
if (receiver->IsJSArray()
&& name->Equals(Heap::length_symbol())
......@@ -1120,7 +1123,6 @@ Object* StoreIC::Store(State state,
#endif
Code* target = Builtins::builtin(Builtins::StoreIC_ArrayLength);
set_target(target);
StubCache::Set(*name, HeapObject::cast(*object)->map(), target);
return receiver->SetProperty(*name, *value, NONE);
}
......@@ -1208,8 +1210,11 @@ void StoreIC::UpdateCaches(LookupResult* lookup,
if (state == UNINITIALIZED || state == MONOMORPHIC_PROTOTYPE_FAILURE) {
set_target(Code::cast(code));
} else if (state == MONOMORPHIC) {
// Only move to mega morphic if the target changes.
// Only move to megamorphic if the target changes.
if (target() != Code::cast(code)) set_target(megamorphic_stub());
} else if (state == MEGAMORPHIC) {
// Update the stub cache.
StubCache::Set(*name, receiver->map(), Code::cast(code));
}
#ifdef DEBUG
......
......@@ -121,7 +121,7 @@ Object* StubCache::ComputeLoadNonexistent(String* name, JSObject* receiver) {
receiver->map()->UpdateCodeCache(cache_name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, receiver->map(), Code::cast(code));
return code;
}
......@@ -139,7 +139,7 @@ Object* StubCache::ComputeLoadField(String* name,
Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, receiver->map(), Code::cast(code));
return code;
}
......@@ -158,7 +158,7 @@ Object* StubCache::ComputeLoadCallback(String* name,
Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, receiver->map(), Code::cast(code));
return code;
}
......@@ -177,7 +177,7 @@ Object* StubCache::ComputeLoadConstant(String* name,
Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, receiver->map(), Code::cast(code));
return code;
}
......@@ -194,13 +194,12 @@ Object* StubCache::ComputeLoadInterceptor(String* name,
Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, receiver->map(), Code::cast(code));
return code;
}
Object* StubCache::ComputeLoadNormal(String* name, JSObject* receiver) {
Code* code = Builtins::builtin(Builtins::LoadIC_Normal);
return Set(name, receiver->map(), code);
return Builtins::builtin(Builtins::LoadIC_Normal);
}
......@@ -223,7 +222,7 @@ Object* StubCache::ComputeLoadGlobal(String* name,
Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, receiver->map(), Code::cast(code));
return code;
}
......@@ -368,7 +367,7 @@ Object* StubCache::ComputeStoreField(String* name,
Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, receiver->map(), Code::cast(code));
return code;
}
......@@ -385,7 +384,7 @@ Object* StubCache::ComputeStoreGlobal(String* name,
Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, receiver->map(), Code::cast(code));
return code;
}
......@@ -403,7 +402,7 @@ Object* StubCache::ComputeStoreCallback(String* name,
Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, receiver->map(), Code::cast(code));
return code;
}
......@@ -420,7 +419,7 @@ Object* StubCache::ComputeStoreInterceptor(String* name,
Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, receiver->map(), Code::cast(code));
return code;
}
......@@ -486,7 +485,7 @@ Object* StubCache::ComputeCallConstant(int argc,
Object* result = map->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, map, Code::cast(code));
return code;
}
......@@ -525,7 +524,7 @@ Object* StubCache::ComputeCallField(int argc,
Object* result = map->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, map, Code::cast(code));
return code;
}
......@@ -563,7 +562,7 @@ Object* StubCache::ComputeCallInterceptor(int argc,
Object* result = map->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, map, Code::cast(code));
return code;
}
......@@ -574,7 +573,7 @@ Object* StubCache::ComputeCallNormal(int argc,
JSObject* receiver) {
Object* code = ComputeCallNormal(argc, in_loop, kind);
if (code->IsFailure()) return code;
return Set(name, receiver->map(), Code::cast(code));
return code;
}
......@@ -607,7 +606,7 @@ Object* StubCache::ComputeCallGlobal(int argc,
Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code));
if (result->IsFailure()) return result;
}
return Set(name, receiver->map(), Code::cast(code));
return code;
}
......
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