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 3767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3778 NestedBlock nested_block(owner(), node); | 3778 NestedBlock nested_block(owner(), node); |
3779 | 3779 |
3780 if (num_context_variables > 0) { | 3780 if (num_context_variables > 0) { |
3781 // The local scope declares variables that are captured. | 3781 // The local scope declares variables that are captured. |
3782 // Allocate and chain a new context (Except don't chain when at the function | 3782 // Allocate and chain a new context (Except don't chain when at the function |
3783 // entry if the function does not capture any variables from outer scopes). | 3783 // entry if the function does not capture any variables from outer scopes). |
3784 Value* allocated_context = | 3784 Value* allocated_context = |
3785 Bind(new(Z) AllocateContextInstr(node->token_pos(), | 3785 Bind(new(Z) AllocateContextInstr(node->token_pos(), |
3786 num_context_variables)); | 3786 num_context_variables)); |
3787 { LocalVariable* tmp_var = EnterTempLocalScope(allocated_context); | 3787 { LocalVariable* tmp_var = EnterTempLocalScope(allocated_context); |
3788 if (HasContextScope() || !is_top_level_sequence) { | 3788 if (!is_top_level_sequence || HasContextScope()) { |
| 3789 ASSERT(is_top_level_sequence || |
| 3790 (nested_block.ContextLevel() == |
| 3791 nested_block.outer()->ContextLevel() + 1)); |
3789 Value* tmp_val = Bind(new(Z) LoadLocalInstr(*tmp_var)); | 3792 Value* tmp_val = Bind(new(Z) LoadLocalInstr(*tmp_var)); |
3790 Value* parent_context = Bind(BuildCurrentContext()); | 3793 Value* parent_context = Bind(BuildCurrentContext()); |
3791 Do(new(Z) StoreInstanceFieldInstr(Context::parent_offset(), | 3794 Do(new(Z) StoreInstanceFieldInstr(Context::parent_offset(), |
3792 tmp_val, | 3795 tmp_val, |
3793 parent_context, | 3796 parent_context, |
3794 kEmitStoreBarrier, | 3797 kEmitStoreBarrier, |
3795 Scanner::kNoSourcePos)); | 3798 Scanner::kNoSourcePos)); |
3796 } | 3799 } |
3797 Do(BuildStoreContext(Bind(ExitTempLocalScope(tmp_var)))); | 3800 Do(BuildStoreContext(Bind(ExitTempLocalScope(tmp_var)))); |
3798 } | 3801 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3987 exit_->LinkTo(preamble_start); | 3990 exit_->LinkTo(preamble_start); |
3988 } | 3991 } |
3989 } | 3992 } |
3990 } | 3993 } |
3991 entry_ = saved_entry; | 3994 entry_ = saved_entry; |
3992 exit_ = saved_exit; | 3995 exit_ = saved_exit; |
3993 } | 3996 } |
3994 | 3997 |
3995 if (is_open() && | 3998 if (is_open() && |
3996 (num_context_variables > 0) && | 3999 (num_context_variables > 0) && |
3997 (HasContextScope() || !is_top_level_sequence)) { | 4000 (!is_top_level_sequence || HasContextScope())) { |
3998 UnchainContexts(1); | 4001 UnchainContexts(1); |
3999 } | 4002 } |
4000 | 4003 |
4001 // If this node sequence is labeled, a break out of the sequence will have | 4004 // If this node sequence is labeled, a break out of the sequence will have |
4002 // taken care of unchaining the context. | 4005 // taken care of unchaining the context. |
4003 if (nested_block.break_target() != NULL) { | 4006 if (nested_block.break_target() != NULL) { |
4004 if (is_open()) Goto(nested_block.break_target()); | 4007 if (is_open()) Goto(nested_block.break_target()); |
4005 exit_ = nested_block.break_target(); | 4008 exit_ = nested_block.break_target(); |
4006 } | 4009 } |
4007 } | 4010 } |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4368 Report::MessageF(Report::kBailout, | 4371 Report::MessageF(Report::kBailout, |
4369 Script::Handle(function.script()), | 4372 Script::Handle(function.script()), |
4370 function.token_pos(), | 4373 function.token_pos(), |
4371 "FlowGraphBuilder Bailout: %s %s", | 4374 "FlowGraphBuilder Bailout: %s %s", |
4372 String::Handle(function.name()).ToCString(), | 4375 String::Handle(function.name()).ToCString(), |
4373 reason); | 4376 reason); |
4374 UNREACHABLE(); | 4377 UNREACHABLE(); |
4375 } | 4378 } |
4376 | 4379 |
4377 } // namespace dart | 4380 } // namespace dart |
OLD | NEW |