Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 #define PRINT_TO_SUPPORT | 541 #define PRINT_TO_SUPPORT |
| 542 #endif // !PRODUCT | 542 #endif // !PRODUCT |
| 543 | 543 |
| 544 #ifndef PRODUCT | 544 #ifndef PRODUCT |
| 545 #define PRINT_OPERANDS_TO_SUPPORT \ | 545 #define PRINT_OPERANDS_TO_SUPPORT \ |
| 546 virtual void PrintOperandsTo(BufferFormatter* f) const; | 546 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 547 #else | 547 #else |
| 548 #define PRINT_OPERANDS_TO_SUPPORT | 548 #define PRINT_OPERANDS_TO_SUPPORT |
| 549 #endif // !PRODUCT | 549 #endif // !PRODUCT |
| 550 | 550 |
| 551 | |
| 552 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.
| |
| 553 intptr_t cid_start; | |
| 554 intptr_t cid_end; | |
| 555 Function* target; | |
| 556 intptr_t count; | |
| 557 CidRangeTarget(intptr_t cid_start_arg, | |
| 558 intptr_t cid_end_arg, | |
| 559 Function* target_arg, | |
| 560 intptr_t count_arg) | |
| 561 : cid_start(cid_start_arg), | |
| 562 cid_end(cid_end_arg), | |
| 563 target(target_arg), | |
| 564 count(count_arg) { | |
| 565 ASSERT(target->IsZoneHandle()); | |
| 566 } | |
| 567 }; | |
| 568 | |
| 569 | |
| 570 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.
| |
| 571 public: | |
| 572 explicit PolymorphicTargets(Zone* zone) : cid_ranges_(zone) {} | |
| 573 | |
| 574 void Add(const CidRangeTarget& target) { cid_ranges_.Add(target); } | |
| 575 | |
| 576 CidRangeTarget& operator[](intptr_t index) const { | |
| 577 return cid_ranges_[index]; | |
| 578 } | |
| 579 | |
| 580 CidRangeTarget At(int index) { return cid_ranges_.At(index); } | |
| 581 | |
| 582 intptr_t length() const { return cid_ranges_.length(); } | |
| 583 | |
| 584 void SetLength(intptr_t len) { cid_ranges_.SetLength(len); } | |
| 585 | |
| 586 bool is_empty() const { return cid_ranges_.is_empty(); } | |
| 587 | |
| 588 void Sort(int compare(const CidRangeTarget* a, const CidRangeTarget* b)) { | |
| 589 cid_ranges_.Sort(compare); | |
| 590 } | |
| 591 | |
| 592 bool HasSingleTarget() const; | |
| 593 bool HasSingleRecognizedTarget() const; | |
| 594 Function& FirstTarget() const; | |
| 595 | |
| 596 private: | |
| 597 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.
| |
| 598 }; | |
| 599 | |
| 600 | |
| 551 class Instruction : public ZoneAllocated { | 601 class Instruction : public ZoneAllocated { |
| 552 public: | 602 public: |
| 553 #define DECLARE_TAG(type) k##type, | 603 #define DECLARE_TAG(type) k##type, |
| 554 enum Tag { FOR_EACH_INSTRUCTION(DECLARE_TAG) }; | 604 enum Tag { FOR_EACH_INSTRUCTION(DECLARE_TAG) }; |
| 555 #undef DECLARE_TAG | 605 #undef DECLARE_TAG |
| 556 | 606 |
| 557 explicit Instruction(intptr_t deopt_id = Thread::kNoDeoptId) | 607 explicit Instruction(intptr_t deopt_id = Thread::kNoDeoptId) |
| 558 : deopt_id_(deopt_id), | 608 : deopt_id_(deopt_id), |
| 559 lifetime_position_(kNoPlaceId), | 609 lifetime_position_(kNoPlaceId), |
| 560 previous_(NULL), | 610 previous_(NULL), |
| (...skipping 2127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2688 PRINT_OPERANDS_TO_SUPPORT | 2738 PRINT_OPERANDS_TO_SUPPORT |
| 2689 | 2739 |
| 2690 private: | 2740 private: |
| 2691 const Array& argument_names_; | 2741 const Array& argument_names_; |
| 2692 TokenPosition token_pos_; | 2742 TokenPosition token_pos_; |
| 2693 ZoneGrowableArray<PushArgumentInstr*>* arguments_; | 2743 ZoneGrowableArray<PushArgumentInstr*>* arguments_; |
| 2694 | 2744 |
| 2695 DISALLOW_COPY_AND_ASSIGN(ClosureCallInstr); | 2745 DISALLOW_COPY_AND_ASSIGN(ClosureCallInstr); |
| 2696 }; | 2746 }; |
| 2697 | 2747 |
| 2698 | |
| 2699 class InstanceCallInstr : public TemplateDefinition<0, Throws> { | 2748 class InstanceCallInstr : public TemplateDefinition<0, Throws> { |
| 2700 public: | 2749 public: |
| 2701 InstanceCallInstr(TokenPosition token_pos, | 2750 InstanceCallInstr(TokenPosition token_pos, |
| 2702 const String& function_name, | 2751 const String& function_name, |
| 2703 Token::Kind token_kind, | 2752 Token::Kind token_kind, |
| 2704 ZoneGrowableArray<PushArgumentInstr*>* arguments, | 2753 ZoneGrowableArray<PushArgumentInstr*>* arguments, |
| 2705 const Array& argument_names, | 2754 const Array& argument_names, |
| 2706 intptr_t checked_argument_count, | 2755 intptr_t checked_argument_count, |
| 2707 const ZoneGrowableArray<const ICData*>& ic_data_array) | 2756 const ZoneGrowableArray<const ICData*>& ic_data_array) |
| 2708 : TemplateDefinition(Thread::Current()->GetNextDeoptId()), | 2757 : TemplateDefinition(Thread::Current()->GetNextDeoptId()), |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2779 const intptr_t checked_argument_count_; | 2828 const intptr_t checked_argument_count_; |
| 2780 bool has_unique_selector_; | 2829 bool has_unique_selector_; |
| 2781 | 2830 |
| 2782 DISALLOW_COPY_AND_ASSIGN(InstanceCallInstr); | 2831 DISALLOW_COPY_AND_ASSIGN(InstanceCallInstr); |
| 2783 }; | 2832 }; |
| 2784 | 2833 |
| 2785 | 2834 |
| 2786 class PolymorphicInstanceCallInstr : public TemplateDefinition<0, Throws> { | 2835 class PolymorphicInstanceCallInstr : public TemplateDefinition<0, Throws> { |
| 2787 public: | 2836 public: |
| 2788 PolymorphicInstanceCallInstr(InstanceCallInstr* instance_call, | 2837 PolymorphicInstanceCallInstr(InstanceCallInstr* instance_call, |
| 2789 const ICData& ic_data, | 2838 const PolymorphicTargets& targets, |
| 2790 bool with_checks, | 2839 bool with_checks, |
| 2791 bool complete) | 2840 bool complete) |
| 2792 : TemplateDefinition(instance_call->deopt_id()), | 2841 : TemplateDefinition(instance_call->deopt_id()), |
| 2793 instance_call_(instance_call), | 2842 instance_call_(instance_call), |
| 2794 ic_data_(ic_data), | 2843 targets_(targets), |
| 2795 with_checks_(with_checks), | 2844 with_checks_(with_checks), |
| 2796 complete_(complete) { | 2845 complete_(complete) { |
| 2797 ASSERT(instance_call_ != NULL); | 2846 ASSERT(instance_call_ != NULL); |
| 2798 ASSERT(!ic_data.NumberOfChecksIs(0)); | 2847 ASSERT(targets.length() != 0); |
| 2799 total_call_count_ = CallCount(); | 2848 total_call_count_ = CallCount(); |
| 2800 } | 2849 } |
| 2801 | 2850 |
| 2802 InstanceCallInstr* instance_call() const { return instance_call_; } | 2851 InstanceCallInstr* instance_call() const { return instance_call_; } |
| 2803 bool with_checks() const { return with_checks_; } | 2852 bool with_checks() const { return with_checks_; } |
| 2804 void set_with_checks(bool b) { with_checks_ = b; } | 2853 void set_with_checks(bool b) { with_checks_ = b; } |
| 2805 bool complete() const { return complete_; } | 2854 bool complete() const { return complete_; } |
| 2806 virtual TokenPosition token_pos() const { | 2855 virtual TokenPosition token_pos() const { |
| 2807 return instance_call_->token_pos(); | 2856 return instance_call_->token_pos(); |
| 2808 } | 2857 } |
| 2809 | 2858 |
| 2810 virtual CompileType ComputeType() const; | 2859 virtual CompileType ComputeType() const; |
| 2811 | 2860 |
| 2812 virtual intptr_t ArgumentCount() const { | 2861 virtual intptr_t ArgumentCount() const { |
| 2813 return instance_call()->ArgumentCount(); | 2862 return instance_call()->ArgumentCount(); |
| 2814 } | 2863 } |
| 2815 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const { | 2864 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const { |
| 2816 return instance_call()->PushArgumentAt(index); | 2865 return instance_call()->PushArgumentAt(index); |
| 2817 } | 2866 } |
| 2818 | 2867 |
| 2868 bool HasSingleTarget() const { return targets_.HasSingleTarget(); } | |
| 2819 bool HasSingleRecognizedTarget() const; | 2869 bool HasSingleRecognizedTarget() const; |
| 2870 bool HasSingleRecognizedCid() const; | |
| 2871 intptr_t SingleCid() const; | |
| 2872 bool HasOnlyDispatcherOrImplicitAccessorTargets() const; | |
| 2873 Function& FirstTarget() const { return targets_.FirstTarget(); } | |
| 2820 | 2874 |
| 2821 virtual intptr_t CallCount() const { return ic_data().AggregateCount(); } | 2875 const PolymorphicTargets& targets() { return targets_; } |
| 2876 intptr_t NumberOfChecks() const { return targets_.length(); } | |
| 2877 | |
| 2878 virtual intptr_t CallCount() const; | |
| 2822 | 2879 |
| 2823 // If this polymophic call site was created to cover the remaining cids after | 2880 // If this polymophic call site was created to cover the remaining cids after |
| 2824 // inlinng then we need to keep track of the total number of calls including | 2881 // inlinng then we need to keep track of the total number of calls including |
| 2825 // the ones that wer inlined. This is different from the CallCount above: Eg | 2882 // the ones that wer inlined. This is different from the CallCount above: Eg |
| 2826 // if there were 100 calls originally, distributed across three class-ids in | 2883 // if there were 100 calls originally, distributed across three class-ids in |
| 2827 // the ratio 50, 40, 7, 3. The first two were inlined, so now we have only | 2884 // the ratio 50, 40, 7, 3. The first two were inlined, so now we have only |
| 2828 // 10 calls in the CallCount above, but the heuristics need to know that the | 2885 // 10 calls in the CallCount above, but the heuristics need to know that the |
| 2829 // last two cids cover 7% and 3% of the calls, not 70% and 30%. | 2886 // last two cids cover 7% and 3% of the calls, not 70% and 30%. |
| 2830 intptr_t total_call_count() { return total_call_count_; } | 2887 intptr_t total_call_count() { return total_call_count_; } |
| 2831 | 2888 |
| 2832 void set_total_call_count(intptr_t count) { total_call_count_ = count; } | 2889 void set_total_call_count(intptr_t count) { total_call_count_ = count; } |
| 2833 | 2890 |
| 2834 DECLARE_INSTRUCTION(PolymorphicInstanceCall) | 2891 DECLARE_INSTRUCTION(PolymorphicInstanceCall) |
| 2835 | 2892 |
| 2836 const ICData& ic_data() const { return ic_data_; } | |
| 2837 | |
| 2838 virtual bool ComputeCanDeoptimize() const { return true; } | 2893 virtual bool ComputeCanDeoptimize() const { return true; } |
| 2839 | 2894 |
| 2840 virtual EffectSet Effects() const { return EffectSet::All(); } | 2895 virtual EffectSet Effects() const { return EffectSet::All(); } |
| 2841 | 2896 |
| 2842 virtual Definition* Canonicalize(FlowGraph* graph); | 2897 virtual Definition* Canonicalize(FlowGraph* graph); |
| 2843 | 2898 |
| 2844 static RawType* ComputeRuntimeType(const ICData& ic_data); | 2899 static RawType* ComputeRuntimeType(const PolymorphicTargets& targets); |
| 2845 | 2900 |
| 2846 PRINT_OPERANDS_TO_SUPPORT | 2901 PRINT_OPERANDS_TO_SUPPORT |
| 2847 | 2902 |
| 2848 private: | 2903 private: |
| 2849 InstanceCallInstr* instance_call_; | 2904 InstanceCallInstr* instance_call_; |
| 2850 const ICData& ic_data_; | 2905 const PolymorphicTargets& targets_; |
| 2851 bool with_checks_; | 2906 bool with_checks_; |
| 2852 const bool complete_; | 2907 const bool complete_; |
| 2853 intptr_t total_call_count_; | 2908 intptr_t total_call_count_; |
| 2854 | 2909 |
| 2910 friend class PolymorphicInliner; | |
| 2911 | |
| 2855 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallInstr); | 2912 DISALLOW_COPY_AND_ASSIGN(PolymorphicInstanceCallInstr); |
| 2856 }; | 2913 }; |
| 2857 | 2914 |
| 2858 | 2915 |
| 2859 class StrictCompareInstr : public TemplateComparison<2, NoThrow, Pure> { | 2916 class StrictCompareInstr : public TemplateComparison<2, NoThrow, Pure> { |
| 2860 public: | 2917 public: |
| 2861 StrictCompareInstr(TokenPosition token_pos, | 2918 StrictCompareInstr(TokenPosition token_pos, |
| 2862 Token::Kind kind, | 2919 Token::Kind kind, |
| 2863 Value* left, | 2920 Value* left, |
| 2864 Value* right, | 2921 Value* right, |
| (...skipping 5178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8043 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ | 8100 LocationSummary* Name::MakeLocationSummary(Zone* zone, bool opt) const { \ |
| 8044 UNIMPLEMENTED(); \ | 8101 UNIMPLEMENTED(); \ |
| 8045 return NULL; \ | 8102 return NULL; \ |
| 8046 } \ | 8103 } \ |
| 8047 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } | 8104 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } |
| 8048 | 8105 |
| 8049 | 8106 |
| 8050 } // namespace dart | 8107 } // namespace dart |
| 8051 | 8108 |
| 8052 #endif // RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ | 8109 #endif // RUNTIME_VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |