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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
9 #include "test/cctest/compiler/graph-builder-tester.h" | 9 #include "test/cctest/compiler/graph-builder-tester.h" |
10 | 10 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 Node* val = r.changer()->GetRepresentationFor(node, kRepBit, kRepTagged); | 131 Node* val = r.changer()->GetRepresentationFor(node, kRepBit, kRepTagged); |
132 r.CheckHeapConstant(val, i == 0 ? r.isolate()->heap()->false_value() | 132 r.CheckHeapConstant(val, i == 0 ? r.isolate()->heap()->false_value() |
133 : r.isolate()->heap()->true_value()); | 133 : r.isolate()->heap()->true_value()); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 TEST(ToTagged_constant) { | 138 TEST(ToTagged_constant) { |
139 RepresentationChangerTester r; | 139 RepresentationChangerTester r; |
140 | 140 |
141 for (size_t i = 0; i < ARRAY_SIZE(double_inputs); i++) { | 141 for (size_t i = 0; i < arraysize(double_inputs); i++) { |
142 Node* n = r.jsgraph()->Float64Constant(double_inputs[i]); | 142 Node* n = r.jsgraph()->Float64Constant(double_inputs[i]); |
143 Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepTagged); | 143 Node* c = r.changer()->GetRepresentationFor(n, kRepFloat64, kRepTagged); |
144 r.CheckNumberConstant(c, double_inputs[i]); | 144 r.CheckNumberConstant(c, double_inputs[i]); |
145 } | 145 } |
146 | 146 |
147 for (size_t i = 0; i < ARRAY_SIZE(int32_inputs); i++) { | 147 for (size_t i = 0; i < arraysize(int32_inputs); i++) { |
148 Node* n = r.jsgraph()->Int32Constant(int32_inputs[i]); | 148 Node* n = r.jsgraph()->Int32Constant(int32_inputs[i]); |
149 Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, | 149 Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeInt32, |
150 kRepTagged); | 150 kRepTagged); |
151 r.CheckNumberConstant(c, static_cast<double>(int32_inputs[i])); | 151 r.CheckNumberConstant(c, static_cast<double>(int32_inputs[i])); |
152 } | 152 } |
153 | 153 |
154 for (size_t i = 0; i < ARRAY_SIZE(uint32_inputs); i++) { | 154 for (size_t i = 0; i < arraysize(uint32_inputs); i++) { |
155 Node* n = r.jsgraph()->Int32Constant(uint32_inputs[i]); | 155 Node* n = r.jsgraph()->Int32Constant(uint32_inputs[i]); |
156 Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, | 156 Node* c = r.changer()->GetRepresentationFor(n, kRepWord32 | kTypeUint32, |
157 kRepTagged); | 157 kRepTagged); |
158 r.CheckNumberConstant(c, static_cast<double>(uint32_inputs[i])); | 158 r.CheckNumberConstant(c, static_cast<double>(uint32_inputs[i])); |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 | 162 |
163 static void CheckChange(IrOpcode::Value expected, MachineTypeUnion from, | 163 static void CheckChange(IrOpcode::Value expected, MachineTypeUnion from, |
164 MachineTypeUnion to) { | 164 MachineTypeUnion to) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 kRepWord32 | kTypeUint32); | 211 kRepWord32 | kTypeUint32); |
212 CheckChange(IrOpcode::kChangeInt32ToFloat64, kRepWord32, kRepFloat64); | 212 CheckChange(IrOpcode::kChangeInt32ToFloat64, kRepWord32, kRepFloat64); |
213 CheckChange(IrOpcode::kChangeFloat64ToInt32, kRepFloat64, kRepWord32); | 213 CheckChange(IrOpcode::kChangeFloat64ToInt32, kRepFloat64, kRepWord32); |
214 } | 214 } |
215 | 215 |
216 | 216 |
217 TEST(Nops) { | 217 TEST(Nops) { |
218 RepresentationChangerTester r; | 218 RepresentationChangerTester r; |
219 | 219 |
220 // X -> X is always a nop for any single representation X. | 220 // X -> X is always a nop for any single representation X. |
221 for (size_t i = 0; i < ARRAY_SIZE(all_reps); i++) { | 221 for (size_t i = 0; i < arraysize(all_reps); i++) { |
222 r.CheckNop(all_reps[i], all_reps[i]); | 222 r.CheckNop(all_reps[i], all_reps[i]); |
223 } | 223 } |
224 | 224 |
225 // 32-bit or 64-bit words can be used as branch conditions (kRepBit). | 225 // 32-bit or 64-bit words can be used as branch conditions (kRepBit). |
226 r.CheckNop(kRepWord32, kRepBit); | 226 r.CheckNop(kRepWord32, kRepBit); |
227 r.CheckNop(kRepWord32, kRepBit | kTypeBool); | 227 r.CheckNop(kRepWord32, kRepBit | kTypeBool); |
228 r.CheckNop(kRepWord64, kRepBit); | 228 r.CheckNop(kRepWord64, kRepBit); |
229 r.CheckNop(kRepWord64, kRepBit | kTypeBool); | 229 r.CheckNop(kRepWord64, kRepBit | kTypeBool); |
230 | 230 |
231 // 32-bit words can be used as smaller word sizes and vice versa, because | 231 // 32-bit words can be used as smaller word sizes and vice versa, because |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 r.CheckTypeError(kRepTagged | kTypeBool, kRepWord64); | 266 r.CheckTypeError(kRepTagged | kTypeBool, kRepWord64); |
267 | 267 |
268 // Word64 / Word32 shouldn't be implicitly converted. | 268 // Word64 / Word32 shouldn't be implicitly converted. |
269 r.CheckTypeError(kRepWord64, kRepWord32); | 269 r.CheckTypeError(kRepWord64, kRepWord32); |
270 r.CheckTypeError(kRepWord32, kRepWord64); | 270 r.CheckTypeError(kRepWord32, kRepWord64); |
271 r.CheckTypeError(kRepWord64, kRepWord32 | kTypeInt32); | 271 r.CheckTypeError(kRepWord64, kRepWord32 | kTypeInt32); |
272 r.CheckTypeError(kRepWord32 | kTypeInt32, kRepWord64); | 272 r.CheckTypeError(kRepWord32 | kTypeInt32, kRepWord64); |
273 r.CheckTypeError(kRepWord64, kRepWord32 | kTypeUint32); | 273 r.CheckTypeError(kRepWord64, kRepWord32 | kTypeUint32); |
274 r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64); | 274 r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64); |
275 | 275 |
276 for (size_t i = 0; i < ARRAY_SIZE(all_reps); i++) { | 276 for (size_t i = 0; i < arraysize(all_reps); i++) { |
277 for (size_t j = 0; j < ARRAY_SIZE(all_reps); j++) { | 277 for (size_t j = 0; j < arraysize(all_reps); j++) { |
278 if (i == j) continue; | 278 if (i == j) continue; |
279 // Only a single from representation is allowed. | 279 // Only a single from representation is allowed. |
280 r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged); | 280 r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged); |
281 } | 281 } |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 | 285 |
286 TEST(CompleteMatrix) { | 286 TEST(CompleteMatrix) { |
287 // TODO(titzer): test all variants in the matrix. | 287 // TODO(titzer): test all variants in the matrix. |
288 // rB | 288 // rB |
289 // tBrB | 289 // tBrB |
290 // tBrT | 290 // tBrT |
291 // rW32 | 291 // rW32 |
292 // tIrW32 | 292 // tIrW32 |
293 // tUrW32 | 293 // tUrW32 |
294 // rW64 | 294 // rW64 |
295 // tIrW64 | 295 // tIrW64 |
296 // tUrW64 | 296 // tUrW64 |
297 // rF64 | 297 // rF64 |
298 // tIrF64 | 298 // tIrF64 |
299 // tUrF64 | 299 // tUrF64 |
300 // tArF64 | 300 // tArF64 |
301 // rT | 301 // rT |
302 // tArT | 302 // tArT |
303 } | 303 } |
OLD | NEW |