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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 140 |
141 pushAction(() { | 141 pushAction(() { |
142 var map = fieldValues[field]; | 142 var map = fieldValues[field]; |
143 assert(map[receiver] == primitive); | 143 assert(map[receiver] == primitive); |
144 map.remove(receiver); | 144 map.remove(receiver); |
145 }); | 145 }); |
146 return next; | 146 return next; |
147 } | 147 } |
148 | 148 |
149 bool shouldShareField(FieldElement field) { | 149 bool shouldShareField(FieldElement field) { |
150 return backend.compiler.world.fieldNeverChanges(field); | 150 // TODO(24781): This query is incorrect for fields assigned only via |
| 151 // |
| 152 // super.field = ... |
| 153 // |
| 154 // return backend.compiler.world.fieldNeverChanges(field); |
| 155 |
| 156 // Native fields are getters with side effects (e.g. layout). |
| 157 if (backend.isNative(field)) return false; |
| 158 return field.isFinal || field.isConst; |
151 } | 159 } |
152 | 160 |
153 /// Returns the the innermost loop that effectively encloses both | 161 /// Returns the the innermost loop that effectively encloses both |
154 /// c1 and c2 (or `null` if there is no such loop). | 162 /// c1 and c2 (or `null` if there is no such loop). |
155 Continuation lowestCommonAncestor(Continuation c1, Continuation c2) { | 163 Continuation lowestCommonAncestor(Continuation c1, Continuation c2) { |
156 int d1 = getDepth(c1), d2 = getDepth(c2); | 164 int d1 = getDepth(c1), d2 = getDepth(c2); |
157 while (c1 != c2) { | 165 while (c1 != c2) { |
158 if (d1 <= d2) { | 166 if (d1 <= d2) { |
159 c2 = loopHierarchy.getEnclosingLoop(c2); | 167 c2 = loopHierarchy.getEnclosingLoop(c2); |
160 d2 = getDepth(c2); | 168 d2 = getDepth(c2); |
161 } else { | 169 } else { |
162 c1 = loopHierarchy.getEnclosingLoop(c1); | 170 c1 = loopHierarchy.getEnclosingLoop(c1); |
163 d1 = getDepth(c1); | 171 d1 = getDepth(c1); |
164 } | 172 } |
165 } | 173 } |
166 return c1; | 174 return c1; |
167 } | 175 } |
168 | 176 |
169 int getDepth(Continuation loop) { | 177 int getDepth(Continuation loop) { |
170 if (loop == null) return -1; | 178 if (loop == null) return -1; |
171 return loopHierarchy.loopDepth[loop]; | 179 return loopHierarchy.loopDepth[loop]; |
172 } | 180 } |
173 } | 181 } |
OLD | NEW |