Chromium Code Reviews| 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/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 3982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3993 // taken care of unchaining the context. | 3993 // taken care of unchaining the context. |
| 3994 if (nested_block.break_target() != NULL) { | 3994 if (nested_block.break_target() != NULL) { |
| 3995 if (is_open()) Goto(nested_block.break_target()); | 3995 if (is_open()) Goto(nested_block.break_target()); |
| 3996 exit_ = nested_block.break_target(); | 3996 exit_ = nested_block.break_target(); |
| 3997 } | 3997 } |
| 3998 } | 3998 } |
| 3999 | 3999 |
| 4000 | 4000 |
| 4001 void EffectGraphVisitor::VisitCatchClauseNode(CatchClauseNode* node) { | 4001 void EffectGraphVisitor::VisitCatchClauseNode(CatchClauseNode* node) { |
| 4002 InlineBailout("EffectGraphVisitor::VisitCatchClauseNode (exception)"); | 4002 InlineBailout("EffectGraphVisitor::VisitCatchClauseNode (exception)"); |
| 4003 // Restores current context from local variable ':saved_context'. | 4003 // Restores current context from local variable ':saved_try_context_var'. |
| 4004 BuildRestoreContext(node->context_var()); | 4004 BuildRestoreContext(node->context_var()); |
| 4005 | 4005 |
| 4006 EffectGraphVisitor for_catch(owner()); | 4006 EffectGraphVisitor for_catch(owner()); |
| 4007 node->VisitChildren(&for_catch); | 4007 node->VisitChildren(&for_catch); |
| 4008 Append(for_catch); | 4008 Append(for_catch); |
| 4009 } | 4009 } |
| 4010 | 4010 |
| 4011 | 4011 |
| 4012 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) { | 4012 void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) { |
| 4013 InlineBailout("EffectGraphVisitor::VisitTryCatchNode (exception)"); | 4013 InlineBailout("EffectGraphVisitor::VisitTryCatchNode (exception)"); |
| 4014 intptr_t original_handler_index = owner()->try_index(); | 4014 intptr_t original_handler_index = owner()->try_index(); |
| 4015 const intptr_t try_handler_index = node->try_index(); | 4015 const intptr_t try_handler_index = node->try_index(); |
| 4016 ASSERT(try_handler_index != original_handler_index); | 4016 ASSERT(try_handler_index != original_handler_index); |
| 4017 owner()->set_try_index(try_handler_index); | 4017 owner()->set_try_index(try_handler_index); |
| 4018 | 4018 |
| 4019 // Preserve current context into local variable '%saved_context'. | 4019 // Preserve current context into local variable ':saved_try_context_var'. |
| 4020 BuildSaveContext(node->context_var()); | 4020 BuildSaveContext(node->context_var()); |
| 4021 | 4021 |
| 4022 EffectGraphVisitor for_try(owner()); | 4022 EffectGraphVisitor for_try(owner()); |
| 4023 node->try_block()->Visit(&for_try); | 4023 node->try_block()->Visit(&for_try); |
| 4024 | 4024 |
| 4025 if (for_try.is_open()) { | 4025 if (for_try.is_open()) { |
| 4026 JoinEntryInstr* after_try = | 4026 JoinEntryInstr* after_try = |
| 4027 new(I) JoinEntryInstr(owner()->AllocateBlockId(), | 4027 new(I) JoinEntryInstr(owner()->AllocateBlockId(), |
| 4028 original_handler_index); | 4028 original_handler_index); |
| 4029 for_try.Goto(after_try); | 4029 for_try.Goto(after_try); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 4050 : catch_block->catch_handler_index(); | 4050 : catch_block->catch_handler_index(); |
| 4051 | 4051 |
| 4052 const intptr_t prev_catch_try_index = owner()->catch_try_index(); | 4052 const intptr_t prev_catch_try_index = owner()->catch_try_index(); |
| 4053 | 4053 |
| 4054 owner()->set_try_index(catch_handler_index); | 4054 owner()->set_try_index(catch_handler_index); |
| 4055 owner()->set_catch_try_index(try_handler_index); | 4055 owner()->set_catch_try_index(try_handler_index); |
| 4056 EffectGraphVisitor for_catch(owner()); | 4056 EffectGraphVisitor for_catch(owner()); |
| 4057 catch_block->Visit(&for_catch); | 4057 catch_block->Visit(&for_catch); |
| 4058 owner()->set_catch_try_index(prev_catch_try_index); | 4058 owner()->set_catch_try_index(prev_catch_try_index); |
| 4059 | 4059 |
| 4060 // NOTE: The implicit variables ':saved_context', ':exception_var' | 4060 // NOTE: The implicit variables ':saved_try_context_var', ':exception_var' |
| 4061 // and ':stacktrace_var' can never be captured variables. | 4061 // and ':stack_trace_var' can never be captured variables. |
| 4062 ASSERT(!catch_block->exception_var().is_captured()); | 4062 ASSERT(!catch_block->exception_var().is_captured()); |
| 4063 ASSERT(!catch_block->stacktrace_var().is_captured()); | 4063 ASSERT(!catch_block->stacktrace_var().is_captured()); |
|
Ivan Posva
2015/02/24 20:52:39
Why is the fact that ':saved_try_context_var' cann
regis
2015/02/24 22:05:12
No idea.
Assert added.
| |
| 4064 | 4064 |
| 4065 CatchBlockEntryInstr* catch_entry = | 4065 CatchBlockEntryInstr* catch_entry = |
| 4066 new(I) CatchBlockEntryInstr(owner()->AllocateBlockId(), | 4066 new(I) CatchBlockEntryInstr(owner()->AllocateBlockId(), |
| 4067 catch_handler_index, | 4067 catch_handler_index, |
| 4068 catch_block->handler_types(), | 4068 catch_block->handler_types(), |
| 4069 try_handler_index, | 4069 try_handler_index, |
| 4070 catch_block->exception_var(), | 4070 catch_block->exception_var(), |
| 4071 catch_block->stacktrace_var(), | 4071 catch_block->stacktrace_var(), |
| 4072 catch_block->needs_stacktrace()); | 4072 catch_block->needs_stacktrace()); |
| 4073 owner()->AddCatchEntry(catch_entry); | 4073 owner()->AddCatchEntry(catch_entry); |
| 4074 AppendFragment(catch_entry, for_catch); | 4074 AppendFragment(catch_entry, for_catch); |
| 4075 | 4075 |
| 4076 if (for_catch.is_open()) { | 4076 if (for_catch.is_open()) { |
| 4077 JoinEntryInstr* join = new(I) JoinEntryInstr(owner()->AllocateBlockId(), | 4077 JoinEntryInstr* join = new(I) JoinEntryInstr(owner()->AllocateBlockId(), |
| 4078 original_handler_index); | 4078 original_handler_index); |
| 4079 for_catch.Goto(join); | 4079 for_catch.Goto(join); |
| 4080 if (is_open()) Goto(join); | 4080 if (is_open()) Goto(join); |
| 4081 exit_ = join; | 4081 exit_ = join; |
| 4082 } | 4082 } |
| 4083 | 4083 |
| 4084 if (finally_block != NULL) { | 4084 if (finally_block != NULL) { |
| 4085 // Create a handler for the code in the catch block, containing the | 4085 // Create a handler for the code in the catch block, containing the |
| 4086 // code in the finally block. | 4086 // code in the finally block. |
| 4087 owner()->set_try_index(original_handler_index); | 4087 owner()->set_try_index(original_handler_index); |
| 4088 EffectGraphVisitor for_finally(owner()); | 4088 EffectGraphVisitor for_finally(owner()); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 4100 for_finally.AddInstruction( | 4100 for_finally.AddInstruction( |
| 4101 new(I) ReThrowInstr(catch_block->token_pos(), catch_handler_index)); | 4101 new(I) ReThrowInstr(catch_block->token_pos(), catch_handler_index)); |
| 4102 for_finally.CloseFragment(); | 4102 for_finally.CloseFragment(); |
| 4103 } | 4103 } |
| 4104 ASSERT(!for_finally.is_open()); | 4104 ASSERT(!for_finally.is_open()); |
| 4105 | 4105 |
| 4106 const Array& types = Array::ZoneHandle(I, Array::New(1, Heap::kOld)); | 4106 const Array& types = Array::ZoneHandle(I, Array::New(1, Heap::kOld)); |
| 4107 types.SetAt(0, Type::Handle(I, Type::DynamicType())); | 4107 types.SetAt(0, Type::Handle(I, Type::DynamicType())); |
| 4108 CatchBlockEntryInstr* finally_entry = | 4108 CatchBlockEntryInstr* finally_entry = |
| 4109 new(I) CatchBlockEntryInstr(owner()->AllocateBlockId(), | 4109 new(I) CatchBlockEntryInstr(owner()->AllocateBlockId(), |
| 4110 original_handler_index, | 4110 original_handler_index, |
| 4111 types, | 4111 types, |
| 4112 catch_handler_index, | 4112 catch_handler_index, |
| 4113 catch_block->exception_var(), | 4113 catch_block->exception_var(), |
| 4114 catch_block->stacktrace_var(), | 4114 catch_block->stacktrace_var(), |
| 4115 catch_block->needs_stacktrace()); | 4115 catch_block->needs_stacktrace()); |
| 4116 owner()->AddCatchEntry(finally_entry); | 4116 owner()->AddCatchEntry(finally_entry); |
| 4117 AppendFragment(finally_entry, for_finally); | 4117 AppendFragment(finally_entry, for_finally); |
| 4118 } | 4118 } |
| 4119 | 4119 |
| 4120 // Generate code for the finally block if one exists. | 4120 // Generate code for the finally block if one exists. |
| 4121 if ((finally_block != NULL) && is_open()) { | 4121 if ((finally_block != NULL) && is_open()) { |
| 4122 EffectGraphVisitor for_finally_block(owner()); | 4122 EffectGraphVisitor for_finally_block(owner()); |
| 4123 finally_block->Visit(&for_finally_block); | 4123 finally_block->Visit(&for_finally_block); |
| 4124 Append(for_finally_block); | 4124 Append(for_finally_block); |
| 4125 } | 4125 } |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4356 Report::MessageF(Report::kBailout, | 4356 Report::MessageF(Report::kBailout, |
| 4357 Script::Handle(function.script()), | 4357 Script::Handle(function.script()), |
| 4358 function.token_pos(), | 4358 function.token_pos(), |
| 4359 "FlowGraphBuilder Bailout: %s %s", | 4359 "FlowGraphBuilder Bailout: %s %s", |
| 4360 String::Handle(function.name()).ToCString(), | 4360 String::Handle(function.name()).ToCString(), |
| 4361 reason); | 4361 reason); |
| 4362 UNREACHABLE(); | 4362 UNREACHABLE(); |
| 4363 } | 4363 } |
| 4364 | 4364 |
| 4365 } // namespace dart | 4365 } // namespace dart |
| OLD | NEW |