| 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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 // Mutate assigned_vars to add the local variable index for all | 402 // Mutate assigned_vars to add the local variable index for all |
| 403 // frame-allocated locals assigned to by the instruction. | 403 // frame-allocated locals assigned to by the instruction. |
| 404 virtual void RecordAssignedVars(BitVector* assigned_vars, | 404 virtual void RecordAssignedVars(BitVector* assigned_vars, |
| 405 intptr_t fixed_parameter_count); | 405 intptr_t fixed_parameter_count); |
| 406 | 406 |
| 407 virtual const char* DebugName() const = 0; | 407 virtual const char* DebugName() const = 0; |
| 408 | 408 |
| 409 // Printing support. | 409 // Printing support. |
| 410 virtual void PrintTo(BufferFormatter* f) const; | 410 virtual void PrintTo(BufferFormatter* f) const; |
| 411 virtual void PrintOperandsTo(BufferFormatter* f) const; | 411 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 412 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
| 413 | 412 |
| 414 #define INSTRUCTION_TYPE_CHECK(type) \ | 413 #define INSTRUCTION_TYPE_CHECK(type) \ |
| 415 bool Is##type() { return (As##type() != NULL); } \ | 414 bool Is##type() { return (As##type() != NULL); } \ |
| 416 virtual type##Instr* As##type() { return NULL; } | 415 virtual type##Instr* As##type() { return NULL; } |
| 417 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) | 416 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) |
| 418 #undef INSTRUCTION_TYPE_CHECK | 417 #undef INSTRUCTION_TYPE_CHECK |
| 419 | 418 |
| 420 // Returns structure describing location constraints required | 419 // Returns structure describing location constraints required |
| 421 // to emit native code for this instruction. | 420 // to emit native code for this instruction. |
| 422 virtual LocationSummary* locs() { | 421 virtual LocationSummary* locs() { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 } | 643 } |
| 645 | 644 |
| 646 MoveOperands* MoveOperandsAt(intptr_t index) const { return moves_[index]; } | 645 MoveOperands* MoveOperandsAt(intptr_t index) const { return moves_[index]; } |
| 647 | 646 |
| 648 void SetSrcSlotAt(intptr_t index, const Location& loc); | 647 void SetSrcSlotAt(intptr_t index, const Location& loc); |
| 649 void SetDestSlotAt(intptr_t index, const Location& loc); | 648 void SetDestSlotAt(intptr_t index, const Location& loc); |
| 650 | 649 |
| 651 intptr_t NumMoves() const { return moves_.length(); } | 650 intptr_t NumMoves() const { return moves_.length(); } |
| 652 | 651 |
| 653 virtual void PrintTo(BufferFormatter* f) const; | 652 virtual void PrintTo(BufferFormatter* f) const; |
| 654 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
| 655 | 653 |
| 656 private: | 654 private: |
| 657 GrowableArray<MoveOperands*> moves_; // Elements cannot be null. | 655 GrowableArray<MoveOperands*> moves_; // Elements cannot be null. |
| 658 | 656 |
| 659 DISALLOW_COPY_AND_ASSIGN(ParallelMoveInstr); | 657 DISALLOW_COPY_AND_ASSIGN(ParallelMoveInstr); |
| 660 }; | 658 }; |
| 661 | 659 |
| 662 | 660 |
| 663 // Basic block entries are administrative nodes. There is a distinguished | 661 // Basic block entries are administrative nodes. There is a distinguished |
| 664 // graph entry with no predecessor. Joins are the only nodes with multiple | 662 // graph entry with no predecessor. Joins are the only nodes with multiple |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 | 876 |
| 879 intptr_t spill_slot_count() const { return spill_slot_count_; } | 877 intptr_t spill_slot_count() const { return spill_slot_count_; } |
| 880 void set_spill_slot_count(intptr_t count) { | 878 void set_spill_slot_count(intptr_t count) { |
| 881 ASSERT(count >= 0); | 879 ASSERT(count >= 0); |
| 882 spill_slot_count_ = count; | 880 spill_slot_count_ = count; |
| 883 } | 881 } |
| 884 | 882 |
| 885 TargetEntryInstr* normal_entry() const { return normal_entry_; } | 883 TargetEntryInstr* normal_entry() const { return normal_entry_; } |
| 886 | 884 |
| 887 virtual void PrintTo(BufferFormatter* f) const; | 885 virtual void PrintTo(BufferFormatter* f) const; |
| 888 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
| 889 | 886 |
| 890 private: | 887 private: |
| 891 virtual void ClearPredecessors() { UNREACHABLE(); } | 888 virtual void ClearPredecessors() { UNREACHABLE(); } |
| 892 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } | 889 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } |
| 893 | 890 |
| 894 TargetEntryInstr* normal_entry_; | 891 TargetEntryInstr* normal_entry_; |
| 895 GrowableArray<TargetEntryInstr*> catch_entries_; | 892 GrowableArray<TargetEntryInstr*> catch_entries_; |
| 896 GrowableArray<Definition*> initial_definitions_; | 893 GrowableArray<Definition*> initial_definitions_; |
| 897 intptr_t spill_slot_count_; | 894 intptr_t spill_slot_count_; |
| 898 | 895 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 921 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; } | 918 ZoneGrowableArray<PhiInstr*>* phis() const { return phis_; } |
| 922 | 919 |
| 923 virtual void PrepareEntry(FlowGraphCompiler* compiler); | 920 virtual void PrepareEntry(FlowGraphCompiler* compiler); |
| 924 | 921 |
| 925 void InsertPhi(intptr_t var_index, intptr_t var_count); | 922 void InsertPhi(intptr_t var_index, intptr_t var_count); |
| 926 void RemoveDeadPhis(); | 923 void RemoveDeadPhis(); |
| 927 | 924 |
| 928 intptr_t phi_count() const { return phi_count_; } | 925 intptr_t phi_count() const { return phi_count_; } |
| 929 | 926 |
| 930 virtual void PrintTo(BufferFormatter* f) const; | 927 virtual void PrintTo(BufferFormatter* f) const; |
| 931 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
| 932 | 928 |
| 933 private: | 929 private: |
| 934 friend class FlowGraph; // Access to predecessors_ when inlining. | 930 friend class FlowGraph; // Access to predecessors_ when inlining. |
| 935 virtual void ClearPredecessors() { predecessors_.Clear(); } | 931 virtual void ClearPredecessors() { predecessors_.Clear(); } |
| 936 virtual void AddPredecessor(BlockEntryInstr* predecessor); | 932 virtual void AddPredecessor(BlockEntryInstr* predecessor); |
| 937 | 933 |
| 938 GrowableArray<BlockEntryInstr*> predecessors_; | 934 GrowableArray<BlockEntryInstr*> predecessors_; |
| 939 ZoneGrowableArray<PhiInstr*>* phis_; | 935 ZoneGrowableArray<PhiInstr*>* phis_; |
| 940 intptr_t phi_count_; | 936 intptr_t phi_count_; |
| 941 | 937 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 // corresponds. | 993 // corresponds. |
| 998 intptr_t catch_try_index() const { | 994 intptr_t catch_try_index() const { |
| 999 ASSERT(IsCatchEntry()); | 995 ASSERT(IsCatchEntry()); |
| 1000 return catch_try_index_; | 996 return catch_try_index_; |
| 1001 } | 997 } |
| 1002 void set_catch_try_index(intptr_t index) { catch_try_index_ = index; } | 998 void set_catch_try_index(intptr_t index) { catch_try_index_ = index; } |
| 1003 | 999 |
| 1004 virtual void PrepareEntry(FlowGraphCompiler* compiler); | 1000 virtual void PrepareEntry(FlowGraphCompiler* compiler); |
| 1005 | 1001 |
| 1006 virtual void PrintTo(BufferFormatter* f) const; | 1002 virtual void PrintTo(BufferFormatter* f) const; |
| 1007 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
| 1008 | 1003 |
| 1009 private: | 1004 private: |
| 1010 virtual void ClearPredecessors() { predecessor_ = NULL; } | 1005 virtual void ClearPredecessors() { predecessor_ = NULL; } |
| 1011 virtual void AddPredecessor(BlockEntryInstr* predecessor) { | 1006 virtual void AddPredecessor(BlockEntryInstr* predecessor) { |
| 1012 ASSERT(predecessor_ == NULL); | 1007 ASSERT(predecessor_ == NULL); |
| 1013 predecessor_ = predecessor; | 1008 predecessor_ = predecessor; |
| 1014 } | 1009 } |
| 1015 | 1010 |
| 1016 BlockEntryInstr* predecessor_; | 1011 BlockEntryInstr* predecessor_; |
| 1017 intptr_t catch_try_index_; | 1012 intptr_t catch_try_index_; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 // NULL iterator. | 1095 // NULL iterator. |
| 1101 void ReplaceWith(Definition* other, ForwardInstructionIterator* iterator); | 1096 void ReplaceWith(Definition* other, ForwardInstructionIterator* iterator); |
| 1102 | 1097 |
| 1103 virtual void RecordAssignedVars(BitVector* assigned_vars, | 1098 virtual void RecordAssignedVars(BitVector* assigned_vars, |
| 1104 intptr_t fixed_parameter_count); | 1099 intptr_t fixed_parameter_count); |
| 1105 | 1100 |
| 1106 // Printing support. These functions are sometimes overridden for custom | 1101 // Printing support. These functions are sometimes overridden for custom |
| 1107 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". | 1102 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". |
| 1108 virtual void PrintTo(BufferFormatter* f) const; | 1103 virtual void PrintTo(BufferFormatter* f) const; |
| 1109 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1104 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1110 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
| 1111 | 1105 |
| 1112 // A value in the constant propagation lattice. | 1106 // A value in the constant propagation lattice. |
| 1113 // - non-constant sentinel | 1107 // - non-constant sentinel |
| 1114 // - a constant (any non-sentinel value) | 1108 // - a constant (any non-sentinel value) |
| 1115 // - unknown sentinel | 1109 // - unknown sentinel |
| 1116 Object& constant_value() const { return constant_value_; } | 1110 Object& constant_value() const { return constant_value_; } |
| 1117 | 1111 |
| 1118 enum RangeOperator { kRangeInit, kRangeWiden, kRangeNarrow }; | 1112 enum RangeOperator { kRangeInit, kRangeWiden, kRangeNarrow }; |
| 1119 | 1113 |
| 1120 virtual bool InferRange(RangeOperator op); | 1114 virtual bool InferRange(RangeOperator op); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 } | 1197 } |
| 1204 | 1198 |
| 1205 virtual intptr_t ResultCid() const { | 1199 virtual intptr_t ResultCid() const { |
| 1206 UNREACHABLE(); | 1200 UNREACHABLE(); |
| 1207 return kIllegalCid; | 1201 return kIllegalCid; |
| 1208 } | 1202 } |
| 1209 | 1203 |
| 1210 DECLARE_INSTRUCTION(Phi) | 1204 DECLARE_INSTRUCTION(Phi) |
| 1211 | 1205 |
| 1212 virtual void PrintTo(BufferFormatter* f) const; | 1206 virtual void PrintTo(BufferFormatter* f) const; |
| 1213 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
| 1214 | 1207 |
| 1215 virtual bool InferRange(RangeOperator op); | 1208 virtual bool InferRange(RangeOperator op); |
| 1216 | 1209 |
| 1217 private: | 1210 private: |
| 1218 friend class ConstantPropagator; // Direct access to inputs_. | 1211 friend class ConstantPropagator; // Direct access to inputs_. |
| 1219 | 1212 |
| 1220 JoinEntryInstr* block_; | 1213 JoinEntryInstr* block_; |
| 1221 GrowableArray<Value*> inputs_; | 1214 GrowableArray<Value*> inputs_; |
| 1222 bool is_alive_; | 1215 bool is_alive_; |
| 1223 Representation representation_; | 1216 Representation representation_; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 UNREACHABLE(); | 1258 UNREACHABLE(); |
| 1266 return 0; | 1259 return 0; |
| 1267 } | 1260 } |
| 1268 | 1261 |
| 1269 virtual intptr_t ResultCid() const { | 1262 virtual intptr_t ResultCid() const { |
| 1270 UNREACHABLE(); | 1263 UNREACHABLE(); |
| 1271 return kIllegalCid; | 1264 return kIllegalCid; |
| 1272 } | 1265 } |
| 1273 | 1266 |
| 1274 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1267 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1275 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
| 1276 | 1268 |
| 1277 private: | 1269 private: |
| 1278 const intptr_t index_; | 1270 const intptr_t index_; |
| 1279 GraphEntryInstr* block_; | 1271 GraphEntryInstr* block_; |
| 1280 | 1272 |
| 1281 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); | 1273 DISALLOW_COPY_AND_ASSIGN(ParameterInstr); |
| 1282 }; | 1274 }; |
| 1283 | 1275 |
| 1284 | 1276 |
| 1285 class PushArgumentInstr : public Definition { | 1277 class PushArgumentInstr : public Definition { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1322 virtual intptr_t Hashcode() const { | 1314 virtual intptr_t Hashcode() const { |
| 1323 UNREACHABLE(); | 1315 UNREACHABLE(); |
| 1324 return 0; | 1316 return 0; |
| 1325 } | 1317 } |
| 1326 | 1318 |
| 1327 virtual bool CanDeoptimize() const { return false; } | 1319 virtual bool CanDeoptimize() const { return false; } |
| 1328 | 1320 |
| 1329 virtual bool HasSideEffect() const { return false; } | 1321 virtual bool HasSideEffect() const { return false; } |
| 1330 | 1322 |
| 1331 virtual void PrintOperandsTo(BufferFormatter* f) const; | 1323 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1332 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
| 1333 | 1324 |
| 1334 private: | 1325 private: |
| 1335 Value* value_; | 1326 Value* value_; |
| 1336 LocationSummary* locs_; | 1327 LocationSummary* locs_; |
| 1337 | 1328 |
| 1338 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr); | 1329 DISALLOW_COPY_AND_ASSIGN(PushArgumentInstr); |
| 1339 }; | 1330 }; |
| 1340 | 1331 |
| 1341 | 1332 |
| 1342 class ReturnInstr : public TemplateInstruction<1> { | 1333 class ReturnInstr : public TemplateInstruction<1> { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 } | 1426 } |
| 1436 | 1427 |
| 1437 ParallelMoveInstr* GetParallelMove() { | 1428 ParallelMoveInstr* GetParallelMove() { |
| 1438 if (parallel_move_ == NULL) { | 1429 if (parallel_move_ == NULL) { |
| 1439 parallel_move_ = new ParallelMoveInstr(); | 1430 parallel_move_ = new ParallelMoveInstr(); |
| 1440 } | 1431 } |
| 1441 return parallel_move_; | 1432 return parallel_move_; |
| 1442 } | 1433 } |
| 1443 | 1434 |
| 1444 virtual void PrintTo(BufferFormatter* f) const; | 1435 virtual void PrintTo(BufferFormatter* f) const; |
| 1445 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
| 1446 | 1436 |
| 1447 private: | 1437 private: |
| 1448 JoinEntryInstr* successor_; | 1438 JoinEntryInstr* successor_; |
| 1449 | 1439 |
| 1450 // Parallel move that will be used by linear scan register allocator to | 1440 // Parallel move that will be used by linear scan register allocator to |
| 1451 // connect live ranges at the end of the block and resolve phis. | 1441 // connect live ranges at the end of the block and resolve phis. |
| 1452 ParallelMoveInstr* parallel_move_; | 1442 ParallelMoveInstr* parallel_move_; |
| 1453 }; | 1443 }; |
| 1454 | 1444 |
| 1455 | 1445 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 virtual intptr_t DeoptimizationTarget() const; | 1503 virtual intptr_t DeoptimizationTarget() const; |
| 1514 virtual Representation RequiredInputRepresentation(intptr_t i) const; | 1504 virtual Representation RequiredInputRepresentation(intptr_t i) const; |
| 1515 | 1505 |
| 1516 // Replace the comparison with another, leaving the branch intact. | 1506 // Replace the comparison with another, leaving the branch intact. |
| 1517 void ReplaceWith(ComparisonInstr* other, | 1507 void ReplaceWith(ComparisonInstr* other, |
| 1518 ForwardInstructionIterator* ignored) { | 1508 ForwardInstructionIterator* ignored) { |
| 1519 comparison_ = other; | 1509 comparison_ = other; |
| 1520 } | 1510 } |
| 1521 | 1511 |
| 1522 virtual void PrintTo(BufferFormatter* f) const; | 1512 virtual void PrintTo(BufferFormatter* f) const; |
| 1523 virtual void PrintToVisualizer(BufferFormatter* f) const; | |
| 1524 | 1513 |
| 1525 private: | 1514 private: |
| 1526 ComparisonInstr* comparison_; | 1515 ComparisonInstr* comparison_; |
| 1527 | 1516 |
| 1528 DISALLOW_COPY_AND_ASSIGN(BranchInstr); | 1517 DISALLOW_COPY_AND_ASSIGN(BranchInstr); |
| 1529 }; | 1518 }; |
| 1530 | 1519 |
| 1531 | 1520 |
| 1532 class StoreContextInstr : public TemplateInstruction<1> { | 1521 class StoreContextInstr : public TemplateInstruction<1> { |
| 1533 public: | 1522 public: |
| (...skipping 2683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4217 ForwardInstructionIterator* current_iterator_; | 4206 ForwardInstructionIterator* current_iterator_; |
| 4218 | 4207 |
| 4219 private: | 4208 private: |
| 4220 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 4209 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 4221 }; | 4210 }; |
| 4222 | 4211 |
| 4223 | 4212 |
| 4224 } // namespace dart | 4213 } // namespace dart |
| 4225 | 4214 |
| 4226 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 4215 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |