| OLD | NEW |
| 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 dart2js.cps_ir.optimize_interceptors; | 5 library dart2js.cps_ir.optimize_interceptors; |
| 6 | 6 |
| 7 import 'optimizers.dart'; | 7 import 'optimizers.dart'; |
| 8 import 'cps_ir_nodes.dart'; | 8 import 'cps_ir_nodes.dart'; |
| 9 import 'loop_hierarchy.dart'; | 9 import 'loop_hierarchy.dart'; |
| 10 import 'cps_fragment.dart'; | 10 import 'cps_fragment.dart'; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 interceptor..replaceUsesWith(constantPrim)..destroy(); | 116 interceptor..replaceUsesWith(constantPrim)..destroy(); |
| 117 let.remove(); | 117 let.remove(); |
| 118 } else if (interceptor.isAlwaysNullOrIntercepted) { | 118 } else if (interceptor.isAlwaysNullOrIntercepted) { |
| 119 Primitive input = interceptor.input.definition; | 119 Primitive input = interceptor.input.definition; |
| 120 Primitive constantPrim = makeConstantFor(constant, | 120 Primitive constantPrim = makeConstantFor(constant, |
| 121 useSite: let, | 121 useSite: let, |
| 122 type: interceptor.type.nonNullable(), | 122 type: interceptor.type.nonNullable(), |
| 123 sourceInformation: interceptor.sourceInformation); | 123 sourceInformation: interceptor.sourceInformation); |
| 124 CpsFragment cps = new CpsFragment(interceptor.sourceInformation); | 124 CpsFragment cps = new CpsFragment(interceptor.sourceInformation); |
| 125 Parameter param = new Parameter(interceptor.hint); | 125 Parameter param = new Parameter(interceptor.hint); |
| 126 param.type = interceptor.type; |
| 126 Continuation cont = cps.letCont(<Parameter>[param]); | 127 Continuation cont = cps.letCont(<Parameter>[param]); |
| 127 if (interceptor.interceptedClasses.every(hasNoFalsyValues)) { | 128 if (interceptor.interceptedClasses.every(hasNoFalsyValues)) { |
| 128 // If null is the only falsy value, compile as "x && CONST". | 129 // If null is the only falsy value, compile as "x && CONST". |
| 129 cps.ifFalsy(input).invokeContinuation(cont, [input]); | 130 cps.ifFalsy(input).invokeContinuation(cont, [input]); |
| 130 } else { | 131 } else { |
| 131 // If there are other falsy values compile as "x == null ? x : CONST". | 132 // If there are other falsy values compile as "x == null ? x : CONST". |
| 132 Primitive condition = cps.applyBuiltin( | 133 Primitive condition = cps.applyBuiltin( |
| 133 BuiltinOperator.LooseEq, | 134 BuiltinOperator.LooseEq, |
| 134 [input, cps.makeNull()]); | 135 [input, cps.makeNull()]); |
| 135 cps.ifTruthy(condition).invokeContinuation(cont, [input]); | 136 cps.ifTruthy(condition).invokeContinuation(cont, [input]); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 sharedConstantFor.remove(prim.value); | 179 sharedConstantFor.remove(prim.value); |
| 179 }); | 180 }); |
| 180 } | 181 } |
| 181 return next; | 182 return next; |
| 182 } | 183 } |
| 183 | 184 |
| 184 bool shouldShareConstant(Constant constant) { | 185 bool shouldShareConstant(Constant constant) { |
| 185 return constant.value.isInterceptor; | 186 return constant.value.isInterceptor; |
| 186 } | 187 } |
| 187 } | 188 } |
| OLD | NEW |