Chromium Code Reviews| 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 interface HVisitor<R> { | 5 interface HVisitor<R> { |
| 6 R visitAdd(HAdd node); | 6 R visitAdd(HAdd node); |
| 7 R visitBitAnd(HBitAnd node); | 7 R visitBitAnd(HBitAnd node); |
| 8 R visitBitNot(HBitNot node); | 8 R visitBitNot(HBitNot node); |
| 9 R visitBitOr(HBitOr node); | 9 R visitBitOr(HBitOr node); |
| 10 R visitBitXor(HBitXor node); | 10 R visitBitXor(HBitXor node); |
| (...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1374 clearAllSideEffects(); | 1374 clearAllSideEffects(); |
| 1375 setUseGvn(); | 1375 setUseGvn(); |
| 1376 } else { | 1376 } else { |
| 1377 setAllSideEffects(); | 1377 setAllSideEffects(); |
| 1378 } | 1378 } |
| 1379 } | 1379 } |
| 1380 | 1380 |
| 1381 bool get builtin() => left.isNumber() && right.isNumber(); | 1381 bool get builtin() => left.isNumber() && right.isNumber(); |
| 1382 | 1382 |
| 1383 HType computeTypeFromInputTypes() { | 1383 HType computeTypeFromInputTypes() { |
| 1384 if (left.isInteger() && right.isInteger()) return left.propagatedType; | 1384 if (left.isInteger() && right.isInteger()) return left.propagatedType; |
|
kasperl
2012/06/22 04:54:36
Maybe replace left.propagatedType with HType.INTEG
| |
| 1385 if (left.isNumber()) { | 1385 if (left.isNumber()) { |
| 1386 if (left.isDouble() || right.isDouble()) return HType.DOUBLE; | 1386 if (left.isDouble() || right.isDouble()) return HType.DOUBLE; |
| 1387 return HType.NUMBER; | 1387 return HType.NUMBER; |
| 1388 } | 1388 } |
| 1389 return HType.UNKNOWN; | 1389 return HType.UNKNOWN; |
| 1390 } | 1390 } |
| 1391 | 1391 |
| 1392 HType computeDesiredTypeForNonTargetInput(HInstruction input) { | 1392 HType computeDesiredTypeForNonTargetInput(HInstruction input) { |
| 1393 // If the desired output type should be an integer we want to get two | 1393 // If the desired output type should be an integer we want to get two |
| 1394 // integers as arguments. | 1394 // integers as arguments. |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1517 bool dataEquals(HInstruction other) => true; | 1517 bool dataEquals(HInstruction other) => true; |
| 1518 } | 1518 } |
| 1519 | 1519 |
| 1520 | 1520 |
| 1521 // TODO(floitsch): Should HBinaryArithmetic really be the super class of | 1521 // TODO(floitsch): Should HBinaryArithmetic really be the super class of |
| 1522 // HBinaryBitOp? | 1522 // HBinaryBitOp? |
| 1523 class HBinaryBitOp extends HBinaryArithmetic { | 1523 class HBinaryBitOp extends HBinaryArithmetic { |
| 1524 HBinaryBitOp(HStatic target, HInstruction left, HInstruction right) | 1524 HBinaryBitOp(HStatic target, HInstruction left, HInstruction right) |
| 1525 : super(target, left, right); | 1525 : super(target, left, right); |
| 1526 | 1526 |
| 1527 bool get builtin() => left.isInteger() && right.isInteger(); | |
| 1528 | |
| 1529 HType computeTypeFromInputTypes() { | 1527 HType computeTypeFromInputTypes() { |
| 1530 // All bitwise operations on primitive types either produce an | 1528 // All bitwise operations on primitive types either produce an |
| 1531 // integer or throw an error. | 1529 // integer or throw an error. |
| 1532 if (left.isPrimitive()) return HType.INTEGER; | 1530 if (left.isPrimitive()) return HType.INTEGER; |
| 1533 return HType.UNKNOWN; | 1531 return HType.UNKNOWN; |
| 1534 } | 1532 } |
| 1535 | 1533 |
| 1536 HType computeDesiredTypeForNonTargetInput(HInstruction input) { | 1534 HType computeDesiredTypeForNonTargetInput(HInstruction input) { |
| 1537 // If the outgoing type should be a number we can get that only if both | 1535 // If the outgoing type should be a number we can get that only if both |
| 1538 // inputs are integers. If we don't know the outgoing type we try to make | 1536 // inputs are integers. If we don't know the outgoing type we try to make |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1553 } | 1551 } |
| 1554 | 1552 |
| 1555 class HShiftLeft extends HBinaryBitOp { | 1553 class HShiftLeft extends HBinaryBitOp { |
| 1556 HShiftLeft(HStatic target, HInstruction left, HInstruction right) | 1554 HShiftLeft(HStatic target, HInstruction left, HInstruction right) |
| 1557 : super(target, left, right); | 1555 : super(target, left, right); |
| 1558 accept(HVisitor visitor) => visitor.visitShiftLeft(this); | 1556 accept(HVisitor visitor) => visitor.visitShiftLeft(this); |
| 1559 | 1557 |
| 1560 // Shift left cannot be mapped to the native operator unless the | 1558 // Shift left cannot be mapped to the native operator unless the |
| 1561 // shift count is guaranteed to be an integer in the [0,31] range. | 1559 // shift count is guaranteed to be an integer in the [0,31] range. |
| 1562 bool get builtin() { | 1560 bool get builtin() { |
| 1563 if (!left.isInteger() || !right.isConstantInteger()) return false; | 1561 if (!left.isInteger() || !right.isConstantInteger()) return false; |
|
kasperl
2012/06/22 04:54:36
Could this be !left.isNumber() now?
| |
| 1564 HConstant rightConstant = right; | 1562 HConstant rightConstant = right; |
| 1565 IntConstant intConstant = rightConstant.constant; | 1563 IntConstant intConstant = rightConstant.constant; |
| 1566 int count = intConstant.value; | 1564 int count = intConstant.value; |
| 1567 return count >= 0 && count <= 31; | 1565 return count >= 0 && count <= 31; |
| 1568 } | 1566 } |
| 1569 | 1567 |
| 1570 ShiftLeftOperation get operation() => const ShiftLeftOperation(); | 1568 ShiftLeftOperation get operation() => const ShiftLeftOperation(); |
| 1571 int typeCode() => 11; | 1569 int typeCode() => 11; |
| 1572 bool typeEquals(other) => other is HShiftLeft; | 1570 bool typeEquals(other) => other is HShiftLeft; |
| 1573 bool dataEquals(HInstruction other) => true; | 1571 bool dataEquals(HInstruction other) => true; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1667 NegateOperation get operation() => const NegateOperation(); | 1665 NegateOperation get operation() => const NegateOperation(); |
| 1668 int typeCode() => 16; | 1666 int typeCode() => 16; |
| 1669 bool typeEquals(other) => other is HNegate; | 1667 bool typeEquals(other) => other is HNegate; |
| 1670 bool dataEquals(HInstruction other) => true; | 1668 bool dataEquals(HInstruction other) => true; |
| 1671 } | 1669 } |
| 1672 | 1670 |
| 1673 class HBitNot extends HInvokeUnary { | 1671 class HBitNot extends HInvokeUnary { |
| 1674 HBitNot(HStatic target, HInstruction input) : super(target, input); | 1672 HBitNot(HStatic target, HInstruction input) : super(target, input); |
| 1675 accept(HVisitor visitor) => visitor.visitBitNot(this); | 1673 accept(HVisitor visitor) => visitor.visitBitNot(this); |
| 1676 | 1674 |
| 1677 bool get builtin() => operand.isInteger(); | 1675 bool get builtin() => operand.isInteger(); |
|
kasperl
2012/06/22 04:54:36
Could we remove this and rely on the implementatio
| |
| 1678 | 1676 |
| 1679 HType computeTypeFromInputTypes() { | 1677 HType computeTypeFromInputTypes() { |
| 1680 // All bitwise operations on primitive types either produce an | 1678 // All bitwise operations on primitive types either produce an |
| 1681 // integer or throw an error. | 1679 // integer or throw an error. |
| 1682 if (operand.isPrimitive()) return HType.INTEGER; | 1680 if (operand.isPrimitive()) return HType.INTEGER; |
| 1683 return HType.UNKNOWN; | 1681 return HType.UNKNOWN; |
| 1684 } | 1682 } |
| 1685 | 1683 |
| 1686 HType computeDesiredTypeForNonTargetInput(HInstruction input) { | 1684 HType computeDesiredTypeForNonTargetInput(HInstruction input) { |
| 1687 // Bit operations only work on integers. If there is no desired output | 1685 // Bit operations only work on integers. If there is no desired output |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2622 HBasicBlock get start() => expression.start; | 2620 HBasicBlock get start() => expression.start; |
| 2623 HBasicBlock get end() { | 2621 HBasicBlock get end() { |
| 2624 // We don't create a switch block if there are no cases. | 2622 // We don't create a switch block if there are no cases. |
| 2625 assert(!statements.isEmpty()); | 2623 assert(!statements.isEmpty()); |
| 2626 return statements.last().end; | 2624 return statements.last().end; |
| 2627 } | 2625 } |
| 2628 | 2626 |
| 2629 bool accept(HStatementInformationVisitor visitor) => | 2627 bool accept(HStatementInformationVisitor visitor) => |
| 2630 visitor.visitSwitchInfo(this); | 2628 visitor.visitSwitchInfo(this); |
| 2631 } | 2629 } |
| OLD | NEW |