Reviewers: ulan,
Message:
PTAL
Description:
Use POLYMORPHIC for polymorphic Keyed(Load|Store)IC
Please review this at https://chromiumcodereview.appspot.com/11794045/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/arm/stub-cache-arm.cc
M src/ast.cc
M src/ia32/stub-cache-ia32.cc
M src/ic.cc
M src/log.h
M src/mips/stub-cache-mips.cc
M src/objects-visiting-inl.h
M src/type-info.h
M src/type-info.cc
M src/x64/stub-cache-x64.cc
Index: src/arm/stub-cache-arm.cc
diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc
index
9eab2d48336a57690b98e5d622818aa5286b5f49..dcc88f712d96e392a0142166b61123f201c0a22a
100644
--- a/src/arm/stub-cache-arm.cc
+++ b/src/arm/stub-cache-arm.cc
@@ -3327,7 +3327,7 @@ Handle<Code>
KeyedLoadStubCompiler::CompileLoadPolymorphic(
__ Jump(miss_ic, RelocInfo::CODE_TARGET, al);
// Return the generated code.
- return GetCode(Code::NORMAL, factory()->empty_string(), MEGAMORPHIC);
+ return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
}
@@ -3431,7 +3431,7 @@ Handle<Code>
KeyedStoreStubCompiler::CompileStorePolymorphic(
__ Jump(miss_ic, RelocInfo::CODE_TARGET, al);
// Return the generated code.
- return GetCode(Code::NORMAL, factory()->empty_string(), MEGAMORPHIC);
+ return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
}
Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index
c43b9138bb8c81c7fc1e4a7bdb9c8be6fae18e68..a63bb8309a87f7e0ca594969fe69347c5a896b68
100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -430,7 +430,7 @@ void Property::RecordTypeFeedback(TypeFeedbackOracle*
oracle,
} else if (is_monomorphic_) {
receiver_types_.Add(oracle->LoadMonomorphicReceiverType(this),
zone);
- } else if (oracle->LoadIsMegamorphicWithTypeInfo(this)) {
+ } else if (oracle->LoadIsPolymorphic(this)) {
receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
oracle->CollectKeyedReceiverTypes(PropertyFeedbackId(),
&receiver_types_);
}
@@ -452,7 +452,7 @@ void Assignment::RecordTypeFeedback(TypeFeedbackOracle*
oracle,
} else if (is_monomorphic_) {
// Record receiver type for monomorphic keyed stores.
receiver_types_.Add(oracle->StoreMonomorphicReceiverType(id), zone);
- } else if (oracle->StoreIsMegamorphicWithTypeInfo(id)) {
+ } else if (oracle->StoreIsPolymorphic(id)) {
receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
oracle->CollectKeyedReceiverTypes(id, &receiver_types_);
}
@@ -468,7 +468,7 @@ void
CountOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle,
// Record receiver type for monomorphic keyed stores.
receiver_types_.Add(
oracle->StoreMonomorphicReceiverType(id), zone);
- } else if (oracle->StoreIsMegamorphicWithTypeInfo(id)) {
+ } else if (oracle->StoreIsPolymorphic(id)) {
receiver_types_.Reserve(kMaxKeyedPolymorphism, zone);
oracle->CollectKeyedReceiverTypes(id, &receiver_types_);
}
Index: src/ia32/stub-cache-ia32.cc
diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc
index
783462714473d2a2d819c5d146d6e930e10073ed..2129be3a874431a935e3feac003b67ff2d056919
100644
--- a/src/ia32/stub-cache-ia32.cc
+++ b/src/ia32/stub-cache-ia32.cc
@@ -2947,7 +2947,7 @@ Handle<Code>
KeyedStoreStubCompiler::CompileStorePolymorphic(
__ jmp(miss_ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(Code::NORMAL, factory()->empty_string(), MEGAMORPHIC);
+ return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
}
@@ -3440,7 +3440,7 @@ Handle<Code>
KeyedLoadStubCompiler::CompileLoadPolymorphic(
GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
// Return the generated code.
- return GetCode(Code::NORMAL, factory()->empty_string(), MEGAMORPHIC);
+ return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
}
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index
a450b9daccf63303ed3e1b9b6ee62374e5056631..0db9aa56204afe81f556c53e86e90adfe5a9f083
100644
--- a/src/ic.cc
+++ b/src/ic.cc
@@ -1109,7 +1109,7 @@ Handle<Code> KeyedLoadIC::ComputePolymorphicStub(
receiver_maps, &handler_ics);
isolate()->counters()->keyed_load_polymorphic_stubs()->Increment();
PROFILE(isolate(),
- CodeCreateEvent(Logger::KEYED_LOAD_MEGAMORPHIC_IC_TAG, *code,
0));
+ CodeCreateEvent(Logger::KEYED_LOAD_POLYMORPHIC_IC_TAG, *code,
0));
return code;
}
@@ -1329,6 +1329,7 @@ void KeyedLoadIC::UpdateCaches(LookupResult* lookup,
switch (state) {
case UNINITIALIZED:
case PREMONOMORPHIC:
+ case POLYMORPHIC:
set_target(*code);
break;
case MONOMORPHIC:
@@ -1342,7 +1343,6 @@ void KeyedLoadIC::UpdateCaches(LookupResult* lookup,
case DEBUG_PREPARE_STEP_IN:
break;
case MONOMORPHIC_PROTOTYPE_FAILURE:
- case POLYMORPHIC:
UNREACHABLE();
break;
}
@@ -1651,7 +1651,7 @@ void KeyedIC::GetReceiverMapsForStub(Handle<Code>
stub,
case MONOMORPHIC:
result->Add(Handle<Map>(stub->FindFirstMap()));
break;
- case MEGAMORPHIC: {
+ case POLYMORPHIC: {
AssertNoAllocation no_allocation;
int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
for (RelocIterator it(*stub, mask); !it.done(); it.next()) {
@@ -1662,10 +1662,11 @@ void KeyedIC::GetReceiverMapsForStub(Handle<Code>
stub,
}
break;
}
+ case MEGAMORPHIC:
+ break;
case UNINITIALIZED:
case PREMONOMORPHIC:
case MONOMORPHIC_PROTOTYPE_FAILURE:
- case POLYMORPHIC:
case DEBUG_BREAK:
case DEBUG_PREPARE_STEP_IN:
UNREACHABLE();
@@ -1877,7 +1878,7 @@ Handle<Code> KeyedStoreIC::ComputePolymorphicStub(
receiver_maps, &handler_ics, &transitioned_maps);
isolate()->counters()->keyed_store_polymorphic_stubs()->Increment();
PROFILE(isolate(),
- CodeCreateEvent(Logger::KEYED_STORE_MEGAMORPHIC_IC_TAG, *code,
0));
+ CodeCreateEvent(Logger::KEYED_STORE_POLYMORPHIC_IC_TAG, *code,
0));
return code;
}
@@ -2101,6 +2102,7 @@ void KeyedStoreIC::UpdateCaches(LookupResult* lookup,
switch (state) {
case UNINITIALIZED:
case PREMONOMORPHIC:
+ case POLYMORPHIC:
set_target(*code);
break;
case MONOMORPHIC:
@@ -2116,7 +2118,6 @@ void KeyedStoreIC::UpdateCaches(LookupResult* lookup,
case DEBUG_PREPARE_STEP_IN:
break;
case MONOMORPHIC_PROTOTYPE_FAILURE:
- case POLYMORPHIC:
UNREACHABLE();
break;
}
Index: src/log.h
diff --git a/src/log.h b/src/log.h
index
eced6050a58da42f3e0d0d9cb2f1951244949111..b5b681711c5cbe1f43de6d70484b9efb966c5880
100644
--- a/src/log.h
+++ b/src/log.h
@@ -127,10 +127,10 @@ class Isolate;
V(EVAL_TAG, "Eval") \
V(FUNCTION_TAG, "Function") \
V(KEYED_LOAD_IC_TAG, "KeyedLoadIC") \
- V(KEYED_LOAD_MEGAMORPHIC_IC_TAG, "KeyedLoadMegamorphicIC") \
+ V(KEYED_LOAD_POLYMORPHIC_IC_TAG, "KeyedLoadPolymorphicIC") \
V(KEYED_EXTERNAL_ARRAY_LOAD_IC_TAG, "KeyedExternalArrayLoadIC") \
V(KEYED_STORE_IC_TAG, "KeyedStoreIC") \
- V(KEYED_STORE_MEGAMORPHIC_IC_TAG, "KeyedStoreMegamorphicIC") \
+ V(KEYED_STORE_POLYMORPHIC_IC_TAG, "KeyedStorePolymorphicIC") \
V(KEYED_EXTERNAL_ARRAY_STORE_IC_TAG, "KeyedExternalArrayStoreIC") \
V(LAZY_COMPILE_TAG, "LazyCompile") \
V(LOAD_IC_TAG, "LoadIC") \
Index: src/mips/stub-cache-mips.cc
diff --git a/src/mips/stub-cache-mips.cc b/src/mips/stub-cache-mips.cc
index
cea15f401dce3554f60a99bd1086203829a16279..03138266272332bedecb92b528ff8207a7fa833b
100644
--- a/src/mips/stub-cache-mips.cc
+++ b/src/mips/stub-cache-mips.cc
@@ -3319,7 +3319,7 @@ Handle<Code>
KeyedLoadStubCompiler::CompileLoadPolymorphic(
__ Jump(miss_ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(Code::NORMAL, factory()->empty_string(), MEGAMORPHIC);
+ return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
}
@@ -3422,7 +3422,7 @@ Handle<Code>
KeyedStoreStubCompiler::CompileStorePolymorphic(
__ Jump(miss_ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(Code::NORMAL, factory()->empty_string(), MEGAMORPHIC);
+ return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
}
Index: src/objects-visiting-inl.h
diff --git a/src/objects-visiting-inl.h b/src/objects-visiting-inl.h
index
925b2562f292558687716cc6be8c0b618d1f7f04..309cddf66c7b617fd3a0236d4ea47fa19dc5c712
100644
--- a/src/objects-visiting-inl.h
+++ b/src/objects-visiting-inl.h
@@ -211,7 +211,8 @@ void
StaticMarkingVisitor<StaticVisitor>::VisitCodeTarget(
// when they might be keeping a Context alive, or when the heap is about
// to be serialized.
if (FLAG_cleanup_code_caches_at_gc && target->is_inline_cache_stub()
- && (target->ic_state() == MEGAMORPHIC ||
heap->flush_monomorphic_ics() ||
+ && (target->ic_state() == MEGAMORPHIC ||
+ target->ic_state() == POLYMORPHIC ||
heap->flush_monomorphic_ics() ||
Serializer::enabled() || target->ic_age() !=
heap->global_ic_age())) {
IC::Clear(rinfo->pc());
target = Code::GetCodeFromTargetAddress(rinfo->target_address());
Index: src/type-info.cc
diff --git a/src/type-info.cc b/src/type-info.cc
index
7a9a5de8097dcd561379887da1b5d197d04fdd67..00e8ee85f7c139fb826115e6848083c70128af9d
100644
--- a/src/type-info.cc
+++ b/src/type-info.cc
@@ -111,14 +111,11 @@ bool
TypeFeedbackOracle::LoadIsMonomorphicNormal(Property* expr) {
}
-bool TypeFeedbackOracle::LoadIsMegamorphicWithTypeInfo(Property* expr) {
+bool TypeFeedbackOracle::LoadIsPolymorphic(Property* expr) {
Handle<Object> map_or_code = GetInfo(expr->PropertyFeedbackId());
if (map_or_code->IsCode()) {
Handle<Code> code = Handle<Code>::cast(map_or_code);
- Builtins* builtins = isolate_->builtins();
- return code->is_keyed_load_stub() &&
- *code != builtins->builtin(Builtins::kKeyedLoadIC_Generic) &&
- code->ic_state() == MEGAMORPHIC;
+ return code->is_keyed_load_stub() && code->ic_state() == POLYMORPHIC;
}
return false;
}
@@ -145,19 +142,15 @@ bool
TypeFeedbackOracle::StoreIsMonomorphicNormal(TypeFeedbackId ast_id) {
}
-bool TypeFeedbackOracle::StoreIsMegamorphicWithTypeInfo(TypeFeedbackId
ast_id) {
+bool TypeFeedbackOracle::StoreIsPolymorphic(TypeFeedbackId ast_id) {
Handle<Object> map_or_code = GetInfo(ast_id);
if (map_or_code->IsCode()) {
Handle<Code> code = Handle<Code>::cast(map_or_code);
- Builtins* builtins = isolate_->builtins();
bool allow_growth =
Code::GetKeyedAccessGrowMode(code->extra_ic_state()) ==
ALLOW_JSARRAY_GROWTH;
- return code->is_keyed_store_stub() &&
- !allow_growth &&
- *code != builtins->builtin(Builtins::kKeyedStoreIC_Generic) &&
- *code != builtins->builtin(Builtins::kKeyedStoreIC_Generic_Strict)
&&
- code->ic_state() == MEGAMORPHIC;
+ return code->is_keyed_store_stub() && !allow_growth &&
+ code->ic_state() == POLYMORPHIC;
}
return false;
}
@@ -667,7 +660,7 @@ void
TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) {
case Code::KEYED_LOAD_IC:
case Code::KEYED_STORE_IC:
if (target->ic_state() == MONOMORPHIC ||
- target->ic_state() == MEGAMORPHIC) {
+ target->ic_state() == POLYMORPHIC) {
SetInfo(ast_id, target);
}
break;
Index: src/type-info.h
diff --git a/src/type-info.h b/src/type-info.h
index
8b2ec49310de9730da50a790d7b8093f0eb9e41e..330ecd34c32effa0efb6dd6c4836bb62147d80bb
100644
--- a/src/type-info.h
+++ b/src/type-info.h
@@ -242,9 +242,9 @@ class TypeFeedbackOracle: public ZoneObject {
bool LoadIsMonomorphicNormal(Property* expr);
bool LoadIsUninitialized(Property* expr);
- bool LoadIsMegamorphicWithTypeInfo(Property* expr);
+ bool LoadIsPolymorphic(Property* expr);
bool StoreIsMonomorphicNormal(TypeFeedbackId ast_id);
- bool StoreIsMegamorphicWithTypeInfo(TypeFeedbackId ast_id);
+ bool StoreIsPolymorphic(TypeFeedbackId ast_id);
bool CallIsMonomorphic(Call* expr);
bool CallNewIsMonomorphic(CallNew* expr);
bool ObjectLiteralStoreIsMonomorphic(ObjectLiteral::Property* prop);
Index: src/x64/stub-cache-x64.cc
diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc
index
994b5bcd0ad6c0aa617b7498a5c34ba5bb1ef17a..82727ef14ece23c6cbf1ddb50e6cdc679a89c3a0
100644
--- a/src/x64/stub-cache-x64.cc
+++ b/src/x64/stub-cache-x64.cc
@@ -2772,7 +2772,7 @@ Handle<Code>
KeyedStoreStubCompiler::CompileStorePolymorphic(
__ jmp(ic, RelocInfo::CODE_TARGET);
// Return the generated code.
- return GetCode(Code::NORMAL, factory()->empty_string(), MEGAMORPHIC);
+ return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
}
@@ -3253,7 +3253,7 @@ Handle<Code>
KeyedLoadStubCompiler::CompileLoadPolymorphic(
GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC);
// Return the generated code.
- return GetCode(Code::NORMAL, factory()->empty_string(), MEGAMORPHIC);
+ return GetCode(Code::NORMAL, factory()->empty_string(), POLYMORPHIC);
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev