| Index: lib/compiler/implementation/ssa/optimize.dart
|
| diff --git a/lib/compiler/implementation/ssa/optimize.dart b/lib/compiler/implementation/ssa/optimize.dart
|
| index 877fc2994ad9675b8feffa7855eaba87e52bbb26..b6157f7116ef32c4fc14165830578b50a3a00dc9 100644
|
| --- a/lib/compiler/implementation/ssa/optimize.dart
|
| +++ b/lib/compiler/implementation/ssa/optimize.dart
|
| @@ -27,11 +27,11 @@ class SsaOptimizerTask extends CompilerTask {
|
| List<OptimizationPhase> phases = <OptimizationPhase>[
|
| // Run trivial constant folding first to optimize
|
| // some patterns useful for type conversion.
|
| - new SsaConstantFolder(backend),
|
| + new SsaConstantFolder(backend, work),
|
| new SsaTypeConversionInserter(compiler),
|
| new SsaTypePropagator(compiler),
|
| new SsaCheckInserter(backend),
|
| - new SsaConstantFolder(backend),
|
| + new SsaConstantFolder(backend, work),
|
| new SsaRedundantPhiEliminator(),
|
| new SsaDeadPhiEliminator(),
|
| new SsaGlobalValueNumberer(compiler),
|
| @@ -90,10 +90,11 @@ class SsaOptimizerTask extends CompilerTask {
|
| class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
|
| final String name = "SsaConstantFolder";
|
| final JavaScriptBackend backend;
|
| + final WorkItem work;
|
| HGraph graph;
|
| Compiler get compiler() => backend.compiler;
|
|
|
| - SsaConstantFolder(this.backend);
|
| + SsaConstantFolder(this.backend, this.work);
|
|
|
| void visitGraph(HGraph visitee) {
|
| graph = visitee;
|
| @@ -578,6 +579,19 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
|
| if (modifiers != null) {
|
| isFinalOrConst = modifiers.isFinal() || modifiers.isConst();
|
| }
|
| + // If field is not final or const but no setters are used then the field
|
| + // might be considered final anyway as it will be either un-initialized
|
| + // or initialized in the constructor initializer list.
|
| + if (!isFinalOrConst && !compiler.world.isSetterUsed(type, node.name)) {
|
| + switch (compiler.pass) {
|
| + case 1:
|
| + compiler.enqueuer.codegen.addToRecompilationCandidates(work.element);
|
| + break;
|
| + case 2:
|
| + isFinalOrConst = true;
|
| + break;
|
| + }
|
| + }
|
| return new HFieldGet(field, node.inputs[0], isFinalOrConst: isFinalOrConst);
|
| }
|
|
|
| @@ -586,6 +600,7 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
|
| if (!receiver.propagatedType.isUseful()) return node;
|
| Type type = receiver.propagatedType.computeType(compiler);
|
| if (type === null) return node;
|
| + compiler.world.setterUsed(type, node.name);
|
| Element field = compiler.world.locateSingleField(type, node.name);
|
| if (field === null) return node;
|
| return new HFieldSet(field, node.inputs[0], node.inputs[1]);
|
|
|