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

Unified Diff: pkg/compiler/lib/src/cps_ir/remove_refinements.dart

Issue 1304383003: dart2js cps: Add path-sensitive types by inserting refinement IR nodes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase 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 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/cps_ir/shrinking_reductions.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/remove_refinements.dart
diff --git a/pkg/compiler/lib/src/cps_ir/remove_refinements.dart b/pkg/compiler/lib/src/cps_ir/remove_refinements.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f5088ae214008351cbb595d737c6578bd1ba4478
--- /dev/null
+++ b/pkg/compiler/lib/src/cps_ir/remove_refinements.dart
@@ -0,0 +1,35 @@
+// 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 cps_ir.optimization.remove_refinements;
+
+import 'optimizers.dart' show Pass;
+import 'shrinking_reductions.dart' show ParentVisitor;
+import 'cps_ir_nodes.dart';
+
+/// Removes all [Refinement] nodes from the IR.
+///
+/// This simplifies subsequent passes that don't rely on path-sensitive
+/// type information but depend on equality between primitives.
+class RemoveRefinements extends RecursiveVisitor implements Pass {
+ String get passName => 'Remove refinement nodes';
+
+ void rewrite(FunctionDefinition node) {
+ new ParentVisitor().visit(node);
+ visit(node);
+ }
+
+ @override
+ Expression traverseLetPrim(LetPrim node) {
+ if (node.primitive is Refinement) {
+ Refinement refinement = node.primitive;
+ refinement.value.definition.substituteFor(refinement);
+ refinement.value.unlink();
+ InteriorNode parent = node.parent;
+ parent.body = node.body;
+ node.body.parent = parent;
+ }
+ return node.body;
+ }
+}
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/optimizers.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