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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/cps_ir/share_interceptors.dart
diff --git a/pkg/compiler/lib/src/cps_ir/share_interceptors.dart b/pkg/compiler/lib/src/cps_ir/share_interceptors.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7b360d4d7e6b588899fe9f340f726c54f1a23fa0
--- /dev/null
+++ b/pkg/compiler/lib/src/cps_ir/share_interceptors.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library dart2js.cps_ir.share_interceptors;
+
+import 'cps_ir_nodes.dart';
+import 'optimizers.dart';
+
+/// Merges calls to `getInterceptor` when one call dominates the other.
+///
+/// Should run after [LoopInvariantCodeMotion] so interceptors lifted out from
+/// loops can be merged.
+class ShareInterceptors extends RecursiveVisitor implements Pass {
+ String get passName => 'Share interceptors';
+
+ final Map<Primitive, Interceptor> interceptorFor =
+ <Primitive, Interceptor>{};
+
+ void rewrite(FunctionDefinition node) {
+ visit(node.body);
+ }
+
+ @override
+ Expression traverseLetPrim(LetPrim node) {
+ if (node.primitive is Interceptor) {
+ Interceptor interceptor = node.primitive;
+ Primitive input = interceptor.input.definition;
+ Interceptor existing = interceptorFor[input];
+ if (existing != null) {
+ existing.interceptedClasses.addAll(interceptor.interceptedClasses);
+ existing.substituteFor(interceptor);
+ } else {
+ interceptorFor[input] = interceptor;
+ pushAction(() {
+ interceptorFor.remove(input);
+ });
+ }
+ }
+ return node.body;
+ }
+}
« 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