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

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

Issue 2246623002: Delete CPS IR (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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/redundant_phi.dart ('k') | pkg/compiler/lib/src/cps_ir/scalar_replacement.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/redundant_refinement.dart
diff --git a/pkg/compiler/lib/src/cps_ir/redundant_refinement.dart b/pkg/compiler/lib/src/cps_ir/redundant_refinement.dart
deleted file mode 100644
index 8cd13b3840ca2f4913e543d0c9d12f423b6ae8fe..0000000000000000000000000000000000000000
--- a/pkg/compiler/lib/src/cps_ir/redundant_refinement.dart
+++ /dev/null
@@ -1,57 +0,0 @@
-// 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.redundant_refinement;
-
-import 'cps_ir_nodes.dart';
-import 'optimizers.dart' show Pass;
-import 'type_mask_system.dart';
-
-/// Removes [Refinement] nodes where the input value is already known to
-/// satisfy the refinement type.
-///
-/// Note: This pass improves loop-invariant code motion in the GVN pass because
-/// GVN will currently not hoist a primitive across a refinement guard.
-/// But some opportunities for hoisting are still missed. A field access can
-/// safely be hoisted across a non-redundant refinement as long as the less
-/// refined value is still known to have the field. For example:
-///
-/// class A { var field; }
-/// class B extends A {}
-///
-/// var x = getA(); // Return type is subclass of A.
-/// while (x is B) { // Refinement to B is not redundant.
-/// x.field.baz++; // x.field is safe for hoisting,
-/// } // but blocked by the refinement node.
-///
-/// Ideally, this pass should go away and GVN should handle refinements
-/// directly.
-class RedundantRefinementEliminator extends TrampolineRecursiveVisitor
- implements Pass {
- String get passName => 'Redundant refinement elimination';
-
- TypeMaskSystem typeSystem;
-
- RedundantRefinementEliminator(this.typeSystem);
-
- void rewrite(FunctionDefinition node) {
- visit(node);
- }
-
- Expression traverseLetPrim(LetPrim node) {
- Expression next = node.body;
- if (node.primitive is Refinement) {
- Refinement refinement = node.primitive;
- Primitive value = refinement.value.definition;
- if (typeSystem.isMorePreciseOrEqual(value.type, refinement.refineType)) {
- refinement
- ..replaceUsesWith(value)
- ..destroy();
- node.remove();
- return next;
- }
- }
- return next;
- }
-}
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/redundant_phi.dart ('k') | pkg/compiler/lib/src/cps_ir/scalar_replacement.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698