Reviewers: Jakob,
Message:
PTAL
Description:
Cleanup the copying of ICs to the Megamorphic Code Cache
Please review this at https://chromiumcodereview.appspot.com/12521007/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/ic.h
M src/ic.cc
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index
866fcce0c690ded60456f6c5afb3ad8660924a73..d673597b54f75625d4837779ae8f76df25c0be8b
100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -1010,6 +1010,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
// not necessarily equal to target()->state().
void IC::PatchCache(State state,
@@ -1032,28 +1046,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, target());
}
}
- if (handler != NULL) {
- UpdateMegamorphicCache(map, *name, handler);
- }
}
+
UpdateMegamorphicCache(receiver->map(), *name, *code);
set_target((strict_mode == kStrictMode)
? *megamorphic_stub_strict()
@@ -1069,16 +1072,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 {
Index: src/ic.h
diff --git a/src/ic.h b/src/ic.h
index
78c364229ffcf67a0d78306698138b7c95e8e9f5..6e0f843066d282df4a5b0322941a3d80415e8fe5
100644
--- a/src/ic.h
+++ b/src/ic.h
@@ -175,6 +175,7 @@ class IC {
Handle<JSObject> receiver,
Handle<String> name,
Handle<Code> code);
+ void CopyICToMegamorphicCache(Handle<String> name);
void PatchCache(State state,
StrictModeFlag strict_mode,
Handle<JSObject> receiver,
--
--
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/groups/opt_out.