Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1126)

Side by Side Diff: runtime/vm/flow_graph_builder.cc

Issue 956583003: Save exception and stack trace variables in async catch clauses and use them (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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->context_var().is_captured());
4062 ASSERT(!catch_block->exception_var().is_captured()); 4063 ASSERT(!catch_block->exception_var().is_captured());
4063 ASSERT(!catch_block->stacktrace_var().is_captured()); 4064 ASSERT(!catch_block->stacktrace_var().is_captured());
4064 4065
4065 CatchBlockEntryInstr* catch_entry = 4066 CatchBlockEntryInstr* catch_entry =
4066 new(I) CatchBlockEntryInstr(owner()->AllocateBlockId(), 4067 new(I) CatchBlockEntryInstr(owner()->AllocateBlockId(),
4067 catch_handler_index, 4068 catch_handler_index,
4068 catch_block->handler_types(), 4069 catch_block->handler_types(),
4069 try_handler_index, 4070 try_handler_index,
4070 catch_block->exception_var(), 4071 catch_block->exception_var(),
4071 catch_block->stacktrace_var(), 4072 catch_block->stacktrace_var(),
4072 catch_block->needs_stacktrace()); 4073 catch_block->needs_stacktrace());
4073 owner()->AddCatchEntry(catch_entry); 4074 owner()->AddCatchEntry(catch_entry);
4074 AppendFragment(catch_entry, for_catch); 4075 AppendFragment(catch_entry, for_catch);
4075 4076
4076 if (for_catch.is_open()) { 4077 if (for_catch.is_open()) {
4077 JoinEntryInstr* join = new(I) JoinEntryInstr(owner()->AllocateBlockId(), 4078 JoinEntryInstr* join = new(I) JoinEntryInstr(owner()->AllocateBlockId(),
4078 original_handler_index); 4079 original_handler_index);
4079 for_catch.Goto(join); 4080 for_catch.Goto(join);
4080 if (is_open()) Goto(join); 4081 if (is_open()) Goto(join);
4081 exit_ = join; 4082 exit_ = join;
4082 } 4083 }
4083 4084
4084 if (finally_block != NULL) { 4085 if (finally_block != NULL) {
4085 // Create a handler for the code in the catch block, containing the 4086 // Create a handler for the code in the catch block, containing the
4086 // code in the finally block. 4087 // code in the finally block.
4087 owner()->set_try_index(original_handler_index); 4088 owner()->set_try_index(original_handler_index);
4088 EffectGraphVisitor for_finally(owner()); 4089 EffectGraphVisitor for_finally(owner());
(...skipping 11 matching lines...) Expand all
4100 for_finally.AddInstruction( 4101 for_finally.AddInstruction(
4101 new(I) ReThrowInstr(catch_block->token_pos(), catch_handler_index)); 4102 new(I) ReThrowInstr(catch_block->token_pos(), catch_handler_index));
4102 for_finally.CloseFragment(); 4103 for_finally.CloseFragment();
4103 } 4104 }
4104 ASSERT(!for_finally.is_open()); 4105 ASSERT(!for_finally.is_open());
4105 4106
4106 const Array& types = Array::ZoneHandle(I, Array::New(1, Heap::kOld)); 4107 const Array& types = Array::ZoneHandle(I, Array::New(1, Heap::kOld));
4107 types.SetAt(0, Type::Handle(I, Type::DynamicType())); 4108 types.SetAt(0, Type::Handle(I, Type::DynamicType()));
4108 CatchBlockEntryInstr* finally_entry = 4109 CatchBlockEntryInstr* finally_entry =
4109 new(I) CatchBlockEntryInstr(owner()->AllocateBlockId(), 4110 new(I) CatchBlockEntryInstr(owner()->AllocateBlockId(),
4110 original_handler_index, 4111 original_handler_index,
4111 types, 4112 types,
4112 catch_handler_index, 4113 catch_handler_index,
4113 catch_block->exception_var(), 4114 catch_block->exception_var(),
4114 catch_block->stacktrace_var(), 4115 catch_block->stacktrace_var(),
4115 catch_block->needs_stacktrace()); 4116 catch_block->needs_stacktrace());
4116 owner()->AddCatchEntry(finally_entry); 4117 owner()->AddCatchEntry(finally_entry);
4117 AppendFragment(finally_entry, for_finally); 4118 AppendFragment(finally_entry, for_finally);
4118 } 4119 }
4119 4120
4120 // Generate code for the finally block if one exists. 4121 // Generate code for the finally block if one exists.
4121 if ((finally_block != NULL) && is_open()) { 4122 if ((finally_block != NULL) && is_open()) {
4122 EffectGraphVisitor for_finally_block(owner()); 4123 EffectGraphVisitor for_finally_block(owner());
4123 finally_block->Visit(&for_finally_block); 4124 finally_block->Visit(&for_finally_block);
4124 Append(for_finally_block); 4125 Append(for_finally_block);
4125 } 4126 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
4356 Report::MessageF(Report::kBailout, 4357 Report::MessageF(Report::kBailout,
4357 Script::Handle(function.script()), 4358 Script::Handle(function.script()),
4358 function.token_pos(), 4359 function.token_pos(),
4359 "FlowGraphBuilder Bailout: %s %s", 4360 "FlowGraphBuilder Bailout: %s %s",
4360 String::Handle(function.name()).ToCString(), 4361 String::Handle(function.name()).ToCString(),
4361 reason); 4362 reason);
4362 UNREACHABLE(); 4363 UNREACHABLE();
4363 } 4364 }
4364 4365
4365 } // namespace dart 4366 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698