Index: runtime/vm/intermediate_language.h |
diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h |
index 6b00393b110b239bacacb0db99de400919cdf2aa..b18bbc84c5b3e9998f5166bb6ab9deaa63fbb593 100644 |
--- a/runtime/vm/intermediate_language.h |
+++ b/runtime/vm/intermediate_language.h |
@@ -548,6 +548,56 @@ FOR_EACH_ABSTRACT_INSTRUCTION(FORWARD_DECLARATION) |
#define PRINT_OPERANDS_TO_SUPPORT |
#endif // !PRODUCT |
+ |
+struct CidRangeTarget { |
Vyacheslav Egorov (Google)
2017/04/10 10:59:28
This needs some comments: e.g. declaring that this
erikcorry
2017/04/19 15:06:40
Done.
|
+ intptr_t cid_start; |
+ intptr_t cid_end; |
+ Function* target; |
+ intptr_t count; |
+ CidRangeTarget(intptr_t cid_start_arg, |
+ intptr_t cid_end_arg, |
+ Function* target_arg, |
+ intptr_t count_arg) |
+ : cid_start(cid_start_arg), |
+ cid_end(cid_end_arg), |
+ target(target_arg), |
+ count(count_arg) { |
+ ASSERT(target->IsZoneHandle()); |
+ } |
+}; |
+ |
+ |
+class PolymorphicTargets : public ZoneAllocated { |
Vyacheslav Egorov (Google)
2017/04/10 10:59:28
I think the better name for this would just be
C
erikcorry
2017/04/19 15:06:40
Done.
|
+ public: |
+ explicit PolymorphicTargets(Zone* zone) : cid_ranges_(zone) {} |
+ |
+ void Add(const CidRangeTarget& target) { cid_ranges_.Add(target); } |
+ |
+ CidRangeTarget& operator[](intptr_t index) const { |
+ return cid_ranges_[index]; |
+ } |
+ |
+ CidRangeTarget At(int index) { return cid_ranges_.At(index); } |
+ |
+ intptr_t length() const { return cid_ranges_.length(); } |
+ |
+ void SetLength(intptr_t len) { cid_ranges_.SetLength(len); } |
+ |
+ bool is_empty() const { return cid_ranges_.is_empty(); } |
+ |
+ void Sort(int compare(const CidRangeTarget* a, const CidRangeTarget* b)) { |
+ cid_ranges_.Sort(compare); |
+ } |
+ |
+ bool HasSingleTarget() const; |
+ bool HasSingleRecognizedTarget() const; |
+ Function& FirstTarget() const; |
+ |
+ private: |
+ BaseGrowableArray<CidRangeTarget, ValueObject, Zone> cid_ranges_; |
Vyacheslav Egorov (Google)
2017/04/10 10:59:28
Why can't this be just GrowableArray<CidRangeTarge
erikcorry
2017/04/19 15:06:40
Done.
|
+}; |
+ |
+ |
class Instruction : public ZoneAllocated { |
public: |
#define DECLARE_TAG(type) k##type, |
@@ -2695,7 +2745,6 @@ class ClosureCallInstr : public TemplateDefinition<1, Throws> { |
DISALLOW_COPY_AND_ASSIGN(ClosureCallInstr); |
}; |
- |
class InstanceCallInstr : public TemplateDefinition<0, Throws> { |
public: |
InstanceCallInstr(TokenPosition token_pos, |
@@ -2786,16 +2835,16 @@ class InstanceCallInstr : public TemplateDefinition<0, Throws> { |
class PolymorphicInstanceCallInstr : public TemplateDefinition<0, Throws> { |
public: |
PolymorphicInstanceCallInstr(InstanceCallInstr* instance_call, |
- const ICData& ic_data, |
+ const PolymorphicTargets& targets, |
bool with_checks, |
bool complete) |
: TemplateDefinition(instance_call->deopt_id()), |
instance_call_(instance_call), |
- ic_data_(ic_data), |
+ targets_(targets), |
with_checks_(with_checks), |
complete_(complete) { |
ASSERT(instance_call_ != NULL); |
- ASSERT(!ic_data.NumberOfChecksIs(0)); |
+ ASSERT(targets.length() != 0); |
total_call_count_ = CallCount(); |
} |
@@ -2816,9 +2865,17 @@ class PolymorphicInstanceCallInstr : public TemplateDefinition<0, Throws> { |
return instance_call()->PushArgumentAt(index); |
} |
+ bool HasSingleTarget() const { return targets_.HasSingleTarget(); } |
bool HasSingleRecognizedTarget() const; |
+ bool HasSingleRecognizedCid() const; |
+ intptr_t SingleCid() const; |
+ bool HasOnlyDispatcherOrImplicitAccessorTargets() const; |
+ Function& FirstTarget() const { return targets_.FirstTarget(); } |
+ |
+ const PolymorphicTargets& targets() { return targets_; } |
+ intptr_t NumberOfChecks() const { return targets_.length(); } |
- virtual intptr_t CallCount() const { return ic_data().AggregateCount(); } |
+ virtual intptr_t CallCount() const; |
// If this polymophic call site was created to cover the remaining cids after |
// inlinng then we need to keep track of the total number of calls including |
@@ -2833,25 +2890,25 @@ class PolymorphicInstanceCallInstr : public TemplateDefinition<0, Throws> { |
DECLARE_INSTRUCTION(PolymorphicInstanceCall) |
- const ICData& ic_data() const { return ic_data_; } |
- |
virtual bool ComputeCanDeoptimize() const { return true; } |
virtual EffectSet Effects() const { return EffectSet::All(); } |
virtual Definition* Canonicalize(FlowGraph* graph); |
- static RawType* ComputeRuntimeType(const ICData& ic_data); |
+ static RawType* ComputeRuntimeType(const PolymorphicTargets& targets); |
PRINT_OPERANDS_TO_SUPPORT |
private: |
InstanceCallInstr* instance_call_; |
- const ICData& ic_data_; |
+ const PolymorphicTargets& targets_; |
bool with_checks_; |
const bool complete_; |
intptr_t total_call_count_; |
+ friend class PolymorphicInliner; |
+ |
DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallInstr); |
}; |