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 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 void FlowGraphVisitor::VisitBlocks() { | 85 void FlowGraphVisitor::VisitBlocks() { |
86 for (intptr_t i = 0; i < block_order_.length(); ++i) { | 86 for (intptr_t i = 0; i < block_order_.length(); ++i) { |
87 Instruction* current = block_order_[i]->Accept(this); | 87 Instruction* current = block_order_[i]->Accept(this); |
88 while ((current != NULL) && !current->IsBlockEntry()) { | 88 while ((current != NULL) && !current->IsBlockEntry()) { |
89 current = current->Accept(this); | 89 current = current->Accept(this); |
90 } | 90 } |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 | 94 |
| 95 // ==== Per-instruction input counts. |
| 96 intptr_t AssertAssignableComp::InputCount() const { |
| 97 // Value and optional instantiator type arguments. |
| 98 return (instantiator_type_arguments() == NULL) ? 1 : 2; |
| 99 } |
| 100 |
| 101 |
| 102 intptr_t InstanceOfComp::InputCount() const { |
| 103 // Value and optional type_arguments. |
| 104 return (type_arguments() == NULL) ? 1 : 2; |
| 105 } |
| 106 |
| 107 |
| 108 intptr_t CreateClosureComp::InputCount() const { |
| 109 // Optional type arguments. |
| 110 return (type_arguments() == NULL) ? 0 : 1; |
| 111 } |
| 112 |
| 113 |
| 114 intptr_t InstanceCallComp::InputCount() const { |
| 115 return ArgumentCount(); |
| 116 } |
| 117 |
| 118 |
| 119 intptr_t StaticCallComp::InputCount() const { |
| 120 return ArgumentCount(); |
| 121 } |
| 122 |
| 123 |
| 124 intptr_t ClosureCallComp::InputCount() const { |
| 125 // Context and arguments. |
| 126 return 1 + ArgumentCount(); |
| 127 } |
| 128 |
| 129 |
| 130 intptr_t AllocateObjectComp::InputCount() const { |
| 131 return arguments().length(); |
| 132 } |
| 133 |
| 134 |
| 135 intptr_t AllocateObjectWithBoundsCheckComp::InputCount() const { |
| 136 return arguments().length(); |
| 137 } |
| 138 |
| 139 |
| 140 intptr_t CreateArrayComp::InputCount() const { |
| 141 return ElementCount(); |
| 142 } |
| 143 |
| 144 |
| 145 intptr_t BranchInstr::InputCount() const { |
| 146 return 1; |
| 147 } |
| 148 |
| 149 |
| 150 intptr_t ReThrowInstr::InputCount() const { |
| 151 return 2; |
| 152 } |
| 153 |
| 154 |
| 155 intptr_t ThrowInstr::InputCount() const { |
| 156 return 1; |
| 157 } |
| 158 |
| 159 |
| 160 intptr_t ReturnInstr::InputCount() const { |
| 161 return 1; |
| 162 } |
| 163 |
| 164 |
| 165 intptr_t BindInstr::InputCount() const { |
| 166 return computation()->InputCount(); |
| 167 } |
| 168 |
| 169 |
| 170 intptr_t DoInstr::InputCount() const { |
| 171 return computation()->InputCount(); |
| 172 } |
| 173 |
| 174 |
| 175 intptr_t TuckTempInstr::InputCount() const { |
| 176 return 0; |
| 177 } |
| 178 |
| 179 |
| 180 intptr_t PickTempInstr::InputCount() const { |
| 181 return 0; |
| 182 } |
| 183 |
| 184 |
| 185 intptr_t TargetEntryInstr::InputCount() const { |
| 186 return 0; |
| 187 } |
| 188 |
| 189 |
| 190 intptr_t JoinEntryInstr::InputCount() const { |
| 191 return 0; |
| 192 } |
| 193 |
| 194 |
95 // ==== Postorder graph traversal. | 195 // ==== Postorder graph traversal. |
96 void JoinEntryInstr::DiscoverBlocks( | 196 void JoinEntryInstr::DiscoverBlocks( |
97 BlockEntryInstr* current_block, | 197 BlockEntryInstr* current_block, |
98 GrowableArray<BlockEntryInstr*>* preorder, | 198 GrowableArray<BlockEntryInstr*>* preorder, |
99 GrowableArray<BlockEntryInstr*>* postorder, | 199 GrowableArray<BlockEntryInstr*>* postorder, |
100 GrowableArray<intptr_t>* parent) { | 200 GrowableArray<intptr_t>* parent) { |
101 // The global graph entry is a TargetEntryInstr, so we can assume | 201 // The global graph entry is a TargetEntryInstr, so we can assume |
102 // current_block is non-null and preorder array is non-empty. | 202 // current_block is non-null and preorder array is non-empty. |
103 ASSERT(current_block != NULL); | 203 ASSERT(current_block != NULL); |
104 ASSERT(!preorder->is_empty()); | 204 ASSERT(!preorder->is_empty()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // true/false order in reverse postorder used as the block ordering in the | 290 // true/false order in reverse postorder used as the block ordering in the |
191 // nonoptimizing compiler. | 291 // nonoptimizing compiler. |
192 ASSERT(true_successor_ != NULL); | 292 ASSERT(true_successor_ != NULL); |
193 ASSERT(false_successor_ != NULL); | 293 ASSERT(false_successor_ != NULL); |
194 false_successor_->DiscoverBlocks(current_block, preorder, postorder, parent); | 294 false_successor_->DiscoverBlocks(current_block, preorder, postorder, parent); |
195 true_successor_->DiscoverBlocks(current_block, preorder, postorder, parent); | 295 true_successor_->DiscoverBlocks(current_block, preorder, postorder, parent); |
196 } | 296 } |
197 | 297 |
198 | 298 |
199 } // namespace dart | 299 } // namespace dart |
OLD | NEW |