Commit 5615a1d6 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Cleanup the copying of ICs to the Megamorphic Code Cache

Review URL: https://chromiumcodereview.appspot.com/12521007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13907 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3e64d690
...@@ -1021,6 +1021,20 @@ void KeyedLoadIC::UpdateMonomorphicIC(Handle<JSObject> receiver, ...@@ -1021,6 +1021,20 @@ void KeyedLoadIC::UpdateMonomorphicIC(Handle<JSObject> receiver,
} }
void IC::CopyICToMegamorphicCache(Handle<String> name) {
MapHandleList receiver_maps;
CodeHandleList handlers;
{
AssertNoAllocation no_gc;
target()->FindAllMaps(&receiver_maps);
target()->FindAllCode(&handlers, receiver_maps.length());
}
for (int i = 0; i < receiver_maps.length(); i++) {
UpdateMegamorphicCache(*receiver_maps.at(i), *name, *handlers.at(i));
}
}
// Since GC may have been invoked, by the time PatchCache is called, |state| is // Since GC may have been invoked, by the time PatchCache is called, |state| is
// not necessarily equal to target()->state(). // not necessarily equal to target()->state().
void IC::PatchCache(State state, void IC::PatchCache(State state,
...@@ -1043,28 +1057,17 @@ void IC::PatchCache(State state, ...@@ -1043,28 +1057,17 @@ void IC::PatchCache(State state,
} }
} }
if (target()->type() != Code::NORMAL) { if (target()->type() != Code::NORMAL) {
// We are transitioning from monomorphic to megamorphic case. Place if (target()->is_load_stub()) {
// the stub compiled for the receiver into stub cache. CopyICToMegamorphicCache(name);
Map* map; } else {
Code* handler; Code* handler = target();
{ Map* map = handler->FindFirstMap();
AssertNoAllocation no_gc;
map = target()->FindFirstMap();
if (map != NULL) { if (map != NULL) {
if (target()->is_load_stub()) { UpdateMegamorphicCache(map, *name, handler);
handler = target()->FindFirstCode();
} else {
handler = target();
}
} else {
// Avoid compiler warnings.
handler = NULL;
} }
} }
if (handler != NULL) {
UpdateMegamorphicCache(map, *name, handler);
}
} }
UpdateMegamorphicCache(receiver->map(), *name, *code); UpdateMegamorphicCache(receiver->map(), *name, *code);
set_target((strict_mode == kStrictMode) set_target((strict_mode == kStrictMode)
? *megamorphic_stub_strict() ? *megamorphic_stub_strict()
...@@ -1080,16 +1083,7 @@ void IC::PatchCache(State state, ...@@ -1080,16 +1083,7 @@ void IC::PatchCache(State state,
if (UpdatePolymorphicIC(state, strict_mode, receiver, name, code)) { if (UpdatePolymorphicIC(state, strict_mode, receiver, name, code)) {
break; break;
} }
MapHandleList receiver_maps; CopyICToMegamorphicCache(name);
CodeHandleList handlers;
{
AssertNoAllocation no_gc;
target()->FindAllMaps(&receiver_maps);
target()->FindAllCode(&handlers, receiver_maps.length());
}
for (int i = 0; i < receiver_maps.length(); i++) {
UpdateMegamorphicCache(*receiver_maps.at(i), *name, *handlers.at(i));
}
UpdateMegamorphicCache(receiver->map(), *name, *code); UpdateMegamorphicCache(receiver->map(), *name, *code);
set_target(*megamorphic_stub()); set_target(*megamorphic_stub());
} else { } else {
......
...@@ -175,6 +175,7 @@ class IC { ...@@ -175,6 +175,7 @@ class IC {
Handle<JSObject> receiver, Handle<JSObject> receiver,
Handle<String> name, Handle<String> name,
Handle<Code> code); Handle<Code> code);
void CopyICToMegamorphicCache(Handle<String> name);
void PatchCache(State state, void PatchCache(State state,
StrictModeFlag strict_mode, StrictModeFlag strict_mode,
Handle<JSObject> receiver, Handle<JSObject> receiver,
......
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