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 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1088 ASSERT(current_context_level >= 0); | 1088 ASSERT(current_context_level >= 0); |
1089 if (owner()->parsed_function()->saved_entry_context_var() != NULL) { | 1089 if (owner()->parsed_function()->saved_entry_context_var() != NULL) { |
1090 // CTX on entry was saved, but not linked as context parent. | 1090 // CTX on entry was saved, but not linked as context parent. |
1091 BuildRestoreContext(*owner()->parsed_function()->saved_entry_context_var()); | 1091 BuildRestoreContext(*owner()->parsed_function()->saved_entry_context_var()); |
1092 } else { | 1092 } else { |
1093 UnchainContexts(current_context_level); | 1093 UnchainContexts(current_context_level); |
1094 } | 1094 } |
1095 | 1095 |
1096 | 1096 |
1097 AddReturnExit(node->token_pos(), return_value); | 1097 AddReturnExit(node->token_pos(), return_value); |
1098 | |
1099 if (function.is_async_closure() && | |
1100 (node->return_type() == ReturnNode::kContinuationTarget)) { | |
1101 JoinEntryInstr* const join = new(I) JoinEntryInstr( | |
1102 owner()->AllocateBlockId(), owner()->try_index()); | |
1103 owner()->await_joins()->Add(join); | |
1104 exit_ = join; | |
1105 } | |
1098 } | 1106 } |
1099 | 1107 |
1100 | 1108 |
1101 // <Expression> ::= Literal { literal: Instance } | 1109 // <Expression> ::= Literal { literal: Instance } |
1102 void EffectGraphVisitor::VisitLiteralNode(LiteralNode* node) { | 1110 void EffectGraphVisitor::VisitLiteralNode(LiteralNode* node) { |
1103 ReturnDefinition(new(I) ConstantInstr(node->literal())); | 1111 ReturnDefinition(new(I) ConstantInstr(node->literal())); |
1104 } | 1112 } |
1105 | 1113 |
1106 | 1114 |
1107 // Type nodes are used when a type is referenced as a literal. Type nodes | 1115 // Type nodes are used when a type is referenced as a literal. Type nodes |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2207 } | 2215 } |
2208 | 2216 |
2209 | 2217 |
2210 void EffectGraphVisitor::VisitAwaitNode(AwaitNode* node) { | 2218 void EffectGraphVisitor::VisitAwaitNode(AwaitNode* node) { |
2211 // Await nodes are temporary during parsing. | 2219 // Await nodes are temporary during parsing. |
2212 UNREACHABLE(); | 2220 UNREACHABLE(); |
2213 } | 2221 } |
2214 | 2222 |
2215 | 2223 |
2216 void EffectGraphVisitor::VisitAwaitMarkerNode(AwaitMarkerNode* node) { | 2224 void EffectGraphVisitor::VisitAwaitMarkerNode(AwaitMarkerNode* node) { |
2217 if (node->marker_type() == AwaitMarkerNode::kNewContinuationState) { | 2225 // We need to create a new await state which involves: |
2218 // We need to create a new await state which involves: | 2226 // * Increase the jump counter. Sanity check against the list of targets. |
2219 // * Increase the jump counter. Sanity check against the list of targets. | 2227 // * Save the current context for resuming. |
2220 // * Save the current context for resuming. | 2228 ASSERT(node->scope() != NULL); |
2221 ASSERT(node->scope() != NULL); | 2229 LocalVariable* jump_var = node->scope()->LookupVariable( |
2222 LocalVariable* jump_var = node->scope()->LookupVariable( | 2230 Symbols::AwaitJumpVar(), false); |
2223 Symbols::AwaitJumpVar(), false); | 2231 LocalVariable* ctx_var = node->scope()->LookupVariable( |
2224 LocalVariable* ctx_var = node->scope()->LookupVariable( | 2232 Symbols::AwaitContextVar(), false); |
2225 Symbols::AwaitContextVar(), false); | 2233 ASSERT((jump_var != NULL) && jump_var->is_captured()); |
2226 ASSERT((jump_var != NULL) && jump_var->is_captured()); | 2234 ASSERT((ctx_var != NULL) && ctx_var->is_captured()); |
2227 ASSERT((ctx_var != NULL) && ctx_var->is_captured()); | 2235 const intptr_t jump_cnt = owner()->next_await_counter(); |
Florian Schneider
2014/10/14 11:47:30
Abbreviations that are not a prefix of the origina
hausner
2014/10/14 19:56:39
We use ctx as much as we use context across our so
| |
2228 const intptr_t jump_cnt = owner()->next_await_counter(); | 2236 ASSERT(jump_cnt >= 0); |
2229 ASSERT(jump_cnt >= 0); | 2237 // Sanity check that we always add a JoinEntryInstr before adding a new |
2230 // Sanity check that we always add a JoinEntryInstr before adding a new | 2238 // state. |
2231 // state. | 2239 ASSERT(jump_cnt == owner()->await_joins()->length()); |
2232 ASSERT(jump_cnt == owner()->await_joins()->length()); | 2240 // Store the counter in :await_jump_var. |
2233 // Store the counter in :await_jump_var. | 2241 Value* jump_val = Bind(new (I) ConstantInstr( |
2234 Value* jump_val = Bind(new (I) ConstantInstr( | 2242 Smi::ZoneHandle(I, Smi::New(jump_cnt)))); |
2235 Smi::ZoneHandle(I, Smi::New(jump_cnt)))); | 2243 Do(BuildStoreLocal(*jump_var, jump_val)); |
2236 Do(BuildStoreLocal(*jump_var, jump_val)); | 2244 // Save the current context for resuming. |
2237 // Save the current context for resuming. | 2245 BuildSaveContext(*ctx_var); |
2238 BuildSaveContext(*ctx_var); | 2246 owner()->await_levels()->Add(owner()->context_level()); |
2239 owner()->await_levels()->Add(owner()->context_level()); | |
2240 return; | |
2241 } | |
2242 if (node->marker_type() == AwaitMarkerNode::kTargetForContinuation) { | |
2243 // We need to create a new await target which involves: | |
2244 // * Append a join that is also added to the list that will later result in | |
2245 // a preamble. | |
2246 JoinEntryInstr* const join = new(I) JoinEntryInstr( | |
2247 owner()->AllocateBlockId(), owner()->try_index()); | |
2248 owner()->await_joins()->Add(join); | |
2249 Goto(join); | |
2250 exit_ = join; | |
2251 return; | |
2252 } | |
2253 UNREACHABLE(); | |
2254 } | 2247 } |
2255 | 2248 |
2256 | 2249 |
2257 intptr_t EffectGraphVisitor::GetCurrentTempLocalIndex() const { | 2250 intptr_t EffectGraphVisitor::GetCurrentTempLocalIndex() const { |
2258 return kFirstLocalSlotFromFp | 2251 return kFirstLocalSlotFromFp |
2259 - owner()->num_stack_locals() | 2252 - owner()->num_stack_locals() |
2260 - owner()->num_copied_params() | 2253 - owner()->num_copied_params() |
2261 - owner()->args_pushed() | 2254 - owner()->args_pushed() |
2262 - owner()->temp_count() + 1; | 2255 - owner()->temp_count() + 1; |
2263 } | 2256 } |
(...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4285 Report::MessageF(Report::kBailout, | 4278 Report::MessageF(Report::kBailout, |
4286 Script::Handle(function.script()), | 4279 Script::Handle(function.script()), |
4287 function.token_pos(), | 4280 function.token_pos(), |
4288 "FlowGraphBuilder Bailout: %s %s", | 4281 "FlowGraphBuilder Bailout: %s %s", |
4289 String::Handle(function.name()).ToCString(), | 4282 String::Handle(function.name()).ToCString(), |
4290 reason); | 4283 reason); |
4291 UNREACHABLE(); | 4284 UNREACHABLE(); |
4292 } | 4285 } |
4293 | 4286 |
4294 } // namespace dart | 4287 } // namespace dart |
OLD | NEW |