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 93ff1af2d086ae10a4dd663a9c4ce9d4937dccb5..4d97c66e09ef193b4040ae8f771c60651f12d25e 100644 |
| --- a/lib/compiler/implementation/ssa/optimize.dart |
| +++ b/lib/compiler/implementation/ssa/optimize.dart |
| @@ -1254,4 +1254,59 @@ class SsaProcessRecompileCandidates |
| } |
| } |
| + HInstruction visitBinaryArithmetic(HBinaryArithmetic node) { |
| + // Determine if one of the operands is an HFieldGet. |
| + HFieldGet field; |
| + HInstruction other; |
|
Søren Gjesse
2012/07/06 08:38:43
Maybe we can also do like this field/other stuff i
Mads Ager (google)
2012/07/06 08:42:18
Yes, let me do that as well. I will pull the confl
|
| + if (node.left is HFieldGet) { |
| + field = node.left; |
| + other = node.right; |
| + } else if (node.right is HFieldGet) { |
| + field = node.right; |
| + other = node.left; |
| + } |
| + // Check that the other operand is a number and that we have type |
| + // information for the field get. |
| + if (other != null && |
| + other is HConstant && |
| + other.isNumber() && |
| + field.element != null && |
| + field.element.enclosingElement.isClass()) { |
| + // If we have type information for the field and it contains |
| + // NUMBER, we mark for recompilation. |
| + Element fieldElement = field.element; |
| + HType fieldSettersType = backend.fieldSettersTypeSoFar(fieldElement); |
| + HType initializersType = backend.typeFromInitializersSoFar(fieldElement); |
| + HType fieldType = fieldSettersType.union(initializersType); |
| + HType type = HType.NUMBER.union(fieldType); |
| + if (!type.isConflicting()) { |
| + switch (compiler.phase) { |
| + case Compiler.PHASE_COMPILING: |
| + compiler.enqueuer.codegen.registerRecompilationCandidate( |
| + work.element); |
| + break; |
| + case Compiler.PHASE_RECOMPILING: |
| + if (compiler.codegenWorld.hasInvokedSetter(fieldElement, |
| + compiler)) { |
| + // If there are invoked setters we don't know for sure |
| + // that the field will hold a value of the calculated |
| + // type, but the fact that the class itself sticks to |
| + // this type for the field is still a strong signal |
| + // indicating the expected type of the field. |
| + field.propagatedType = type; |
| + graph.highTypeLikelyhood = true; |
| + } else { |
| + // If there are no invoked setters we know the type of |
| + // this field for sure. |
| + field.guaranteedType = type; |
| + print(node); |
| + } |
| + break; |
| + default: |
| + assert(false); |
| + break; |
| + } |
| + } |
| + } |
| + } |
| } |