OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of ssa; | 5 part of ssa; |
6 | 6 |
7 abstract class OptimizationPhase { | 7 abstract class OptimizationPhase { |
8 String get name; | 8 String get name; |
9 void visitGraph(HGraph graph); | 9 void visitGraph(HGraph graph); |
10 } | 10 } |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 } | 391 } |
392 | 392 |
393 HInstruction handleIdentityCheck(HInvokeBinary node) { | 393 HInstruction handleIdentityCheck(HInvokeBinary node) { |
394 HInstruction left = node.left; | 394 HInstruction left = node.left; |
395 HInstruction right = node.right; | 395 HInstruction right = node.right; |
396 HType leftType = types[left]; | 396 HType leftType = types[left]; |
397 HType rightType = types[right]; | 397 HType rightType = types[right]; |
398 assert(!leftType.isConflicting() && !rightType.isConflicting()); | 398 assert(!leftType.isConflicting() && !rightType.isConflicting()); |
399 | 399 |
400 // We don't optimize on numbers to preserve the runtime semantics. | 400 // We don't optimize on numbers to preserve the runtime semantics. |
401 if (!(left.isNumber(types) && right.isNumber(types)) && | 401 if (!(left.isNumberOrNull(types) && right.isNumberOrNull(types)) && |
402 leftType.intersection(rightType, compiler).isConflicting()) { | 402 leftType.intersection(rightType, compiler).isConflicting()) { |
403 return graph.addConstantBool(false, constantSystem); | 403 return graph.addConstantBool(false, constantSystem); |
404 } | 404 } |
405 | 405 |
406 if (left.isConstantBoolean() && right.isBoolean(types)) { | 406 if (left.isConstantBoolean() && right.isBoolean(types)) { |
407 HConstant constant = left; | 407 HConstant constant = left; |
408 if (constant.constant.isTrue()) { | 408 if (constant.constant.isTrue()) { |
409 return right; | 409 return right; |
410 } else { | 410 } else { |
411 return new HNot(right); | 411 return new HNot(right); |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 return result; | 613 return result; |
614 } | 614 } |
615 | 615 |
616 HInstruction visitInvokeDynamicSetter(HInvokeDynamicSetter node) { | 616 HInstruction visitInvokeDynamicSetter(HInvokeDynamicSetter node) { |
617 Element field = | 617 Element field = |
618 findConcreteFieldForDynamicAccess(node.receiver, node.selector); | 618 findConcreteFieldForDynamicAccess(node.receiver, node.selector); |
619 if (field == null || !field.isAssignable()) return node; | 619 if (field == null || !field.isAssignable()) return node; |
620 HInstruction value = node.inputs[1]; | 620 HInstruction value = node.inputs[1]; |
621 if (compiler.enableTypeAssertions) { | 621 if (compiler.enableTypeAssertions) { |
622 HInstruction other = value.convertType( | 622 HInstruction other = value.convertType( |
623 compiler, field, HTypeConversion.CHECKED_MODE_CHECK); | 623 compiler, |
| 624 field.computeType(compiler), |
| 625 HTypeConversion.CHECKED_MODE_CHECK); |
624 if (other != value) { | 626 if (other != value) { |
625 node.block.addBefore(node, other); | 627 node.block.addBefore(node, other); |
626 value = other; | 628 value = other; |
627 } | 629 } |
628 } | 630 } |
629 return new HFieldSet(field, node.inputs[0], value); | 631 return new HFieldSet(field, node.inputs[0], value); |
630 } | 632 } |
631 | 633 |
632 HInstruction visitStringConcat(HStringConcat node) { | 634 HInstruction visitStringConcat(HStringConcat node) { |
633 DartString folded = const LiteralDartString(""); | 635 DartString folded = const LiteralDartString(""); |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 } | 1347 } |
1346 | 1348 |
1347 // For other fields having setters in the generative constructor body, set | 1349 // For other fields having setters in the generative constructor body, set |
1348 // the type to UNKNOWN to avoid relying on the type set in the initializer | 1350 // the type to UNKNOWN to avoid relying on the type set in the initializer |
1349 // list. | 1351 // list. |
1350 allSetters.forEach((Element element) { | 1352 allSetters.forEach((Element element) { |
1351 backend.registerFieldConstructor(element, HType.UNKNOWN); | 1353 backend.registerFieldConstructor(element, HType.UNKNOWN); |
1352 }); | 1354 }); |
1353 } | 1355 } |
1354 } | 1356 } |
OLD | NEW |