| Index: pkg/compiler/lib/src/cps_ir/eagerly_load_statics.dart
|
| diff --git a/pkg/compiler/lib/src/cps_ir/eagerly_load_statics.dart b/pkg/compiler/lib/src/cps_ir/eagerly_load_statics.dart
|
| index 6f733e31f02e5df72ad70f907d39342804537361..e03f9cad33bc96a02b3daaa241c94945cdb25fd9 100644
|
| --- a/pkg/compiler/lib/src/cps_ir/eagerly_load_statics.dart
|
| +++ b/pkg/compiler/lib/src/cps_ir/eagerly_load_statics.dart
|
| @@ -7,6 +7,7 @@ library dart2js.cps_ir.eagerly_load_statics;
|
| import 'cps_ir_nodes.dart';
|
| import 'optimizers.dart' show Pass;
|
| import '../elements/elements.dart';
|
| +import 'cps_fragment.dart';
|
|
|
| /// Replaces [GetLazyStatic] with [GetStatic] when the static field is known
|
| /// to have been initialized.
|
| @@ -30,6 +31,12 @@ class EagerlyLoadStatics extends TrampolineRecursiveVisitor implements Pass {
|
| visit(node.body);
|
| }
|
|
|
| + Expression traverseLetPrim(LetPrim node) {
|
| + Expression next = node.body;
|
| + visit(node.primitive);
|
| + return next;
|
| + }
|
| +
|
| Expression traverseLetCont(LetCont node) {
|
| for (Continuation cont in node.continuations) {
|
| initializersAt[cont] = cloneFieldMap(initializerFor);
|
| @@ -51,10 +58,13 @@ class EagerlyLoadStatics extends TrampolineRecursiveVisitor implements Pass {
|
|
|
| void visitGetLazyStatic(GetLazyStatic node) {
|
| Primitive initializer = initializerFor[node.element];
|
| - if (initializer != null) {
|
| - GetStatic newNode = new GetStatic.witnessed(node.element, initializer,
|
| - node.sourceInformation);
|
| - newNode.type = node.type;
|
| + if (initializer is GetLazyStatic && initializer.isFinal) {
|
| + // No reason to create a GetStatic when the field is final.
|
| + node.replaceWithFragment(new CpsFragment(), initializer);
|
| + } else if (initializer != null) {
|
| + GetStatic newNode = new GetStatic.witnessed(node.element,
|
| + initializer, sourceInformation: node.sourceInformation)
|
| + ..type = node.type;
|
| node.replaceWith(newNode);
|
| } else {
|
| initializerFor[node.element] = node;
|
|
|