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 | |
363 TEST(Run_WasmI64Shl) { | |
ahaas
2016/03/30 12:00:08
This test should be in test-run-wasm-64.cc
titzer
2016/03/30 12:10:26
Done.
| |
364 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); | |
365 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | |
366 | |
367 FOR_UINT64_INPUTS(i) { | |
368 FOR_UINT64_INPUTS(j) { | |
369 uint64_t expected = (*i) << (*j & 0x3f); | |
370 CHECK_EQ(expected, r.Call(*i, *j)); | |
371 } | |
372 } | |
373 } | |
374 | |
375 TEST(Run_WasmI64Shr) { | |
376 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); | |
ahaas
2016/03/30 12:00:08
same here.
titzer
2016/03/30 12:10:26
Done.
| |
377 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | |
378 | |
379 FOR_UINT64_INPUTS(i) { | |
380 FOR_UINT64_INPUTS(j) { | |
381 uint64_t expected = (*i) >> (*j & 0x3f); | |
382 CHECK_EQ(expected, r.Call(*i, *j)); | |
383 } | |
384 } | |
385 } | |
386 | |
387 TEST(Run_WasmI64Sar) { | |
ahaas
2016/03/30 12:00:09
same here.
titzer
2016/03/30 12:10:26
Done.
| |
388 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | |
389 BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | |
390 | |
391 FOR_INT64_INPUTS(i) { | |
392 FOR_INT64_INPUTS(j) { | |
393 int64_t expected = (*i) >> (*j & 0x3f); | |
394 CHECK_EQ(expected, r.Call(*i, *j)); | |
395 } | |
396 } | |
397 } | |
398 | |
327 TEST(Run_WASM_Int32DivS_trap) { | 399 TEST(Run_WASM_Int32DivS_trap) { |
328 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); | 400 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); |
329 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 401 BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
330 CHECK_EQ(0, r.Call(0, 100)); | 402 CHECK_EQ(0, r.Call(0, 100)); |
331 CHECK_TRAP(r.Call(100, 0)); | 403 CHECK_TRAP(r.Call(100, 0)); |
332 CHECK_TRAP(r.Call(-1001, 0)); | 404 CHECK_TRAP(r.Call(-1001, 0)); |
333 CHECK_TRAP(r.Call(std::numeric_limits<int32_t>::min(), -1)); | 405 CHECK_TRAP(r.Call(std::numeric_limits<int32_t>::min(), -1)); |
334 CHECK_TRAP(r.Call(std::numeric_limits<int32_t>::min(), 0)); | 406 CHECK_TRAP(r.Call(std::numeric_limits<int32_t>::min(), 0)); |
335 } | 407 } |
336 | 408 |
(...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2723 | 2795 |
2724 #if WASM_64 | 2796 #if WASM_64 |
2725 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } | 2797 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } |
2726 #endif | 2798 #endif |
2727 | 2799 |
2728 | 2800 |
2729 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } | 2801 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } |
2730 | 2802 |
2731 | 2803 |
2732 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } | 2804 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } |
OLD | NEW |