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 ab0b54f1d689146ea7508cf6ebb1c50005375343..4eba79907fee2910147e9a50abf5968963a882b8 100644 |
| --- a/lib/compiler/implementation/ssa/optimize.dart |
| +++ b/lib/compiler/implementation/ssa/optimize.dart |
| @@ -36,7 +36,8 @@ class SsaOptimizerTask extends CompilerTask { |
| new SsaDeadPhiEliminator(), |
| new SsaGlobalValueNumberer(compiler), |
| new SsaCodeMotion(), |
| - new SsaDeadCodeEliminator()]; |
| + new SsaDeadCodeEliminator(), |
| + new SsaGatherRecompileCandidates(backend, work)]; |
| runPhases(graph, phases); |
| }); |
| } |
| @@ -1169,3 +1170,52 @@ class SsaTypeConversionInserter extends HBaseVisitor |
| } |
| } |
| } |
| + |
| +class SsaGatherRecompileCandidates |
| + extends HBaseVisitor implements OptimizationPhase { |
| + final String name = "SsaGatherRecompileCandidates"; |
| + final JavaScriptBackend backend; |
| + final WorkItem work; |
| + HGraph graph; |
| + Compiler get compiler() => backend.compiler; |
| + |
| + SsaGatherRecompileCandidates(this.backend, this.work); |
| + |
| + void visitGraph(HGraph visitee) { |
| + graph = visitee; |
| + visitDominatorTree(visitee); |
| + } |
| + |
| + HInstruction visitEquals(HEquals node) { |
| + // Try to optimize the case where a field which is known to always be an |
| + // integer is compared with a constant integer literal. |
| + if (node.left is HFieldGet && |
| + node.right is HConstant && |
| + node.right.isInteger()) { |
| + HFieldGet left = node.left; |
| + HConstant right = node.right; |
| + Type type = left.receiver.propagatedType.computeType(compiler); |
|
floitsch
2012/06/15 15:00:50
move type into the 'if'?
Søren Gjesse
2012/06/18 11:32:17
Done.
|
| + if (left.element != null && right.isInteger()) { |
|
floitsch
2012/06/15 15:00:50
we know already that right is an integer.
Søren Gjesse
2012/06/18 11:32:17
Done.
|
| + switch (compiler.pass) { |
| + case 1: |
| + if (compiler.codegenWorld.couldHaveFieldOnlyIntegerSetters( |
| + type, left.element.name) && |
| + compiler.codegenWorld.couldHaveFieldOnlyIntegerInitializer( |
| + type, left.element.name)) { |
| + compiler.enqueuer.codegen.registerRecompilationCandidate( |
| + work.element); |
| + } |
| + break; |
| + case 2: |
| + if (compiler.codegenWorld.hasFieldOnlyIntegerSetters( |
| + type, left.element.name) && |
| + compiler.codegenWorld.hasFieldOnlyIntegerInitializer( |
| + type, left.element.name)) { |
| + left.guaranteedType = HType.INTEGER; |
| + } |
| + break; |
| + } |
| + } |
| + } |
| + } |
| +} |