OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "src/wasm/wasm-macro-gen.h" | 9 #include "src/wasm/wasm-macro-gen.h" |
10 | 10 |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 TestInt32Unop(kExprI32Eqz, 0, 1); | 320 TestInt32Unop(kExprI32Eqz, 0, 1); |
321 TestInt32Unop(kExprI32Eqz, 0, -1); | 321 TestInt32Unop(kExprI32Eqz, 0, -1); |
322 TestInt32Unop(kExprI32Eqz, 0, -827343); | 322 TestInt32Unop(kExprI32Eqz, 0, -827343); |
323 TestInt32Unop(kExprI32Eqz, 0, 8888888); | 323 TestInt32Unop(kExprI32Eqz, 0, 8888888); |
324 TestInt32Unop(kExprI32Eqz, 1, 0); | 324 TestInt32Unop(kExprI32Eqz, 1, 0); |
325 } | 325 } |
326 | 326 |
327 TEST(Run_WASM_Int32DivS_trap) { | 327 TEST(Run_WASM_Int32DivS_trap) { |
328 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); | 328 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); |
329 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 329 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 330 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
330 CHECK_EQ(0, r.Call(0, 100)); | 331 CHECK_EQ(0, r.Call(0, 100)); |
331 CHECK_TRAP(r.Call(100, 0)); | 332 CHECK_TRAP(r.Call(100, 0)); |
332 CHECK_TRAP(r.Call(-1001, 0)); | 333 CHECK_TRAP(r.Call(-1001, 0)); |
333 CHECK_TRAP(r.Call(std::numeric_limits<int32_t>::min(), -1)); | 334 CHECK_TRAP(r.Call(kMin, -1)); |
334 CHECK_TRAP(r.Call(std::numeric_limits<int32_t>::min(), 0)); | 335 CHECK_TRAP(r.Call(kMin, 0)); |
335 } | 336 } |
336 | 337 |
337 | 338 |
338 TEST(Run_WASM_Int32RemS_trap) { | 339 TEST(Run_WASM_Int32RemS_trap) { |
339 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); | 340 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); |
340 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 341 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 342 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
341 CHECK_EQ(33, r.Call(133, 100)); | 343 CHECK_EQ(33, r.Call(133, 100)); |
342 CHECK_EQ(0, r.Call(std::numeric_limits<int32_t>::min(), -1)); | 344 CHECK_EQ(0, r.Call(kMin, -1)); |
343 CHECK_TRAP(r.Call(100, 0)); | 345 CHECK_TRAP(r.Call(100, 0)); |
344 CHECK_TRAP(r.Call(-1001, 0)); | 346 CHECK_TRAP(r.Call(-1001, 0)); |
345 CHECK_TRAP(r.Call(std::numeric_limits<int32_t>::min(), 0)); | 347 CHECK_TRAP(r.Call(kMin, 0)); |
346 } | 348 } |
347 | 349 |
348 | 350 |
349 TEST(Run_WASM_Int32DivU_trap) { | 351 TEST(Run_WASM_Int32DivU_trap) { |
350 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); | 352 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); |
351 BUILD(r, WASM_I32_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 353 BUILD(r, WASM_I32_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 354 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
352 CHECK_EQ(0, r.Call(0, 100)); | 355 CHECK_EQ(0, r.Call(0, 100)); |
353 CHECK_EQ(0, r.Call(std::numeric_limits<int32_t>::min(), -1)); | 356 CHECK_EQ(0, r.Call(kMin, -1)); |
354 CHECK_TRAP(r.Call(100, 0)); | 357 CHECK_TRAP(r.Call(100, 0)); |
355 CHECK_TRAP(r.Call(-1001, 0)); | 358 CHECK_TRAP(r.Call(-1001, 0)); |
356 CHECK_TRAP(r.Call(std::numeric_limits<int32_t>::min(), 0)); | 359 CHECK_TRAP(r.Call(kMin, 0)); |
357 } | 360 } |
358 | 361 |
359 | 362 |
360 TEST(Run_WASM_Int32RemU_trap) { | 363 TEST(Run_WASM_Int32RemU_trap) { |
361 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); | 364 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); |
362 BUILD(r, WASM_I32_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 365 BUILD(r, WASM_I32_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
363 CHECK_EQ(17, r.Call(217, 100)); | 366 CHECK_EQ(17, r.Call(217, 100)); |
| 367 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
364 CHECK_TRAP(r.Call(100, 0)); | 368 CHECK_TRAP(r.Call(100, 0)); |
365 CHECK_TRAP(r.Call(-1001, 0)); | 369 CHECK_TRAP(r.Call(-1001, 0)); |
366 CHECK_TRAP(r.Call(std::numeric_limits<int32_t>::min(), 0)); | 370 CHECK_TRAP(r.Call(kMin, 0)); |
367 CHECK_EQ(std::numeric_limits<int32_t>::min(), | 371 CHECK_EQ(kMin, r.Call(kMin, -1)); |
368 r.Call(std::numeric_limits<int32_t>::min(), -1)); | 372 } |
| 373 |
| 374 TEST(Run_WASM_Int32DivS_asmjs) { |
| 375 TestingModule module; |
| 376 module.origin = kAsmJsOrigin; |
| 377 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); |
| 378 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 379 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
| 380 CHECK_EQ(0, r.Call(0, 100)); |
| 381 CHECK_EQ(0, r.Call(100, 0)); |
| 382 CHECK_EQ(0, r.Call(-1001, 0)); |
| 383 CHECK_EQ(kMin, r.Call(kMin, -1)); |
| 384 CHECK_EQ(0, r.Call(kMin, 0)); |
| 385 } |
| 386 |
| 387 TEST(Run_WASM_Int32RemS_asmjs) { |
| 388 TestingModule module; |
| 389 module.origin = kAsmJsOrigin; |
| 390 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); |
| 391 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 392 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
| 393 CHECK_EQ(33, r.Call(133, 100)); |
| 394 CHECK_EQ(0, r.Call(kMin, -1)); |
| 395 CHECK_EQ(0, r.Call(100, 0)); |
| 396 CHECK_EQ(0, r.Call(-1001, 0)); |
| 397 CHECK_EQ(0, r.Call(kMin, 0)); |
| 398 } |
| 399 |
| 400 TEST(Run_WASM_Int32DivU_asmjs) { |
| 401 TestingModule module; |
| 402 module.origin = kAsmJsOrigin; |
| 403 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); |
| 404 BUILD(r, WASM_I32_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 405 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
| 406 CHECK_EQ(0, r.Call(0, 100)); |
| 407 CHECK_EQ(0, r.Call(kMin, -1)); |
| 408 CHECK_EQ(0, r.Call(100, 0)); |
| 409 CHECK_EQ(0, r.Call(-1001, 0)); |
| 410 CHECK_EQ(0, r.Call(kMin, 0)); |
| 411 } |
| 412 |
| 413 TEST(Run_WASM_Int32RemU_asmjs) { |
| 414 TestingModule module; |
| 415 module.origin = kAsmJsOrigin; |
| 416 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); |
| 417 BUILD(r, WASM_I32_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 418 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
| 419 CHECK_EQ(17, r.Call(217, 100)); |
| 420 CHECK_EQ(0, r.Call(100, 0)); |
| 421 CHECK_EQ(0, r.Call(-1001, 0)); |
| 422 CHECK_EQ(0, r.Call(kMin, 0)); |
| 423 CHECK_EQ(kMin, r.Call(kMin, -1)); |
369 } | 424 } |
370 | 425 |
371 | 426 |
372 TEST(Run_WASM_Int32DivS_byzero_const) { | 427 TEST(Run_WASM_Int32DivS_byzero_const) { |
373 for (int8_t denom = -2; denom < 8; denom++) { | 428 for (int8_t denom = -2; denom < 8; denom++) { |
374 WasmRunner<int32_t> r(MachineType::Int32()); | 429 WasmRunner<int32_t> r(MachineType::Int32()); |
375 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_I8(denom))); | 430 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_I8(denom))); |
376 for (int32_t val = -7; val < 8; val++) { | 431 for (int32_t val = -7; val < 8; val++) { |
377 if (denom == 0) { | 432 if (denom == 0) { |
378 CHECK_TRAP(r.Call(val)); | 433 CHECK_TRAP(r.Call(val)); |
(...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2723 | 2778 |
2724 #if WASM_64 | 2779 #if WASM_64 |
2725 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } | 2780 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } |
2726 #endif | 2781 #endif |
2727 | 2782 |
2728 | 2783 |
2729 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } | 2784 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } |
2730 | 2785 |
2731 | 2786 |
2732 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } | 2787 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } |
OLD | NEW |