| 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/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/flow_graph_builder.h" | 8 #include "vm/flow_graph_builder.h" |
| 9 #include "vm/flow_graph_compiler.h" | 9 #include "vm/flow_graph_compiler.h" |
| 10 #include "vm/locations.h" | 10 #include "vm/locations.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 intptr_t CreateArrayComp::InputCount() const { | 84 intptr_t CreateArrayComp::InputCount() const { |
| 85 return ElementCount() + 1; | 85 return ElementCount() + 1; |
| 86 } | 86 } |
| 87 | 87 |
| 88 | 88 |
| 89 intptr_t BranchInstr::InputCount() const { | 89 intptr_t BranchInstr::InputCount() const { |
| 90 return 1; | 90 return 1; |
| 91 } | 91 } |
| 92 | 92 |
| 93 | 93 |
| 94 Value* BranchInstr::InputAt(intptr_t i) const { |
| 95 if (i == 0) return value(); |
| 96 UNREACHABLE(); |
| 97 return NULL; |
| 98 } |
| 99 |
| 100 |
| 94 intptr_t ReThrowInstr::InputCount() const { | 101 intptr_t ReThrowInstr::InputCount() const { |
| 95 return 2; | 102 return 2; |
| 96 } | 103 } |
| 97 | 104 |
| 98 | 105 |
| 106 Value* ReThrowInstr::InputAt(intptr_t i) const { |
| 107 if (i == 0) return exception(); |
| 108 if (i == 1) return stack_trace(); |
| 109 UNREACHABLE(); |
| 110 return NULL; |
| 111 } |
| 112 |
| 113 |
| 99 intptr_t ThrowInstr::InputCount() const { | 114 intptr_t ThrowInstr::InputCount() const { |
| 100 return 1; | 115 return 1; |
| 101 } | 116 } |
| 102 | 117 |
| 103 | 118 |
| 119 Value* ThrowInstr::InputAt(intptr_t i) const { |
| 120 if (i == 0) return exception(); |
| 121 UNREACHABLE(); |
| 122 return NULL; |
| 123 } |
| 124 |
| 125 |
| 104 intptr_t ReturnInstr::InputCount() const { | 126 intptr_t ReturnInstr::InputCount() const { |
| 105 return 1; | 127 return 1; |
| 106 } | 128 } |
| 107 | 129 |
| 108 | 130 |
| 131 Value* ReturnInstr::InputAt(intptr_t i) const { |
| 132 if (i == 0) return value(); |
| 133 UNREACHABLE(); |
| 134 return NULL; |
| 135 } |
| 136 |
| 137 |
| 109 intptr_t BindInstr::InputCount() const { | 138 intptr_t BindInstr::InputCount() const { |
| 110 return computation()->InputCount(); | 139 return computation()->InputCount(); |
| 111 } | 140 } |
| 112 | 141 |
| 113 | 142 |
| 143 Value* BindInstr::InputAt(intptr_t i) const { |
| 144 return computation()->InputAt(i); |
| 145 } |
| 146 |
| 147 |
| 148 intptr_t PhiInstr::InputCount() const { |
| 149 return inputs_.length(); |
| 150 } |
| 151 |
| 152 |
| 153 Value* PhiInstr::InputAt(intptr_t i) const { |
| 154 return inputs_[i]; |
| 155 } |
| 156 |
| 157 |
| 114 intptr_t DoInstr::InputCount() const { | 158 intptr_t DoInstr::InputCount() const { |
| 115 return computation()->InputCount(); | 159 return computation()->InputCount(); |
| 116 } | 160 } |
| 117 | 161 |
| 118 | 162 |
| 163 Value* DoInstr::InputAt(intptr_t i) const { |
| 164 return computation()->InputAt(i); |
| 165 } |
| 166 |
| 167 |
| 119 intptr_t GraphEntryInstr::InputCount() const { | 168 intptr_t GraphEntryInstr::InputCount() const { |
| 120 return 0; | 169 return 0; |
| 121 } | 170 } |
| 122 | 171 |
| 123 | 172 |
| 173 Value* GraphEntryInstr::InputAt(intptr_t i) const { |
| 174 UNREACHABLE(); |
| 175 return NULL; |
| 176 } |
| 177 |
| 178 |
| 124 intptr_t TargetEntryInstr::InputCount() const { | 179 intptr_t TargetEntryInstr::InputCount() const { |
| 125 return 0; | 180 return 0; |
| 126 } | 181 } |
| 127 | 182 |
| 128 | 183 |
| 184 Value* TargetEntryInstr::InputAt(intptr_t i) const { |
| 185 UNREACHABLE(); |
| 186 return NULL; |
| 187 } |
| 188 |
| 189 |
| 129 intptr_t JoinEntryInstr::InputCount() const { | 190 intptr_t JoinEntryInstr::InputCount() const { |
| 130 return 0; | 191 return 0; |
| 131 } | 192 } |
| 132 | 193 |
| 133 | 194 |
| 195 Value* JoinEntryInstr::InputAt(intptr_t i) const { |
| 196 UNREACHABLE(); |
| 197 return NULL; |
| 198 } |
| 199 |
| 200 |
| 134 // ==== Recording assigned variables. | 201 // ==== Recording assigned variables. |
| 135 void Computation::RecordAssignedVars(BitVector* assigned_vars) { | 202 void Computation::RecordAssignedVars(BitVector* assigned_vars) { |
| 136 // Nothing to do for the base class. | 203 // Nothing to do for the base class. |
| 137 } | 204 } |
| 138 | 205 |
| 139 | 206 |
| 140 void StoreLocalComp::RecordAssignedVars(BitVector* assigned_vars) { | 207 void StoreLocalComp::RecordAssignedVars(BitVector* assigned_vars) { |
| 141 if (!local().is_captured()) { | 208 if (!local().is_captured()) { |
| 142 assigned_vars->Add(local().BitIndexIn(assigned_vars)); | 209 assigned_vars->Add(local().BitIndexIn(assigned_vars->length())); |
| 143 } | 210 } |
| 144 } | 211 } |
| 145 | 212 |
| 146 | 213 |
| 147 void Instruction::RecordAssignedVars(BitVector* assigned_vars) { | 214 void Instruction::RecordAssignedVars(BitVector* assigned_vars) { |
| 148 // Nothing to do for the base class. | 215 // Nothing to do for the base class. |
| 149 } | 216 } |
| 150 | 217 |
| 151 | 218 |
| 152 void DoInstr::RecordAssignedVars(BitVector* assigned_vars) { | 219 void DoInstr::RecordAssignedVars(BitVector* assigned_vars) { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 // nonoptimizing compiler. | 343 // nonoptimizing compiler. |
| 277 ASSERT(true_successor_ != NULL); | 344 ASSERT(true_successor_ != NULL); |
| 278 ASSERT(false_successor_ != NULL); | 345 ASSERT(false_successor_ != NULL); |
| 279 false_successor_->DiscoverBlocks(current_block, preorder, postorder, | 346 false_successor_->DiscoverBlocks(current_block, preorder, postorder, |
| 280 parent, assigned_vars, variable_count); | 347 parent, assigned_vars, variable_count); |
| 281 true_successor_->DiscoverBlocks(current_block, preorder, postorder, | 348 true_successor_->DiscoverBlocks(current_block, preorder, postorder, |
| 282 parent, assigned_vars, variable_count); | 349 parent, assigned_vars, variable_count); |
| 283 } | 350 } |
| 284 | 351 |
| 285 | 352 |
| 353 void JoinEntryInstr::InsertPhi(intptr_t var_index, intptr_t var_count) { |
| 354 // Lazily initialize the array of phis. |
| 355 // Currently, phis are stored in a sparse array that holds the phi |
| 356 // for variable with index i at position i. |
| 357 // TODO(fschneider): Store phis in a more compact way. |
| 358 if (phis_ == NULL) { |
| 359 phis_ = new ZoneGrowableArray<PhiInstr*>(var_count); |
| 360 for (intptr_t i = 0; i < var_count; i++) { |
| 361 phis_->Add(NULL); |
| 362 } |
| 363 } |
| 364 ASSERT((*phis_)[var_index] == NULL); |
| 365 (*phis_)[var_index] = new PhiInstr(PredecessorCount()); |
| 366 phi_count_++; |
| 367 } |
| 368 |
| 369 |
| 286 intptr_t Instruction::SuccessorCount() const { | 370 intptr_t Instruction::SuccessorCount() const { |
| 287 ASSERT(!IsBranch()); | 371 ASSERT(!IsBranch()); |
| 288 ASSERT(!IsGraphEntry()); | 372 ASSERT(!IsGraphEntry()); |
| 289 ASSERT(StraightLineSuccessor() == NULL || | 373 ASSERT(StraightLineSuccessor() == NULL || |
| 290 StraightLineSuccessor()->IsBlockEntry()); | 374 StraightLineSuccessor()->IsBlockEntry()); |
| 291 return StraightLineSuccessor() != NULL ? 1 : 0; | 375 return StraightLineSuccessor() != NULL ? 1 : 0; |
| 292 } | 376 } |
| 293 | 377 |
| 294 | 378 |
| 295 BlockEntryInstr* Instruction::SuccessorAt(intptr_t index) const { | 379 BlockEntryInstr* Instruction::SuccessorAt(intptr_t index) const { |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 StubCode::GetAllocationStubForClosure(closure_function)); | 1078 StubCode::GetAllocationStubForClosure(closure_function)); |
| 995 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); | 1079 const ExternalLabel label(closure_function.ToCString(), stub.EntryPoint()); |
| 996 compiler->GenerateCall(token_index(), try_index(), &label, | 1080 compiler->GenerateCall(token_index(), try_index(), &label, |
| 997 PcDescriptors::kOther); | 1081 PcDescriptors::kOther); |
| 998 __ Drop(2); // Discard type arguments and receiver. | 1082 __ Drop(2); // Discard type arguments and receiver. |
| 999 } | 1083 } |
| 1000 | 1084 |
| 1001 #undef __ | 1085 #undef __ |
| 1002 | 1086 |
| 1003 } // namespace dart | 1087 } // namespace dart |
| OLD | NEW |