Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(567)

Unified Diff: lib/compiler/implementation/ssa/optimize.dart

Issue 10539156: Track fields which are known to be always set to integer constants (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comment and addressed initializers Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+ }
+ }
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698