| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/representation-change.h" | 5 #include "src/compiler/representation-change.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 ? use_info.minus_zero_check() | 667 ? use_info.minus_zero_check() |
| 668 : CheckForMinusZeroMode::kDontCheckForMinusZero); | 668 : CheckForMinusZeroMode::kDontCheckForMinusZero); |
| 669 } else if (output_type->Is(Type::Unsigned32())) { | 669 } else if (output_type->Is(Type::Unsigned32())) { |
| 670 op = machine()->ChangeFloat64ToUint32(); | 670 op = machine()->ChangeFloat64ToUint32(); |
| 671 } else if (use_info.truncation().IsUsedAsWord32()) { | 671 } else if (use_info.truncation().IsUsedAsWord32()) { |
| 672 op = machine()->TruncateFloat64ToWord32(); | 672 op = machine()->TruncateFloat64ToWord32(); |
| 673 } else { | 673 } else { |
| 674 return TypeError(node, output_rep, output_type, | 674 return TypeError(node, output_rep, output_type, |
| 675 MachineRepresentation::kWord32); | 675 MachineRepresentation::kWord32); |
| 676 } | 676 } |
| 677 } else if (output_rep == MachineRepresentation::kTaggedSigned) { | 677 } else if (IsAnyTagged(output_rep)) { |
| 678 if (output_type->Is(Type::Signed32())) { | 678 if (output_rep == MachineRepresentation::kTaggedSigned && |
| 679 output_type->Is(Type::SignedSmall())) { |
| 679 op = simplified()->ChangeTaggedSignedToInt32(); | 680 op = simplified()->ChangeTaggedSignedToInt32(); |
| 680 } else if (use_info.truncation().IsUsedAsWord32()) { | 681 } else if (output_type->Is(Type::Signed32())) { |
| 681 if (use_info.type_check() != TypeCheckKind::kNone) { | |
| 682 op = simplified()->CheckedTruncateTaggedToWord32(); | |
| 683 } else { | |
| 684 op = simplified()->TruncateTaggedToWord32(); | |
| 685 } | |
| 686 } else { | |
| 687 return TypeError(node, output_rep, output_type, | |
| 688 MachineRepresentation::kWord32); | |
| 689 } | |
| 690 } else if (output_rep == MachineRepresentation::kTagged || | |
| 691 output_rep == MachineRepresentation::kTaggedPointer) { | |
| 692 if (output_type->Is(Type::Signed32())) { | |
| 693 op = simplified()->ChangeTaggedToInt32(); | 682 op = simplified()->ChangeTaggedToInt32(); |
| 694 } else if (use_info.type_check() == TypeCheckKind::kSignedSmall) { | 683 } else if (use_info.type_check() == TypeCheckKind::kSignedSmall) { |
| 695 op = simplified()->CheckedTaggedSignedToInt32(); | 684 op = simplified()->CheckedTaggedSignedToInt32(); |
| 696 } else if (use_info.type_check() == TypeCheckKind::kSigned32) { | 685 } else if (use_info.type_check() == TypeCheckKind::kSigned32) { |
| 697 op = simplified()->CheckedTaggedToInt32( | 686 op = simplified()->CheckedTaggedToInt32( |
| 698 output_type->Maybe(Type::MinusZero()) | 687 output_type->Maybe(Type::MinusZero()) |
| 699 ? use_info.minus_zero_check() | 688 ? use_info.minus_zero_check() |
| 700 : CheckForMinusZeroMode::kDontCheckForMinusZero); | 689 : CheckForMinusZeroMode::kDontCheckForMinusZero); |
| 701 } else if (output_type->Is(Type::Unsigned32())) { | 690 } else if (output_type->Is(Type::Unsigned32())) { |
| 702 op = simplified()->ChangeTaggedToUint32(); | 691 op = simplified()->ChangeTaggedToUint32(); |
| 703 } else if (use_info.truncation().IsUsedAsWord32()) { | 692 } else if (use_info.truncation().IsUsedAsWord32()) { |
| 704 if (output_type->Is(Type::NumberOrOddball())) { | 693 if (output_type->Is(Type::NumberOrOddball())) { |
| 705 op = simplified()->TruncateTaggedToWord32(); | 694 op = simplified()->TruncateTaggedToWord32(); |
| 706 } else if (use_info.type_check() != TypeCheckKind::kNone) { | 695 } else if (use_info.type_check() == TypeCheckKind::kNumber) { |
| 707 op = simplified()->CheckedTruncateTaggedToWord32(); | 696 op = simplified()->CheckedTruncateTaggedToWord32( |
| 697 CheckTaggedInputMode::kNumber); |
| 698 } else if (use_info.type_check() == TypeCheckKind::kNumberOrOddball) { |
| 699 op = simplified()->CheckedTruncateTaggedToWord32( |
| 700 CheckTaggedInputMode::kNumberOrOddball); |
| 708 } else { | 701 } else { |
| 709 return TypeError(node, output_rep, output_type, | 702 return TypeError(node, output_rep, output_type, |
| 710 MachineRepresentation::kWord32); | 703 MachineRepresentation::kWord32); |
| 711 } | 704 } |
| 712 } else { | 705 } else { |
| 713 return TypeError(node, output_rep, output_type, | 706 return TypeError(node, output_rep, output_type, |
| 714 MachineRepresentation::kWord32); | 707 MachineRepresentation::kWord32); |
| 715 } | 708 } |
| 716 } else if (output_rep == MachineRepresentation::kWord32) { | 709 } else if (output_rep == MachineRepresentation::kWord32) { |
| 717 // Only the checked case should get here, the non-checked case is | 710 // Only the checked case should get here, the non-checked case is |
| 718 // handled in GetRepresentationFor. | 711 // handled in GetRepresentationFor. |
| 719 if (use_info.type_check() == TypeCheckKind::kSignedSmall || | 712 if (use_info.type_check() == TypeCheckKind::kSignedSmall || |
| 720 use_info.type_check() == TypeCheckKind::kSigned32) { | 713 use_info.type_check() == TypeCheckKind::kSigned32) { |
| 721 if (output_type->Is(Type::Signed32())) { | 714 if (output_type->Is(Type::Signed32())) { |
| 722 return node; | 715 return node; |
| 723 } else if (output_type->Is(Type::Unsigned32())) { | 716 } else if (output_type->Is(Type::Unsigned32())) { |
| 724 op = simplified()->CheckedUint32ToInt32(); | 717 op = simplified()->CheckedUint32ToInt32(); |
| 725 } else { | 718 } else { |
| 726 return TypeError(node, output_rep, output_type, | 719 return TypeError(node, output_rep, output_type, |
| 727 MachineRepresentation::kWord32); | 720 MachineRepresentation::kWord32); |
| 728 } | 721 } |
| 729 } else { | 722 } else if (use_info.type_check() == TypeCheckKind::kNumber || |
| 730 DCHECK_EQ(TypeCheckKind::kNumberOrOddball, use_info.type_check()); | 723 use_info.type_check() == TypeCheckKind::kNumberOrOddball) { |
| 731 return node; | 724 return node; |
| 732 } | 725 } |
| 733 } else if (output_rep == MachineRepresentation::kWord8 || | 726 } else if (output_rep == MachineRepresentation::kWord8 || |
| 734 output_rep == MachineRepresentation::kWord16) { | 727 output_rep == MachineRepresentation::kWord16) { |
| 735 DCHECK(use_info.representation() == MachineRepresentation::kWord32); | 728 DCHECK(use_info.representation() == MachineRepresentation::kWord32); |
| 736 DCHECK(use_info.type_check() == TypeCheckKind::kSignedSmall || | 729 DCHECK(use_info.type_check() == TypeCheckKind::kSignedSmall || |
| 737 use_info.type_check() == TypeCheckKind::kSigned32); | 730 use_info.type_check() == TypeCheckKind::kSigned32); |
| 738 return node; | 731 return node; |
| 739 } | 732 } |
| 740 | 733 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 node); | 1094 node); |
| 1102 } | 1095 } |
| 1103 | 1096 |
| 1104 Node* RepresentationChanger::InsertChangeUint32ToFloat64(Node* node) { | 1097 Node* RepresentationChanger::InsertChangeUint32ToFloat64(Node* node) { |
| 1105 return jsgraph()->graph()->NewNode(machine()->ChangeUint32ToFloat64(), node); | 1098 return jsgraph()->graph()->NewNode(machine()->ChangeUint32ToFloat64(), node); |
| 1106 } | 1099 } |
| 1107 | 1100 |
| 1108 } // namespace compiler | 1101 } // namespace compiler |
| 1109 } // namespace internal | 1102 } // namespace internal |
| 1110 } // namespace v8 | 1103 } // namespace v8 |
| OLD | NEW |