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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/cps_ir/redundant_phi.dart

Issue 417043003: Implement shrinking reductions in CPS IR (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove unused method Created 6 years, 4 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 part of dart2js.cps_optimizers; 5 part of dart2js.cps_optimizers;
6 6
7 /// Eliminate redundant phis from the given [FunctionDefinition]. 7 /// Eliminate redundant phis from the given [FunctionDefinition].
8 /// 8 ///
9 /// Phis in this case are [Continuations] together with corresponding 9 /// Phis in this case are [Continuations] together with corresponding
10 /// [InvokeContinuation]s. A [Continuation] parameter at position i is redundant 10 /// [InvokeContinuation]s. A [Continuation] parameter at position i is redundant
11 /// if for all [InvokeContinuation]s, the parameter at position i is identical 11 /// if for all [InvokeContinuation]s, the parameter at position i is identical
12 /// (except for feedback). Redundant parameters are removed from the 12 /// (except for feedback). Redundant parameters are removed from the
13 /// continuation signature, all invocations, and replaced within the 13 /// continuation signature, all invocations, and replaced within the
14 /// continuation body. 14 /// continuation body.
15 class RedundantPhiEliminator extends RecursiveVisitor { 15 class RedundantPhiEliminator extends RecursiveVisitor implements Pass {
16 final Map<Continuation, List<InvokeContinuation>> cont2invokes = 16 final Map<Continuation, List<InvokeContinuation>> cont2invokes =
17 <Continuation, List<InvokeContinuation>>{}; 17 <Continuation, List<InvokeContinuation>>{};
18 // For each reference r used in a continuation invocation i, stores the 18 // For each reference r used in a continuation invocation i, stores the
19 // corresponding continuation i.continuation. If required by other passes, 19 // corresponding continuation i.continuation. If required by other passes,
20 // we could consider adding parent pointers to references instead. 20 // we could consider adding parent pointers to references instead.
21 final Map<Reference, Continuation> ref2cont = <Reference, Continuation>{}; 21 final Map<Reference, Continuation> ref2cont = <Reference, Continuation>{};
22 final Set<Continuation> workSet = new Set<Continuation>(); 22 final Set<Continuation> workSet = new Set<Continuation>();
23 23
24 void rewrite(final FunctionDefinition root) { 24 void rewrite(final FunctionDefinition root) {
25 // Traverse the tree once to build the work set. 25 // Traverse the tree once to build the work set.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 .add(node); 121 .add(node);
122 122
123 // And the reference map. 123 // And the reference map.
124 node.arguments.forEach((Reference ref) { 124 node.arguments.forEach((Reference ref) {
125 assert(!ref2cont.containsKey(ref)); 125 assert(!ref2cont.containsKey(ref));
126 ref2cont[ref] = node.continuation.definition; 126 ref2cont[ref] = node.continuation.definition;
127 }); 127 });
128 } 128 }
129 } 129 }
130 130
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698