OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/simplified-lowering.h" | 5 #include "src/compiler/simplified-lowering.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
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 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 case IrOpcode::kNumberShiftRightLogical: { | 833 case IrOpcode::kNumberShiftRightLogical: { |
834 VisitBinop(node, UseInfo::TruncatingWord32(), | 834 VisitBinop(node, UseInfo::TruncatingWord32(), |
835 UseInfo::TruncatingWord32(), kMachUint32); | 835 UseInfo::TruncatingWord32(), kMachUint32); |
836 if (lower()) lowering->DoShift(node, lowering->machine()->Word32Shr()); | 836 if (lower()) lowering->DoShift(node, lowering->machine()->Word32Shr()); |
837 break; | 837 break; |
838 } | 838 } |
839 case IrOpcode::kNumberToInt32: { | 839 case IrOpcode::kNumberToInt32: { |
840 MachineTypeUnion use_rep = use & kRepMask; | 840 MachineTypeUnion use_rep = use & kRepMask; |
841 Node* input = node->InputAt(0); | 841 Node* input = node->InputAt(0); |
842 Type* in_upper = NodeProperties::GetType(input); | 842 Type* in_upper = NodeProperties::GetType(input); |
843 MachineTypeUnion in = GetInfo(input)->output; | |
844 if (in_upper->Is(Type::Signed32())) { | 843 if (in_upper->Is(Type::Signed32())) { |
845 // If the input has type int32, pass through representation. | 844 // If the input has type int32, pass through representation. |
846 VisitUnop(node, UseInfoFromRepresentation(use_rep), | 845 VisitUnop(node, UseInfoFromRepresentation(use_rep), |
847 kTypeInt32 | use_rep); | 846 kTypeInt32 | use_rep); |
848 if (lower()) DeferReplacement(node, node->InputAt(0)); | 847 if (lower()) DeferReplacement(node, node->InputAt(0)); |
849 } else if ((in & kTypeMask) == kTypeUint32 || | 848 } else { |
850 in_upper->Is(Type::Unsigned32())) { | |
851 // Just change representation if necessary. | 849 // Just change representation if necessary. |
852 VisitUnop(node, UseInfo::TruncatingWord32(), kTypeInt32 | kRepWord32); | 850 VisitUnop(node, UseInfo::TruncatingWord32(), kMachInt32); |
853 if (lower()) DeferReplacement(node, node->InputAt(0)); | 851 if (lower()) DeferReplacement(node, node->InputAt(0)); |
854 } else if ((in & kTypeMask) == kTypeInt32 || | |
855 (in & kRepMask) == kRepWord32) { | |
856 // Just change representation if necessary. | |
857 VisitUnop(node, UseInfo::TruncatingWord32(), kTypeInt32 | kRepWord32); | |
858 if (lower()) DeferReplacement(node, node->InputAt(0)); | |
859 } else { | |
860 // Require the input in float64 format and perform truncation. | |
861 // TODO(turbofan): avoid a truncation with a smi check. | |
862 VisitUnop(node, UseInfo::Float64TruncatingToWord32(), | |
863 kTypeInt32 | kRepWord32); | |
864 if (lower()) { | |
865 NodeProperties::ChangeOp( | |
866 node, lowering->machine()->TruncateFloat64ToInt32( | |
867 TruncationMode::kJavaScript)); | |
868 } | |
869 } | 852 } |
870 break; | 853 break; |
871 } | 854 } |
872 case IrOpcode::kNumberToUint32: { | 855 case IrOpcode::kNumberToUint32: { |
873 MachineTypeUnion use_rep = use & kRepMask; | 856 MachineTypeUnion use_rep = use & kRepMask; |
874 Node* input = node->InputAt(0); | 857 Node* input = node->InputAt(0); |
875 Type* in_upper = NodeProperties::GetType(input); | 858 Type* in_upper = NodeProperties::GetType(input); |
876 MachineTypeUnion in = GetInfo(input)->output; | |
877 if (in_upper->Is(Type::Unsigned32())) { | 859 if (in_upper->Is(Type::Unsigned32())) { |
878 // If the input has type uint32, pass through representation. | 860 // If the input has type uint32, pass through representation. |
879 VisitUnop(node, UseInfoFromRepresentation(use_rep), | 861 VisitUnop(node, UseInfoFromRepresentation(use_rep), |
880 kTypeUint32 | use_rep); | 862 kTypeUint32 | use_rep); |
881 if (lower()) DeferReplacement(node, node->InputAt(0)); | 863 if (lower()) DeferReplacement(node, node->InputAt(0)); |
882 } else if ((in & kTypeMask) == kTypeInt32 || | 864 } else { |
883 in_upper->Is(Type::Signed32())) { | |
884 // Just change representation if necessary. | 865 // Just change representation if necessary. |
885 VisitUnop(node, UseInfo::TruncatingWord32(), | 866 VisitUnop(node, UseInfo::TruncatingWord32(), kMachUint32); |
886 kTypeUint32 | kRepWord32); | |
887 if (lower()) DeferReplacement(node, node->InputAt(0)); | 867 if (lower()) DeferReplacement(node, node->InputAt(0)); |
888 } else if ((in & kTypeMask) == kTypeUint32 || | |
889 (in & kRepMask) == kRepWord32) { | |
890 // Just change representation if necessary. | |
891 VisitUnop(node, UseInfo::TruncatingWord32(), | |
892 kTypeUint32 | kRepWord32); | |
893 if (lower()) DeferReplacement(node, node->InputAt(0)); | |
894 } else { | |
895 // Require the input in float64 format and perform truncation. | |
896 // TODO(turbofan): avoid a truncation with a smi check. | |
897 VisitUnop(node, UseInfo::Float64TruncatingToWord32(), | |
898 kTypeUint32 | kRepWord32); | |
899 if (lower()) { | |
900 NodeProperties::ChangeOp( | |
901 node, lowering->machine()->TruncateFloat64ToInt32( | |
902 TruncationMode::kJavaScript)); | |
903 } | |
904 } | 868 } |
905 break; | 869 break; |
906 } | 870 } |
907 case IrOpcode::kNumberIsHoleNaN: { | 871 case IrOpcode::kNumberIsHoleNaN: { |
908 VisitUnop(node, UseInfo::Float64(), kMachBool); | 872 VisitUnop(node, UseInfo::Float64(), kMachBool); |
909 if (lower()) { | 873 if (lower()) { |
910 // NumberIsHoleNaN(x) => Word32Equal(Float64ExtractLowWord32(x), | 874 // NumberIsHoleNaN(x) => Word32Equal(Float64ExtractLowWord32(x), |
911 // #HoleNaNLower32) | 875 // #HoleNaNLower32) |
912 node->ReplaceInput(0, | 876 node->ReplaceInput(0, |
913 jsgraph_->graph()->NewNode( | 877 jsgraph_->graph()->NewNode( |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 ReplaceEffectUses(node, comparison); | 1669 ReplaceEffectUses(node, comparison); |
1706 node->ReplaceInput(0, comparison); | 1670 node->ReplaceInput(0, comparison); |
1707 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1671 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1708 node->TrimInputCount(2); | 1672 node->TrimInputCount(2); |
1709 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); | 1673 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); |
1710 } | 1674 } |
1711 | 1675 |
1712 } // namespace compiler | 1676 } // namespace compiler |
1713 } // namespace internal | 1677 } // namespace internal |
1714 } // namespace v8 | 1678 } // namespace v8 |
OLD | NEW |