| 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.share_final_fields; | 5 library dart2js.cps_ir.share_final_fields; |
| 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 '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 return next; | 98 return next; |
| 99 } | 99 } |
| 100 | 100 |
| 101 Primitive refinedReceiver = primitive.object.definition; | 101 Primitive refinedReceiver = primitive.object.definition; |
| 102 Primitive receiver = refinedReceiver.effectiveDefinition; | 102 Primitive receiver = refinedReceiver.effectiveDefinition; |
| 103 | 103 |
| 104 // Try to reuse an existing load for the same input. | 104 // Try to reuse an existing load for the same input. |
| 105 var map = fieldValues.putIfAbsent(field, () => <Primitive,Primitive>{}); | 105 var map = fieldValues.putIfAbsent(field, () => <Primitive,Primitive>{}); |
| 106 Primitive existing = map[receiver]; | 106 Primitive existing = map[receiver]; |
| 107 if (existing != null) { | 107 if (existing != null) { |
| 108 existing.substituteFor(primitive); | 108 primitive..replaceUsesWith(existing)..destroy(); |
| 109 primitive.destroy(); | |
| 110 node.remove(); | 109 node.remove(); |
| 111 return next; | 110 return next; |
| 112 } | 111 } |
| 113 | 112 |
| 114 map[receiver] = primitive; | 113 map[receiver] = primitive; |
| 115 | 114 |
| 116 if (primitive.objectIsNotNull) { | 115 if (primitive.objectIsNotNull) { |
| 117 // Determine how far the GetField can be lifted. The outermost loop that | 116 // Determine how far the GetField can be lifted. The outermost loop that |
| 118 // contains the input binding should also contain the load. | 117 // contains the input binding should also contain the load. |
| 119 // Don't move above a refinement guard since that might be unsafe. | 118 // Don't move above a refinement guard since that might be unsafe. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 } | 171 } |
| 173 } | 172 } |
| 174 return c1; | 173 return c1; |
| 175 } | 174 } |
| 176 | 175 |
| 177 int getDepth(Continuation loop) { | 176 int getDepth(Continuation loop) { |
| 178 if (loop == null) return -1; | 177 if (loop == null) return -1; |
| 179 return loopHierarchy.loopDepth[loop]; | 178 return loopHierarchy.loopDepth[loop]; |
| 180 } | 179 } |
| 181 } | 180 } |
| OLD | NEW |