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/base/utils/random-number-generator.h" | 9 #include "src/base/utils/random-number-generator.h" |
10 | 10 |
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1850 memory[0] = 11111111; | 1850 memory[0] = 11111111; |
1851 memory[1] = 22222222; | 1851 memory[1] = 22222222; |
1852 memory[2] = 33333333; | 1852 memory[2] = 33333333; |
1853 memory[3] = 44444444; | 1853 memory[3] = 44444444; |
1854 CHECK_EQ(22222222, r.Call(0)); | 1854 CHECK_EQ(22222222, r.Call(0)); |
1855 CHECK_EQ(33333333, r.Call(4)); | 1855 CHECK_EQ(33333333, r.Call(4)); |
1856 CHECK_EQ(44444444, r.Call(8)); | 1856 CHECK_EQ(44444444, r.Call(8)); |
1857 } | 1857 } |
1858 | 1858 |
1859 | 1859 |
| 1860 // TODO(titzer): Fix for mips and re-enable. |
| 1861 #if !V8_TARGET_ARCH_MIPS && !V8_TARGET_ARCH_MIPS64 |
| 1862 |
1860 TEST(Run_Wasm_LoadMemI32_const_oob) { | 1863 TEST(Run_Wasm_LoadMemI32_const_oob) { |
1861 TestingModule module; | 1864 TestingModule module; |
1862 const int kMemSize = 12; | 1865 const int kMemSize = 12; |
1863 module.AddMemoryElems<byte>(kMemSize); | 1866 module.AddMemoryElems<byte>(kMemSize); |
1864 | 1867 |
1865 for (int offset = 0; offset < kMemSize + 5; offset++) { | 1868 for (int offset = 0; offset < kMemSize + 5; offset++) { |
1866 for (int index = 0; index < kMemSize + 5; index++) { | 1869 for (int index = 0; index < kMemSize + 5; index++) { |
1867 WasmRunner<int32_t> r; | 1870 WasmRunner<int32_t> r; |
1868 r.env()->module = &module; | 1871 r.env()->module = &module; |
1869 module.RandomizeMemory(); | 1872 module.RandomizeMemory(); |
1870 | 1873 |
1871 BUILD(r, | 1874 BUILD(r, |
1872 WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset, WASM_I8(index))); | 1875 WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset, WASM_I8(index))); |
1873 | 1876 |
1874 if ((offset + index) <= (kMemSize - sizeof(int32_t))) { | 1877 if ((offset + index) <= (kMemSize - sizeof(int32_t))) { |
1875 CHECK_EQ(module.raw_val_at<int32_t>(offset + index), r.Call()); | 1878 CHECK_EQ(module.raw_val_at<int32_t>(offset + index), r.Call()); |
1876 } else { | 1879 } else { |
1877 CHECK_TRAP(r.Call()); | 1880 CHECK_TRAP(r.Call()); |
1878 } | 1881 } |
1879 } | 1882 } |
1880 } | 1883 } |
1881 } | 1884 } |
1882 | 1885 |
| 1886 #endif |
| 1887 |
1883 | 1888 |
1884 TEST(Run_Wasm_StoreMemI32_offset) { | 1889 TEST(Run_Wasm_StoreMemI32_offset) { |
1885 WasmRunner<int32_t> r(MachineType::Int32()); | 1890 WasmRunner<int32_t> r(MachineType::Int32()); |
1886 const int32_t kWritten = 0xaabbccdd; | 1891 const int32_t kWritten = 0xaabbccdd; |
1887 TestingModule module; | 1892 TestingModule module; |
1888 int32_t* memory = module.AddMemoryElems<int32_t>(4); | 1893 int32_t* memory = module.AddMemoryElems<int32_t>(4); |
1889 r.env()->module = &module; | 1894 r.env()->module = &module; |
1890 | 1895 |
1891 BUILD(r, WASM_STORE_MEM_OFFSET(MachineType::Int32(), 4, WASM_GET_LOCAL(0), | 1896 BUILD(r, WASM_STORE_MEM_OFFSET(MachineType::Int32(), 4, WASM_GET_LOCAL(0), |
1892 WASM_I32(kWritten))); | 1897 WASM_I32(kWritten))); |
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2636 // Build the calling function. | 2641 // Build the calling function. |
2637 WasmRunner<int32_t> r; | 2642 WasmRunner<int32_t> r; |
2638 r.env()->module = &module; | 2643 r.env()->module = &module; |
2639 BUILD(r, WASM_CALL_FUNCTION0(index)); | 2644 BUILD(r, WASM_CALL_FUNCTION0(index)); |
2640 | 2645 |
2641 int32_t result = r.Call(); | 2646 int32_t result = r.Call(); |
2642 CHECK_EQ(kExpected, result); | 2647 CHECK_EQ(kExpected, result); |
2643 } | 2648 } |
2644 | 2649 |
2645 | 2650 |
| 2651 // TODO(tizer): Fix on arm and reenable. |
| 2652 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 2653 |
2646 TEST(Run_WasmCallF32StackParameter) { | 2654 TEST(Run_WasmCallF32StackParameter) { |
2647 // Build the target function. | 2655 // Build the target function. |
2648 LocalType param_types[20]; | 2656 LocalType param_types[20]; |
2649 for (int i = 0; i < 20; i++) param_types[i] = kAstF32; | 2657 for (int i = 0; i < 20; i++) param_types[i] = kAstF32; |
2650 FunctionSig sig(1, 19, param_types); | 2658 FunctionSig sig(1, 19, param_types); |
2651 TestingModule module; | 2659 TestingModule module; |
2652 WasmFunctionCompiler t(&sig); | 2660 WasmFunctionCompiler t(&sig); |
2653 BUILD(t, WASM_GET_LOCAL(17)); | 2661 BUILD(t, WASM_GET_LOCAL(17)); |
2654 uint32_t index = t.CompileAndAdd(&module); | 2662 uint32_t index = t.CompileAndAdd(&module); |
2655 | 2663 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2687 WASM_F64(32.0), WASM_F64(64.0), WASM_F64(128.0), | 2695 WASM_F64(32.0), WASM_F64(64.0), WASM_F64(128.0), |
2688 WASM_F64(256.0), WASM_F64(1.5), WASM_F64(2.5), | 2696 WASM_F64(256.0), WASM_F64(1.5), WASM_F64(2.5), |
2689 WASM_F64(4.5), WASM_F64(8.5), WASM_F64(16.5), | 2697 WASM_F64(4.5), WASM_F64(8.5), WASM_F64(16.5), |
2690 WASM_F64(32.5), WASM_F64(64.5), WASM_F64(128.5), | 2698 WASM_F64(32.5), WASM_F64(64.5), WASM_F64(128.5), |
2691 WASM_F64(256.5), WASM_F64(512.5))); | 2699 WASM_F64(256.5), WASM_F64(512.5))); |
2692 | 2700 |
2693 float result = r.Call(); | 2701 float result = r.Call(); |
2694 CHECK_EQ(256.5, result); | 2702 CHECK_EQ(256.5, result); |
2695 } | 2703 } |
2696 | 2704 |
| 2705 #endif |
| 2706 |
2697 | 2707 |
2698 TEST(Run_WasmCallVoid) { | 2708 TEST(Run_WasmCallVoid) { |
2699 const byte kMemOffset = 8; | 2709 const byte kMemOffset = 8; |
2700 const int32_t kElemNum = kMemOffset / sizeof(int32_t); | 2710 const int32_t kElemNum = kMemOffset / sizeof(int32_t); |
2701 const int32_t kExpected = -414444; | 2711 const int32_t kExpected = -414444; |
2702 // Build the target function. | 2712 // Build the target function. |
2703 TestSignatures sigs; | 2713 TestSignatures sigs; |
2704 TestingModule module; | 2714 TestingModule module; |
2705 module.AddMemory(16); | 2715 module.AddMemory(16); |
2706 module.RandomizeMemory(); | 2716 module.RandomizeMemory(); |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3541 TEST(Run_Wasm_F64CopySign) { | 3551 TEST(Run_Wasm_F64CopySign) { |
3542 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64()); | 3552 WasmRunner<double> r(MachineType::Float64(), MachineType::Float64()); |
3543 BUILD(r, WASM_F64_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 3553 BUILD(r, WASM_F64_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
3544 | 3554 |
3545 FOR_FLOAT64_INPUTS(i) { | 3555 FOR_FLOAT64_INPUTS(i) { |
3546 FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(copysign(*i, *j), r.Call(*i, *j)); } | 3556 FOR_FLOAT64_INPUTS(j) { CheckDoubleEq(copysign(*i, *j), r.Call(*i, *j)); } |
3547 } | 3557 } |
3548 } | 3558 } |
3549 | 3559 |
3550 | 3560 |
| 3561 // TODO(tizer): Fix on arm and reenable. |
| 3562 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 |
| 3563 |
3551 TEST(Run_Wasm_F32CopySign) { | 3564 TEST(Run_Wasm_F32CopySign) { |
3552 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); | 3565 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); |
3553 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 3566 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
3554 | 3567 |
3555 FOR_FLOAT32_INPUTS(i) { | 3568 FOR_FLOAT32_INPUTS(i) { |
3556 FOR_FLOAT32_INPUTS(j) { CheckFloatEq(copysign(*i, *j), r.Call(*i, *j)); } | 3569 FOR_FLOAT32_INPUTS(j) { CheckFloatEq(copysign(*i, *j), r.Call(*i, *j)); } |
3557 } | 3570 } |
3558 } | 3571 } |
| 3572 |
| 3573 #endif |
OLD | NEW |