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 4201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4212 BuildRestoreContext(node->context_var()); | 4212 BuildRestoreContext(node->context_var()); |
4213 | 4213 |
4214 EffectGraphVisitor for_catch(owner()); | 4214 EffectGraphVisitor for_catch(owner()); |
4215 node->VisitChildren(&for_catch); | 4215 node->VisitChildren(&for_catch); |
4216 Append(for_catch); | 4216 Append(for_catch); |
4217 } | 4217 } |
4218 | 4218 |
4219 | 4219 |
4220 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) { | 4220 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) { |
4221 InlineBailout("EffectGraphVisitor::VisitTryCatchNode (exception)"); | 4221 InlineBailout("EffectGraphVisitor::VisitTryCatchNode (exception)"); |
4222 intptr_t original_handler_index = owner()->try_index(); | 4222 const intptr_t original_handler_index = owner()->try_index(); |
4223 const intptr_t try_handler_index = node->try_index(); | 4223 const intptr_t try_handler_index = node->try_index(); |
4224 ASSERT(try_handler_index != original_handler_index); | 4224 ASSERT(try_handler_index != original_handler_index); |
4225 owner()->set_try_index(try_handler_index); | 4225 owner()->set_try_index(try_handler_index); |
4226 | 4226 |
4227 // Preserve current context into local variable ':saved_try_context_var'. | 4227 // Preserve current context into local variable ':saved_try_context_var'. |
4228 BuildSaveContext(node->context_var()); | 4228 BuildSaveContext(node->context_var()); |
4229 | 4229 |
4230 EffectGraphVisitor for_try(owner()); | 4230 EffectGraphVisitor for_try(owner()); |
4231 node->try_block()->Visit(&for_try); | 4231 node->try_block()->Visit(&for_try); |
4232 | 4232 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4284 | 4284 |
4285 if (for_catch.is_open()) { | 4285 if (for_catch.is_open()) { |
4286 JoinEntryInstr* join = new(Z) JoinEntryInstr(owner()->AllocateBlockId(), | 4286 JoinEntryInstr* join = new(Z) JoinEntryInstr(owner()->AllocateBlockId(), |
4287 original_handler_index); | 4287 original_handler_index); |
4288 for_catch.Goto(join); | 4288 for_catch.Goto(join); |
4289 if (is_open()) Goto(join); | 4289 if (is_open()) Goto(join); |
4290 exit_ = join; | 4290 exit_ = join; |
4291 } | 4291 } |
4292 | 4292 |
4293 if (finally_block != NULL) { | 4293 if (finally_block != NULL) { |
| 4294 ASSERT(node->rethrow_clause() != NULL); |
4294 // Create a handler for the code in the catch block, containing the | 4295 // Create a handler for the code in the catch block, containing the |
4295 // code in the finally block. | 4296 // code in the finally block. |
4296 owner()->set_try_index(original_handler_index); | 4297 owner()->set_try_index(original_handler_index); |
4297 EffectGraphVisitor for_finally(owner()); | 4298 EffectGraphVisitor for_finally(owner()); |
4298 for_finally.BuildRestoreContext(catch_block->context_var()); | 4299 for_finally.BuildRestoreContext(catch_block->context_var()); |
4299 | 4300 |
4300 finally_block->Visit(&for_finally); | 4301 node->rethrow_clause()->Visit(&for_finally); |
4301 if (for_finally.is_open()) { | 4302 if (for_finally.is_open()) { |
4302 // Rethrow the exception. Manually build the graph for rethrow. | 4303 // Rethrow the exception. Manually build the graph for rethrow. |
4303 Value* exception = for_finally.Bind( | 4304 Value* exception = for_finally.Bind( |
4304 for_finally.BuildLoadLocal(catch_block->rethrow_exception_var())); | 4305 for_finally.BuildLoadLocal(catch_block->rethrow_exception_var())); |
4305 for_finally.PushArgument(exception); | 4306 for_finally.PushArgument(exception); |
4306 Value* stacktrace = for_finally.Bind( | 4307 Value* stacktrace = for_finally.Bind( |
4307 for_finally.BuildLoadLocal(catch_block->rethrow_stacktrace_var())); | 4308 for_finally.BuildLoadLocal(catch_block->rethrow_stacktrace_var())); |
4308 for_finally.PushArgument(stacktrace); | 4309 for_finally.PushArgument(stacktrace); |
4309 for_finally.AddInstruction( | 4310 for_finally.AddInstruction( |
4310 new(Z) ReThrowInstr(catch_block->token_pos(), catch_handler_index)); | 4311 new(Z) ReThrowInstr(catch_block->token_pos(), catch_handler_index)); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4580 Report::MessageF(Report::kBailout, | 4581 Report::MessageF(Report::kBailout, |
4581 Script::Handle(function.script()), | 4582 Script::Handle(function.script()), |
4582 function.token_pos(), | 4583 function.token_pos(), |
4583 "FlowGraphBuilder Bailout: %s %s", | 4584 "FlowGraphBuilder Bailout: %s %s", |
4584 String::Handle(function.name()).ToCString(), | 4585 String::Handle(function.name()).ToCString(), |
4585 reason); | 4586 reason); |
4586 UNREACHABLE(); | 4587 UNREACHABLE(); |
4587 } | 4588 } |
4588 | 4589 |
4589 } // namespace dart | 4590 } // namespace dart |
OLD | NEW |