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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } | 317 } |
318 | 318 |
319 TEST(Run_WasmI32Eqz) { | 319 TEST(Run_WasmI32Eqz) { |
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_WasmI32Shl) { |
| 328 WasmRunner<uint32_t> r(MachineType::Uint32(), MachineType::Uint32()); |
| 329 BUILD(r, WASM_I32_SHL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 330 |
| 331 FOR_UINT32_INPUTS(i) { |
| 332 FOR_UINT32_INPUTS(j) { |
| 333 uint32_t expected = (*i) << (*j & 0x1f); |
| 334 CHECK_EQ(expected, r.Call(*i, *j)); |
| 335 } |
| 336 } |
| 337 } |
| 338 |
| 339 TEST(Run_WasmI32Shr) { |
| 340 WasmRunner<uint32_t> r(MachineType::Uint32(), MachineType::Uint32()); |
| 341 BUILD(r, WASM_I32_SHR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 342 |
| 343 FOR_UINT32_INPUTS(i) { |
| 344 FOR_UINT32_INPUTS(j) { |
| 345 uint32_t expected = (*i) >> (*j & 0x1f); |
| 346 CHECK_EQ(expected, r.Call(*i, *j)); |
| 347 } |
| 348 } |
| 349 } |
| 350 |
| 351 TEST(Run_WasmI32Sar) { |
| 352 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); |
| 353 BUILD(r, WASM_I32_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
| 354 |
| 355 FOR_INT32_INPUTS(i) { |
| 356 FOR_INT32_INPUTS(j) { |
| 357 int32_t expected = (*i) >> (*j & 0x1f); |
| 358 CHECK_EQ(expected, r.Call(*i, *j)); |
| 359 } |
| 360 } |
| 361 } |
| 362 |
327 TEST(Run_WASM_Int32DivS_trap) { | 363 TEST(Run_WASM_Int32DivS_trap) { |
328 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); | 364 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); |
329 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 365 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
330 const int32_t kMin = std::numeric_limits<int32_t>::min(); | 366 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
331 CHECK_EQ(0, r.Call(0, 100)); | 367 CHECK_EQ(0, r.Call(0, 100)); |
332 CHECK_TRAP(r.Call(100, 0)); | 368 CHECK_TRAP(r.Call(100, 0)); |
333 CHECK_TRAP(r.Call(-1001, 0)); | 369 CHECK_TRAP(r.Call(-1001, 0)); |
334 CHECK_TRAP(r.Call(kMin, -1)); | 370 CHECK_TRAP(r.Call(kMin, -1)); |
335 CHECK_TRAP(r.Call(kMin, 0)); | 371 CHECK_TRAP(r.Call(kMin, 0)); |
336 } | 372 } |
(...skipping 2441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2778 | 2814 |
2779 #if WASM_64 | 2815 #if WASM_64 |
2780 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } | 2816 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } |
2781 #endif | 2817 #endif |
2782 | 2818 |
2783 | 2819 |
2784 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } | 2820 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } |
2785 | 2821 |
2786 | 2822 |
2787 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } | 2823 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } |
OLD | NEW |