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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/redundant_phi.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
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 dart2js.cps_ir.redundant_phi_elimination; 5 library dart2js.cps_ir.redundant_phi_elimination;
6 6
7 import 'cps_ir_nodes.dart'; 7 import 'cps_ir_nodes.dart';
8 import 'optimizers.dart'; 8 import 'optimizers.dart';
9 9
10 /// Eliminate redundant phis from the given [FunctionDefinition]. 10 /// Eliminate redundant phis from the given [FunctionDefinition].
11 /// 11 ///
12 /// Phis in this case are [Continuations] together with corresponding 12 /// Phis in this case are [Continuations] together with corresponding
13 /// [InvokeContinuation]s. A [Continuation] parameter at position i is redundant 13 /// [InvokeContinuation]s. A [Continuation] parameter at position i is redundant
14 /// if for all [InvokeContinuation]s, the parameter at position i is identical 14 /// if for all [InvokeContinuation]s, the parameter at position i is identical
15 /// (except for feedback). Redundant parameters are removed from the 15 /// (except for feedback). Redundant parameters are removed from the
16 /// continuation signature, all invocations, and replaced within the 16 /// continuation signature, all invocations, and replaced within the
17 /// continuation body. 17 /// continuation body.
18 class RedundantPhiEliminator extends TrampolineRecursiveVisitor implements Pass { 18 class RedundantPhiEliminator extends TrampolineRecursiveVisitor
19 implements Pass {
19 String get passName => 'Redundant phi elimination'; 20 String get passName => 'Redundant phi elimination';
20 21
21 final Set<Continuation> workSet = new Set<Continuation>(); 22 final Set<Continuation> workSet = new Set<Continuation>();
22 23
23 @override 24 @override
24 void rewrite(FunctionDefinition root) { 25 void rewrite(FunctionDefinition root) {
25 // Traverse the tree once to build the work set. 26 // Traverse the tree once to build the work set.
26 visit(root); 27 visit(root);
27 28
28 // Process each continuation one-by-one. 29 // Process each continuation one-by-one.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 116 }
116 dst++; 117 dst++;
117 continue; 118 continue;
118 } 119 }
119 120
120 Primitive oldDefinition = cont.parameters[src]; 121 Primitive oldDefinition = cont.parameters[src];
121 122
122 // Add continuations of about-to-be modified invokes to worklist since 123 // Add continuations of about-to-be modified invokes to worklist since
123 // we might introduce new optimization opportunities. 124 // we might introduce new optimization opportunities.
124 for (Reference ref = oldDefinition.firstRef; 125 for (Reference ref = oldDefinition.firstRef;
125 ref != null; 126 ref != null;
126 ref = ref.next) { 127 ref = ref.next) {
127 Node parent = ref.parent; 128 Node parent = ref.parent;
128 if (parent is InvokeContinuation) { 129 if (parent is InvokeContinuation) {
129 Continuation thatCont = parent.continuation; 130 Continuation thatCont = parent.continuation;
130 if (thatCont != cont) { 131 if (thatCont != cont) {
131 workSet.add(thatCont); 132 workSet.add(thatCont);
132 } 133 }
133 } 134 }
134 } 135 }
135 136
136 // Replace individual parameters: 137 // Replace individual parameters:
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 /// Returns the LetCont that now binds [continuation]. 196 /// Returns the LetCont that now binds [continuation].
196 LetCont _makeUniqueBinding(Continuation continuation) { 197 LetCont _makeUniqueBinding(Continuation continuation) {
197 LetCont letCont = continuation.parent; 198 LetCont letCont = continuation.parent;
198 if (letCont.continuations.length == 1) return letCont; 199 if (letCont.continuations.length == 1) return letCont;
199 letCont.continuations.remove(continuation); 200 letCont.continuations.remove(continuation);
200 LetCont newBinding = new LetCont(continuation, null); 201 LetCont newBinding = new LetCont(continuation, null);
201 continuation.parent = newBinding; 202 continuation.parent = newBinding;
202 newBinding.insertBelow(letCont); 203 newBinding.insertBelow(letCont);
203 return newBinding; 204 return newBinding;
204 } 205 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/redundant_join.dart ('k') | pkg/compiler/lib/src/cps_ir/redundant_refinement.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698