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

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

Issue 655773003: Initialize the async jump variable with a smi to avoid polymorphic comparison. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.h » ('j') | 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) 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/parser.h" 7 #include "vm/parser.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 preamble_->Add(new(I) StoreLocalNode( 135 preamble_->Add(new(I) StoreLocalNode(
136 Scanner::kNoSourcePos, result_param, result_)); 136 Scanner::kNoSourcePos, result_param, result_));
137 LoadLocalNode* load_result_param = new(I) LoadLocalNode( 137 LoadLocalNode* load_result_param = new(I) LoadLocalNode(
138 Scanner::kNoSourcePos, result_param); 138 Scanner::kNoSourcePos, result_param);
139 LocalScope* is_future_scope = ChainNewScope(preamble_->scope()); 139 LocalScope* is_future_scope = ChainNewScope(preamble_->scope());
140 SequenceNode* is_future_branch = new (I) SequenceNode( 140 SequenceNode* is_future_branch = new (I) SequenceNode(
141 Scanner::kNoSourcePos, is_future_scope); 141 Scanner::kNoSourcePos, is_future_scope);
142 AwaitMarkerNode* await_marker = new (I) AwaitMarkerNode( 142 AwaitMarkerNode* await_marker = new (I) AwaitMarkerNode(
143 AwaitMarkerNode::kNewContinuationState); 143 AwaitMarkerNode::kNewContinuationState);
144 await_marker->set_scope(is_future_scope); 144 await_marker->set_scope(is_future_scope);
145 GetVariableInScope(is_future_scope, Symbols::AwaitJumpVar());
hausner 2014/10/14 16:29:55 I am not sure why the lookup of these variables is
Florian Schneider 2014/10/15 11:40:59 Here the side effect occurs twice (here and again
146 GetVariableInScope(is_future_scope, Symbols::AwaitContextVar());
147 is_future_branch->Add(await_marker); 145 is_future_branch->Add(await_marker);
148 ArgumentListNode* args = new(I) ArgumentListNode(Scanner::kNoSourcePos); 146 ArgumentListNode* args = new(I) ArgumentListNode(Scanner::kNoSourcePos);
149 args->Add(new(I) LoadLocalNode(Scanner::kNoSourcePos, async_op)); 147 args->Add(new(I) LoadLocalNode(Scanner::kNoSourcePos, async_op));
150 is_future_branch->Add(new (I) StoreLocalNode( 148 is_future_branch->Add(new (I) StoreLocalNode(
151 Scanner::kNoSourcePos, 149 Scanner::kNoSourcePos,
152 result_param, 150 result_param,
153 new(I) InstanceCallNode( 151 new(I) InstanceCallNode(
154 Scanner::kNoSourcePos, 152 Scanner::kNoSourcePos,
155 load_result_param, 153 load_result_param,
156 Symbols::FutureThen(), 154 Symbols::FutureThen(),
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 270 }
273 271
274 272
275 LocalScope* AwaitTransformer::ChainNewScope(LocalScope* parent) { 273 LocalScope* AwaitTransformer::ChainNewScope(LocalScope* parent) {
276 return new (I) LocalScope( 274 return new (I) LocalScope(
277 parent, parent->function_level(), parent->loop_level()); 275 parent, parent->function_level(), parent->loop_level());
278 } 276 }
279 277
280 278
281 void AwaitTransformer::VisitBinaryOpNode(BinaryOpNode* node) { 279 void AwaitTransformer::VisitBinaryOpNode(BinaryOpNode* node) {
282 node->left()->Visit(this); 280 AstNode* new_left = Transform(node->left());
283 AstNode* new_left = result_;
284 AstNode* new_right = NULL; 281 AstNode* new_right = NULL;
285 // Preserve lazy evaluaton. 282 // Preserve lazy evaluaton.
286 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) { 283 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) {
287 new_right = LazyTransform(node->kind(), new_left, node->right()); 284 new_right = LazyTransform(node->kind(), new_left, node->right());
288 } else { 285 } else {
289 new_right = Transform(node->right()); 286 new_right = Transform(node->right());
290 } 287 }
291 LocalVariable* result = AddToPreambleNewTempVar( 288 LocalVariable* result = AddToPreambleNewTempVar(
292 new(I) BinaryOpNode(node->token_pos(), 289 new(I) BinaryOpNode(node->token_pos(),
293 node->kind(), 290 node->kind(),
294 new_left, 291 new_left,
295 new_right)); 292 new_right));
296 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); 293 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result);
297 } 294 }
298 295
299 296
300 void AwaitTransformer::VisitBinaryOpWithMask32Node( 297 void AwaitTransformer::VisitBinaryOpWithMask32Node(
301 BinaryOpWithMask32Node* node) { 298 BinaryOpWithMask32Node* node) {
302 node->left()->Visit(this); 299 ASSERT((node->kind() != Token::kAND) && (node->kind() != Token::kOR));
303 AstNode* new_left = result_; 300 AstNode* new_left = Transform(node->left());
304 AstNode* new_right = NULL; 301 AstNode* new_right = Transform(node->right());
305 // Preserve lazy evaluaton.
306 if ((node->kind() == Token::kAND) || (node->kind() == Token::kOR)) {
307 new_right = LazyTransform(node->kind(), new_left, node->right());
308 } else {
309 new_right = Transform(node->right());
310 }
311 LocalVariable* result = AddToPreambleNewTempVar( 302 LocalVariable* result = AddToPreambleNewTempVar(
312 new(I) BinaryOpWithMask32Node(node->token_pos(), 303 new(I) BinaryOpWithMask32Node(node->token_pos(),
313 node->kind(), 304 node->kind(),
314 new_left, 305 new_left,
315 new_right, 306 new_right,
316 node->mask32())); 307 node->mask32()));
317 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result); 308 result_ = new(I) LoadLocalNode(Scanner::kNoSourcePos, result);
318 } 309 }
319 310
320 311
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 void AwaitTransformer::VisitThrowNode(ThrowNode* node) { 575 void AwaitTransformer::VisitThrowNode(ThrowNode* node) {
585 // TODO(mlippautz): Check if relevant. 576 // TODO(mlippautz): Check if relevant.
586 AstNode* new_exception = Transform(node->exception()); 577 AstNode* new_exception = Transform(node->exception());
587 AstNode* new_stacktrace = Transform(node->stacktrace()); 578 AstNode* new_stacktrace = Transform(node->stacktrace());
588 result_ = new(I) ThrowNode(node->token_pos(), 579 result_ = new(I) ThrowNode(node->token_pos(),
589 new_exception, 580 new_exception,
590 new_stacktrace); 581 new_stacktrace);
591 } 582 }
592 583
593 } // namespace dart 584 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698