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

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

Issue 1313783003: dart2js cps: Generate interceptors at use-site and share afterwards. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Revert patch #3. I read Golem results backwards. Created 5 years, 3 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library dart2js.cps_ir.share_interceptors;
6
7 import 'cps_ir_nodes.dart';
8 import 'optimizers.dart';
9
10 /// Merges calls to `getInterceptor` when one call dominates the other.
11 ///
12 /// Should run after [LoopInvariantCodeMotion] so interceptors lifted out from
13 /// loops can be merged.
14 class ShareInterceptors extends RecursiveVisitor implements Pass {
15 String get passName => 'Share interceptors';
16
17 final Map<Primitive, Interceptor> interceptorFor =
18 <Primitive, Interceptor>{};
19
20 void rewrite(FunctionDefinition node) {
21 visit(node.body);
22 }
23
24 @override
25 Expression traverseLetPrim(LetPrim node) {
26 if (node.primitive is Interceptor) {
27 Interceptor interceptor = node.primitive;
28 Primitive input = interceptor.input.definition;
29 Interceptor existing = interceptorFor[input];
30 if (existing != null) {
31 existing.interceptedClasses.addAll(interceptor.interceptedClasses);
32 existing.substituteFor(interceptor);
33 } else {
34 interceptorFor[input] = interceptor;
35 pushAction(() {
36 interceptorFor.remove(input);
37 });
38 }
39 }
40 return node.body;
41 }
42 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/optimizers.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698