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

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

Issue 1375213003: dart2js cps: Maintain parent pointers instead of recomputing them. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.share_interceptors; 5 library dart2js.cps_ir.share_interceptors;
6 6
7 import 'optimizers.dart'; 7 import 'optimizers.dart';
8 import 'cps_ir_nodes.dart'; 8 import 'cps_ir_nodes.dart';
9 import 'loop_hierarchy.dart'; 9 import 'loop_hierarchy.dart';
10 import '../constants/values.dart'; 10 import '../constants/values.dart';
11 11
12 /// Removes redundant `getInterceptor` calls. 12 /// Removes redundant `getInterceptor` calls.
13 /// 13 ///
14 /// The pass performs three optimizations for interceptors: 14 /// The pass performs three optimizations for interceptors:
15 ///- pull interceptors out of loops 15 ///- pull interceptors out of loops
16 ///- replace interceptors with constants 16 ///- replace interceptors with constants
17 ///- share interceptors when one is in scope of the other 17 ///- share interceptors when one is in scope of the other
18 class ShareInterceptors extends RecursiveVisitor implements Pass { 18 class ShareInterceptors extends TrampolineRecursiveVisitor implements Pass {
19 String get passName => 'Share interceptors'; 19 String get passName => 'Share interceptors';
20 20
21 /// The innermost loop containing a given primitive. 21 /// The innermost loop containing a given primitive.
22 final Map<Primitive, Continuation> loopHeaderFor = 22 final Map<Primitive, Continuation> loopHeaderFor =
23 <Primitive, Continuation>{}; 23 <Primitive, Continuation>{};
24 24
25 /// An interceptor currently in scope for a given primitive. 25 /// An interceptor currently in scope for a given primitive.
26 final Map<Primitive, Primitive> interceptorFor = 26 final Map<Primitive, Primitive> interceptorFor =
27 <Primitive, Primitive>{}; 27 <Primitive, Primitive>{};
28 28
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 if (existing != null) { 108 if (existing != null) {
109 existing.substituteFor(interceptor); 109 existing.substituteFor(interceptor);
110 interceptor.destroy(); 110 interceptor.destroy();
111 node.remove(); 111 node.remove();
112 return next; 112 return next;
113 } 113 }
114 114
115 // The interceptor could not be shared. Replace it with a constant. 115 // The interceptor could not be shared. Replace it with a constant.
116 Constant constantPrim = new Constant(constant); 116 Constant constantPrim = new Constant(constant);
117 node.primitive = constantPrim; 117 node.primitive = constantPrim;
118 constantPrim.parent = node;
118 constantPrim.hint = interceptor.hint; 119 constantPrim.hint = interceptor.hint;
119 constantPrim.type = interceptor.type; 120 constantPrim.type = interceptor.type;
120 constantPrim.substituteFor(interceptor); 121 constantPrim.substituteFor(interceptor);
121 interceptor.destroy(); 122 interceptor.destroy();
122 sharedConstantFor[constant] = constantPrim; 123 sharedConstantFor[constant] = constantPrim;
123 } else { 124 } else {
124 interceptorFor[input] = interceptor; 125 interceptorFor[input] = interceptor;
125 } 126 }
126 127
127 // Determine the outermost loop where the input to the interceptor call 128 // Determine the outermost loop where the input to the interceptor call
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 187 }
187 } 188 }
188 return c1; 189 return c1;
189 } 190 }
190 191
191 int getDepth(Continuation loop) { 192 int getDepth(Continuation loop) {
192 if (loop == null) return -1; 193 if (loop == null) return -1;
193 return loopHierarchy.loopDepth[loop]; 194 return loopHierarchy.loopDepth[loop];
194 } 195 }
195 } 196 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/scalar_replacement.dart ('k') | pkg/compiler/lib/src/cps_ir/shrinking_reductions.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698