Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 } | 421 } |
| 422 | 422 |
| 423 protected: | 423 protected: |
| 424 // Fetch deopt id without checking if this computation can deoptimize. | 424 // Fetch deopt id without checking if this computation can deoptimize. |
| 425 intptr_t GetDeoptId() const { | 425 intptr_t GetDeoptId() const { |
| 426 return deopt_id_; | 426 return deopt_id_; |
| 427 } | 427 } |
| 428 | 428 |
| 429 private: | 429 private: |
| 430 friend class Definition; // Needed for InsertBefore, InsertAfter. | 430 friend class Definition; // Needed for InsertBefore, InsertAfter. |
| 431 friend class LICM; | |
|
srdjan
2012/09/06 13:44:26
Please add why, or move the comment if it is valid
Florian Schneider
2012/09/06 13:49:30
Moved it to below where the comment applies.
| |
| 431 | 432 |
| 432 // Classes that set deopt_id_. | 433 // Classes that set deopt_id_. |
| 433 friend class UnboxDoubleInstr; | 434 friend class UnboxDoubleInstr; |
| 434 friend class UnboxedDoubleBinaryOpInstr; | 435 friend class UnboxedDoubleBinaryOpInstr; |
| 435 friend class CheckClassInstr; | 436 friend class CheckClassInstr; |
| 436 friend class CheckSmiInstr; | 437 friend class CheckSmiInstr; |
| 437 friend class CheckNonSmiInstr; | 438 friend class CheckNonSmiInstr; |
| 438 friend class CheckArrayBoundInstr; | 439 friend class CheckArrayBoundInstr; |
| 439 friend class CheckEitherNonSmiInstr; | 440 friend class CheckEitherNonSmiInstr; |
| 440 | 441 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } | 598 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } |
| 598 | 599 |
| 599 const GrowableArray<BlockEntryInstr*>& dominated_blocks() { | 600 const GrowableArray<BlockEntryInstr*>& dominated_blocks() { |
| 600 return dominated_blocks_; | 601 return dominated_blocks_; |
| 601 } | 602 } |
| 602 | 603 |
| 603 void AddDominatedBlock(BlockEntryInstr* block) { | 604 void AddDominatedBlock(BlockEntryInstr* block) { |
| 604 dominated_blocks_.Add(block); | 605 dominated_blocks_.Add(block); |
| 605 } | 606 } |
| 606 | 607 |
| 608 bool Dominates(BlockEntryInstr* other) const; | |
| 609 | |
| 607 Instruction* last_instruction() const { return last_instruction_; } | 610 Instruction* last_instruction() const { return last_instruction_; } |
| 608 void set_last_instruction(Instruction* instr) { last_instruction_ = instr; } | 611 void set_last_instruction(Instruction* instr) { last_instruction_ = instr; } |
| 609 | 612 |
| 610 ParallelMoveInstr* parallel_move() const { | 613 ParallelMoveInstr* parallel_move() const { |
| 611 return parallel_move_; | 614 return parallel_move_; |
| 612 } | 615 } |
| 613 | 616 |
| 614 bool HasParallelMove() const { | 617 bool HasParallelMove() const { |
| 615 return parallel_move_ != NULL; | 618 return parallel_move_ != NULL; |
| 616 } | 619 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 637 return NULL; | 640 return NULL; |
| 638 } | 641 } |
| 639 virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } | 642 virtual void SetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } |
| 640 | 643 |
| 641 virtual intptr_t ArgumentCount() const { return 0; } | 644 virtual intptr_t ArgumentCount() const { return 0; } |
| 642 | 645 |
| 643 virtual bool CanDeoptimize() const { return false; } | 646 virtual bool CanDeoptimize() const { return false; } |
| 644 | 647 |
| 645 intptr_t try_index() const { return try_index_; } | 648 intptr_t try_index() const { return try_index_; } |
| 646 | 649 |
| 650 const ZoneGrowableArray<BlockEntryInstr*>* loop_info() const { | |
| 651 return loop_info_; | |
| 652 } | |
| 653 void set_loop_info(const ZoneGrowableArray<BlockEntryInstr*>* loop_info) { | |
| 654 loop_info_ = loop_info; | |
| 655 } | |
| 656 | |
| 647 protected: | 657 protected: |
| 648 explicit BlockEntryInstr(intptr_t try_index) | 658 explicit BlockEntryInstr(intptr_t try_index) |
| 649 : try_index_(try_index), | 659 : try_index_(try_index), |
| 650 preorder_number_(-1), | 660 preorder_number_(-1), |
| 651 postorder_number_(-1), | 661 postorder_number_(-1), |
| 652 block_id_(-1), | 662 block_id_(-1), |
| 653 dominator_(NULL), | 663 dominator_(NULL), |
| 654 dominated_blocks_(1), | 664 dominated_blocks_(1), |
| 655 last_instruction_(NULL), | 665 last_instruction_(NULL), |
| 656 parallel_move_(NULL) { } | 666 parallel_move_(NULL), |
| 667 loop_info_(NULL) { } | |
| 657 | 668 |
| 658 private: | 669 private: |
| 659 const intptr_t try_index_; | 670 const intptr_t try_index_; |
| 660 intptr_t preorder_number_; | 671 intptr_t preorder_number_; |
| 661 intptr_t postorder_number_; | 672 intptr_t postorder_number_; |
| 662 // Starting and ending lifetime positions for this block. Used by | 673 // Starting and ending lifetime positions for this block. Used by |
| 663 // the linear scan register allocator. | 674 // the linear scan register allocator. |
| 664 intptr_t block_id_; | 675 intptr_t block_id_; |
| 665 intptr_t start_pos_; | 676 intptr_t start_pos_; |
| 666 intptr_t end_pos_; | 677 intptr_t end_pos_; |
| 667 BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry. | 678 BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry. |
| 668 // TODO(fschneider): Optimize the case of one child to save space. | 679 // TODO(fschneider): Optimize the case of one child to save space. |
| 669 GrowableArray<BlockEntryInstr*> dominated_blocks_; | 680 GrowableArray<BlockEntryInstr*> dominated_blocks_; |
| 670 Instruction* last_instruction_; | 681 Instruction* last_instruction_; |
| 671 | 682 |
| 672 // Parallel move that will be used by linear scan register allocator to | 683 // Parallel move that will be used by linear scan register allocator to |
| 673 // connect live ranges at the start of the block. | 684 // connect live ranges at the start of the block. |
| 674 ParallelMoveInstr* parallel_move_; | 685 ParallelMoveInstr* parallel_move_; |
| 675 | 686 |
| 687 const ZoneGrowableArray<BlockEntryInstr*>* loop_info_; | |
| 688 | |
| 676 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); | 689 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); |
| 677 }; | 690 }; |
| 678 | 691 |
| 679 | 692 |
| 680 class ForwardInstructionIterator : public ValueObject { | 693 class ForwardInstructionIterator : public ValueObject { |
| 681 public: | 694 public: |
| 682 explicit ForwardInstructionIterator(BlockEntryInstr* block_entry) | 695 explicit ForwardInstructionIterator(BlockEntryInstr* block_entry) |
| 683 : block_entry_(block_entry), current_(block_entry) { | 696 : block_entry_(block_entry), current_(block_entry) { |
| 684 ASSERT(block_entry_->last_instruction()->next() == NULL); | 697 ASSERT(block_entry_->last_instruction()->next() == NULL); |
| 685 Advance(); | 698 Advance(); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 996 UNREACHABLE(); | 1009 UNREACHABLE(); |
| 997 return false; | 1010 return false; |
| 998 } | 1011 } |
| 999 | 1012 |
| 1000 // Returns a hash code for use with hash maps. | 1013 // Returns a hash code for use with hash maps. |
| 1001 virtual intptr_t Hashcode() const; | 1014 virtual intptr_t Hashcode() const; |
| 1002 | 1015 |
| 1003 virtual void RecordAssignedVars(BitVector* assigned_vars, | 1016 virtual void RecordAssignedVars(BitVector* assigned_vars, |
| 1004 intptr_t fixed_parameter_count); | 1017 intptr_t fixed_parameter_count); |
| 1005 | 1018 |
| 1019 // Get the block entry for that instruction. | |
| 1020 virtual BlockEntryInstr* GetBlock() const; | |
| 1021 | |
| 1006 // Printing support. These functions are sometimes overridden for custom | 1022 // Printing support. These functions are sometimes overridden for custom |
| 1007 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". | 1023 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". |
| 1008 virtual void PrintTo(BufferFormatter* f) const; | 1024 virtual void PrintTo(BufferFormatter* f) const; |
| 1009 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1025 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1010 virtual void PrintToVisualizer(BufferFormatter* f) const; | 1026 virtual void PrintToVisualizer(BufferFormatter* f) const; |
| 1011 | 1027 |
| 1012 private: | 1028 private: |
| 1013 intptr_t temp_index_; | 1029 intptr_t temp_index_; |
| 1014 intptr_t ssa_temp_index_; | 1030 intptr_t ssa_temp_index_; |
| 1015 // TODO(regis): GrowableArray<const AbstractType*> propagated_types_; | 1031 // TODO(regis): GrowableArray<const AbstractType*> propagated_types_; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1029 explicit PhiInstr(JoinEntryInstr* block, intptr_t num_inputs) | 1045 explicit PhiInstr(JoinEntryInstr* block, intptr_t num_inputs) |
| 1030 : block_(block), | 1046 : block_(block), |
| 1031 inputs_(num_inputs), | 1047 inputs_(num_inputs), |
| 1032 is_alive_(false), | 1048 is_alive_(false), |
| 1033 representation_(kTagged) { | 1049 representation_(kTagged) { |
| 1034 for (intptr_t i = 0; i < num_inputs; ++i) { | 1050 for (intptr_t i = 0; i < num_inputs; ++i) { |
| 1035 inputs_.Add(NULL); | 1051 inputs_.Add(NULL); |
| 1036 } | 1052 } |
| 1037 } | 1053 } |
| 1038 | 1054 |
| 1055 // Get the block entry for that instruction. | |
| 1056 virtual BlockEntryInstr* GetBlock() const { return block(); } | |
| 1039 JoinEntryInstr* block() const { return block_; } | 1057 JoinEntryInstr* block() const { return block_; } |
| 1040 | 1058 |
| 1041 virtual RawAbstractType* CompileType() const; | 1059 virtual RawAbstractType* CompileType() const; |
| 1042 virtual intptr_t GetPropagatedCid(); | 1060 virtual intptr_t GetPropagatedCid(); |
| 1043 | 1061 |
| 1044 virtual intptr_t ArgumentCount() const { return 0; } | 1062 virtual intptr_t ArgumentCount() const { return 0; } |
| 1045 | 1063 |
| 1046 intptr_t InputCount() const { return inputs_.length(); } | 1064 intptr_t InputCount() const { return inputs_.length(); } |
| 1047 | 1065 |
| 1048 Value* InputAt(intptr_t i) const { return inputs_[i]; } | 1066 Value* InputAt(intptr_t i) const { return inputs_[i]; } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 GrowableArray<Value*> inputs_; | 1108 GrowableArray<Value*> inputs_; |
| 1091 bool is_alive_; | 1109 bool is_alive_; |
| 1092 Representation representation_; | 1110 Representation representation_; |
| 1093 | 1111 |
| 1094 DISALLOW_COPY_AND_ASSIGN(PhiInstr); | 1112 DISALLOW_COPY_AND_ASSIGN(PhiInstr); |
| 1095 }; | 1113 }; |
| 1096 | 1114 |
| 1097 | 1115 |
| 1098 class ParameterInstr : public Definition { | 1116 class ParameterInstr : public Definition { |
| 1099 public: | 1117 public: |
| 1100 explicit ParameterInstr(intptr_t index) : index_(index) { } | 1118 explicit ParameterInstr(intptr_t index, GraphEntryInstr* block) |
| 1119 : index_(index), block_(block) { } | |
| 1101 | 1120 |
| 1102 DECLARE_INSTRUCTION(Parameter) | 1121 DECLARE_INSTRUCTION(Parameter) |
| 1103 | 1122 |
| 1104 intptr_t index() const { return index_; } | 1123 intptr_t index() const { return index_; } |
| 1105 | 1124 |
| 1125 // Get the block entry for that instruction. | |
| 1126 virtual BlockEntryInstr* GetBlock() const { return block_; } | |
| 1127 | |
| 1106 // Compile type of the passed-in parameter. | 1128 // Compile type of the passed-in parameter. |
| 1107 virtual RawAbstractType* CompileType() const; | 1129 virtual RawAbstractType* CompileType() const; |
| 1108 | 1130 |
| 1109 // No known propagated cid for parameters. | 1131 // No known propagated cid for parameters. |
| 1110 virtual intptr_t GetPropagatedCid(); | 1132 virtual intptr_t GetPropagatedCid(); |
| 1111 | 1133 |
| 1112 virtual intptr_t ArgumentCount() const { return 0; } | 1134 virtual intptr_t ArgumentCount() const { return 0; } |
| 1113 | 1135 |
| 1114 intptr_t InputCount() const { return 0; } | 1136 intptr_t InputCount() const { return 0; } |
| 1115 Value* InputAt(intptr_t i) const { | 1137 Value* InputAt(intptr_t i) const { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1128 virtual intptr_t ResultCid() const { | 1150 virtual intptr_t ResultCid() const { |
| 1129 UNREACHABLE(); | 1151 UNREACHABLE(); |
| 1130 return kIllegalCid; | 1152 return kIllegalCid; |
| 1131 } | 1153 } |
| 1132 | 1154 |
| 1133 virtual void PrintTo(BufferFormatter* f) const; | 1155 virtual void PrintTo(BufferFormatter* f) const; |
| 1134 virtual void PrintToVisualizer(BufferFormatter* f) const; | 1156 virtual void PrintToVisualizer(BufferFormatter* f) const; |
| 1135 | 1157 |
| 1136 private: | 1158 private: |
| 1137 const intptr_t index_; | 1159 const intptr_t index_; |
| 1160 GraphEntryInstr* block_; | |
| 1138 | 1161 |
| 1139 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); | 1162 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); |
| 1140 }; | 1163 }; |
| 1141 | 1164 |
| 1142 | 1165 |
| 1143 class PushArgumentInstr : public Definition { | 1166 class PushArgumentInstr : public Definition { |
| 1144 public: | 1167 public: |
| 1145 explicit PushArgumentInstr(Value* value) : value_(value), locs_(NULL) { | 1168 explicit PushArgumentInstr(Value* value) : value_(value), locs_(NULL) { |
| 1146 ASSERT(value != NULL); | 1169 ASSERT(value != NULL); |
| 1147 set_use_kind(kEffect); // Override the default. | 1170 set_use_kind(kEffect); // Override the default. |
| (...skipping 2122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3270 ForwardInstructionIterator* current_iterator_; | 3293 ForwardInstructionIterator* current_iterator_; |
| 3271 | 3294 |
| 3272 private: | 3295 private: |
| 3273 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 3296 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 3274 }; | 3297 }; |
| 3275 | 3298 |
| 3276 | 3299 |
| 3277 } // namespace dart | 3300 } // namespace dart |
| 3278 | 3301 |
| 3279 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 3302 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |