OLD | NEW |
1 library dart2js.cps_ir.backward_null_check_remover; | 1 library dart2js.cps_ir.backward_null_check_remover; |
2 | 2 |
3 import 'cps_ir_nodes.dart'; | 3 import 'cps_ir_nodes.dart'; |
4 import 'optimizers.dart'; | 4 import 'optimizers.dart'; |
5 import 'type_mask_system.dart'; | 5 import 'type_mask_system.dart'; |
6 import 'cps_fragment.dart'; | 6 import 'cps_fragment.dart'; |
7 | 7 |
8 /// Removes null checks that are follwed by another instruction that will | 8 /// Removes null checks that are follwed by another instruction that will |
9 /// perform the same check. | 9 /// perform the same check. |
10 /// | 10 /// |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 64 } |
65 return null; | 65 return null; |
66 } | 66 } |
67 | 67 |
68 /// It has been determined that the null check in [prim] made redundant by | 68 /// It has been determined that the null check in [prim] made redundant by |
69 /// [newNullCheck]. Eliminate [prim] if it is not needed any more. | 69 /// [newNullCheck]. Eliminate [prim] if it is not needed any more. |
70 void tryEliminateRedundantNullCheck(Primitive prim, Primitive newNullCheck) { | 70 void tryEliminateRedundantNullCheck(Primitive prim, Primitive newNullCheck) { |
71 if (prim is ReceiverCheck && prim.isNullCheck) { | 71 if (prim is ReceiverCheck && prim.isNullCheck) { |
72 Primitive value = prim.value; | 72 Primitive value = prim.value; |
73 LetPrim let = prim.parent; | 73 LetPrim let = prim.parent; |
74 prim..replaceUsesWith(value)..destroy(); | 74 prim |
| 75 ..replaceUsesWith(value) |
| 76 ..destroy(); |
75 let.remove(); | 77 let.remove(); |
76 } else if (prim is GetLength || prim is GetField || prim is GetIndex) { | 78 } else if (prim is GetLength || prim is GetField || prim is GetIndex) { |
77 if (prim.hasNoRefinedUses) { | 79 if (prim.hasNoRefinedUses) { |
78 destroyRefinementsOfDeadPrimitive(prim); | 80 destroyRefinementsOfDeadPrimitive(prim); |
79 LetPrim let = prim.parent; | 81 LetPrim let = prim.parent; |
80 prim..destroy(); | 82 prim..destroy(); |
81 let.remove(); | 83 let.remove(); |
82 } | 84 } |
83 } | 85 } |
84 } | 86 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 void visitLetHandler(LetHandler node) { | 119 void visitLetHandler(LetHandler node) { |
118 nullCheckedValue = null; | 120 nullCheckedValue = null; |
119 } | 121 } |
120 | 122 |
121 visitInvokeContinuation(InvokeContinuation node) { | 123 visitInvokeContinuation(InvokeContinuation node) { |
122 if (!node.isRecursive) { | 124 if (!node.isRecursive) { |
123 nullCheckedValue = nullCheckedValueAt[node.continuation]; | 125 nullCheckedValue = nullCheckedValueAt[node.continuation]; |
124 } | 126 } |
125 } | 127 } |
126 } | 128 } |
OLD | NEW |