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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 Function(Type::Int)(Type::Int)) | 218 Function(Type::Int)(Type::Int)) |
219 ->Name(), | 219 ->Name(), |
220 StrEq("(double, float) -> int /\\ (int) -> int")); | 220 StrEq("(double, float) -> int /\\ (int) -> int")); |
221 | 221 |
222 EXPECT_THAT(Type::FroundType(zone())->Name(), StrEq("fround")); | 222 EXPECT_THAT(Type::FroundType(zone())->Name(), StrEq("fround")); |
223 | 223 |
224 EXPECT_THAT(Type::MinMaxType(zone(), Type::Signed(), Type::Int())->Name(), | 224 EXPECT_THAT(Type::MinMaxType(zone(), Type::Signed(), Type::Int())->Name(), |
225 StrEq("(int, int...) -> signed")); | 225 StrEq("(int, int...) -> signed")); |
226 EXPECT_THAT(Type::MinMaxType(zone(), Type::Float(), Type::Floatish())->Name(), | 226 EXPECT_THAT(Type::MinMaxType(zone(), Type::Float(), Type::Floatish())->Name(), |
227 StrEq("(floatish, floatish...) -> float")); | 227 StrEq("(floatish, floatish...) -> float")); |
228 EXPECT_THAT(Type::MinMaxType(zone(), Type::Double(), Type::Double())->Name(), | 228 EXPECT_THAT(Type::MinMaxType(zone(), Type::Double(), Type::DoubleQ())->Name(), |
229 StrEq("(double, double...) -> double")); | 229 StrEq("(double?, double?...) -> double")); |
230 | |
231 EXPECT_THAT(Type::FFIType(zone())->Name(), StrEq("Function")); | |
232 | |
233 EXPECT_THAT(Type::FunctionTableType(zone(), 4)->Name(), | |
234 StrEq("[unbound][4]")); | |
235 auto* ft = Type::FunctionTableType(zone(), 15); | |
236 ft->AsFunctionTableType()->set_signature(Function(Type::Double)(Type::Int)); | |
237 EXPECT_THAT(ft->Name(), StrEq("(int) -> double[15]")); | |
230 } | 238 } |
231 | 239 |
232 TEST_F(AsmTypeTest, IsExactly) { | 240 TEST_F(AsmTypeTest, IsExactly) { |
233 Type* test_types[] = { | 241 Type* test_types[] = { |
234 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 242 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
235 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 243 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
236 #undef CREATE | 244 #undef CREATE |
237 Function(Type::Int)(Type::Double), | 245 Function(Type::Int)(Type::Double), |
238 Function(Type::Int)(Type::DoubleQ), | 246 Function(Type::Int)(Type::DoubleQ), |
239 Overload(Function(Type::Int)(Type::Double)), | 247 Overload(Function(Type::Int)(Type::Double)), |
240 Function(Type::Int)(Type::Int, Type::Int), | 248 Function(Type::Int)(Type::Int, Type::Int), |
241 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), | 249 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
242 Function(Type::Int)(Type::Float), Type::FroundType(zone()), | 250 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
251 Type::FFIType(zone()), Type::FunctionTableType(zone(), 10), | |
243 }; | 252 }; |
244 | 253 |
245 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | 254 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { |
246 for (size_t jj = 0; jj < arraysize(test_types); ++jj) { | 255 for (size_t jj = 0; jj < arraysize(test_types); ++jj) { |
247 EXPECT_EQ(ii == jj, test_types[ii]->IsExactly(test_types[jj])) | 256 EXPECT_EQ(ii == jj, test_types[ii]->IsExactly(test_types[jj])) |
248 << test_types[ii]->Name() | 257 << test_types[ii]->Name() |
249 << ((ii == jj) ? " is not exactly " : " is exactly ") | 258 << ((ii == jj) ? " is not exactly " : " is exactly ") |
250 << test_types[jj]->Name(); | 259 << test_types[jj]->Name(); |
251 } | 260 } |
252 } | 261 } |
253 } | 262 } |
254 | 263 |
255 TEST_F(AsmTypeTest, IsA) { | 264 TEST_F(AsmTypeTest, IsA) { |
256 Type* test_types[] = { | 265 Type* test_types[] = { |
257 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 266 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
258 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 267 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
259 #undef CREATE | 268 #undef CREATE |
260 Function(Type::Int)(Type::Double), | 269 Function(Type::Int)(Type::Double), |
261 Function(Type::Int)(Type::DoubleQ), | 270 Function(Type::Int)(Type::DoubleQ), |
262 Overload(Function(Type::Int)(Type::Double)), | 271 Overload(Function(Type::Int)(Type::Double)), |
263 Function(Type::Int)(Type::Int, Type::Int), | 272 Function(Type::Int)(Type::Int, Type::Int), |
264 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), | 273 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
265 Function(Type::Int)(Type::Float), Type::FroundType(zone()), | 274 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
275 Type::FFIType(zone()), Type::FunctionTableType(zone(), 10), | |
266 }; | 276 }; |
267 | 277 |
268 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | 278 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { |
269 for (size_t jj = 0; jj < arraysize(test_types); ++jj) { | 279 for (size_t jj = 0; jj < arraysize(test_types); ++jj) { |
270 const bool Expected = | 280 const bool Expected = |
271 (ii == jj) || ParentsOf(test_types[ii]).count(test_types[jj]) != 0; | 281 (ii == jj) || ParentsOf(test_types[ii]).count(test_types[jj]) != 0; |
272 EXPECT_EQ(Expected, test_types[ii]->IsA(test_types[jj])) | 282 EXPECT_EQ(Expected, test_types[ii]->IsA(test_types[jj])) |
273 << test_types[ii]->Name() << (Expected ? " is not a " : " is a ") | 283 << test_types[ii]->Name() << (Expected ? " is not a " : " is a ") |
274 << test_types[jj]->Name(); | 284 << test_types[jj]->Name(); |
275 } | 285 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 auto* fi2d = Function(Type::Double)(Type::Float, Type::Int); | 360 auto* fi2d = Function(Type::Double)(Type::Float, Type::Int); |
351 auto* idif2i = | 361 auto* idif2i = |
352 Function(Type::Int)(Type::Int, Type::Double, Type::Int, Type::Float); | 362 Function(Type::Int)(Type::Int, Type::Double, Type::Int, Type::Float); |
353 auto* overload = Overload(idf2v, i2f, /*i2d missing, */ fi2d, idif2i); | 363 auto* overload = Overload(idf2v, i2f, /*i2d missing, */ fi2d, idif2i); |
354 EXPECT_EQ(Type::Void(), overload->AsCallableType()->ValidateCall(idf2v)); | 364 EXPECT_EQ(Type::Void(), overload->AsCallableType()->ValidateCall(idf2v)); |
355 EXPECT_EQ(Type::Float(), overload->AsCallableType()->ValidateCall(i2f)); | 365 EXPECT_EQ(Type::Float(), overload->AsCallableType()->ValidateCall(i2f)); |
356 EXPECT_EQ(Type::Double(), overload->AsCallableType()->ValidateCall(fi2d)); | 366 EXPECT_EQ(Type::Double(), overload->AsCallableType()->ValidateCall(fi2d)); |
357 EXPECT_EQ(Type::Int(), overload->AsCallableType()->ValidateCall(idif2i)); | 367 EXPECT_EQ(Type::Int(), overload->AsCallableType()->ValidateCall(idif2i)); |
358 EXPECT_EQ(Type::None(), overload->AsCallableType()->ValidateCall(i2d)); | 368 EXPECT_EQ(Type::None(), overload->AsCallableType()->ValidateCall(i2d)); |
359 EXPECT_EQ(Type::None(), i2f->AsCallableType()->ValidateCall(i2d)); | 369 EXPECT_EQ(Type::None(), i2f->AsCallableType()->ValidateCall(i2d)); |
370 | |
371 auto* ffi = Type::FFIType(zone()); | |
372 AsmType* (*kReturnTypes[])() = { | |
373 Type::Void, Type::Double, Type::Signed, | |
374 }; | |
375 AsmType* (*kExternTypes[])() = { | |
376 Type::Double, Type::Signed, Type::FixNum, | |
377 }; | |
378 for (size_t ii = 0; ii < arraysize(kReturnTypes); ++ii) { | |
379 for (size_t jj = 0; jj < arraysize(kExternTypes); ++jj) { | |
380 auto* f = Function(kReturnTypes[ii])(kExternTypes[jj]); | |
381 EXPECT_EQ(kReturnTypes[ii](), ffi->AsCallableType()->ValidateCall(f)) | |
382 << kReturnTypes[ii]()->Name(); | |
383 | |
384 // Call with extern type should fail. | |
bradnelson
2016/06/17 23:38:50
Comment seems off here
John
2016/06/20 15:09:53
Done.
| |
385 f = Function(kReturnTypes[ii])(kExternTypes[jj], Type::Int); | |
386 EXPECT_EQ(Type::None(), ffi->AsCallableType()->ValidateCall(f)) | |
387 << kReturnTypes[ii]()->Name(); | |
388 } | |
389 } | |
390 | |
391 auto* ft0 = Type::FunctionTableType(zone(), 10); | |
392 ft0->AsFunctionTableType()->set_signature(fi2d); | |
393 EXPECT_EQ(Type::Double(), ft0->AsCallableType()->ValidateCall(fi2d)); | |
394 EXPECT_EQ(Type::None(), ft0->AsCallableType()->ValidateCall(i2d)); | |
395 | |
396 auto* ft1 = Type::FunctionTableType(zone(), 10); | |
397 EXPECT_EQ(Type::Double(), ft1->AsCallableType()->ValidateCall(fi2d)); | |
398 EXPECT_EQ(Type::Double(), ft1->AsCallableType()->ValidateCall(fi2d)); | |
399 EXPECT_EQ(Type::None(), ft1->AsCallableType()->ValidateCall(i2d)); | |
400 } | |
401 | |
402 TEST_F(AsmTypeTest, ToReturnType) { | |
403 std::unordered_map<AsmType*, AsmType*> kToReturnType = { | |
404 {Type::Signed(), Type::Signed()}, {Type::FixNum(), Type::Signed()}, | |
405 {Type::Double(), Type::Double()}, {Type::Float(), Type::Float()}, | |
406 {Type::Void(), Type::Void()}, | |
407 }; | |
408 | |
409 Type* test_types[] = { | |
410 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | |
411 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | |
412 #undef CREATE | |
413 Function(Type::Int)(Type::Double), | |
414 Function(Type::Int)(Type::DoubleQ), | |
415 Overload(Function(Type::Int)(Type::Double)), | |
416 Function(Type::Int)(Type::Int, Type::Int), | |
417 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), | |
418 Function(Type::Int)(Type::Float), Type::FroundType(zone()), | |
419 Type::FFIType(zone()), Type::FunctionTableType(zone(), 10), | |
420 }; | |
421 | |
422 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | |
423 auto* return_type = Type::None(); | |
424 auto to_return_type_iter = kToReturnType.find(test_types[ii]); | |
425 if (to_return_type_iter != kToReturnType.end()) { | |
426 return_type = to_return_type_iter->second; | |
427 } | |
428 EXPECT_EQ(return_type, test_types[ii]->ToReturnType()) | |
429 << return_type->Name() << " != " << test_types[ii]->ToReturnType(); | |
430 } | |
360 } | 431 } |
361 | 432 |
362 TEST_F(AsmTypeTest, IsReturnType) { | 433 TEST_F(AsmTypeTest, IsReturnType) { |
363 Type* test_types[] = { | 434 Type* test_types[] = { |
364 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 435 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
365 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 436 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
366 #undef CREATE | 437 #undef CREATE |
367 Function(Type::Int)(Type::Double), | 438 Function(Type::Int)(Type::Double), |
368 Function(Type::Int)(Type::DoubleQ), | 439 Function(Type::Int)(Type::DoubleQ), |
369 Overload(Function(Type::Int)(Type::Double)), | 440 Overload(Function(Type::Int)(Type::Double)), |
370 Function(Type::Int)(Type::Int, Type::Int), | 441 Function(Type::Int)(Type::Int, Type::Int), |
371 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), | 442 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
372 Function(Type::Int)(Type::Float), Type::FroundType(zone()), | 443 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
444 Type::FFIType(zone()), Type::FunctionTableType(zone(), 10), | |
373 }; | 445 }; |
374 | 446 |
375 std::unordered_set<Type*> return_types{ | 447 std::unordered_set<Type*> return_types{ |
376 Type::Double(), Type::Signed(), Type::Float(), Type::Void(), | 448 Type::Double(), Type::Signed(), Type::Float(), Type::Void(), |
377 }; | 449 }; |
378 | 450 |
379 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | 451 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { |
380 const bool IsReturnType = return_types.count(test_types[ii]); | 452 const bool IsReturnType = return_types.count(test_types[ii]); |
381 EXPECT_EQ(IsReturnType, test_types[ii]->IsReturnType()) | 453 EXPECT_EQ(IsReturnType, test_types[ii]->IsReturnType()) |
382 << test_types[ii]->Name() | 454 << test_types[ii]->Name() |
383 << (IsReturnType ? " is not a return type" : " is a return type"); | 455 << (IsReturnType ? " is not a return type" : " is a return type"); |
384 } | 456 } |
385 } | 457 } |
386 | 458 |
459 TEST_F(AsmTypeTest, ToParameterType) { | |
460 std::unordered_map<AsmType*, AsmType*> kToParameterType = { | |
461 {Type::Int(), Type::Int()}, {Type::Signed(), Type::Int()}, | |
462 {Type::Unsigned(), Type::Int()}, {Type::FixNum(), Type::Int()}, | |
463 {Type::Double(), Type::Double()}, {Type::Float(), Type::Float()}, | |
464 }; | |
465 | |
466 Type* test_types[] = { | |
467 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | |
468 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | |
469 #undef CREATE | |
470 Function(Type::Int)(Type::Double), | |
471 Function(Type::Int)(Type::DoubleQ), | |
472 Overload(Function(Type::Int)(Type::Double)), | |
473 Function(Type::Int)(Type::Int, Type::Int), | |
474 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), | |
475 Function(Type::Int)(Type::Float), Type::FroundType(zone()), | |
476 Type::FFIType(zone()), Type::FunctionTableType(zone(), 10), | |
477 }; | |
478 | |
479 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | |
480 auto* parameter_type = Type::None(); | |
481 auto to_parameter_type_iter = kToParameterType.find(test_types[ii]); | |
482 if (to_parameter_type_iter != kToParameterType.end()) { | |
483 parameter_type = to_parameter_type_iter->second; | |
484 } | |
485 EXPECT_EQ(parameter_type, test_types[ii]->ToParameterType()) | |
486 << parameter_type->Name() | |
487 << " != " << test_types[ii]->ToParameterType(); | |
488 } | |
489 } | |
490 | |
387 TEST_F(AsmTypeTest, IsParameterType) { | 491 TEST_F(AsmTypeTest, IsParameterType) { |
388 Type* test_types[] = { | 492 Type* test_types[] = { |
389 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 493 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
390 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 494 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
391 #undef CREATE | 495 #undef CREATE |
392 Function(Type::Int)(Type::Double), | 496 Function(Type::Int)(Type::Double), |
393 Function(Type::Int)(Type::DoubleQ), | 497 Function(Type::Int)(Type::DoubleQ), |
394 Overload(Function(Type::Int)(Type::Double)), | 498 Overload(Function(Type::Int)(Type::Double)), |
395 Function(Type::Int)(Type::Int, Type::Int), | 499 Function(Type::Int)(Type::Int, Type::Int), |
396 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), | 500 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
397 Function(Type::Int)(Type::Float), Type::FroundType(zone()), | 501 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
502 Type::FFIType(zone()), Type::FunctionTableType(zone(), 10), | |
398 }; | 503 }; |
399 | 504 |
400 std::unordered_set<Type*> parameter_types{ | 505 std::unordered_set<Type*> parameter_types{ |
401 Type::Double(), Type::Int(), Type::Float(), | 506 Type::Double(), Type::Int(), Type::Float(), |
402 }; | 507 }; |
403 | 508 |
404 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | 509 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { |
405 const bool IsParameterType = parameter_types.count(test_types[ii]); | 510 const bool IsParameterType = parameter_types.count(test_types[ii]); |
406 EXPECT_EQ(IsParameterType, test_types[ii]->IsParameterType()) | 511 EXPECT_EQ(IsParameterType, test_types[ii]->IsParameterType()) |
407 << test_types[ii]->Name() | 512 << test_types[ii]->Name() |
408 << (IsParameterType ? " is not a parameter type" | 513 << (IsParameterType ? " is not a parameter type" |
409 : " is a parameter type"); | 514 : " is a parameter type"); |
410 } | 515 } |
411 } | 516 } |
412 | 517 |
413 TEST_F(AsmTypeTest, IsComparableType) { | 518 TEST_F(AsmTypeTest, IsComparableType) { |
414 Type* test_types[] = { | 519 Type* test_types[] = { |
415 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 520 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
416 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 521 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
417 #undef CREATE | 522 #undef CREATE |
418 Function(Type::Int)(Type::Double), | 523 Function(Type::Int)(Type::Double), |
419 Function(Type::Int)(Type::DoubleQ), | 524 Function(Type::Int)(Type::DoubleQ), |
420 Overload(Function(Type::Int)(Type::Double)), | 525 Overload(Function(Type::Int)(Type::Double)), |
421 Function(Type::Int)(Type::Int, Type::Int), | 526 Function(Type::Int)(Type::Int, Type::Int), |
422 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), | 527 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
423 Function(Type::Int)(Type::Float), Type::FroundType(zone()), | 528 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
529 Type::FFIType(zone()), Type::FunctionTableType(zone(), 10), | |
424 }; | 530 }; |
425 | 531 |
426 std::unordered_set<Type*> comparable_types{ | 532 std::unordered_set<Type*> comparable_types{ |
427 Type::Double(), Type::Signed(), Type::Unsigned(), Type::Float(), | 533 Type::Double(), Type::Signed(), Type::Unsigned(), Type::Float(), |
428 }; | 534 }; |
429 | 535 |
430 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | 536 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { |
431 const bool IsComparableType = comparable_types.count(test_types[ii]); | 537 const bool IsComparableType = comparable_types.count(test_types[ii]); |
432 EXPECT_EQ(IsComparableType, test_types[ii]->IsComparableType()) | 538 EXPECT_EQ(IsComparableType, test_types[ii]->IsComparableType()) |
433 << test_types[ii]->Name() | 539 << test_types[ii]->Name() |
434 << (IsComparableType ? " is not a comparable type" | 540 << (IsComparableType ? " is not a comparable type" |
435 : " is a comparable type"); | 541 : " is a comparable type"); |
436 } | 542 } |
437 } | 543 } |
438 | 544 |
439 TEST_F(AsmTypeTest, ElementSizeInBytes) { | 545 TEST_F(AsmTypeTest, ElementSizeInBytes) { |
440 Type* test_types[] = { | 546 Type* test_types[] = { |
441 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 547 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
442 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 548 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
443 #undef CREATE | 549 #undef CREATE |
444 Function(Type::Int)(Type::Double), | 550 Function(Type::Int)(Type::Double), |
445 Function(Type::Int)(Type::DoubleQ), | 551 Function(Type::Int)(Type::DoubleQ), |
446 Overload(Function(Type::Int)(Type::Double)), | 552 Overload(Function(Type::Int)(Type::Double)), |
447 Function(Type::Int)(Type::Int, Type::Int), | 553 Function(Type::Int)(Type::Int, Type::Int), |
448 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), | 554 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
449 Function(Type::Int)(Type::Float), Type::FroundType(zone()), | 555 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
556 Type::FFIType(zone()), Type::FunctionTableType(zone(), 10), | |
450 }; | 557 }; |
451 | 558 |
452 auto ElementSizeInBytesForType = [](Type* type) -> int32_t { | 559 auto ElementSizeInBytesForType = [](Type* type) -> int32_t { |
453 if (type == Type::Int8Array() || type == Type::Uint8Array()) { | 560 if (type == Type::Int8Array() || type == Type::Uint8Array()) { |
454 return 1; | 561 return 1; |
455 } | 562 } |
456 if (type == Type::Int16Array() || type == Type::Uint16Array()) { | 563 if (type == Type::Int16Array() || type == Type::Uint16Array()) { |
457 return 2; | 564 return 2; |
458 } | 565 } |
459 if (type == Type::Int32Array() || type == Type::Uint32Array() || | 566 if (type == Type::Int32Array() || type == Type::Uint32Array() || |
(...skipping 16 matching lines...) Expand all Loading... | |
476 Type* test_types[] = { | 583 Type* test_types[] = { |
477 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 584 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
478 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 585 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
479 #undef CREATE | 586 #undef CREATE |
480 Function(Type::Int)(Type::Double), | 587 Function(Type::Int)(Type::Double), |
481 Function(Type::Int)(Type::DoubleQ), | 588 Function(Type::Int)(Type::DoubleQ), |
482 Overload(Function(Type::Int)(Type::Double)), | 589 Overload(Function(Type::Int)(Type::Double)), |
483 Function(Type::Int)(Type::Int, Type::Int), | 590 Function(Type::Int)(Type::Int, Type::Int), |
484 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), | 591 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
485 Function(Type::Int)(Type::Float), Type::FroundType(zone()), | 592 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
593 Type::FFIType(zone()), Type::FunctionTableType(zone(), 10), | |
486 }; | 594 }; |
487 | 595 |
488 auto LoadTypeForType = [](Type* type) -> Type* { | 596 auto LoadTypeForType = [](Type* type) -> Type* { |
489 if (type == Type::Int8Array() || type == Type::Uint8Array() || | 597 if (type == Type::Int8Array() || type == Type::Uint8Array() || |
490 type == Type::Int16Array() || type == Type::Uint16Array() || | 598 type == Type::Int16Array() || type == Type::Uint16Array() || |
491 type == Type::Int32Array() || type == Type::Uint32Array()) { | 599 type == Type::Int32Array() || type == Type::Uint32Array()) { |
492 return Type::Intish(); | 600 return Type::Intish(); |
493 } | 601 } |
494 | 602 |
495 if (type == Type::Float32Array()) { | 603 if (type == Type::Float32Array()) { |
(...skipping 16 matching lines...) Expand all Loading... | |
512 Type* test_types[] = { | 620 Type* test_types[] = { |
513 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), | 621 #define CREATE(CamelName, string_name, number, parent_types) Type::CamelName(), |
514 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) | 622 FOR_EACH_ASM_VALUE_TYPE_LIST(CREATE) |
515 #undef CREATE | 623 #undef CREATE |
516 Function(Type::Int)(Type::Double), | 624 Function(Type::Int)(Type::Double), |
517 Function(Type::Int)(Type::DoubleQ), | 625 Function(Type::Int)(Type::DoubleQ), |
518 Overload(Function(Type::Int)(Type::Double)), | 626 Overload(Function(Type::Int)(Type::Double)), |
519 Function(Type::Int)(Type::Int, Type::Int), | 627 Function(Type::Int)(Type::Int, Type::Int), |
520 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), | 628 Type::MinMaxType(zone(), Type::Signed(), Type::Int()), |
521 Function(Type::Int)(Type::Float), Type::FroundType(zone()), | 629 Function(Type::Int)(Type::Float), Type::FroundType(zone()), |
630 Type::FFIType(zone()), Type::FunctionTableType(zone(), 10), | |
522 }; | 631 }; |
523 | 632 |
524 auto StoreTypeForType = [](Type* type) -> Type* { | 633 auto StoreTypeForType = [](Type* type) -> Type* { |
525 if (type == Type::Int8Array() || type == Type::Uint8Array() || | 634 if (type == Type::Int8Array() || type == Type::Uint8Array() || |
526 type == Type::Int16Array() || type == Type::Uint16Array() || | 635 type == Type::Int16Array() || type == Type::Uint16Array() || |
527 type == Type::Int32Array() || type == Type::Uint32Array()) { | 636 type == Type::Int32Array() || type == Type::Uint32Array()) { |
528 return Type::Intish(); | 637 return Type::Intish(); |
529 } | 638 } |
530 | 639 |
531 if (type == Type::Float32Array()) { | 640 if (type == Type::Float32Array()) { |
(...skipping 10 matching lines...) Expand all Loading... | |
542 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { | 651 for (size_t ii = 0; ii < arraysize(test_types); ++ii) { |
543 EXPECT_EQ(StoreTypeForType(test_types[ii]), test_types[ii]->StoreType()) | 652 EXPECT_EQ(StoreTypeForType(test_types[ii]), test_types[ii]->StoreType()) |
544 << test_types[ii]->Name(); | 653 << test_types[ii]->Name(); |
545 } | 654 } |
546 } | 655 } |
547 | 656 |
548 } // namespace | 657 } // namespace |
549 } // namespace wasm | 658 } // namespace wasm |
550 } // namespace internal | 659 } // namespace internal |
551 } // namespace v8 | 660 } // namespace v8 |
OLD | NEW |