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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart

Issue 853083005: Revert "Allow LetCont to bind multiple continuations." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 library tree_ir_builder; 5 library tree_ir_builder;
6 6
7 import '../dart2jslib.dart' as dart2js; 7 import '../dart2jslib.dart' as dart2js;
8 import '../dart_types.dart'; 8 import '../dart_types.dart';
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../cps_ir/cps_ir_nodes.dart' as cps_ir; 10 import '../cps_ir/cps_ir_nodes.dart' as cps_ir;
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } else { 352 } else {
353 return new Assign(variable, definition, visit(node.body)); 353 return new Assign(variable, definition, visit(node.body));
354 } 354 }
355 } 355 }
356 356
357 Statement visitRunnableBody(cps_ir.RunnableBody node) { 357 Statement visitRunnableBody(cps_ir.RunnableBody node) {
358 return visit(node.body); 358 return visit(node.body);
359 } 359 }
360 360
361 Statement visitLetCont(cps_ir.LetCont node) { 361 Statement visitLetCont(cps_ir.LetCont node) {
362 // Introduce labels for continuations that need them. 362 Label label;
363 for (cps_ir.Continuation continuation in node.continuations) { 363 if (node.continuation.hasMultipleUses) {
364 if (continuation.hasMultipleUses) { 364 label = new Label();
365 labels[continuation] = new Label(); 365 labels[node.continuation] = label;
366 }
367 } 366 }
368 Statement body = visit(node.body); 367 Statement body = visit(node.body);
369 // Continuations are bound at the same level, but they have to be 368 // The continuation's body is not always translated directly here because
370 // translated as if nested. This is because the body can invoke any 369 // it may have been already translated:
371 // of them from anywhere, so it must be nested inside all of them.
372 //
373 // The continuation bodies are not always translated directly here because
374 // they may have been already translated:
375 // * For singly-used continuations, the continuation's body is 370 // * For singly-used continuations, the continuation's body is
376 // translated at the site of the continuation invocation. 371 // translated at the site of the continuation invocation.
377 // * For recursive continuations, there is a single non-recursive 372 // * For recursive continuations, there is a single non-recursive
378 // invocation. The continuation's body is translated at the site 373 // invocation. The continuation's body is translated at the site
379 // of the non-recursive continuation invocation. 374 // of the non-recursive continuation invocation.
380 // See visitInvokeContinuation for the implementation. 375 // See visitInvokeContinuation for the implementation.
381 Statement current = body; 376 if (label == null || node.continuation.isRecursive) return body;
382 for (cps_ir.Continuation continuation in node.continuations.reversed) { 377 return new LabeledStatement(label, body, visit(node.continuation.body));
383 Label label = labels[continuation];
384 if (label != null && !continuation.isRecursive) {
385 current =
386 new LabeledStatement(label, current, visit(continuation.body));
387 }
388 }
389 return current;
390 } 378 }
391 379
392 Statement visitInvokeStatic(cps_ir.InvokeStatic node) { 380 Statement visitInvokeStatic(cps_ir.InvokeStatic node) {
393 // Calls are translated to direct style. 381 // Calls are translated to direct style.
394 List<Expression> arguments = translateArguments(node.arguments); 382 List<Expression> arguments = translateArguments(node.arguments);
395 Expression invoke = new InvokeStatic(node.target, node.selector, arguments); 383 Expression invoke = new InvokeStatic(node.target, node.selector, arguments);
396 return continueWithExpression(node.continuation, invoke); 384 return continueWithExpression(node.continuation, invoke);
397 } 385 }
398 386
399 Statement visitInvokeMethod(cps_ir.InvokeMethod node) { 387 Statement visitInvokeMethod(cps_ir.InvokeMethod node) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 // visited. 558 // visited.
571 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node.'); 559 internalError(CURRENT_ELEMENT_SPANNABLE, 'Unexpected IR node: $node.');
572 return null; 560 return null;
573 } 561 }
574 562
575 Expression visitIsTrue(cps_ir.IsTrue node) { 563 Expression visitIsTrue(cps_ir.IsTrue node) {
576 return getVariableReference(node.value); 564 return getVariableReference(node.value);
577 } 565 }
578 } 566 }
579 567
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/type_propagation.dart ('k') | tests/compiler/dart2js/backend_dart/opt_constprop_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698