| 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 VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define 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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 : deopt_id_(Isolate::Current()->GetNextDeoptId()), | 635 : deopt_id_(Isolate::Current()->GetNextDeoptId()), |
| 636 lifetime_position_(-1), | 636 lifetime_position_(-1), |
| 637 previous_(NULL), | 637 previous_(NULL), |
| 638 next_(NULL), | 638 next_(NULL), |
| 639 env_(NULL), | 639 env_(NULL), |
| 640 expr_id_(kNoExprId) { } | 640 expr_id_(kNoExprId) { } |
| 641 | 641 |
| 642 virtual Tag tag() const = 0; | 642 virtual Tag tag() const = 0; |
| 643 | 643 |
| 644 intptr_t deopt_id() const { | 644 intptr_t deopt_id() const { |
| 645 ASSERT(CanDeoptimize() || CanBeDeoptimizationTarget()); | 645 ASSERT(CanDeoptimize() || CanBecomeDeoptimizationTarget()); |
| 646 return deopt_id_; | 646 return deopt_id_; |
| 647 } | 647 } |
| 648 | 648 |
| 649 ICData* GetICData(const Array& ic_data_array) const; | 649 ICData* GetICData(const Array& ic_data_array) const; |
| 650 | 650 |
| 651 bool IsBlockEntry() { return (AsBlockEntry() != NULL); } | 651 bool IsBlockEntry() { return (AsBlockEntry() != NULL); } |
| 652 virtual BlockEntryInstr* AsBlockEntry() { return NULL; } | 652 virtual BlockEntryInstr* AsBlockEntry() { return NULL; } |
| 653 | 653 |
| 654 bool IsDefinition() { return (AsDefinition() != NULL); } | 654 bool IsDefinition() { return (AsDefinition() != NULL); } |
| 655 virtual Definition* AsDefinition() { return NULL; } | 655 virtual Definition* AsDefinition() { return NULL; } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 // All instructions that participate in CSE have to override this function. | 839 // All instructions that participate in CSE have to override this function. |
| 840 // This function can assume that the argument has the same type as this. | 840 // This function can assume that the argument has the same type as this. |
| 841 virtual bool AttributesEqual(Instruction* other) const { | 841 virtual bool AttributesEqual(Instruction* other) const { |
| 842 UNREACHABLE(); | 842 UNREACHABLE(); |
| 843 return false; | 843 return false; |
| 844 } | 844 } |
| 845 | 845 |
| 846 virtual void InheritDeoptTarget(Instruction* other); | 846 virtual void InheritDeoptTarget(Instruction* other); |
| 847 | 847 |
| 848 bool NeedsEnvironment() const { | 848 bool NeedsEnvironment() const { |
| 849 return CanDeoptimize() || CanBeDeoptimizationTarget(); | 849 return CanDeoptimize() || CanBecomeDeoptimizationTarget(); |
| 850 } | 850 } |
| 851 | 851 |
| 852 virtual bool CanBeDeoptimizationTarget() const { | 852 virtual bool CanBecomeDeoptimizationTarget() const { |
| 853 return false; | 853 return false; |
| 854 } | 854 } |
| 855 | 855 |
| 856 void InheritDeoptTargetAfter(Instruction* other); | 856 void InheritDeoptTargetAfter(Instruction* other); |
| 857 | 857 |
| 858 virtual bool MayThrow() const = 0; | 858 virtual bool MayThrow() const = 0; |
| 859 | 859 |
| 860 protected: | 860 protected: |
| 861 // Fetch deopt id without checking if this computation can deoptimize. | 861 // Fetch deopt id without checking if this computation can deoptimize. |
| 862 intptr_t GetDeoptId() const { | 862 intptr_t GetDeoptId() const { |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 intptr_t fixed_parameter_count); | 1145 intptr_t fixed_parameter_count); |
| 1146 | 1146 |
| 1147 virtual intptr_t InputCount() const { return 0; } | 1147 virtual intptr_t InputCount() const { return 0; } |
| 1148 virtual Value* InputAt(intptr_t i) const { | 1148 virtual Value* InputAt(intptr_t i) const { |
| 1149 UNREACHABLE(); | 1149 UNREACHABLE(); |
| 1150 return NULL; | 1150 return NULL; |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 virtual intptr_t ArgumentCount() const { return 0; } | 1153 virtual intptr_t ArgumentCount() const { return 0; } |
| 1154 | 1154 |
| 1155 virtual bool CanBeDeoptimizationTarget() const { | 1155 virtual bool CanBecomeDeoptimizationTarget() const { |
| 1156 // BlockEntry environment is copied to Goto and Branch instructions | 1156 // BlockEntry environment is copied to Goto and Branch instructions |
| 1157 // when we insert new blocks targeting this block. | 1157 // when we insert new blocks targeting this block. |
| 1158 return true; | 1158 return true; |
| 1159 } | 1159 } |
| 1160 | 1160 |
| 1161 virtual bool CanDeoptimize() const { return false; } | 1161 virtual bool CanDeoptimize() const { return false; } |
| 1162 | 1162 |
| 1163 virtual EffectSet Effects() const { return EffectSet::None(); } | 1163 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 1164 virtual EffectSet Dependencies() const { return EffectSet::None(); } | 1164 virtual EffectSet Dependencies() const { return EffectSet::None(); } |
| 1165 | 1165 |
| (...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1853 SetInputAt(0, value); | 1853 SetInputAt(0, value); |
| 1854 } | 1854 } |
| 1855 | 1855 |
| 1856 DECLARE_INSTRUCTION(Return) | 1856 DECLARE_INSTRUCTION(Return) |
| 1857 | 1857 |
| 1858 virtual intptr_t ArgumentCount() const { return 0; } | 1858 virtual intptr_t ArgumentCount() const { return 0; } |
| 1859 | 1859 |
| 1860 intptr_t token_pos() const { return token_pos_; } | 1860 intptr_t token_pos() const { return token_pos_; } |
| 1861 Value* value() const { return inputs_[0]; } | 1861 Value* value() const { return inputs_[0]; } |
| 1862 | 1862 |
| 1863 virtual bool CanBeDeoptimizationTarget() const { | 1863 virtual bool CanBecomeDeoptimizationTarget() const { |
| 1864 // Return instruction might turn into a Goto instruction after inlining. | 1864 // Return instruction might turn into a Goto instruction after inlining. |
| 1865 // Every Goto must have an environment. | 1865 // Every Goto must have an environment. |
| 1866 return true; | 1866 return true; |
| 1867 } | 1867 } |
| 1868 | 1868 |
| 1869 virtual bool CanDeoptimize() const { return false; } | 1869 virtual bool CanDeoptimize() const { return false; } |
| 1870 | 1870 |
| 1871 virtual EffectSet Effects() const { return EffectSet::None(); } | 1871 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 1872 | 1872 |
| 1873 virtual bool MayThrow() const { return false; } | 1873 virtual bool MayThrow() const { return false; } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1933 | 1933 |
| 1934 DECLARE_INSTRUCTION(Goto) | 1934 DECLARE_INSTRUCTION(Goto) |
| 1935 | 1935 |
| 1936 virtual intptr_t ArgumentCount() const { return 0; } | 1936 virtual intptr_t ArgumentCount() const { return 0; } |
| 1937 | 1937 |
| 1938 JoinEntryInstr* successor() const { return successor_; } | 1938 JoinEntryInstr* successor() const { return successor_; } |
| 1939 void set_successor(JoinEntryInstr* successor) { successor_ = successor; } | 1939 void set_successor(JoinEntryInstr* successor) { successor_ = successor; } |
| 1940 virtual intptr_t SuccessorCount() const; | 1940 virtual intptr_t SuccessorCount() const; |
| 1941 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; | 1941 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; |
| 1942 | 1942 |
| 1943 virtual bool CanBeDeoptimizationTarget() const { | 1943 virtual bool CanBecomeDeoptimizationTarget() const { |
| 1944 // Goto instruction can be used as a deoptimization target when LICM | 1944 // Goto instruction can be used as a deoptimization target when LICM |
| 1945 // hoists instructions out of the loop. | 1945 // hoists instructions out of the loop. |
| 1946 return true; | 1946 return true; |
| 1947 } | 1947 } |
| 1948 | 1948 |
| 1949 virtual bool CanDeoptimize() const { return false; } | 1949 virtual bool CanDeoptimize() const { return false; } |
| 1950 | 1950 |
| 1951 virtual EffectSet Effects() const { return EffectSet::None(); } | 1951 virtual EffectSet Effects() const { return EffectSet::None(); } |
| 1952 | 1952 |
| 1953 ParallelMoveInstr* parallel_move() const { | 1953 ParallelMoveInstr* parallel_move() const { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 class BranchInstr : public ControlInstruction { | 2009 class BranchInstr : public ControlInstruction { |
| 2010 public: | 2010 public: |
| 2011 explicit BranchInstr(ComparisonInstr* comparison, bool is_checked = false); | 2011 explicit BranchInstr(ComparisonInstr* comparison, bool is_checked = false); |
| 2012 | 2012 |
| 2013 DECLARE_INSTRUCTION(Branch) | 2013 DECLARE_INSTRUCTION(Branch) |
| 2014 | 2014 |
| 2015 virtual intptr_t ArgumentCount() const; | 2015 virtual intptr_t ArgumentCount() const; |
| 2016 intptr_t InputCount() const; | 2016 intptr_t InputCount() const; |
| 2017 Value* InputAt(intptr_t i) const; | 2017 Value* InputAt(intptr_t i) const; |
| 2018 virtual bool CanDeoptimize() const; | 2018 virtual bool CanDeoptimize() const; |
| 2019 virtual bool CanBeDeoptimizationTarget() const; | 2019 virtual bool CanBecomeDeoptimizationTarget() const; |
| 2020 | 2020 |
| 2021 virtual EffectSet Effects() const; | 2021 virtual EffectSet Effects() const; |
| 2022 | 2022 |
| 2023 ComparisonInstr* comparison() const { return comparison_; } | 2023 ComparisonInstr* comparison() const { return comparison_; } |
| 2024 void SetComparison(ComparisonInstr* comp); | 2024 void SetComparison(ComparisonInstr* comp); |
| 2025 | 2025 |
| 2026 bool is_checked() const { return is_checked_; } | 2026 bool is_checked() const { return is_checked_; } |
| 2027 | 2027 |
| 2028 virtual LocationSummary* locs(); | 2028 virtual LocationSummary* locs(); |
| 2029 virtual intptr_t DeoptimizationTarget() const; | 2029 virtual intptr_t DeoptimizationTarget() const; |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2755 } | 2755 } |
| 2756 | 2756 |
| 2757 | 2757 |
| 2758 inline bool BranchInstr::CanDeoptimize() const { | 2758 inline bool BranchInstr::CanDeoptimize() const { |
| 2759 // Branches need a deoptimization info in checked mode if they | 2759 // Branches need a deoptimization info in checked mode if they |
| 2760 // can throw a type check error. | 2760 // can throw a type check error. |
| 2761 return comparison()->CanDeoptimize() || is_checked(); | 2761 return comparison()->CanDeoptimize() || is_checked(); |
| 2762 } | 2762 } |
| 2763 | 2763 |
| 2764 | 2764 |
| 2765 inline bool BranchInstr::CanBeDeoptimizationTarget() const { | 2765 inline bool BranchInstr::CanBecomeDeoptimizationTarget() const { |
| 2766 return comparison()->CanBeDeoptimizationTarget(); | 2766 return comparison()->CanBecomeDeoptimizationTarget(); |
| 2767 } | 2767 } |
| 2768 | 2768 |
| 2769 | 2769 |
| 2770 inline EffectSet BranchInstr::Effects() const { | 2770 inline EffectSet BranchInstr::Effects() const { |
| 2771 return comparison()->Effects(); | 2771 return comparison()->Effects(); |
| 2772 } | 2772 } |
| 2773 | 2773 |
| 2774 | 2774 |
| 2775 inline LocationSummary* BranchInstr::locs() { | 2775 inline LocationSummary* BranchInstr::locs() { |
| 2776 if (comparison()->locs_ == NULL) { | 2776 if (comparison()->locs_ == NULL) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2804 StrictCompareInstr(intptr_t token_pos, | 2804 StrictCompareInstr(intptr_t token_pos, |
| 2805 Token::Kind kind, | 2805 Token::Kind kind, |
| 2806 Value* left, | 2806 Value* left, |
| 2807 Value* right); | 2807 Value* right); |
| 2808 | 2808 |
| 2809 DECLARE_INSTRUCTION(StrictCompare) | 2809 DECLARE_INSTRUCTION(StrictCompare) |
| 2810 virtual CompileType ComputeType() const; | 2810 virtual CompileType ComputeType() const; |
| 2811 | 2811 |
| 2812 virtual void PrintOperandsTo(BufferFormatter* f) const; | 2812 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 2813 | 2813 |
| 2814 virtual bool CanBeDeoptimizationTarget() const { | 2814 virtual bool CanBecomeDeoptimizationTarget() const { |
| 2815 // StrictCompare can be merged into Branch and thus needs an environment. | 2815 // StrictCompare can be merged into Branch and thus needs an environment. |
| 2816 return true; | 2816 return true; |
| 2817 } | 2817 } |
| 2818 | 2818 |
| 2819 virtual bool CanDeoptimize() const { return false; } | 2819 virtual bool CanDeoptimize() const { return false; } |
| 2820 | 2820 |
| 2821 virtual Definition* Canonicalize(FlowGraph* flow_graph); | 2821 virtual Definition* Canonicalize(FlowGraph* flow_graph); |
| 2822 | 2822 |
| 2823 virtual void EmitBranchCode(FlowGraphCompiler* compiler, | 2823 virtual void EmitBranchCode(FlowGraphCompiler* compiler, |
| 2824 BranchInstr* branch); | 2824 BranchInstr* branch); |
| (...skipping 3585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6410 ForwardInstructionIterator* current_iterator_; | 6410 ForwardInstructionIterator* current_iterator_; |
| 6411 | 6411 |
| 6412 private: | 6412 private: |
| 6413 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 6413 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 6414 }; | 6414 }; |
| 6415 | 6415 |
| 6416 | 6416 |
| 6417 } // namespace dart | 6417 } // namespace dart |
| 6418 | 6418 |
| 6419 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 6419 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |