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

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

Issue 1743283002: dart2js cps: Use definitions by default, not references. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix long lines and use helpers that we already have Created 4 years, 9 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 library dart2js.cps_ir.update_refinements; 1 library dart2js.cps_ir.update_refinements;
2 2
3 import 'cps_ir_nodes.dart'; 3 import 'cps_ir_nodes.dart';
4 import 'optimizers.dart' show Pass; 4 import 'optimizers.dart' show Pass;
5 import 'type_mask_system.dart'; 5 import 'type_mask_system.dart';
6 import '../world.dart'; 6 import '../world.dart';
7 7
8 /// Updates all references to use the most refined version in scope. 8 /// Updates all references to use the most refined version in scope.
9 /// 9 ///
10 /// [GVN] and [RedundantJoinElimination], and possibly other passes, can create 10 /// [GVN] and [RedundantJoinElimination], and possibly other passes, can create
(...skipping 19 matching lines...) Expand all
30 visit(node); 30 visit(node);
31 } 31 }
32 32
33 Expression traverseLetPrim(LetPrim node) { 33 Expression traverseLetPrim(LetPrim node) {
34 Expression next = node.body; 34 Expression next = node.body;
35 visit(node.primitive); 35 visit(node.primitive);
36 return next; 36 return next;
37 } 37 }
38 38
39 visitReceiverCheck(ReceiverCheck node) { 39 visitReceiverCheck(ReceiverCheck node) {
40 if (refine(node.value)) { 40 if (refine(node.valueRef)) {
41 // Update the type if the input has changed. 41 // Update the type if the input has changed.
42 Primitive value = node.value.definition; 42 Primitive value = node.value;
43 if (value.type.needsNoSuchMethodHandling(node.selector, classWorld)) { 43 if (value.type.needsNoSuchMethodHandling(node.selector, classWorld)) {
44 node.type = typeSystem.receiverTypeFor(node.selector, value.type); 44 node.type = typeSystem.receiverTypeFor(node.selector, value.type);
45 } else { 45 } else {
46 // Check is no longer needed. 46 // Check is no longer needed.
47 node..replaceUsesWith(value)..destroy(); 47 node..replaceUsesWith(value)..destroy();
48 LetPrim letPrim = node.parent; 48 LetPrim letPrim = node.parent;
49 letPrim.remove(); 49 letPrim.remove();
50 return; 50 return;
51 } 51 }
52 } 52 }
(...skipping 16 matching lines...) Expand all
69 Primitive old = refinementFor[value]; 69 Primitive old = refinementFor[value];
70 refinementFor[value] = node; 70 refinementFor[value] = node;
71 pushAction(() { 71 pushAction(() {
72 refinementFor[value] = old; 72 refinementFor[value] = old;
73 }); 73 });
74 } 74 }
75 75
76 visitBoundsCheck(BoundsCheck node) { 76 visitBoundsCheck(BoundsCheck node) {
77 super.visitBoundsCheck(node); 77 super.visitBoundsCheck(node);
78 if (node.hasIntegerCheck && 78 if (node.hasIntegerCheck &&
79 typeSystem.isDefinitelyInt(node.index.definition.type)) { 79 typeSystem.isDefinitelyInt(node.index.type)) {
80 node.checks &= ~BoundsCheck.INTEGER; 80 node.checks &= ~BoundsCheck.INTEGER;
81 } 81 }
82 } 82 }
83 83
84 processReference(Reference ref) { 84 processReference(Reference ref) {
85 refine(ref); 85 refine(ref);
86 } 86 }
87 87
88 bool refine(Reference ref) { 88 bool refine(Reference ref) {
89 Definition def = ref.definition; 89 Definition def = ref.definition;
90 if (def is Primitive) { 90 if (def is Primitive) {
91 Primitive refinement = refinementFor[def.effectiveDefinition]; 91 Primitive refinement = refinementFor[def.effectiveDefinition];
92 if (refinement != null && refinement != ref.definition) { 92 if (refinement != null && refinement != ref.definition) {
93 ref.changeTo(refinement); 93 ref.changeTo(refinement);
94 return true; 94 return true;
95 } 95 }
96 } 96 }
97 return false; 97 return false;
98 } 98 }
99 } 99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698