| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/kernel_binary_flowgraph.h" | 5 #include "vm/kernel_binary_flowgraph.h" |
| 6 #include "vm/compiler.h" | 6 #include "vm/compiler.h" |
| 7 #include "vm/longjump.h" | 7 #include "vm/longjump.h" |
| 8 #include "vm/object_store.h" | 8 #include "vm/object_store.h" |
| 9 | 9 |
| 10 #if !defined(DART_PRECOMPILED_RUNTIME) | 10 #if !defined(DART_PRECOMPILED_RUNTIME) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 ASSERT(tag == kFunctionNode); | 33 ASSERT(tag == kFunctionNode); |
| 34 if (++next_read_ == field) return; | 34 if (++next_read_ == field) return; |
| 35 } | 35 } |
| 36 case kPosition: | 36 case kPosition: |
| 37 position_ = builder_->ReadPosition(); // read position. | 37 position_ = builder_->ReadPosition(); // read position. |
| 38 if (++next_read_ == field) return; | 38 if (++next_read_ == field) return; |
| 39 case kEndPosition: | 39 case kEndPosition: |
| 40 end_position_ = builder_->ReadPosition(); // read end position. | 40 end_position_ = builder_->ReadPosition(); // read end position. |
| 41 if (++next_read_ == field) return; | 41 if (++next_read_ == field) return; |
| 42 case kAsyncMarker: | 42 case kAsyncMarker: |
| 43 async_marker_ = static_cast<FunctionNode::AsyncMarker>( | 43 async_marker_ = static_cast<AsyncMarker>(builder_->ReadByte()); |
| 44 builder_->ReadByte()); // read async marker. | |
| 45 if (++next_read_ == field) return; | 44 if (++next_read_ == field) return; |
| 46 case kDartAsyncMarker: | 45 case kDartAsyncMarker: |
| 47 dart_async_marker_ = static_cast<FunctionNode::AsyncMarker>( | 46 dart_async_marker_ = static_cast<AsyncMarker>( |
| 48 builder_->ReadByte()); // read dart async marker. | 47 builder_->ReadByte()); // read dart async marker. |
| 49 if (++next_read_ == field) return; | 48 if (++next_read_ == field) return; |
| 50 case kTypeParameters: | 49 case kTypeParameters: |
| 51 builder_->SkipTypeParametersList(); // read type parameters. | 50 builder_->SkipTypeParametersList(); // read type parameters. |
| 52 if (++next_read_ == field) return; | 51 if (++next_read_ == field) return; |
| 53 case kTotalParameterCount: | 52 case kTotalParameterCount: |
| 54 total_parameter_count_ = | 53 total_parameter_count_ = |
| 55 builder_->ReadUInt(); // read total parameter count. | 54 builder_->ReadUInt(); // read total parameter count. |
| 56 if (++next_read_ == field) return; | 55 if (++next_read_ == field) return; |
| 57 case kRequiredParameterCount: | 56 case kRequiredParameterCount: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 if (++next_read_ == field) return; | 97 if (++next_read_ == field) return; |
| 99 case kInitializer: | 98 case kInitializer: |
| 100 if (builder_->ReadTag() == kSomething) | 99 if (builder_->ReadTag() == kSomething) |
| 101 builder_->SkipExpression(); // read initializer. | 100 builder_->SkipExpression(); // read initializer. |
| 102 if (++next_read_ == field) return; | 101 if (++next_read_ == field) return; |
| 103 case kEnd: | 102 case kEnd: |
| 104 return; | 103 return; |
| 105 } | 104 } |
| 106 } | 105 } |
| 107 | 106 |
| 107 FieldHelper::FieldHelper(StreamingFlowGraphBuilder* builder, intptr_t offset) |
| 108 : builder_(builder), |
| 109 next_read_(kStart), |
| 110 has_function_literal_initializer_(false) { |
| 111 builder_->SetOffset(offset); |
| 112 } |
| 113 |
| 108 void FieldHelper::ReadUntilExcluding(Field field, | 114 void FieldHelper::ReadUntilExcluding(Field field, |
| 109 bool detect_function_literal_initializer) { | 115 bool detect_function_literal_initializer) { |
| 110 if (field <= next_read_) return; | 116 if (field <= next_read_) return; |
| 111 | 117 |
| 112 // Ordered with fall-through. | 118 // Ordered with fall-through. |
| 113 switch (next_read_) { | 119 switch (next_read_) { |
| 114 case kStart: { | 120 case kStart: { |
| 115 Tag tag = builder_->ReadTag(); // read tag. | 121 Tag tag = builder_->ReadTag(); // read tag. |
| 116 ASSERT(tag == kField); | 122 ASSERT(tag == kField); |
| 117 if (++next_read_ == field) return; | 123 if (++next_read_ == field) return; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 canonical_name_ = | 195 canonical_name_ = |
| 190 builder_->ReadCanonicalNameReference(); // read canonical_name. | 196 builder_->ReadCanonicalNameReference(); // read canonical_name. |
| 191 if (++next_read_ == field) return; | 197 if (++next_read_ == field) return; |
| 192 case kPosition: | 198 case kPosition: |
| 193 position_ = builder_->ReadPosition(false); // read position. | 199 position_ = builder_->ReadPosition(false); // read position. |
| 194 if (++next_read_ == field) return; | 200 if (++next_read_ == field) return; |
| 195 case kEndPosition: | 201 case kEndPosition: |
| 196 end_position_ = builder_->ReadPosition(false); // read end position. | 202 end_position_ = builder_->ReadPosition(false); // read end position. |
| 197 if (++next_read_ == field) return; | 203 if (++next_read_ == field) return; |
| 198 case kKind: | 204 case kKind: |
| 199 kind_ = static_cast<Procedure::ProcedureKind>( | 205 kind_ = static_cast<Kind>(builder_->ReadByte()); |
| 200 builder_->ReadByte()); // read kind. | |
| 201 if (++next_read_ == field) return; | 206 if (++next_read_ == field) return; |
| 202 case kFlags: | 207 case kFlags: |
| 203 flags_ = builder_->ReadFlags(); // read flags. | 208 flags_ = builder_->ReadFlags(); // read flags. |
| 204 if (++next_read_ == field) return; | 209 if (++next_read_ == field) return; |
| 205 case kName: | 210 case kName: |
| 206 builder_->SkipName(); // read name. | 211 builder_->SkipName(); // read name. |
| 207 if (++next_read_ == field) return; | 212 if (++next_read_ == field) return; |
| 208 case kSourceUriIndex: | 213 case kSourceUriIndex: |
| 209 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. | 214 source_uri_index_ = builder_->ReadUInt(); // read source_uri_index. |
| 210 builder_->current_script_id_ = source_uri_index_; | 215 builder_->current_script_id_ = source_uri_index_; |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 | 805 |
| 801 intptr_t list_length = | 806 intptr_t list_length = |
| 802 builder_->ReadListLength(); // read type_parameters list length. | 807 builder_->ReadListLength(); // read type_parameters list length. |
| 803 for (intptr_t i = 0; i < list_length; ++i) { | 808 for (intptr_t i = 0; i < list_length; ++i) { |
| 804 builder_->SkipStringReference(); // read ith name index. | 809 builder_->SkipStringReference(); // read ith name index. |
| 805 VisitDartType(); // read ith bound. | 810 VisitDartType(); // read ith bound. |
| 806 } | 811 } |
| 807 function_node_helper.SetJustRead(FunctionNodeHelper::kTypeParameters); | 812 function_node_helper.SetJustRead(FunctionNodeHelper::kTypeParameters); |
| 808 | 813 |
| 809 if (FLAG_causal_async_stacks && | 814 if (FLAG_causal_async_stacks && |
| 810 (function_node_helper.dart_async_marker_ == FunctionNode::kAsync || | 815 (function_node_helper.dart_async_marker_ == FunctionNodeHelper::kAsync || |
| 811 function_node_helper.dart_async_marker_ == FunctionNode::kAsyncStar)) { | 816 function_node_helper.dart_async_marker_ == |
| 817 FunctionNodeHelper::kAsyncStar)) { |
| 812 LocalVariable* asyncStackTraceVar = MakeVariable( | 818 LocalVariable* asyncStackTraceVar = MakeVariable( |
| 813 TokenPosition::kNoSource, TokenPosition::kNoSource, | 819 TokenPosition::kNoSource, TokenPosition::kNoSource, |
| 814 Symbols::AsyncStackTraceVar(), AbstractType::dynamic_type()); | 820 Symbols::AsyncStackTraceVar(), AbstractType::dynamic_type()); |
| 815 scope_->AddVariable(asyncStackTraceVar); | 821 scope_->AddVariable(asyncStackTraceVar); |
| 816 } | 822 } |
| 817 | 823 |
| 818 if (function_node_helper.async_marker_ == FunctionNode::kSyncYielding) { | 824 if (function_node_helper.async_marker_ == FunctionNodeHelper::kSyncYielding) { |
| 819 LocalScope* scope = parsed_function_->node_sequence()->scope(); | 825 LocalScope* scope = parsed_function_->node_sequence()->scope(); |
| 820 intptr_t offset = parsed_function_->function().num_fixed_parameters(); | 826 intptr_t offset = parsed_function_->function().num_fixed_parameters(); |
| 821 for (intptr_t i = 0; | 827 for (intptr_t i = 0; |
| 822 i < parsed_function_->function().NumOptionalPositionalParameters(); | 828 i < parsed_function_->function().NumOptionalPositionalParameters(); |
| 823 i++) { | 829 i++) { |
| 824 scope->VariableAt(offset + i)->set_is_forced_stack(); | 830 scope->VariableAt(offset + i)->set_is_forced_stack(); |
| 825 } | 831 } |
| 826 } | 832 } |
| 827 | 833 |
| 828 // Read (but don't visit) the positional and named parameters, because they've | 834 // Read (but don't visit) the positional and named parameters, because they've |
| 829 // already been added to the scope. | 835 // already been added to the scope. |
| 830 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kBody); | 836 function_node_helper.ReadUntilExcluding(FunctionNodeHelper::kBody); |
| 831 | 837 |
| 832 if (builder_->ReadTag() == kSomething) { | 838 if (builder_->ReadTag() == kSomething) { |
| 833 PositionScope scope(builder_->reader_); | 839 PositionScope scope(builder_->reader_); |
| 834 VisitStatement(); // Read body | 840 VisitStatement(); // Read body |
| 835 first_body_token_position_ = builder_->reader_->min_position(); | 841 first_body_token_position_ = builder_->reader_->min_position(); |
| 836 } | 842 } |
| 837 | 843 |
| 838 // Ensure that :await_jump_var, :await_ctx_var, :async_op and | 844 // Ensure that :await_jump_var, :await_ctx_var, :async_op and |
| 839 // :async_stack_trace are captured. | 845 // :async_stack_trace are captured. |
| 840 if (function_node_helper.async_marker_ == FunctionNode::kSyncYielding) { | 846 if (function_node_helper.async_marker_ == FunctionNodeHelper::kSyncYielding) { |
| 841 { | 847 { |
| 842 LocalVariable* temp = NULL; | 848 LocalVariable* temp = NULL; |
| 843 LookupCapturedVariableByName( | 849 LookupCapturedVariableByName( |
| 844 (depth_.function_ == 0) ? &result_->yield_jump_variable : &temp, | 850 (depth_.function_ == 0) ? &result_->yield_jump_variable : &temp, |
| 845 Symbols::AwaitJumpVar()); | 851 Symbols::AwaitJumpVar()); |
| 846 } | 852 } |
| 847 { | 853 { |
| 848 LocalVariable* temp = NULL; | 854 LocalVariable* temp = NULL; |
| 849 LookupCapturedVariableByName( | 855 LookupCapturedVariableByName( |
| 850 (depth_.function_ == 0) ? &result_->yield_context_variable : &temp, | 856 (depth_.function_ == 0) ? &result_->yield_context_variable : &temp, |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 VisitStatement(); // read finalizer. | 1371 VisitStatement(); // read finalizer. |
| 1366 | 1372 |
| 1367 --depth_.catch_; | 1373 --depth_.catch_; |
| 1368 return; | 1374 return; |
| 1369 } | 1375 } |
| 1370 case kYieldStatement: { | 1376 case kYieldStatement: { |
| 1371 builder_->ReadPosition(); // read position. | 1377 builder_->ReadPosition(); // read position. |
| 1372 word flags = builder_->ReadByte(); // read flags. | 1378 word flags = builder_->ReadByte(); // read flags. |
| 1373 builder_->SkipExpression(); // read expression. | 1379 builder_->SkipExpression(); // read expression. |
| 1374 | 1380 |
| 1375 ASSERT((flags & YieldStatement::kFlagNative) == | 1381 ASSERT(flags == kNativeYieldFlags); |
| 1376 YieldStatement::kFlagNative); | |
| 1377 if (depth_.function_ == 0) { | 1382 if (depth_.function_ == 0) { |
| 1378 AddSwitchVariable(); | 1383 AddSwitchVariable(); |
| 1379 // Promote all currently visible local variables into the context. | 1384 // Promote all currently visible local variables into the context. |
| 1380 // TODO(27590) CaptureLocalVariables promotes to many variables into | 1385 // TODO(27590) CaptureLocalVariables promotes to many variables into |
| 1381 // the scope. Mark those variables as stack_local. | 1386 // the scope. Mark those variables as stack_local. |
| 1382 // TODO(27590) we don't need to promote those variables that are | 1387 // TODO(27590) we don't need to promote those variables that are |
| 1383 // not used across yields. | 1388 // not used across yields. |
| 1384 scope_->CaptureLocalVariables(current_function_scope_); | 1389 scope_->CaptureLocalVariables(current_function_scope_); |
| 1385 } | 1390 } |
| 1386 return; | 1391 return; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 | 1574 |
| 1570 void StreamingScopeBuilder::HandleLocalFunction(intptr_t parent_kernel_offset) { | 1575 void StreamingScopeBuilder::HandleLocalFunction(intptr_t parent_kernel_offset) { |
| 1571 // "Peek" ahead into the function node | 1576 // "Peek" ahead into the function node |
| 1572 intptr_t offset = builder_->ReaderOffset(); | 1577 intptr_t offset = builder_->ReaderOffset(); |
| 1573 | 1578 |
| 1574 FunctionNodeHelper function_node_helper(builder_); | 1579 FunctionNodeHelper function_node_helper(builder_); |
| 1575 function_node_helper.ReadUntilExcluding( | 1580 function_node_helper.ReadUntilExcluding( |
| 1576 FunctionNodeHelper::kPositionalParameters); | 1581 FunctionNodeHelper::kPositionalParameters); |
| 1577 | 1582 |
| 1578 LocalScope* saved_function_scope = current_function_scope_; | 1583 LocalScope* saved_function_scope = current_function_scope_; |
| 1579 FunctionNode::AsyncMarker saved_function_async_marker = | 1584 FunctionNodeHelper::AsyncMarker saved_function_async_marker = |
| 1580 current_function_async_marker_; | 1585 current_function_async_marker_; |
| 1581 StreamingScopeBuilder::DepthState saved_depth_state = depth_; | 1586 DepthState saved_depth_state = depth_; |
| 1582 depth_ = DepthState(depth_.function_ + 1); | 1587 depth_ = DepthState(depth_.function_ + 1); |
| 1583 EnterScope(relative_kernel_offset_ + parent_kernel_offset); | 1588 EnterScope(relative_kernel_offset_ + parent_kernel_offset); |
| 1584 current_function_scope_ = scope_; | 1589 current_function_scope_ = scope_; |
| 1585 current_function_async_marker_ = function_node_helper.async_marker_; | 1590 current_function_async_marker_ = function_node_helper.async_marker_; |
| 1586 if (depth_.function_ == 1) { | 1591 if (depth_.function_ == 1) { |
| 1587 FunctionScope function_scope = {relative_kernel_offset_ + offset, scope_}; | 1592 FunctionScope function_scope = {relative_kernel_offset_ + offset, scope_}; |
| 1588 result_->function_scopes.Add(function_scope); | 1593 result_->function_scopes.Add(function_scope); |
| 1589 } | 1594 } |
| 1590 | 1595 |
| 1591 // read positional_parameters and named_parameters. | 1596 // read positional_parameters and named_parameters. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1672 LocalVariable* v = NULL; | 1677 LocalVariable* v = NULL; |
| 1673 | 1678 |
| 1674 // If we are inside a function with yield points then Kernel transformer | 1679 // If we are inside a function with yield points then Kernel transformer |
| 1675 // could have lifted some of the auxiliary exception variables into the | 1680 // could have lifted some of the auxiliary exception variables into the |
| 1676 // context to preserve them across yield points because they might | 1681 // context to preserve them across yield points because they might |
| 1677 // be needed for rethrow. | 1682 // be needed for rethrow. |
| 1678 // Check if it did and capture such variables instead of introducing | 1683 // Check if it did and capture such variables instead of introducing |
| 1679 // new local ones. | 1684 // new local ones. |
| 1680 // Note: function that wrap kSyncYielding function does not contain | 1685 // Note: function that wrap kSyncYielding function does not contain |
| 1681 // its own try/catches. | 1686 // its own try/catches. |
| 1682 if (current_function_async_marker_ == FunctionNode::kSyncYielding) { | 1687 if (current_function_async_marker_ == FunctionNodeHelper::kSyncYielding) { |
| 1683 ASSERT(current_function_scope_->parent() != NULL); | 1688 ASSERT(current_function_scope_->parent() != NULL); |
| 1684 v = current_function_scope_->parent()->LocalLookupVariable( | 1689 v = current_function_scope_->parent()->LocalLookupVariable( |
| 1685 GenerateName(prefix, nesting_depth - 1)); | 1690 GenerateName(prefix, nesting_depth - 1)); |
| 1686 if (v != NULL) { | 1691 if (v != NULL) { |
| 1687 scope_->CaptureVariable(v); | 1692 scope_->CaptureVariable(v); |
| 1688 } | 1693 } |
| 1689 } | 1694 } |
| 1690 | 1695 |
| 1691 // No need to create variables for try/catch-statements inside | 1696 // No need to create variables for try/catch-statements inside |
| 1692 // nested functions. | 1697 // nested functions. |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2553 result_ = H.Canonicalize(*receiver); | 2558 result_ = H.Canonicalize(*receiver); |
| 2554 } | 2559 } |
| 2555 } | 2560 } |
| 2556 | 2561 |
| 2557 void StreamingConstantEvaluator::EvaluateNot() { | 2562 void StreamingConstantEvaluator::EvaluateNot() { |
| 2558 result_ ^= Bool::Get(!EvaluateBooleanExpressionHere()).raw(); | 2563 result_ ^= Bool::Get(!EvaluateBooleanExpressionHere()).raw(); |
| 2559 } | 2564 } |
| 2560 | 2565 |
| 2561 void StreamingConstantEvaluator::EvaluateLogicalExpression() { | 2566 void StreamingConstantEvaluator::EvaluateLogicalExpression() { |
| 2562 bool left = EvaluateBooleanExpressionHere(); // read left. | 2567 bool left = EvaluateBooleanExpressionHere(); // read left. |
| 2563 LogicalExpression::Operator op = static_cast<LogicalExpression::Operator>( | 2568 LogicalOperator op = static_cast<LogicalOperator>(builder_->ReadByte()); |
| 2564 builder_->ReadByte()); // read operator. | 2569 if (op == kAnd) { |
| 2565 if (op == LogicalExpression::kAnd) { | |
| 2566 if (left) { | 2570 if (left) { |
| 2567 EvaluateBooleanExpressionHere(); // read right. | 2571 EvaluateBooleanExpressionHere(); // read right. |
| 2568 } else { | 2572 } else { |
| 2569 builder_->SkipExpression(); // read right. | 2573 builder_->SkipExpression(); // read right. |
| 2570 } | 2574 } |
| 2571 } else { | 2575 } else { |
| 2572 ASSERT(op == LogicalExpression::kOr); | 2576 ASSERT(op == kOr); |
| 2573 if (!left) { | 2577 if (!left) { |
| 2574 EvaluateBooleanExpressionHere(); // read right. | 2578 EvaluateBooleanExpressionHere(); // read right. |
| 2575 } else { | 2579 } else { |
| 2576 builder_->SkipExpression(); // read right. | 2580 builder_->SkipExpression(); // read right. |
| 2577 } | 2581 } |
| 2578 } | 2582 } |
| 2579 } | 2583 } |
| 2580 | 2584 |
| 2581 void StreamingConstantEvaluator::EvaluateConditionalExpression() { | 2585 void StreamingConstantEvaluator::EvaluateConditionalExpression() { |
| 2582 bool condition = EvaluateBooleanExpressionHere(); | 2586 bool condition = EvaluateBooleanExpressionHere(); |
| (...skipping 3219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5802 | 5806 |
| 5803 Fragment StreamingFlowGraphBuilder::BuildLogicalExpression( | 5807 Fragment StreamingFlowGraphBuilder::BuildLogicalExpression( |
| 5804 TokenPosition* position) { | 5808 TokenPosition* position) { |
| 5805 if (position != NULL) *position = TokenPosition::kNoSource; | 5809 if (position != NULL) *position = TokenPosition::kNoSource; |
| 5806 | 5810 |
| 5807 bool negate; | 5811 bool negate; |
| 5808 Fragment instructions = TranslateCondition(&negate); // read left. | 5812 Fragment instructions = TranslateCondition(&negate); // read left. |
| 5809 | 5813 |
| 5810 TargetEntryInstr* right_entry; | 5814 TargetEntryInstr* right_entry; |
| 5811 TargetEntryInstr* constant_entry; | 5815 TargetEntryInstr* constant_entry; |
| 5812 LogicalExpression::Operator op = | 5816 LogicalOperator op = static_cast<LogicalOperator>(ReadByte()); |
| 5813 static_cast<LogicalExpression::Operator>(ReadByte()); | |
| 5814 | 5817 |
| 5815 if (op == LogicalExpression::kAnd) { | 5818 if (op == kAnd) { |
| 5816 instructions += BranchIfTrue(&right_entry, &constant_entry, negate); | 5819 instructions += BranchIfTrue(&right_entry, &constant_entry, negate); |
| 5817 } else { | 5820 } else { |
| 5818 instructions += BranchIfTrue(&constant_entry, &right_entry, negate); | 5821 instructions += BranchIfTrue(&constant_entry, &right_entry, negate); |
| 5819 } | 5822 } |
| 5820 | 5823 |
| 5821 Value* top = stack(); | 5824 Value* top = stack(); |
| 5822 Fragment right_fragment(right_entry); | 5825 Fragment right_fragment(right_entry); |
| 5823 right_fragment += TranslateCondition(&negate); // read right. | 5826 right_fragment += TranslateCondition(&negate); // read right. |
| 5824 | 5827 |
| 5825 right_fragment += Constant(Bool::True()); | 5828 right_fragment += Constant(Bool::True()); |
| 5826 right_fragment += | 5829 right_fragment += |
| 5827 StrictCompare(negate ? Token::kNE_STRICT : Token::kEQ_STRICT); | 5830 StrictCompare(negate ? Token::kNE_STRICT : Token::kEQ_STRICT); |
| 5828 right_fragment += StoreLocal(TokenPosition::kNoSource, | 5831 right_fragment += StoreLocal(TokenPosition::kNoSource, |
| 5829 parsed_function()->expression_temp_var()); | 5832 parsed_function()->expression_temp_var()); |
| 5830 right_fragment += Drop(); | 5833 right_fragment += Drop(); |
| 5831 | 5834 |
| 5832 ASSERT(top == stack()); | 5835 ASSERT(top == stack()); |
| 5833 Fragment constant_fragment(constant_entry); | 5836 Fragment constant_fragment(constant_entry); |
| 5834 constant_fragment += Constant(Bool::Get(op == LogicalExpression::kOr)); | 5837 constant_fragment += Constant(Bool::Get(op == kOr)); |
| 5835 constant_fragment += StoreLocal(TokenPosition::kNoSource, | 5838 constant_fragment += StoreLocal(TokenPosition::kNoSource, |
| 5836 parsed_function()->expression_temp_var()); | 5839 parsed_function()->expression_temp_var()); |
| 5837 constant_fragment += Drop(); | 5840 constant_fragment += Drop(); |
| 5838 | 5841 |
| 5839 JoinEntryInstr* join = BuildJoinEntry(); | 5842 JoinEntryInstr* join = BuildJoinEntry(); |
| 5840 right_fragment += Goto(join); | 5843 right_fragment += Goto(join); |
| 5841 constant_fragment += Goto(join); | 5844 constant_fragment += Goto(join); |
| 5842 | 5845 |
| 5843 return Fragment(instructions.entry, join) + | 5846 return Fragment(instructions.entry, join) + |
| 5844 LoadLocal(parsed_function()->expression_temp_var()); | 5847 LoadLocal(parsed_function()->expression_temp_var()); |
| (...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7207 } | 7210 } |
| 7208 catch_depth_dec(); | 7211 catch_depth_dec(); |
| 7209 | 7212 |
| 7210 return Fragment(try_body.entry, after_try); | 7213 return Fragment(try_body.entry, after_try); |
| 7211 } | 7214 } |
| 7212 | 7215 |
| 7213 Fragment StreamingFlowGraphBuilder::BuildYieldStatement() { | 7216 Fragment StreamingFlowGraphBuilder::BuildYieldStatement() { |
| 7214 TokenPosition position = ReadPosition(); // read position. | 7217 TokenPosition position = ReadPosition(); // read position. |
| 7215 uint8_t flags = ReadByte(); // read flags. | 7218 uint8_t flags = ReadByte(); // read flags. |
| 7216 | 7219 |
| 7217 ASSERT((flags & YieldStatement::kFlagNative) == | 7220 ASSERT(flags == kNativeYieldFlags); // Must have been desugared. |
| 7218 YieldStatement::kFlagNative); // Must have been desugared. | |
| 7219 | 7221 |
| 7220 // Setup yield/continue point: | 7222 // Setup yield/continue point: |
| 7221 // | 7223 // |
| 7222 // ... | 7224 // ... |
| 7223 // :await_jump_var = index; | 7225 // :await_jump_var = index; |
| 7224 // :await_ctx_var = :current_context_var | 7226 // :await_ctx_var = :current_context_var |
| 7225 // return <expr> | 7227 // return <expr> |
| 7226 // | 7228 // |
| 7227 // Continuation<index>: | 7229 // Continuation<index>: |
| 7228 // Drop(1) | 7230 // Drop(1) |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7381 if (declaration) { | 7383 if (declaration) { |
| 7382 name = &H.DartSymbol(name_index); | 7384 name = &H.DartSymbol(name_index); |
| 7383 } else { | 7385 } else { |
| 7384 name = &Symbols::AnonymousClosure(); | 7386 name = &Symbols::AnonymousClosure(); |
| 7385 } | 7387 } |
| 7386 // NOTE: This is not TokenPosition in the general sense! | 7388 // NOTE: This is not TokenPosition in the general sense! |
| 7387 function = Function::NewClosureFunction( | 7389 function = Function::NewClosureFunction( |
| 7388 *name, parsed_function()->function(), position); | 7390 *name, parsed_function()->function(), position); |
| 7389 | 7391 |
| 7390 function.set_is_debuggable(function_node_helper.dart_async_marker_ == | 7392 function.set_is_debuggable(function_node_helper.dart_async_marker_ == |
| 7391 FunctionNode::kSync); | 7393 FunctionNodeHelper::kSync); |
| 7392 switch (function_node_helper.dart_async_marker_) { | 7394 switch (function_node_helper.dart_async_marker_) { |
| 7393 case FunctionNode::kSyncStar: | 7395 case FunctionNodeHelper::kSyncStar: |
| 7394 function.set_modifier(RawFunction::kSyncGen); | 7396 function.set_modifier(RawFunction::kSyncGen); |
| 7395 break; | 7397 break; |
| 7396 case FunctionNode::kAsync: | 7398 case FunctionNodeHelper::kAsync: |
| 7397 function.set_modifier(RawFunction::kAsync); | 7399 function.set_modifier(RawFunction::kAsync); |
| 7398 function.set_is_inlinable(!FLAG_causal_async_stacks); | 7400 function.set_is_inlinable(!FLAG_causal_async_stacks); |
| 7399 break; | 7401 break; |
| 7400 case FunctionNode::kAsyncStar: | 7402 case FunctionNodeHelper::kAsyncStar: |
| 7401 function.set_modifier(RawFunction::kAsyncGen); | 7403 function.set_modifier(RawFunction::kAsyncGen); |
| 7402 function.set_is_inlinable(!FLAG_causal_async_stacks); | 7404 function.set_is_inlinable(!FLAG_causal_async_stacks); |
| 7403 break; | 7405 break; |
| 7404 default: | 7406 default: |
| 7405 // no special modifier | 7407 // no special modifier |
| 7406 break; | 7408 break; |
| 7407 } | 7409 } |
| 7408 function.set_is_generated_body(function_node_helper.async_marker_ == | 7410 function.set_is_generated_body(function_node_helper.async_marker_ == |
| 7409 FunctionNode::kSyncYielding); | 7411 FunctionNodeHelper::kSyncYielding); |
| 7410 if (function.IsAsyncClosure() || function.IsAsyncGenClosure()) { | 7412 if (function.IsAsyncClosure() || function.IsAsyncGenClosure()) { |
| 7411 function.set_is_inlinable(!FLAG_causal_async_stacks); | 7413 function.set_is_inlinable(!FLAG_causal_async_stacks); |
| 7412 } | 7414 } |
| 7413 | 7415 |
| 7414 function.set_end_token_pos(function_node_helper.end_position_); | 7416 function.set_end_token_pos(function_node_helper.end_position_); |
| 7415 LocalScope* scope = scopes()->function_scopes[i].scope; | 7417 LocalScope* scope = scopes()->function_scopes[i].scope; |
| 7416 const ContextScope& context_scope = ContextScope::Handle( | 7418 const ContextScope& context_scope = ContextScope::Handle( |
| 7417 Z, scope->PreserveOuterScope(flow_graph_builder_->context_depth_)); | 7419 Z, scope->PreserveOuterScope(flow_graph_builder_->context_depth_)); |
| 7418 function.set_context_scope(context_scope); | 7420 function.set_context_scope(context_scope); |
| 7419 function.set_kernel_offset(offset); | 7421 function.set_kernel_offset(offset); |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7778 } | 7780 } |
| 7779 } | 7781 } |
| 7780 | 7782 |
| 7781 return Array::Handle(Array::null()); | 7783 return Array::Handle(Array::null()); |
| 7782 } | 7784 } |
| 7783 | 7785 |
| 7784 } // namespace kernel | 7786 } // namespace kernel |
| 7785 } // namespace dart | 7787 } // namespace dart |
| 7786 | 7788 |
| 7787 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 7789 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
| OLD | NEW |