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

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

Issue 1380513002: Revert "dart2js cps: Add helpers for common IR manipulation." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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 cps_ir.optimization.remove_refinements; 5 library cps_ir.optimization.remove_refinements;
6 6
7 import 'optimizers.dart' show Pass; 7 import 'optimizers.dart' show Pass;
8 import 'shrinking_reductions.dart' show ParentVisitor; 8 import 'shrinking_reductions.dart' show ParentVisitor;
9 import 'cps_ir_nodes.dart'; 9 import 'cps_ir_nodes.dart';
10 10
11 /// Removes all [Refinement] nodes from the IR. 11 /// Removes all [Refinement] nodes from the IR.
12 /// 12 ///
13 /// This simplifies subsequent passes that don't rely on path-sensitive 13 /// This simplifies subsequent passes that don't rely on path-sensitive
14 /// type information but depend on equality between primitives. 14 /// type information but depend on equality between primitives.
15 class RemoveRefinements extends RecursiveVisitor implements Pass { 15 class RemoveRefinements extends RecursiveVisitor implements Pass {
16 String get passName => 'Remove refinement nodes'; 16 String get passName => 'Remove refinement nodes';
17 17
18 void rewrite(FunctionDefinition node) { 18 void rewrite(FunctionDefinition node) {
19 new ParentVisitor().visit(node); 19 new ParentVisitor().visit(node);
20 visit(node); 20 visit(node);
21 } 21 }
22 22
23 @override 23 @override
24 Expression traverseLetPrim(LetPrim node) { 24 Expression traverseLetPrim(LetPrim node) {
25 Expression next = node.body;
26 if (node.primitive is Refinement) { 25 if (node.primitive is Refinement) {
27 Refinement refinement = node.primitive; 26 Refinement refinement = node.primitive;
28 refinement.value.definition.substituteFor(refinement); 27 refinement.value.definition.substituteFor(refinement);
29 refinement.destroy(); 28 refinement.value.unlink();
30 node.remove(); 29 InteriorNode parent = node.parent;
30 parent.body = node.body;
31 node.body.parent = parent;
31 } 32 }
32 return next; 33 return node.body;
33 } 34 }
34 } 35 }
OLDNEW
« 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