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

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

Issue 1368963002: dart2js cps: Logical rewriter should treat Throw as a terminator. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | 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) 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.optimization.logical_rewriter; 5 library tree_ir.optimization.logical_rewriter;
6 6
7 import '../tree_ir_nodes.dart'; 7 import '../tree_ir_nodes.dart';
8 import 'optimization.dart' show Pass; 8 import 'optimization.dart' show Pass;
9 import '../../constants/values.dart' as values; 9 import '../../constants/values.dart' as values;
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 return node.target.binding == target || 88 return node.target.binding == target ||
89 target is Continue && target.target == node.target; 89 target is Continue && target.target == node.target;
90 } 90 }
91 91
92 bool isFallthroughReturn(Return node) { 92 bool isFallthroughReturn(Return node) {
93 return isNull(node.value) && fallthrough.target == null; 93 return isNull(node.value) && fallthrough.target == null;
94 } 94 }
95 95
96 bool isTerminator(Statement node) { 96 bool isTerminator(Statement node) {
97 return (node is Jump || node is Return) && !isFallthrough(node) || 97 return (node is Jump || node is Return) && !isFallthrough(node) ||
98 (node is ExpressionStatement && node.next is Unreachable); 98 (node is ExpressionStatement && node.next is Unreachable) ||
99 node is Throw;
99 } 100 }
100 101
101 Statement visitIf(If node) { 102 Statement visitIf(If node) {
102 // If one of the branches is empty (i.e. just a fallthrough), then that 103 // If one of the branches is empty (i.e. just a fallthrough), then that
103 // branch should preferably be the 'else' so we won't have to print it. 104 // branch should preferably be the 'else' so we won't have to print it.
104 // In other words, we wish to perform this rewrite: 105 // In other words, we wish to perform this rewrite:
105 // if (E) {} else {S} 106 // if (E) {} else {S}
106 // ==> 107 // ==>
107 // if (!E) {S} 108 // if (!E) {S}
108 // In the tree language, empty statements do not exist yet, so we must check 109 // In the tree language, empty statements do not exist yet, so we must check
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 return e2 is VariableUse && e1.variable == e2.variable; 546 return e2 is VariableUse && e1.variable == e2.variable;
546 } 547 }
547 return false; 548 return false;
548 } 549 }
549 550
550 void destroyVariableUse(VariableUse node) { 551 void destroyVariableUse(VariableUse node) {
551 --node.variable.readCount; 552 --node.variable.readCount;
552 } 553 }
553 } 554 }
554 555
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698