OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/wasm/asm-types.h" | 5 #include "src/wasm/asm-types.h" |
6 | 6 |
7 #include <unordered_map> | 7 #include <unordered_map> |
8 #include <unordered_set> | 8 #include <unordered_set> |
9 | 9 |
10 #include "src/base/macros.h" | 10 #include "src/base/macros.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 TEST_F(AsmTypeTest, ValidateBits) { | 142 TEST_F(AsmTypeTest, ValidateBits) { |
143 // Generic validation tests for the bits in the type system's type | 143 // Generic validation tests for the bits in the type system's type |
144 // definitions. | 144 // definitions. |
145 | 145 |
146 std::unordered_set<Type*> seen_types; | 146 std::unordered_set<Type*> seen_types; |
147 std::unordered_set<uint32_t> seen_numbers; | 147 std::unordered_set<uint32_t> seen_numbers; |
148 uint32_t total_types = 0; | 148 uint32_t total_types = 0; |
149 #define V(CamelName, string_name, number, parent_types) \ | 149 #define V(CamelName, string_name, number, parent_types) \ |
150 do { \ | 150 do { \ |
151 ++total_types; \ | 151 ++total_types; \ |
| 152 if (AsmValueTypeParents::CamelName != 0) { \ |
| 153 EXPECT_NE(0, ParentsOf(AsmType::CamelName()).size()) << #CamelName; \ |
| 154 } \ |
152 seen_types.insert(Type::CamelName()); \ | 155 seen_types.insert(Type::CamelName()); \ |
153 seen_numbers.insert(number); \ | 156 seen_numbers.insert(number); \ |
154 /* Every ASM type must have a valid number. */ \ | 157 /* Every ASM type must have a valid number. */ \ |
155 EXPECT_NE(0, number) << Type::CamelName()->Name(); \ | 158 EXPECT_NE(0, number) << Type::CamelName()->Name(); \ |
156 /* Inheritance cycles - unlikely, but we're paranoid and check for it */ \ | 159 /* Inheritance cycles - unlikely, but we're paranoid and check for it */ \ |
157 /* anyways.*/ \ | 160 /* anyways.*/ \ |
158 EXPECT_EQ(0, (1 << (number)) & AsmValueTypeParents::CamelName); \ | 161 EXPECT_EQ(0, (1 << (number)) & AsmValueTypeParents::CamelName); \ |
159 } while (0); | 162 } while (0); |
160 FOR_EACH_ASM_VALUE_TYPE_LIST(V) | 163 FOR_EACH_ASM_VALUE_TYPE_LIST(V) |
161 #undef V | 164 #undef V |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 #undef V | 212 #undef V |
210 | 213 |
211 EXPECT_THAT(Function(Type::Int)(Type::Double, Type::Float)->Name(), | 214 EXPECT_THAT(Function(Type::Int)(Type::Double, Type::Float)->Name(), |
212 StrEq("(double, float) -> int")); | 215 StrEq("(double, float) -> int")); |
213 | 216 |
214 EXPECT_THAT(Overload(Function(Type::Int)(Type::Double, Type::Float), | 217 EXPECT_THAT(Overload(Function(Type::Int)(Type::Double, Type::Float), |
215 Function(Type::Int)(Type::Int)) | 218 Function(Type::Int)(Type::Int)) |
216 ->Name(), | 219 ->Name(), |
217 StrEq("(double, float) -> int /\\ (int) -> int")); | 220 StrEq("(double, float) -> int /\\ (int) -> int")); |
218 | 221 |
219 EXPECT_THAT(Type::FroundType(zone(), Type::Int())->Name(), | 222 EXPECT_THAT(Type::FroundType(zone())->Name(), StrEq("fround")); |
220 StrEq("(int) -> float")); | |
221 EXPECT_THAT(Type::FroundType(zone(), Type::Floatish())->Name(), | |
222 StrEq("(floatish) -> float")); | |
223 EXPECT_THAT(Type::FroundType(zone(), Type::DoubleQ())->Name(), | |
224 StrEq("(double?) -> float")); | |
225 | 223 |
226 EXPECT_THAT(Type::MinMaxType(zone(), Type::Int())->Name(), | 224 EXPECT_THAT(Type::MinMaxType(zone(), Type::Signed(), Type::Int())->Name(), |
227 StrEq("(int, int...) -> int")); | 225 StrEq("(int, int...) -> signed")); |
228 EXPECT_THAT(Type::MinMaxType(zone(), Type::Floatish())->Name(), | 226 EXPECT_THAT(Type::MinMaxType(zone(), Type::Float(), Type::Floatish())->Name(), |
229 StrEq("(floatish, floatish...) -> floatish")); | 227 StrEq("(floatish, floatish...) -> float")); |
230 EXPECT_THAT(Type::MinMaxType(zone(), Type::DoubleQ())->Name(), | 228 EXPECT_THAT(Type::MinMaxType(zone(), Type::Double(), Type::Double())->Name(), |
231 StrEq("(double?, double?...) -> double?")); | 229 StrEq("(double, double...) -> double")); |
232 } | 230 } |
233 | 231 |
234 TEST_F(AsmTypeTest, IsExactly) { | 232 TEST_F(AsmTypeTest, IsExactly) { |
235 Type* test_types[] = { | 233 Type* test_types[] = { |
236 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 234 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
237 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 235 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
238 #undef CREATE | 236 #undef CREATE |
239 Function(Type::Int)(Type::Double), | 237 Function(Type::Int)(Type::Double), |
240 Function(Type::Int)(Type::DoubleQ), | 238 Function(Type::Int)(Type::DoubleQ), |
241 Overload(Function(Type::Int)(Type::Double)), | 239 Overload(Function(Type::Int)(Type::Double)), |
242 Function(Type::Int)(Type::Int, Type::Int), | 240 Function(Type::Int)(Type::Int, Type::Int), |
243 Type::MinMaxType(zone(), Type::Int()), Function(Type::Int)(Type::Float), | 241 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
244 Type::FroundType(zone(), Type::Int()), | 242 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
245 }; | 243 }; |
246 | 244 |
247 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | 245 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { |
248 for (size_t jj = 0; jj < arraysize(test_types); ++jj) { | 246 for (size_t jj = 0; jj < arraysize(test_types); ++jj) { |
249 EXPECT_EQ(ii == jj, test_types[ii]->IsExactly(test_types[jj])) | 247 EXPECT_EQ(ii == jj, test_types[ii]->IsExactly(test_types[jj])) |
250 << test_types[ii]->Name() | 248 << test_types[ii]->Name() |
251 << ((ii == jj) ? " is not exactly " : " is exactly ") | 249 << ((ii == jj) ? " is not exactly " : " is exactly ") |
252 << test_types[jj]->Name(); | 250 << test_types[jj]->Name(); |
253 } | 251 } |
254 } | 252 } |
255 } | 253 } |
256 | 254 |
257 TEST_F(AsmTypeTest, IsA) { | 255 TEST_F(AsmTypeTest, IsA) { |
258 Type* test_types[] = { | 256 Type* test_types[] = { |
259 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 257 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
260 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 258 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
261 #undef CREATE | 259 #undef CREATE |
262 Function(Type::Int)(Type::Double), | 260 Function(Type::Int)(Type::Double), |
263 Function(Type::Int)(Type::DoubleQ), | 261 Function(Type::Int)(Type::DoubleQ), |
264 Overload(Function(Type::Int)(Type::Double)), | 262 Overload(Function(Type::Int)(Type::Double)), |
265 Function(Type::Int)(Type::Int, Type::Int), | 263 Function(Type::Int)(Type::Int, Type::Int), |
266 Type::MinMaxType(zone(), Type::Int()), Function(Type::Int)(Type::Float), | 264 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
267 Type::FroundType(zone(), Type::Int()), | 265 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
268 }; | 266 }; |
269 | 267 |
270 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | 268 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { |
271 for (size_t jj = 0; jj < arraysize(test_types); ++jj) { | 269 for (size_t jj = 0; jj < arraysize(test_types); ++jj) { |
272 const bool Expected = | 270 const bool Expected = |
273 (ii == jj) || ParentsOf(test_types[ii]).count(test_types[jj]) != 0; | 271 (ii == jj) || ParentsOf(test_types[ii]).count(test_types[jj]) != 0; |
274 EXPECT_EQ(Expected, test_types[ii]->IsA(test_types[jj])) | 272 EXPECT_EQ(Expected, test_types[ii]->IsA(test_types[jj])) |
275 << test_types[ii]->Name() << (Expected ? " is not a " : " is a ") | 273 << test_types[ii]->Name() << (Expected ? " is not a " : " is a ") |
276 << test_types[jj]->Name(); | 274 << test_types[jj]->Name(); |
277 } | 275 } |
278 } | 276 } |
279 } | 277 } |
280 | 278 |
281 TEST_F(AsmTypeTest, ValidateCall) { | 279 TEST_F(AsmTypeTest, ValidateCall) { |
282 auto* min_max_int = Type::MinMaxType(zone(), Type::Int()); | 280 auto* min_max_int = Type::MinMaxType(zone(), Type::Signed(), Type::Int()); |
283 auto* i2i = Function(Type::Int)(Type::Int); | 281 auto* i2s = Function(Type::Signed)(Type::Int); |
284 auto* ii2i = Function(Type::Int)(Type::Int, Type::Int); | 282 auto* ii2s = Function(Type::Signed)(Type::Int, Type::Int); |
285 auto* iii2i = Function(Type::Int)(Type::Int, Type::Int, Type::Int); | 283 auto* iii2s = Function(Type::Signed)(Type::Int, Type::Int, Type::Int); |
286 auto* iiii2i = | 284 auto* iiii2s = |
287 Function(Type::Int)(Type::Int, Type::Int, Type::Int, Type::Int); | 285 Function(Type::Signed)(Type::Int, Type::Int, Type::Int, Type::Int); |
288 | 286 |
289 EXPECT_EQ(Type::Int(), | 287 EXPECT_EQ(Type::Signed(), |
290 min_max_int->AsCallableType()->ValidateCall(min_max_int)); | 288 min_max_int->AsCallableType()->ValidateCall(min_max_int)); |
291 EXPECT_EQ(Type::Int(), min_max_int->AsCallableType()->ValidateCall(ii2i)); | 289 EXPECT_EQ(Type::Signed(), min_max_int->AsCallableType()->ValidateCall(ii2s)); |
292 EXPECT_EQ(Type::Int(), min_max_int->AsCallableType()->ValidateCall(iii2i)); | 290 EXPECT_EQ(Type::Signed(), min_max_int->AsCallableType()->ValidateCall(iii2s)); |
293 EXPECT_EQ(Type::Int(), min_max_int->AsCallableType()->ValidateCall(iiii2i)); | 291 EXPECT_EQ(Type::Signed(), |
294 EXPECT_EQ(Type::None(), min_max_int->AsCallableType()->ValidateCall(i2i)); | 292 min_max_int->AsCallableType()->ValidateCall(iiii2s)); |
| 293 EXPECT_EQ(Type::None(), min_max_int->AsCallableType()->ValidateCall(i2s)); |
295 | 294 |
296 auto* min_max_double = Type::MinMaxType(zone(), Type::Double()); | 295 auto* min_max_double = |
| 296 Type::MinMaxType(zone(), Type::Double(), Type::Double()); |
297 auto* d2d = Function(Type::Double)(Type::Double); | 297 auto* d2d = Function(Type::Double)(Type::Double); |
298 auto* dd2d = Function(Type::Double)(Type::Double, Type::Double); | 298 auto* dd2d = Function(Type::Double)(Type::Double, Type::Double); |
299 auto* ddd2d = | 299 auto* ddd2d = |
300 Function(Type::Double)(Type::Double, Type::Double, Type::Double); | 300 Function(Type::Double)(Type::Double, Type::Double, Type::Double); |
301 auto* dddd2d = Function(Type::Double)(Type::Double, Type::Double, | 301 auto* dddd2d = Function(Type::Double)(Type::Double, Type::Double, |
302 Type::Double, Type::Double); | 302 Type::Double, Type::Double); |
303 EXPECT_EQ(Type::Double(), | 303 EXPECT_EQ(Type::Double(), |
304 min_max_double->AsCallableType()->ValidateCall(min_max_double)); | 304 min_max_double->AsCallableType()->ValidateCall(min_max_double)); |
305 EXPECT_EQ(Type::Double(), | 305 EXPECT_EQ(Type::Double(), |
306 min_max_double->AsCallableType()->ValidateCall(dd2d)); | 306 min_max_double->AsCallableType()->ValidateCall(dd2d)); |
307 EXPECT_EQ(Type::Double(), | 307 EXPECT_EQ(Type::Double(), |
308 min_max_double->AsCallableType()->ValidateCall(ddd2d)); | 308 min_max_double->AsCallableType()->ValidateCall(ddd2d)); |
309 EXPECT_EQ(Type::Double(), | 309 EXPECT_EQ(Type::Double(), |
310 min_max_double->AsCallableType()->ValidateCall(dddd2d)); | 310 min_max_double->AsCallableType()->ValidateCall(dddd2d)); |
311 EXPECT_EQ(Type::None(), min_max_double->AsCallableType()->ValidateCall(d2d)); | 311 EXPECT_EQ(Type::None(), min_max_double->AsCallableType()->ValidateCall(d2d)); |
312 | 312 |
313 auto* min_max = Overload(min_max_int, min_max_double); | 313 auto* min_max = Overload(min_max_int, min_max_double); |
314 EXPECT_EQ(Type::None(), min_max->AsCallableType()->ValidateCall(min_max)); | 314 EXPECT_EQ(Type::None(), min_max->AsCallableType()->ValidateCall(min_max)); |
315 EXPECT_EQ(Type::None(), min_max->AsCallableType()->ValidateCall(i2i)); | 315 EXPECT_EQ(Type::None(), min_max->AsCallableType()->ValidateCall(i2s)); |
316 EXPECT_EQ(Type::None(), min_max->AsCallableType()->ValidateCall(d2d)); | 316 EXPECT_EQ(Type::None(), min_max->AsCallableType()->ValidateCall(d2d)); |
317 EXPECT_EQ(Type::Int(), min_max->AsCallableType()->ValidateCall(min_max_int)); | 317 EXPECT_EQ(Type::Signed(), |
318 EXPECT_EQ(Type::Int(), min_max->AsCallableType()->ValidateCall(ii2i)); | 318 min_max->AsCallableType()->ValidateCall(min_max_int)); |
319 EXPECT_EQ(Type::Int(), min_max->AsCallableType()->ValidateCall(iii2i)); | 319 EXPECT_EQ(Type::Signed(), min_max->AsCallableType()->ValidateCall(ii2s)); |
320 EXPECT_EQ(Type::Int(), min_max->AsCallableType()->ValidateCall(iiii2i)); | 320 EXPECT_EQ(Type::Signed(), min_max->AsCallableType()->ValidateCall(iii2s)); |
| 321 EXPECT_EQ(Type::Signed(), min_max->AsCallableType()->ValidateCall(iiii2s)); |
321 EXPECT_EQ(Type::Double(), | 322 EXPECT_EQ(Type::Double(), |
322 min_max->AsCallableType()->ValidateCall(min_max_double)); | 323 min_max->AsCallableType()->ValidateCall(min_max_double)); |
323 EXPECT_EQ(Type::Double(), min_max->AsCallableType()->ValidateCall(dd2d)); | 324 EXPECT_EQ(Type::Double(), min_max->AsCallableType()->ValidateCall(dd2d)); |
324 EXPECT_EQ(Type::Double(), min_max->AsCallableType()->ValidateCall(ddd2d)); | 325 EXPECT_EQ(Type::Double(), min_max->AsCallableType()->ValidateCall(ddd2d)); |
325 EXPECT_EQ(Type::Double(), min_max->AsCallableType()->ValidateCall(dddd2d)); | 326 EXPECT_EQ(Type::Double(), min_max->AsCallableType()->ValidateCall(dddd2d)); |
326 | 327 |
327 auto* fround_floatish = Type::FroundType(zone(), Type::Floatish()); | 328 auto* fround = Type::FroundType(zone()); |
328 auto* fround_floatq = Type::FroundType(zone(), Type::FloatQ()); | |
329 auto* fround_float = Type::FroundType(zone(), Type::Float()); | |
330 auto* fround_doubleq = Type::FroundType(zone(), Type::DoubleQ()); | |
331 auto* fround_double = Type::FroundType(zone(), Type::Double()); | |
332 auto* fround_signed = Type::FroundType(zone(), Type::Signed()); | |
333 auto* fround_unsigned = Type::FroundType(zone(), Type::Unsigned()); | |
334 auto* fround_fixnum = Type::FroundType(zone(), Type::FixNum()); | |
335 auto* fround = | |
336 Overload(fround_floatish, fround_floatq, fround_float, fround_doubleq, | |
337 fround_double, fround_signed, fround_unsigned, fround_fixnum); | |
338 | 329 |
339 EXPECT_EQ(Type::Float(), fround->AsCallableType()->ValidateCall( | 330 EXPECT_EQ(Type::Float(), fround->AsCallableType()->ValidateCall( |
340 Function(Type::Float)(Type::Floatish))); | 331 Function(Type::Float)(Type::Floatish))); |
341 EXPECT_EQ(Type::Float(), fround->AsCallableType()->ValidateCall( | 332 EXPECT_EQ(Type::Float(), fround->AsCallableType()->ValidateCall( |
342 Function(Type::Float)(Type::FloatQ))); | 333 Function(Type::Float)(Type::FloatQ))); |
343 EXPECT_EQ(Type::Float(), fround->AsCallableType()->ValidateCall( | 334 EXPECT_EQ(Type::Float(), fround->AsCallableType()->ValidateCall( |
344 Function(Type::Float)(Type::Float))); | 335 Function(Type::Float)(Type::Float))); |
345 EXPECT_EQ(Type::Float(), fround->AsCallableType()->ValidateCall( | 336 EXPECT_EQ(Type::Float(), fround->AsCallableType()->ValidateCall( |
346 Function(Type::Float)(Type::DoubleQ))); | 337 Function(Type::Float)(Type::DoubleQ))); |
347 EXPECT_EQ(Type::Float(), fround->AsCallableType()->ValidateCall( | 338 EXPECT_EQ(Type::Float(), fround->AsCallableType()->ValidateCall( |
(...skipping 22 matching lines...) Expand all Loading... |
370 | 361 |
371 TEST_F(AsmTypeTest, IsReturnType) { | 362 TEST_F(AsmTypeTest, IsReturnType) { |
372 Type* test_types[] = { | 363 Type* test_types[] = { |
373 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 364 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
374 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 365 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
375 #undef CREATE | 366 #undef CREATE |
376 Function(Type::Int)(Type::Double), | 367 Function(Type::Int)(Type::Double), |
377 Function(Type::Int)(Type::DoubleQ), | 368 Function(Type::Int)(Type::DoubleQ), |
378 Overload(Function(Type::Int)(Type::Double)), | 369 Overload(Function(Type::Int)(Type::Double)), |
379 Function(Type::Int)(Type::Int, Type::Int), | 370 Function(Type::Int)(Type::Int, Type::Int), |
380 Type::MinMaxType(zone(), Type::Int()), Function(Type::Int)(Type::Float), | 371 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
381 Type::FroundType(zone(), Type::Int()), | 372 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
382 }; | 373 }; |
383 | 374 |
384 std::unordered_set<Type*> return_types{ | 375 std::unordered_set<Type*> return_types{ |
385 Type::Double(), Type::Signed(), Type::Float(), Type::Void(), | 376 Type::Double(), Type::Signed(), Type::Float(), Type::Void(), |
386 }; | 377 }; |
387 | 378 |
388 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | 379 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { |
389 const bool IsReturnType = return_types.count(test_types[ii]); | 380 const bool IsReturnType = return_types.count(test_types[ii]); |
390 EXPECT_EQ(IsReturnType, test_types[ii]->IsReturnType()) | 381 EXPECT_EQ(IsReturnType, test_types[ii]->IsReturnType()) |
391 << test_types[ii]->Name() | 382 << test_types[ii]->Name() |
392 << (IsReturnType ? " is not a return type" : " is a return type"); | 383 << (IsReturnType ? " is not a return type" : " is a return type"); |
393 } | 384 } |
394 } | 385 } |
395 | 386 |
396 TEST_F(AsmTypeTest, IsParameterType) { | 387 TEST_F(AsmTypeTest, IsParameterType) { |
397 Type* test_types[] = { | 388 Type* test_types[] = { |
398 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 389 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
399 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 390 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
400 #undef CREATE | 391 #undef CREATE |
401 Function(Type::Int)(Type::Double), | 392 Function(Type::Int)(Type::Double), |
402 Function(Type::Int)(Type::DoubleQ), | 393 Function(Type::Int)(Type::DoubleQ), |
403 Overload(Function(Type::Int)(Type::Double)), | 394 Overload(Function(Type::Int)(Type::Double)), |
404 Function(Type::Int)(Type::Int, Type::Int), | 395 Function(Type::Int)(Type::Int, Type::Int), |
405 Type::MinMaxType(zone(), Type::Int()), Function(Type::Int)(Type::Float), | 396 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
406 Type::FroundType(zone(), Type::Int()), | 397 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
407 }; | 398 }; |
408 | 399 |
409 std::unordered_set<Type*> parameter_types{ | 400 std::unordered_set<Type*> parameter_types{ |
410 Type::Double(), Type::Int(), Type::Float(), | 401 Type::Double(), Type::Int(), Type::Float(), |
411 }; | 402 }; |
412 | 403 |
413 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | 404 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { |
414 const bool IsParameterType = parameter_types.count(test_types[ii]); | 405 const bool IsParameterType = parameter_types.count(test_types[ii]); |
415 EXPECT_EQ(IsParameterType, test_types[ii]->IsParameterType()) | 406 EXPECT_EQ(IsParameterType, test_types[ii]->IsParameterType()) |
416 << test_types[ii]->Name() | 407 << test_types[ii]->Name() |
417 << (IsParameterType ? " is not a parameter type" | 408 << (IsParameterType ? " is not a parameter type" |
418 : " is a parameter type"); | 409 : " is a parameter type"); |
419 } | 410 } |
420 } | 411 } |
421 | 412 |
422 TEST_F(AsmTypeTest, IsComparableType) { | 413 TEST_F(AsmTypeTest, IsComparableType) { |
423 Type* test_types[] = { | 414 Type* test_types[] = { |
424 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 415 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
425 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 416 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
426 #undef CREATE | 417 #undef CREATE |
427 Function(Type::Int)(Type::Double), | 418 Function(Type::Int)(Type::Double), |
428 Function(Type::Int)(Type::DoubleQ), | 419 Function(Type::Int)(Type::DoubleQ), |
429 Overload(Function(Type::Int)(Type::Double)), | 420 Overload(Function(Type::Int)(Type::Double)), |
430 Function(Type::Int)(Type::Int, Type::Int), | 421 Function(Type::Int)(Type::Int, Type::Int), |
431 Type::MinMaxType(zone(), Type::Int()), Function(Type::Int)(Type::Float), | 422 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
432 Type::FroundType(zone(), Type::Int()), | 423 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
433 }; | 424 }; |
434 | 425 |
435 std::unordered_set<Type*> comparable_types{ | 426 std::unordered_set<Type*> comparable_types{ |
436 Type::Double(), Type::Signed(), Type::Unsigned(), Type::Float(), | 427 Type::Double(), Type::Signed(), Type::Unsigned(), Type::Float(), |
437 }; | 428 }; |
438 | 429 |
439 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | 430 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { |
440 const bool IsComparableType = comparable_types.count(test_types[ii]); | 431 const bool IsComparableType = comparable_types.count(test_types[ii]); |
441 EXPECT_EQ(IsComparableType, test_types[ii]->IsComparableType()) | 432 EXPECT_EQ(IsComparableType, test_types[ii]->IsComparableType()) |
442 << test_types[ii]->Name() | 433 << test_types[ii]->Name() |
443 << (IsComparableType ? " is not a comparable type" | 434 << (IsComparableType ? " is not a comparable type" |
444 : " is a comparable type"); | 435 : " is a comparable type"); |
445 } | 436 } |
446 } | 437 } |
447 | 438 |
448 TEST_F(AsmTypeTest, ElementSizeInBytes) { | 439 TEST_F(AsmTypeTest, ElementSizeInBytes) { |
449 Type* test_types[] = { | 440 Type* test_types[] = { |
450 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 441 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
451 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 442 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
452 #undef CREATE | 443 #undef CREATE |
453 Function(Type::Int)(Type::Double), | 444 Function(Type::Int)(Type::Double), |
454 Function(Type::Int)(Type::DoubleQ), | 445 Function(Type::Int)(Type::DoubleQ), |
455 Overload(Function(Type::Int)(Type::Double)), | 446 Overload(Function(Type::Int)(Type::Double)), |
456 Function(Type::Int)(Type::Int, Type::Int), | 447 Function(Type::Int)(Type::Int, Type::Int), |
457 Type::MinMaxType(zone(), Type::Int()), Function(Type::Int)(Type::Float), | 448 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
458 Type::FroundType(zone(), Type::Int()), | 449 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
459 }; | 450 }; |
460 | 451 |
461 auto ElementSizeInBytesForType = [](Type* type) -> int32_t { | 452 auto ElementSizeInBytesForType = [](Type* type) -> int32_t { |
462 if (type == Type::Int8Array() || type == Type::Uint8Array()) { | 453 if (type == Type::Int8Array() || type == Type::Uint8Array()) { |
463 return 1; | 454 return 1; |
464 } | 455 } |
465 if (type == Type::Int16Array() || type == Type::Uint16Array()) { | 456 if (type == Type::Int16Array() || type == Type::Uint16Array()) { |
466 return 2; | 457 return 2; |
467 } | 458 } |
468 if (type == Type::Int32Array() || type == Type::Uint32Array() || | 459 if (type == Type::Int32Array() || type == Type::Uint32Array() || |
(...skipping 14 matching lines...) Expand all Loading... |
483 | 474 |
484 TEST_F(AsmTypeTest, LoadType) { | 475 TEST_F(AsmTypeTest, LoadType) { |
485 Type* test_types[] = { | 476 Type* test_types[] = { |
486 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 477 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
487 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 478 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
488 #undef CREATE | 479 #undef CREATE |
489 Function(Type::Int)(Type::Double), | 480 Function(Type::Int)(Type::Double), |
490 Function(Type::Int)(Type::DoubleQ), | 481 Function(Type::Int)(Type::DoubleQ), |
491 Overload(Function(Type::Int)(Type::Double)), | 482 Overload(Function(Type::Int)(Type::Double)), |
492 Function(Type::Int)(Type::Int, Type::Int), | 483 Function(Type::Int)(Type::Int, Type::Int), |
493 Type::MinMaxType(zone(), Type::Int()), Function(Type::Int)(Type::Float), | 484 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
494 Type::FroundType(zone(), Type::Int()), | 485 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
495 }; | 486 }; |
496 | 487 |
497 auto LoadTypeForType = [](Type* type) -> Type* { | 488 auto LoadTypeForType = [](Type* type) -> Type* { |
498 if (type == Type::Int8Array() || type == Type::Uint8Array() || | 489 if (type == Type::Int8Array() || type == Type::Uint8Array() || |
499 type == Type::Int16Array() || type == Type::Uint16Array() || | 490 type == Type::Int16Array() || type == Type::Uint16Array() || |
500 type == Type::Int32Array() || type == Type::Uint32Array()) { | 491 type == Type::Int32Array() || type == Type::Uint32Array()) { |
501 return Type::Intish(); | 492 return Type::Intish(); |
502 } | 493 } |
503 | 494 |
504 if (type == Type::Float32Array()) { | 495 if (type == Type::Float32Array()) { |
(...skipping 14 matching lines...) Expand all Loading... |
519 | 510 |
520 TEST_F(AsmTypeTest, StoreType) { | 511 TEST_F(AsmTypeTest, StoreType) { |
521 Type* test_types[] = { | 512 Type* test_types[] = { |
522 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 513 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
523 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 514 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
524 #undef CREATE | 515 #undef CREATE |
525 Function(Type::Int)(Type::Double), | 516 Function(Type::Int)(Type::Double), |
526 Function(Type::Int)(Type::DoubleQ), | 517 Function(Type::Int)(Type::DoubleQ), |
527 Overload(Function(Type::Int)(Type::Double)), | 518 Overload(Function(Type::Int)(Type::Double)), |
528 Function(Type::Int)(Type::Int, Type::Int), | 519 Function(Type::Int)(Type::Int, Type::Int), |
529 Type::MinMaxType(zone(), Type::Int()), Function(Type::Int)(Type::Float), | 520 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
530 Type::FroundType(zone(), Type::Int()), | 521 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
531 }; | 522 }; |
532 | 523 |
533 auto StoreTypeForType = [](Type* type) -> Type* { | 524 auto StoreTypeForType = [](Type* type) -> Type* { |
534 if (type == Type::Int8Array() || type == Type::Uint8Array() || | 525 if (type == Type::Int8Array() || type == Type::Uint8Array() || |
535 type == Type::Int16Array() || type == Type::Uint16Array() || | 526 type == Type::Int16Array() || type == Type::Uint16Array() || |
536 type == Type::Int32Array() || type == Type::Uint32Array()) { | 527 type == Type::Int32Array() || type == Type::Uint32Array()) { |
537 return Type::Intish(); | 528 return Type::Intish(); |
538 } | 529 } |
539 | 530 |
540 if (type == Type::Float32Array()) { | 531 if (type == Type::Float32Array()) { |
(...skipping 10 matching lines...) Expand all Loading... |
551 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | 542 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { |
552 EXPECT_EQ(StoreTypeForType(test_types[ii]), test_types[ii]->StoreType()) | 543 EXPECT_EQ(StoreTypeForType(test_types[ii]), test_types[ii]->StoreType()) |
553 << test_types[ii]->Name(); | 544 << test_types[ii]->Name(); |
554 } | 545 } |
555 } | 546 } |
556 | 547 |
557 } // namespace | 548 } // namespace |
558 } // namespace wasm | 549 } // namespace wasm |
559 } // namespace internal | 550 } // namespace internal |
560 } // namespace v8 | 551 } // namespace v8 |
OLD | NEW |