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

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

Issue 2697193008: [Kernel] replace function debuggable field with originalAsyncMarker field (Closed)
Patch Set: ASSERT in kernel_reader Created 3 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
« no previous file with comments | « runtime/vm/kernel_reader.cc ('k') | no next file » | 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) 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 <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 8
9 #include "vm/kernel_to_il.h" 9 #include "vm/kernel_to_il.h"
10 10
(...skipping 6038 matching lines...) Expand 10 before | Expand all | Expand 10 after
6049 instructions += TranslateExpression(node->expression()); 6049 instructions += TranslateExpression(node->expression());
6050 instructions += Return(TokenPosition::kNoSource); 6050 instructions += Return(TokenPosition::kNoSource);
6051 6051
6052 // Note: DropTempsInstr serves as an anchor instruction. It will not 6052 // Note: DropTempsInstr serves as an anchor instruction. It will not
6053 // be linked into the resulting graph. 6053 // be linked into the resulting graph.
6054 DropTempsInstr* anchor = new (Z) DropTempsInstr(0, NULL); 6054 DropTempsInstr* anchor = new (Z) DropTempsInstr(0, NULL);
6055 yield_continuations_.Add(YieldContinuation(anchor, CurrentTryIndex())); 6055 yield_continuations_.Add(YieldContinuation(anchor, CurrentTryIndex()));
6056 6056
6057 Fragment continuation(instructions.entry, anchor); 6057 Fragment continuation(instructions.entry, anchor);
6058 6058
6059 // TODO(27590): we need a better way to detect if we need to check for an 6059 if (parsed_function_->function().IsAsyncClosure() ||
6060 // exception after yield or not. 6060 parsed_function_->function().IsAsyncGenClosure()) {
6061 if (parsed_function_->function().NumOptionalPositionalParameters() == 3) { 6061 // If function is async closure or async gen closure it takes three
6062 // If function takes three parameters then the second and the third 6062 // parameters where the second and the third are exception and stack_trace.
6063 // are exception and stack_trace. Check if exception is non-null 6063 // Check if exception is non-null and rethrow it.
6064 // and rethrow it.
6065 // 6064 //
6066 // :async_op([:result, :exception, :stack_trace]) { 6065 // :async_op([:result, :exception, :stack_trace]) {
6067 // ... 6066 // ...
6068 // Continuation<index>: 6067 // Continuation<index>:
6069 // if (:exception != null) rethrow(:exception, :stack_trace); 6068 // if (:exception != null) rethrow(:exception, :stack_trace);
6070 // ... 6069 // ...
6071 // } 6070 // }
6072 // 6071 //
6073 LocalScope* scope = parsed_function_->node_sequence()->scope(); 6072 LocalScope* scope = parsed_function_->node_sequence()->scope();
6074 LocalVariable* exception_var = scope->VariableAt(2); 6073 LocalVariable* exception_var = scope->VariableAt(2);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
6125 if (parent->IsFunctionExpression()) { 6124 if (parent->IsFunctionExpression()) {
6126 name = &Symbols::AnonymousClosure(); 6125 name = &Symbols::AnonymousClosure();
6127 } else { 6126 } else {
6128 ASSERT(parent->IsFunctionDeclaration()); 6127 ASSERT(parent->IsFunctionDeclaration());
6129 name = &H.DartSymbol( 6128 name = &H.DartSymbol(
6130 FunctionDeclaration::Cast(parent)->variable()->name()); 6129 FunctionDeclaration::Cast(parent)->variable()->name());
6131 } 6130 }
6132 // NOTE: This is not TokenPosition in the general sense! 6131 // NOTE: This is not TokenPosition in the general sense!
6133 function = Function::NewClosureFunction( 6132 function = Function::NewClosureFunction(
6134 *name, parsed_function_->function(), position); 6133 *name, parsed_function_->function(), position);
6135 function.set_is_debuggable(node->debuggable()); 6134
6135 function.set_is_debuggable(node->dart_async_marker() ==
6136 FunctionNode::kSync);
6137 switch (node->dart_async_marker()) {
6138 case FunctionNode::kSyncStar:
6139 function.set_modifier(RawFunction::kSyncGen);
6140 break;
6141 case FunctionNode::kAsync:
6142 function.set_modifier(RawFunction::kAsync);
6143 break;
6144 case FunctionNode::kAsyncStar:
6145 function.set_modifier(RawFunction::kAsyncGen);
6146 break;
6147 default:
6148 // no special modifier
6149 break;
6150 }
6151 function.set_is_generated_body(node->async_marker() ==
6152 FunctionNode::kSyncYielding);
6153
6136 function.set_end_token_pos(node->end_position()); 6154 function.set_end_token_pos(node->end_position());
6137 LocalScope* scope = scopes_->function_scopes[i].scope; 6155 LocalScope* scope = scopes_->function_scopes[i].scope;
6138 const ContextScope& context_scope = 6156 const ContextScope& context_scope =
6139 ContextScope::Handle(Z, scope->PreserveOuterScope(context_depth_)); 6157 ContextScope::Handle(Z, scope->PreserveOuterScope(context_depth_));
6140 function.set_context_scope(context_scope); 6158 function.set_context_scope(context_scope);
6141 function.set_kernel_function(node); 6159 function.set_kernel_function(node);
6142 KernelReader::SetupFunctionParameters(H, T, dart::Class::Handle(Z), 6160 KernelReader::SetupFunctionParameters(H, T, dart::Class::Handle(Z),
6143 function, node, 6161 function, node,
6144 false, // is_method 6162 false, // is_method
6145 true); // is_closure 6163 true); // is_closure
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
6281 thread->clear_sticky_error(); 6299 thread->clear_sticky_error();
6282 return error.raw(); 6300 return error.raw();
6283 } 6301 }
6284 } 6302 }
6285 6303
6286 6304
6287 } // namespace kernel 6305 } // namespace kernel
6288 } // namespace dart 6306 } // namespace dart
6289 6307
6290 #endif // !defined(DART_PRECOMPILED_RUNTIME) 6308 #endif // !defined(DART_PRECOMPILED_RUNTIME)
OLDNEW
« no previous file with comments | « runtime/vm/kernel_reader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698