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/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
6 | 6 |
7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 2229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2240 return kFirstLocalSlotFromFp | 2240 return kFirstLocalSlotFromFp |
2241 - owner()->num_stack_locals() | 2241 - owner()->num_stack_locals() |
2242 - owner()->num_copied_params() | 2242 - owner()->num_copied_params() |
2243 - owner()->args_pushed() | 2243 - owner()->args_pushed() |
2244 - owner()->temp_count() + 1; | 2244 - owner()->temp_count() + 1; |
2245 } | 2245 } |
2246 | 2246 |
2247 | 2247 |
2248 LocalVariable* EffectGraphVisitor::EnterTempLocalScope( | 2248 LocalVariable* EffectGraphVisitor::EnterTempLocalScope( |
2249 Value* value, TokenPosition token_pos) { | 2249 Value* value, TokenPosition token_pos) { |
2250 Do(new(Z) PushTempInstr(value)); | |
2251 owner()->AllocateTemp(); | |
2252 | |
2253 ASSERT(value->definition()->temp_index() == (owner()->temp_count() - 1)); | 2250 ASSERT(value->definition()->temp_index() == (owner()->temp_count() - 1)); |
2254 intptr_t index = GetCurrentTempLocalIndex(); | 2251 intptr_t index = GetCurrentTempLocalIndex(); |
2255 char name[64]; | 2252 char name[64]; |
2256 OS::SNPrint(name, 64, ":tmp_local%" Pd, index); | 2253 OS::SNPrint(name, 64, ":tmp_local%" Pd, index); |
2257 LocalVariable* var = | 2254 LocalVariable* var = |
2258 new(Z) LocalVariable(TokenPosition::kNoSource, | 2255 new(Z) LocalVariable(TokenPosition::kNoSource, |
2259 String::ZoneHandle(Z, Symbols::New(T, name)), | 2256 String::ZoneHandle(Z, Symbols::New(T, name)), |
2260 *value->Type()->ToAbstractType()); | 2257 *value->Type()->ToAbstractType()); |
2261 var->set_index(index); | 2258 var->set_index(index); |
2262 return var; | 2259 return var; |
2263 } | 2260 } |
2264 | 2261 |
2265 | 2262 |
2266 Definition* EffectGraphVisitor::ExitTempLocalScope( | 2263 Definition* EffectGraphVisitor::ExitTempLocalScope( |
2267 LocalVariable* var, TokenPosition token_pos) { | 2264 LocalVariable* var, TokenPosition token_pos) { |
2268 Value* tmp = Bind(new(Z) LoadLocalInstr(*var, token_pos)); | 2265 Value* tmp = Bind(new(Z) LoadLocalInstr(*var, token_pos)); |
2269 owner()->DeallocateTemps(1); | 2266 owner()->DeallocateTemps(1); |
2270 ASSERT(GetCurrentTempLocalIndex() == var->index()); | 2267 ASSERT(GetCurrentTempLocalIndex() == var->index()); |
2271 return new(Z) DropTempsInstr(1, tmp); | 2268 return new(Z) DropTempsInstr(1, tmp); |
2272 } | 2269 } |
2273 | 2270 |
2274 | 2271 |
2275 void EffectGraphVisitor::BuildLetTempExpressions(LetNode* node) { | 2272 void EffectGraphVisitor::BuildLetTempExpressions(LetNode* node) { |
2276 intptr_t num_temps = node->num_temps(); | 2273 intptr_t num_temps = node->num_temps(); |
2277 for (intptr_t i = 0; i < num_temps; ++i) { | 2274 for (intptr_t i = 0; i < num_temps; ++i) { |
2278 ValueGraphVisitor for_value(owner()); | 2275 ValueGraphVisitor for_value(owner()); |
2279 node->InitializerAt(i)->Visit(&for_value); | 2276 node->InitializerAt(i)->Visit(&for_value); |
2280 Append(for_value); | 2277 Append(for_value); |
2281 Value* temp_val = for_value.value(); | |
2282 ASSERT(!node->TempAt(i)->HasIndex() || | 2278 ASSERT(!node->TempAt(i)->HasIndex() || |
2283 (node->TempAt(i)->index() == GetCurrentTempLocalIndex())); | 2279 (node->TempAt(i)->index() == GetCurrentTempLocalIndex())); |
2284 node->TempAt(i)->set_index(GetCurrentTempLocalIndex()); | 2280 node->TempAt(i)->set_index(GetCurrentTempLocalIndex()); |
2285 Do(new(Z) PushTempInstr(temp_val)); | |
2286 owner()->AllocateTemp(); | |
2287 } | 2281 } |
2288 } | 2282 } |
2289 | 2283 |
2290 | 2284 |
2291 void EffectGraphVisitor::VisitLetNode(LetNode* node) { | 2285 void EffectGraphVisitor::VisitLetNode(LetNode* node) { |
2292 BuildLetTempExpressions(node); | 2286 BuildLetTempExpressions(node); |
2293 | 2287 |
2294 // Visit body. | 2288 // Visit body. |
2295 for (intptr_t i = 0; i < node->nodes().length(); ++i) { | 2289 for (intptr_t i = 0; i < node->nodes().length(); ++i) { |
2296 EffectGraphVisitor for_effect(owner()); | 2290 EffectGraphVisitor for_effect(owner()); |
(...skipping 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4616 Script::Handle(function.script()), | 4610 Script::Handle(function.script()), |
4617 function.token_pos(), | 4611 function.token_pos(), |
4618 Report::AtLocation, | 4612 Report::AtLocation, |
4619 "FlowGraphBuilder Bailout: %s %s", | 4613 "FlowGraphBuilder Bailout: %s %s", |
4620 String::Handle(function.name()).ToCString(), | 4614 String::Handle(function.name()).ToCString(), |
4621 reason); | 4615 reason); |
4622 UNREACHABLE(); | 4616 UNREACHABLE(); |
4623 } | 4617 } |
4624 | 4618 |
4625 } // namespace dart | 4619 } // namespace dart |
OLD | NEW |