| 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 #include "vm/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/object.h" | 7 #include "vm/object.h" |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 #include "vm/scopes.h" | 9 #include "vm/scopes.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 // ==== Support for visiting flow graphs. | 13 // ==== Support for visiting flow graphs. |
| 14 #define DEFINE_ACCEPT(ShortName, ClassName) \ | 14 #define DEFINE_ACCEPT(ShortName, ClassName) \ |
| 15 void ClassName::Accept(FlowGraphVisitor* visitor) { \ | 15 void ClassName::Accept(FlowGraphVisitor* visitor) { \ |
| 16 visitor->Visit##ShortName(this); \ | 16 visitor->Visit##ShortName(this); \ |
| 17 } | 17 } |
| 18 | 18 |
| 19 FOR_EACH_COMPUTATION(DEFINE_ACCEPT) | 19 FOR_EACH_COMPUTATION(DEFINE_ACCEPT) |
| 20 | 20 |
| 21 #undef DEFINE_ACCEPT | 21 #undef DEFINE_ACCEPT |
| 22 | 22 |
| 23 | 23 |
| 24 Instruction* JoinEntryInstr::Accept(FlowGraphVisitor* visitor) { | 24 #define DEFINE_ACCEPT(ShortName) \ |
| 25 visitor->VisitJoinEntry(this); | 25 Instruction* ShortName##Instr::Accept(FlowGraphVisitor* visitor) { \ |
| 26 return successor_; | 26 visitor->Visit##ShortName(this); \ |
| 27 return StraightLineSuccessor(); \ |
| 27 } | 28 } |
| 28 | 29 |
| 30 FOR_EACH_INSTRUCTION(DEFINE_ACCEPT) |
| 29 | 31 |
| 30 Instruction* TargetEntryInstr::Accept(FlowGraphVisitor* visitor) { | 32 #undef DEFINE_ACCEPT |
| 31 visitor->VisitTargetEntry(this); | |
| 32 return successor_; | |
| 33 } | |
| 34 | |
| 35 | |
| 36 Instruction* PickTempInstr::Accept(FlowGraphVisitor* visitor) { | |
| 37 visitor->VisitPickTemp(this); | |
| 38 return successor_; | |
| 39 } | |
| 40 | |
| 41 | |
| 42 Instruction* TuckTempInstr::Accept(FlowGraphVisitor* visitor) { | |
| 43 visitor->VisitTuckTemp(this); | |
| 44 return successor_; | |
| 45 } | |
| 46 | |
| 47 | |
| 48 Instruction* DoInstr::Accept(FlowGraphVisitor* visitor) { | |
| 49 visitor->VisitDo(this); | |
| 50 return successor_; | |
| 51 } | |
| 52 | |
| 53 | |
| 54 Instruction* BindInstr::Accept(FlowGraphVisitor* visitor) { | |
| 55 visitor->VisitBind(this); | |
| 56 return successor_; | |
| 57 } | |
| 58 | |
| 59 | |
| 60 Instruction* ReturnInstr::Accept(FlowGraphVisitor* visitor) { | |
| 61 visitor->VisitReturn(this); | |
| 62 return NULL; | |
| 63 } | |
| 64 | |
| 65 | |
| 66 Instruction* ThrowInstr::Accept(FlowGraphVisitor* visitor) { | |
| 67 visitor->VisitThrow(this); | |
| 68 return NULL; | |
| 69 } | |
| 70 | |
| 71 | |
| 72 Instruction* ReThrowInstr::Accept(FlowGraphVisitor* visitor) { | |
| 73 visitor->VisitReThrow(this); | |
| 74 return NULL; | |
| 75 } | |
| 76 | |
| 77 | |
| 78 Instruction* BranchInstr::Accept(FlowGraphVisitor* visitor) { | |
| 79 visitor->VisitBranch(this); | |
| 80 return NULL; | |
| 81 } | |
| 82 | 33 |
| 83 | 34 |
| 84 // Default implementation of visiting basic blocks. Can be overridden. | 35 // Default implementation of visiting basic blocks. Can be overridden. |
| 85 void FlowGraphVisitor::VisitBlocks() { | 36 void FlowGraphVisitor::VisitBlocks() { |
| 86 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 37 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
| 87 Instruction* current = block_order_[i]->Accept(this); | 38 Instruction* current = block_order_[i]->Accept(this); |
| 88 while ((current != NULL) && !current->IsBlockEntry()) { | 39 while ((current != NULL) && !current->IsBlockEntry()) { |
| 89 current = current->Accept(this); | 40 current = current->Accept(this); |
| 90 } | 41 } |
| 91 } | 42 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // true/false order in reverse postorder used as the block ordering in the | 241 // true/false order in reverse postorder used as the block ordering in the |
| 291 // nonoptimizing compiler. | 242 // nonoptimizing compiler. |
| 292 ASSERT(true_successor_ != NULL); | 243 ASSERT(true_successor_ != NULL); |
| 293 ASSERT(false_successor_ != NULL); | 244 ASSERT(false_successor_ != NULL); |
| 294 false_successor_->DiscoverBlocks(current_block, preorder, postorder, parent); | 245 false_successor_->DiscoverBlocks(current_block, preorder, postorder, parent); |
| 295 true_successor_->DiscoverBlocks(current_block, preorder, postorder, parent); | 246 true_successor_->DiscoverBlocks(current_block, preorder, postorder, parent); |
| 296 } | 247 } |
| 297 | 248 |
| 298 | 249 |
| 299 } // namespace dart | 250 } // namespace dart |
| OLD | NEW |