Chromium Code Reviews| Index: runtime/vm/intermediate_language.h |
| diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h |
| index 823f4774b718309cd26bfb9df3363c42e2245f6f..1cdc5ecf1e1c73e651d7c0bab0334fcf8cc984ae 100644 |
| --- a/runtime/vm/intermediate_language.h |
| +++ b/runtime/vm/intermediate_language.h |
| @@ -2812,6 +2812,10 @@ class InstanceCallInstr : public TemplateDefinition<0, Throws> { |
| bool has_unique_selector() const { return has_unique_selector_; } |
| void set_has_unique_selector(bool b) { has_unique_selector_ = b; } |
| + virtual intptr_t CallCount() const { |
| + return ic_data() == NULL ? 0 : ic_data()->AggregateCount(); |
| + } |
| + |
| virtual bool ComputeCanDeoptimize() const { return true; } |
| virtual Definition* Canonicalize(FlowGraph* flow_graph); |
| @@ -2850,12 +2854,10 @@ class PolymorphicInstanceCallInstr : public TemplateDefinition<0, Throws> { |
| public: |
| PolymorphicInstanceCallInstr(InstanceCallInstr* instance_call, |
| const CallTargets& targets, |
| - bool with_checks, |
| bool complete) |
| : TemplateDefinition(instance_call->deopt_id()), |
| instance_call_(instance_call), |
| targets_(targets), |
| - with_checks_(with_checks), |
| complete_(complete) { |
| ASSERT(instance_call_ != NULL); |
| ASSERT(targets.length() != 0); |
| @@ -2863,8 +2865,6 @@ class PolymorphicInstanceCallInstr : public TemplateDefinition<0, Throws> { |
| } |
| InstanceCallInstr* instance_call() const { return instance_call_; } |
| - bool with_checks() const { return with_checks_; } |
| - void set_with_checks(bool b) { with_checks_ = b; } |
| bool complete() const { return complete_; } |
| virtual TokenPosition token_pos() const { |
| return instance_call_->token_pos(); |
| @@ -2878,6 +2878,9 @@ class PolymorphicInstanceCallInstr : public TemplateDefinition<0, Throws> { |
| virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const { |
| return instance_call()->PushArgumentAt(index); |
| } |
| + const Array& argument_names() const { |
| + return instance_call()->argument_names(); |
| + } |
| bool HasOnlyDispatcherOrImplicitAccessorTargets() const; |
| @@ -2914,7 +2917,6 @@ class PolymorphicInstanceCallInstr : public TemplateDefinition<0, Throws> { |
| private: |
| InstanceCallInstr* instance_call_; |
| const CallTargets& targets_; |
| - bool with_checks_; |
| const bool complete_; |
| intptr_t total_call_count_; |
| @@ -3227,6 +3229,7 @@ class StaticCallInstr : public TemplateDefinition<0, Throws> { |
| const ZoneGrowableArray<const ICData*>& ic_data_array) |
| : TemplateDefinition(Thread::Current()->GetNextDeoptId()), |
| ic_data_(NULL), |
| + call_count_(0), |
| token_pos_(token_pos), |
| function_(function), |
| argument_names_(argument_names), |
| @@ -3244,9 +3247,11 @@ class StaticCallInstr : public TemplateDefinition<0, Throws> { |
| const Function& function, |
| const Array& argument_names, |
| ZoneGrowableArray<PushArgumentInstr*>* arguments, |
| - intptr_t deopt_id) |
| + intptr_t deopt_id, |
| + intptr_t call_count) |
| : TemplateDefinition(deopt_id), |
| ic_data_(NULL), |
| + call_count_(call_count), |
| token_pos_(token_pos), |
| function_(function), |
| argument_names_(argument_names), |
| @@ -3259,6 +3264,23 @@ class StaticCallInstr : public TemplateDefinition<0, Throws> { |
| ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); |
| } |
| + // Generate a replacement call instruction for an instance call which |
| + // has been found to have only one target. |
| + // TODO(askesc): Un-templatize when call instructions get common superclass |
|
Vyacheslav Egorov (Google)
2017/05/18 16:19:35
We moved from TODO(username) to TODO(bug-number).
|
| + template <class C> |
| + static StaticCallInstr* FromCall(Zone* zone, |
| + const C* call, |
| + const Function& target) { |
| + ZoneGrowableArray<PushArgumentInstr*>* args = |
| + new (zone) ZoneGrowableArray<PushArgumentInstr*>(call->ArgumentCount()); |
| + for (intptr_t i = 0; i < call->ArgumentCount(); i++) { |
| + args->Add(call->PushArgumentAt(i)); |
| + } |
| + return new (zone) |
| + StaticCallInstr(call->token_pos(), target, call->argument_names(), args, |
| + call->deopt_id(), call->CallCount()); |
| + } |
| + |
| // ICData for static calls carries call count. |
| const ICData* ic_data() const { return ic_data_; } |
| bool HasICData() const { return (ic_data() != NULL) && !ic_data()->IsNull(); } |
| @@ -3280,7 +3302,7 @@ class StaticCallInstr : public TemplateDefinition<0, Throws> { |
| } |
| virtual intptr_t CallCount() const { |
| - return ic_data() == NULL ? 0 : ic_data()->AggregateCount(); |
| + return ic_data() == NULL ? call_count_ : ic_data()->AggregateCount(); |
| } |
| virtual bool ComputeCanDeoptimize() const { return true; } |
| @@ -3309,6 +3331,7 @@ class StaticCallInstr : public TemplateDefinition<0, Throws> { |
| private: |
| const ICData* ic_data_; |
| + const intptr_t call_count_; |
| const TokenPosition token_pos_; |
| const Function& function_; |
| const Array& argument_names_; |