Chromium Code Reviews| Index: lib/compiler/implementation/ssa/optimize.dart |
| diff --git a/lib/compiler/implementation/ssa/optimize.dart b/lib/compiler/implementation/ssa/optimize.dart |
| index 9d2412b87b75e7ad39b3a502548b30c9142567b0..e2eadc20d72c7a2234eab3830fe1d9a0f6fd0661 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; |
| @@ -580,6 +581,21 @@ 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 |
|
floitsch
2012/06/13 12:51:10
move this comment down to the "isFinalOrConst = tr
Søren Gjesse
2012/06/14 06:37:10
Done.
|
| + // might be considered final anyway as it will be either un-initialized |
| + // or initialized in the constructor initializer list. |
| + if (!isFinalOrConst && |
| + !compiler.codegenWorld.hasInvokedSetter(field, compiler) && |
|
ngeoffray
2012/06/13 22:02:26
Why don't you just use the resolverWorld here?
Søren Gjesse
2012/06/14 06:37:10
Because I don't know how. If that is possible we s
|
| + !compiler.codegenWorld.hasFieldSetter(field, compiler)) { |
| + 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); |
| } |