From: verwaest@chromium.org Date: Mon, 11 Mar 2013 15:11:39 +0000 (+0000) Subject: Cleanup the copying of ICs to the Megamorphic Code Cache X-Git-Tag: upstream/4.7.83~14879 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5615a1d606579f5a24caa711c3b6ba028f40fec7;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/ic.cc b/src/ic.cc index f69d79a..da2211b 100644 --- a/src/ic.cc +++ b/src/ic.cc @@ -1021,6 +1021,20 @@ void KeyedLoadIC::UpdateMonomorphicIC(Handle receiver, } +void IC::CopyICToMegamorphicCache(Handle 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 // not necessarily equal to target()->state(). void IC::PatchCache(State state, @@ -1043,28 +1057,17 @@ void IC::PatchCache(State state, } } if (target()->type() != Code::NORMAL) { - // We are transitioning from monomorphic to megamorphic case. Place - // the stub compiled for the receiver into stub cache. - Map* map; - Code* handler; - { - AssertNoAllocation no_gc; - map = target()->FindFirstMap(); + if (target()->is_load_stub()) { + CopyICToMegamorphicCache(name); + } else { + Code* handler = target(); + Map* map = handler->FindFirstMap(); if (map != NULL) { - if (target()->is_load_stub()) { - handler = target()->FindFirstCode(); - } else { - handler = target(); - } - } else { - // Avoid compiler warnings. - handler = NULL; + UpdateMegamorphicCache(map, *name, handler); } } - if (handler != NULL) { - UpdateMegamorphicCache(map, *name, handler); - } } + UpdateMegamorphicCache(receiver->map(), *name, *code); set_target((strict_mode == kStrictMode) ? *megamorphic_stub_strict() @@ -1080,16 +1083,7 @@ void IC::PatchCache(State state, if (UpdatePolymorphicIC(state, strict_mode, receiver, name, code)) { break; } - 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)); - } + CopyICToMegamorphicCache(name); UpdateMegamorphicCache(receiver->map(), *name, *code); set_target(*megamorphic_stub()); } else { diff --git a/src/ic.h b/src/ic.h index f5f822b..b225955 100644 --- a/src/ic.h +++ b/src/ic.h @@ -175,6 +175,7 @@ class IC { Handle receiver, Handle name, Handle code); + void CopyICToMegamorphicCache(Handle name); void PatchCache(State state, StrictModeFlag strict_mode, Handle receiver,