| 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 '../common/names.dart'; | 5 import '../common/names.dart'; |
| 6 import '../universe/selector.dart'; | 6 import '../universe/selector.dart'; |
| 7 import 'type_mask_system.dart'; | 7 import 'type_mask_system.dart'; |
| 8 import 'cps_fragment.dart'; | 8 import 'cps_fragment.dart'; |
| 9 | 9 |
| 10 /// Removes null checks that are follwed by another instruction that will | 10 /// Removes null checks that are follwed by another instruction that will |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 /// It has been determined that the null check in [prim] made redundant by | 71 /// It has been determined that the null check in [prim] made redundant by |
| 72 /// [newNullCheck]. Eliminate [prim] if it is not needed any more. | 72 /// [newNullCheck]. Eliminate [prim] if it is not needed any more. |
| 73 void tryEliminateRedundantNullCheck(Primitive prim, Primitive newNullCheck) { | 73 void tryEliminateRedundantNullCheck(Primitive prim, Primitive newNullCheck) { |
| 74 if (prim is NullCheck) { | 74 if (prim is NullCheck) { |
| 75 Primitive value = prim.value.definition; | 75 Primitive value = prim.value.definition; |
| 76 LetPrim let = prim.parent; | 76 LetPrim let = prim.parent; |
| 77 prim..replaceUsesWith(value)..destroy(); | 77 prim..replaceUsesWith(value)..destroy(); |
| 78 let.remove(); | 78 let.remove(); |
| 79 } else if (prim is GetLength || prim is GetField || prim is GetIndex) { | 79 } else if (prim is GetLength || prim is GetField || prim is GetIndex) { |
| 80 if (prim.hasNoEffectiveUses) { | 80 if (prim.hasNoRefinedUses) { |
| 81 destroyRefinementsOfDeadPrimitive(prim); | 81 destroyRefinementsOfDeadPrimitive(prim); |
| 82 LetPrim let = prim.parent; | 82 LetPrim let = prim.parent; |
| 83 prim..destroy(); | 83 prim..destroy(); |
| 84 let.remove(); | 84 let.remove(); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 /// True if [prim] can be moved above a null check. This is safe if [prim] | 89 /// True if [prim] can be moved above a null check. This is safe if [prim] |
| 90 /// cannot throw or have side effects and does not carry any path-sensitive | 90 /// cannot throw or have side effects and does not carry any path-sensitive |
| (...skipping 29 matching lines...) Expand all Loading... |
| 120 void visitLetHandler(LetHandler node) { | 120 void visitLetHandler(LetHandler node) { |
| 121 nullCheckedValue = null; | 121 nullCheckedValue = null; |
| 122 } | 122 } |
| 123 | 123 |
| 124 visitInvokeContinuation(InvokeContinuation node) { | 124 visitInvokeContinuation(InvokeContinuation node) { |
| 125 if (!node.isRecursive) { | 125 if (!node.isRecursive) { |
| 126 nullCheckedValue = nullCheckedValueAt[node.continuation.definition]; | 126 nullCheckedValue = nullCheckedValueAt[node.continuation.definition]; |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 } | 129 } |
| OLD | NEW |