| 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.eagerly_load_statics; | 5 library dart2js.cps_ir.eagerly_load_statics; |
| 6 | 6 |
| 7 import '../elements/elements.dart'; |
| 8 import 'cps_fragment.dart'; |
| 7 import 'cps_ir_nodes.dart'; | 9 import 'cps_ir_nodes.dart'; |
| 8 import 'optimizers.dart' show Pass; | 10 import 'optimizers.dart' show Pass; |
| 9 import '../elements/elements.dart'; | |
| 10 import 'cps_fragment.dart'; | |
| 11 | 11 |
| 12 /// Replaces [GetLazyStatic] with [GetStatic] when the static field is known | 12 /// Replaces [GetLazyStatic] with [GetStatic] when the static field is known |
| 13 /// to have been initialized. | 13 /// to have been initialized. |
| 14 /// | 14 /// |
| 15 /// Apart from [GetStatic] generating better code, this improves the side-effect | 15 /// Apart from [GetStatic] generating better code, this improves the side-effect |
| 16 /// analysis in the [GVN] pass, since [GetStatic] has no effects. | 16 /// analysis in the [GVN] pass, since [GetStatic] has no effects. |
| 17 class EagerlyLoadStatics extends TrampolineRecursiveVisitor implements Pass { | 17 class EagerlyLoadStatics extends TrampolineRecursiveVisitor implements Pass { |
| 18 String get passName => 'Eagerly load statics'; | 18 String get passName => 'Eagerly load statics'; |
| 19 | 19 |
| 20 Map<FieldElement, Primitive> initializerFor = <FieldElement, Primitive>{}; | 20 Map<FieldElement, Primitive> initializerFor = <FieldElement, Primitive>{}; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 node.replaceWith(newNode); | 67 node.replaceWith(newNode); |
| 68 } else { | 68 } else { |
| 69 initializerFor[node.element] = node; | 69 initializerFor[node.element] = node; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 void visitSetStatic(SetStatic node) { | 73 void visitSetStatic(SetStatic node) { |
| 74 initializerFor.putIfAbsent(node.element, () => node); | 74 initializerFor.putIfAbsent(node.element, () => node); |
| 75 } | 75 } |
| 76 } | 76 } |
| OLD | NEW |