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

Unified Diff: lib/compiler/implementation/ssa/codegen.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: 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/codegen.dart
diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
index 0e9fe182853f588e9b96fc6f46b764fa921629fb..721ad498529857a3a0363d52b8e70662601b199c 100644
--- a/lib/compiler/implementation/ssa/codegen.dart
+++ b/lib/compiler/implementation/ssa/codegen.dart
@@ -1172,7 +1172,35 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
buffer.add(')');
endExpression(JSPrecedence.CALL_PRECEDENCE);
} else {
- visitInvokeStatic(node);
+ if (node.left is HFieldGet && node.right is HConstant) {
ngeoffray 2012/06/14 13:01:21 This is too late in the game. The node.builtin sho
Søren Gjesse 2012/06/15 13:19:59 Removed all this as the SSA optimization phase now
+ HFieldGet left = node.left;
+ HConstant right = node.right;
+ Type type = left.receiver.propagatedType.computeType(compiler);
+ if (left.element != null &&
+ compiler.codegenWorld.hasFieldOnlyIntegerSetters(
+ type, left.element.name)) {
+ switch (compiler.pass) {
+ case 1:
+ visitInvokeStatic(node);
+ break;
+ case 2:
+ if (right.isConstantInteger()) {
+ buffer.add('(');
+ use(node.left, JSPrecedence.EQUALITY_PRECEDENCE);
+ buffer.add(' === ');
+ use(node.right, JSPrecedence.RELATIONAL_PRECEDENCE);
+ buffer.add(')');
+ } else {
+ visitInvokeStatic(node);
+ }
+ break;
+ }
+ } else {
+ visitInvokeStatic(node);
+ }
+ } else {
+ visitInvokeStatic(node);
+ }
}
}
@@ -1728,7 +1756,12 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
buffer.add(name);
Type type = node.receiver.propagatedType.computeType(compiler);
if (type != null) {
- world.registerFieldSetter(node.element.name, type);
+ Type valueType = node.value.propagatedType.computeType(compiler);
+ if (valueType.toString() == "int") {
ngeoffray 2012/06/14 13:01:21 You should change that to node.value.isInteger()
Søren Gjesse 2012/06/15 13:19:59 Done.
+ world.registerFieldSetter(node.element.name, type, true);
+ } else {
+ world.registerFieldSetter(node.element.name, type, false);
+ }
}
} else {
declareInstruction(node.receiver);

Powered by Google App Engine
This is Rietveld 408576698