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

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

Issue 1375513002: dart2js cps: Add helpers for common IR manipulation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix type annotation 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.insert_refinements; 5 library cps_ir.optimization.insert_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 import '../types/constants.dart'; 10 import '../types/constants.dart';
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 assert(!cont.isRecursive); 61 assert(!cont.isRecursive);
62 LetCont let = cont.parent; 62 LetCont let = cont.parent;
63 InteriorNode useParent = use.parent; 63 InteriorNode useParent = use.parent;
64 if (useParent == let) return; 64 if (useParent == let) return;
65 if (let.continuations.length > 1) { 65 if (let.continuations.length > 1) {
66 // Create a new LetCont binding only this continuation. 66 // Create a new LetCont binding only this continuation.
67 let.continuations.remove(cont); 67 let.continuations.remove(cont);
68 let = new LetCont(cont, null); 68 let = new LetCont(cont, null);
69 cont.parent = let; 69 cont.parent = let;
70 } else { 70 } else {
71 // Remove LetCont from current position. 71 let.remove(); // Reuse the existing LetCont.
72 InteriorNode letParent = let.parent;
73 letParent.body = let.body;
74 let.body.parent = letParent;
75 } 72 }
76 73 let.insertAbove(use);
77 // Insert LetCont before use.
78 useParent.body = let;
79 let.body = use;
80 use.parent = let;
81 let.parent = useParent;
82 } 74 }
83 75
84 Primitive unfoldInterceptor(Primitive prim) { 76 Primitive unfoldInterceptor(Primitive prim) {
85 return prim is Interceptor ? prim.input.definition : prim; 77 return prim is Interceptor ? prim.input.definition : prim;
86 } 78 }
87 79
88 /// Enqueues [cont] for processing in a context where [refined] is the 80 /// Enqueues [cont] for processing in a context where [refined] is the
89 /// current refinement for its value. 81 /// current refinement for its value.
90 void pushRefinement(Continuation cont, Refinement refined) { 82 void pushRefinement(Continuation cont, Refinement refined) {
91 Primitive value = refined.effectiveDefinition; 83 Primitive value = refined.effectiveDefinition;
92 Primitive currentRefinement = refinementFor[value]; 84 Primitive currentRefinement = refinementFor[value];
93 pushAction(() { 85 pushAction(() {
94 refinementFor[value] = currentRefinement; 86 refinementFor[value] = currentRefinement;
95 if (refined.hasNoUses) { 87 if (refined.hasNoUses) {
96 // Clean up refinements that are not used. 88 // Clean up refinements that are not used.
97 refined.value.unlink(); 89 refined.destroy();
98 } else { 90 } else {
99 cont.body = new LetPrim(refined, cont.body); 91 LetPrim let = new LetPrim(refined);
100 refined.parent = cont.body; 92 refined.parent = let;
101 refined.value.parent = refined; 93 let.insertBelow(cont);
102 } 94 }
103 }); 95 });
104 push(cont); 96 push(cont);
105 pushAction(() { 97 pushAction(() {
106 refinementFor[value] = refined; 98 refinementFor[value] = refined;
107 }); 99 });
108 } 100 }
109 101
110 void visitInvokeMethod(InvokeMethod node) { 102 void visitInvokeMethod(InvokeMethod node) {
111 Continuation cont = node.continuation.definition; 103 Continuation cont = node.continuation.definition;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 cont.firstRef.parent is Branch)) { 215 cont.firstRef.parent is Branch)) {
224 // Do not push the continuation here. 216 // Do not push the continuation here.
225 // visitInvokeMethod and visitBranch will do that. 217 // visitInvokeMethod and visitBranch will do that.
226 } else { 218 } else {
227 push(cont); 219 push(cont);
228 } 220 }
229 } 221 }
230 return node.body; 222 return node.body;
231 } 223 }
232 } 224 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart ('k') | pkg/compiler/lib/src/cps_ir/mutable_ssa.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698