Index: src/compiler/type-hint-analyzer.cc |
diff --git a/src/compiler/type-hint-analyzer.cc b/src/compiler/type-hint-analyzer.cc |
index 89d674bae80e1bc3ec95aad26e1da23bbd856ceb..7121accf74afcc507a1d60708aeeb60a77e91167 100644 |
--- a/src/compiler/type-hint-analyzer.cc |
+++ b/src/compiler/type-hint-analyzer.cc |
@@ -16,7 +16,7 @@ namespace compiler { |
namespace { |
// TODO(bmeurer): This detour via types is ugly. |
-BinaryOperationHints::Hint ToHint(Type* type) { |
+BinaryOperationHints::Hint ToBinaryOperationHint(Type* type) { |
if (type->Is(Type::None())) return BinaryOperationHints::kNone; |
if (type->Is(Type::SignedSmall())) return BinaryOperationHints::kSignedSmall; |
if (type->Is(Type::Signed32())) return BinaryOperationHints::kSigned32; |
@@ -25,8 +25,18 @@ BinaryOperationHints::Hint ToHint(Type* type) { |
return BinaryOperationHints::kAny; |
} |
-} // namespace |
+// TODO(bmeurer): This detour via types is ugly. |
+CompareOperationHints::Hint ToCompareOperationHint(Type* type) { |
+ if (type->Is(Type::None())) return CompareOperationHints::kNone; |
+ if (type->Is(Type::SignedSmall())) return CompareOperationHints::kSignedSmall; |
+ if (type->Is(Type::Signed32())) return CompareOperationHints::kSigned32; |
+ if (type->Is(Type::Number())) |
+ return CompareOperationHints::kNumberOrUndefined; |
+ if (type->Is(Type::String())) return CompareOperationHints::kString; |
+ return CompareOperationHints::kAny; |
+} |
+} // namespace |
bool TypeHintAnalysis::GetBinaryOperationHints( |
TypeFeedbackId id, BinaryOperationHints* hints) const { |
@@ -35,12 +45,32 @@ bool TypeHintAnalysis::GetBinaryOperationHints( |
Handle<Code> code = i->second; |
DCHECK_EQ(Code::BINARY_OP_IC, code->kind()); |
BinaryOpICState state(code->GetIsolate(), code->extra_ic_state()); |
- *hints = BinaryOperationHints(ToHint(state.GetLeftType()), |
- ToHint(state.GetRightType()), |
- ToHint(state.GetResultType())); |
+ *hints = BinaryOperationHints(ToBinaryOperationHint(state.GetLeftType()), |
+ ToBinaryOperationHint(state.GetRightType()), |
+ ToBinaryOperationHint(state.GetResultType())); |
return true; |
} |
+bool TypeHintAnalysis::GetCompareOperationHints( |
Benedikt Meurer
2016/06/07 04:11:00
Please avoid the detour via types here, and do a s
Jarin
2016/06/09 13:37:32
Done.
|
+ TypeFeedbackId id, CompareOperationHints* hints) const { |
+ auto i = infos_.find(id); |
+ if (i == infos_.end()) return false; |
+ Handle<Code> code = i->second; |
+ DCHECK_EQ(Code::COMPARE_IC, code->kind()); |
+ |
+ Handle<Map> map; |
+ Map* raw_map = code->FindFirstMap(); |
+ if (raw_map != nullptr) Map::TryUpdate(handle(raw_map)).ToHandle(&map); |
+ |
+ CompareICStub stub(code->stub_key(), code->GetIsolate()); |
+ Type* left = CompareICState::StateToType(zone(), stub.left()); |
+ Type* right = CompareICState::StateToType(zone(), stub.right()); |
+ Type* combined = CompareICState::StateToType(zone(), stub.state(), map); |
+ *hints = CompareOperationHints(ToCompareOperationHint(left), |
+ ToCompareOperationHint(right), |
+ ToCompareOperationHint(combined)); |
+ return true; |
+} |
bool TypeHintAnalysis::GetToBooleanHints(TypeFeedbackId id, |
ToBooleanHints* hints) const { |
@@ -67,7 +97,6 @@ bool TypeHintAnalysis::GetToBooleanHints(TypeFeedbackId id, |
return true; |
} |
- |
TypeHintAnalysis* TypeHintAnalyzer::Analyze(Handle<Code> code) { |
DisallowHeapAllocation no_gc; |
TypeHintAnalysis::Infos infos(zone()); |
@@ -79,6 +108,7 @@ TypeHintAnalysis* TypeHintAnalyzer::Analyze(Handle<Code> code) { |
Code* target = Code::GetCodeFromTargetAddress(target_address); |
switch (target->kind()) { |
case Code::BINARY_OP_IC: |
+ case Code::COMPARE_IC: |
case Code::TO_BOOLEAN_IC: { |
// Add this feedback to the {infos}. |
TypeFeedbackId id(static_cast<unsigned>(rinfo->data())); |
@@ -90,7 +120,7 @@ TypeHintAnalysis* TypeHintAnalyzer::Analyze(Handle<Code> code) { |
break; |
} |
} |
- return new (zone()) TypeHintAnalysis(infos); |
+ return new (zone()) TypeHintAnalysis(infos, zone()); |
} |
} // namespace compiler |