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 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 } | 1038 } |
1039 } | 1039 } |
1040 | 1040 |
1041 | 1041 |
1042 static void CheckChangeOf(IrOpcode::Value change, Node* of, Node* node) { | 1042 static void CheckChangeOf(IrOpcode::Value change, Node* of, Node* node) { |
1043 CHECK_EQ(change, node->opcode()); | 1043 CHECK_EQ(change, node->opcode()); |
1044 CHECK_EQ(of, node->InputAt(0)); | 1044 CHECK_EQ(of, node->InputAt(0)); |
1045 } | 1045 } |
1046 | 1046 |
1047 | 1047 |
1048 TEST(LowerNumberToInt32_to_nop) { | |
1049 // NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepTagged | |
1050 TestingGraph t(Type::Signed32()); | |
1051 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); | |
1052 Node* use = t.Use(trunc, kRepTagged); | |
1053 t.Return(use); | |
1054 t.Lower(); | |
1055 CHECK_EQ(t.p0, use->InputAt(0)); | |
1056 } | |
1057 | |
1058 | |
1059 TEST(LowerNumberToInt32_to_ChangeTaggedToFloat64) { | |
1060 // NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepFloat64 | |
1061 TestingGraph t(Type::Signed32()); | |
1062 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); | |
1063 Node* use = t.Use(trunc, kRepFloat64); | |
1064 t.Return(use); | |
1065 t.Lower(); | |
1066 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p0, use->InputAt(0)); | |
1067 } | |
1068 | |
1069 | |
1070 TEST(LowerNumberToInt32_to_ChangeTaggedToInt32) { | 1048 TEST(LowerNumberToInt32_to_ChangeTaggedToInt32) { |
1071 // NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepWord32 | 1049 // NumberToInt32(x: kRepTagged | kTypeInt32) used as kRepWord32 |
1072 TestingGraph t(Type::Signed32()); | 1050 TestingGraph t(Type::Signed32()); |
1073 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); | 1051 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToInt32(), t.p0); |
1074 Node* use = t.Use(trunc, kTypeInt32); | 1052 Node* use = t.Use(trunc, kTypeInt32); |
1075 t.Return(use); | 1053 t.Return(use); |
1076 t.Lower(); | 1054 t.Lower(); |
1077 CheckChangeOf(IrOpcode::kChangeTaggedToInt32, t.p0, use->InputAt(0)); | 1055 CheckChangeOf(IrOpcode::kChangeTaggedToInt32, t.p0, use->InputAt(0)); |
1078 } | 1056 } |
1079 | 1057 |
(...skipping 18 matching lines...) Expand all Loading... |
1098 t.Return(use); | 1076 t.Return(use); |
1099 t.Lower(); | 1077 t.Lower(); |
1100 Node* node = use->InputAt(0); | 1078 Node* node = use->InputAt(0); |
1101 CHECK_EQ(IrOpcode::kTruncateFloat64ToInt32, node->opcode()); | 1079 CHECK_EQ(IrOpcode::kTruncateFloat64ToInt32, node->opcode()); |
1102 Node* of = node->InputAt(0); | 1080 Node* of = node->InputAt(0); |
1103 CHECK_EQ(IrOpcode::kChangeTaggedToFloat64, of->opcode()); | 1081 CHECK_EQ(IrOpcode::kChangeTaggedToFloat64, of->opcode()); |
1104 CHECK_EQ(t.p0, of->InputAt(0)); | 1082 CHECK_EQ(t.p0, of->InputAt(0)); |
1105 } | 1083 } |
1106 | 1084 |
1107 | 1085 |
1108 TEST(LowerNumberToUint32_to_nop) { | |
1109 // NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepTagged | |
1110 TestingGraph t(Type::Unsigned32()); | |
1111 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); | |
1112 Node* use = t.Use(trunc, kRepTagged); | |
1113 t.Return(use); | |
1114 t.Lower(); | |
1115 CHECK_EQ(t.p0, use->InputAt(0)); | |
1116 } | |
1117 | |
1118 | |
1119 TEST(LowerNumberToUint32_to_ChangeTaggedToFloat64) { | |
1120 // NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepWord32 | |
1121 TestingGraph t(Type::Unsigned32()); | |
1122 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); | |
1123 Node* use = t.Use(trunc, kRepFloat64); | |
1124 t.Return(use); | |
1125 t.Lower(); | |
1126 CheckChangeOf(IrOpcode::kChangeTaggedToFloat64, t.p0, use->InputAt(0)); | |
1127 } | |
1128 | |
1129 | |
1130 TEST(LowerNumberToUint32_to_ChangeTaggedToUint32) { | 1086 TEST(LowerNumberToUint32_to_ChangeTaggedToUint32) { |
1131 // NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepWord32 | 1087 // NumberToUint32(x: kRepTagged | kTypeUint32) used as kRepWord32 |
1132 TestingGraph t(Type::Unsigned32()); | 1088 TestingGraph t(Type::Unsigned32()); |
1133 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); | 1089 Node* trunc = t.graph()->NewNode(t.simplified()->NumberToUint32(), t.p0); |
1134 Node* use = t.Use(trunc, kTypeUint32); | 1090 Node* use = t.Use(trunc, kTypeUint32); |
1135 t.Return(use); | 1091 t.Return(use); |
1136 t.Lower(); | 1092 t.Lower(); |
1137 CheckChangeOf(IrOpcode::kChangeTaggedToUint32, t.p0, use->InputAt(0)); | 1093 CheckChangeOf(IrOpcode::kChangeTaggedToUint32, t.p0, use->InputAt(0)); |
1138 } | 1094 } |
1139 | 1095 |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 t.Return(use); | 1971 t.Return(use); |
2016 t.Lower(); | 1972 t.Lower(); |
2017 | 1973 |
2018 CHECK_EQ(d.expected, OpParameter<MachineType>(phi)); | 1974 CHECK_EQ(d.expected, OpParameter<MachineType>(phi)); |
2019 } | 1975 } |
2020 } | 1976 } |
2021 | 1977 |
2022 } // namespace compiler | 1978 } // namespace compiler |
2023 } // namespace internal | 1979 } // namespace internal |
2024 } // namespace v8 | 1980 } // namespace v8 |
OLD | NEW |