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

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

Issue 10638013: Improve tracking of the type of fields after object construction (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 4a9ba2de33052cbcdaa81bb64dcdf974d0782292..9b8dc6666dce10a2cd1058265fc7567395a6e208 100644
--- a/lib/compiler/implementation/ssa/optimize.dart
+++ b/lib/compiler/implementation/ssa/optimize.dart
@@ -1188,6 +1188,41 @@ class SsaProcessRecompileCandidates
visitDominatorTree(visitee);
}
+ void visitFieldGet(HFieldGet node) {
+ if (!node.element.enclosingElement.isClass()) return;
+ Element field = node.element;
+ HType type = backend.optimisticFieldTypeAfterConstruction(field);
+ switch (compiler.phase) {
+ case Compiler.PHASE_COMPILING:
+ if (!type.isConflicting()) {
+ compiler.enqueuer.codegen.registerRecompilationCandidate(
+ work.element);
+ }
+ break;
+ case Compiler.PHASE_RECOMPILING:
+ if (!type.isConflicting() && !type.isUnknown()) {
+ // Check if optimistic type is based on a setter in the constructor
+ // body.
+ if (backend.hasConstructorBodyFieldSetter(field)) {
+ // There is at least one field setter from the constructor.
+ // TODO(sgjesse): Collect the type for all the field setters so that
+ // this could be a guarenteed type if all field setters have the
+ // same type and there are no invoked setters.
+ node.propagatedType = type;
+ } else {
+ // Optimistic type is based in field initializer list.
+ if (!compiler.codegenWorld.hasFieldSetter(field, compiler) &&
+ !compiler.codegenWorld.hasInvokedSetter(field, compiler)) {
floitsch 2012/06/22 08:18:12 what about implicit null-initializations?
Søren Gjesse 2012/06/22 09:22:36 All the implicit null initialized fields will be i
+ node.guaranteedType = type;
+ } else {
+ node.propagatedType = type;
+ }
+ }
+ }
+ break;
+ }
+ }
+
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.
@@ -1232,4 +1267,5 @@ class SsaProcessRecompileCandidates
}
}
}
+
}
« lib/compiler/implementation/ssa/codegen.dart ('K') | « lib/compiler/implementation/ssa/codegen.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698