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

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

Issue 893193004: Propagate the stack trace of the inner-most throw when using async/await. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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/ast_transformer.h" 5 #include "vm/ast_transformer.h"
6 6
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/parser.h" 8 #include "vm/parser.h"
9 #include "vm/thread.h" 9 #include "vm/thread.h"
10 10
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // 124 //
125 // :saved_try_ctx_var = :await_saved_try_ctx_var_y; 125 // :saved_try_ctx_var = :await_saved_try_ctx_var_y;
126 // :await_temp_var_(X+1) = :result_param; 126 // :await_temp_var_(X+1) = :result_param;
127 127
128 LocalVariable* async_op = GetVariableInScope( 128 LocalVariable* async_op = GetVariableInScope(
129 preamble_->scope(), Symbols::AsyncOperation()); 129 preamble_->scope(), Symbols::AsyncOperation());
130 LocalVariable* result_param = GetVariableInScope( 130 LocalVariable* result_param = GetVariableInScope(
131 preamble_->scope(), Symbols::AsyncOperationParam()); 131 preamble_->scope(), Symbols::AsyncOperationParam());
132 LocalVariable* error_param = GetVariableInScope( 132 LocalVariable* error_param = GetVariableInScope(
133 preamble_->scope(), Symbols::AsyncOperationErrorParam()); 133 preamble_->scope(), Symbols::AsyncOperationErrorParam());
134 LocalVariable* stack_trace_param = GetVariableInScope(
135 preamble_->scope(), Symbols::AsyncOperationStackTraceParam());
134 136
135 AstNode* transformed_expr = Transform(node->expr()); 137 AstNode* transformed_expr = Transform(node->expr());
136 preamble_->Add(new(Z) StoreLocalNode( 138 preamble_->Add(new(Z) StoreLocalNode(
137 Scanner::kNoSourcePos, result_param, transformed_expr)); 139 Scanner::kNoSourcePos, result_param, transformed_expr));
138 140
139 LoadLocalNode* load_result_param = new(Z) LoadLocalNode( 141 LoadLocalNode* load_result_param = new(Z) LoadLocalNode(
140 Scanner::kNoSourcePos, result_param); 142 Scanner::kNoSourcePos, result_param);
141 143
142 const Class& future_cls = 144 const Class& future_cls =
143 Class::ZoneHandle(Z, thread()->isolate()->object_store()->future_class()); 145 Class::ZoneHandle(Z, thread()->isolate()->object_store()->future_class());
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 LocalVariable* async_saved_try_ctx = 219 LocalVariable* async_saved_try_ctx =
218 GetVariableInScope(preamble_->scope(), async_saved_try_ctx_name); 220 GetVariableInScope(preamble_->scope(), async_saved_try_ctx_name);
219 preamble_->Add(new (Z) StoreLocalNode( 221 preamble_->Add(new (Z) StoreLocalNode(
220 Scanner::kNoSourcePos, 222 Scanner::kNoSourcePos,
221 parsed_function_.saved_try_ctx(), 223 parsed_function_.saved_try_ctx(),
222 new (Z) LoadLocalNode(Scanner::kNoSourcePos, async_saved_try_ctx))); 224 new (Z) LoadLocalNode(Scanner::kNoSourcePos, async_saved_try_ctx)));
223 } 225 }
224 226
225 LoadLocalNode* load_error_param = new (Z) LoadLocalNode( 227 LoadLocalNode* load_error_param = new (Z) LoadLocalNode(
226 Scanner::kNoSourcePos, error_param); 228 Scanner::kNoSourcePos, error_param);
229 LoadLocalNode* load_stack_trace_param = new (Z) LoadLocalNode(
230 Scanner::kNoSourcePos, stack_trace_param);
227 SequenceNode* error_ne_null_branch = new (Z) SequenceNode( 231 SequenceNode* error_ne_null_branch = new (Z) SequenceNode(
228 Scanner::kNoSourcePos, ChainNewScope(preamble_->scope())); 232 Scanner::kNoSourcePos, ChainNewScope(preamble_->scope()));
229 error_ne_null_branch->Add(new (Z) ThrowNode( 233 error_ne_null_branch->Add(new (Z) ThrowNode(
230 Scanner::kNoSourcePos, 234 Scanner::kNoSourcePos,
231 load_error_param, 235 load_error_param,
232 NULL)); 236 load_stack_trace_param));
233 preamble_->Add(new (Z) IfNode( 237 preamble_->Add(new (Z) IfNode(
234 Scanner::kNoSourcePos, 238 Scanner::kNoSourcePos,
235 new (Z) ComparisonNode( 239 new (Z) ComparisonNode(
236 Scanner::kNoSourcePos, 240 Scanner::kNoSourcePos,
237 Token::kNE, 241 Token::kNE,
238 load_error_param, 242 load_error_param,
239 new (Z) LiteralNode(Scanner::kNoSourcePos, 243 new (Z) LiteralNode(Scanner::kNoSourcePos,
240 Object::null_instance())), 244 Object::null_instance())),
241 error_ne_null_branch, 245 error_ne_null_branch,
242 NULL)); 246 NULL));
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 void AwaitTransformer::VisitThrowNode(ThrowNode* node) { 599 void AwaitTransformer::VisitThrowNode(ThrowNode* node) {
596 // TODO(mlippautz): Check if relevant. 600 // TODO(mlippautz): Check if relevant.
597 AstNode* new_exception = Transform(node->exception()); 601 AstNode* new_exception = Transform(node->exception());
598 AstNode* new_stacktrace = Transform(node->stacktrace()); 602 AstNode* new_stacktrace = Transform(node->stacktrace());
599 result_ = new(Z) ThrowNode(node->token_pos(), 603 result_ = new(Z) ThrowNode(node->token_pos(),
600 new_exception, 604 new_exception,
601 new_stacktrace); 605 new_stacktrace);
602 } 606 }
603 607
604 } // namespace dart 608 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698