Commit 9c9e4583 authored by Eric Holk's avatar Eric Holk Committed by Commit Bot

[wasm] Enable remaining cctests with trap handlers

Bug: v8:5277
Change-Id: I47ad0b7dbd9471e350b7aa1b6dd5ad122b97021a
Reviewed-on: https://chromium-review.googlesource.com/990239Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Eric Holk <eholk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52459}
parent 9ca75fb6
...@@ -1056,10 +1056,8 @@ WASM_EXEC_TEST(SignallingNanSurvivesI32ReinterpretF32) { ...@@ -1056,10 +1056,8 @@ WASM_EXEC_TEST(SignallingNanSurvivesI32ReinterpretF32) {
#endif #endif
WASM_EXEC_TEST(LoadMaxUint32Offset) { WASM_EXEC_TEST(LoadMaxUint32Offset) {
// TODO(eholk): Fix this test for the trap handler.
if (trap_handler::IsTrapHandlerEnabled()) return;
WasmRunner<int32_t> r(execution_mode); WasmRunner<int32_t> r(execution_mode);
r.builder().AddMemoryElems<int32_t>(8); r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), // type BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), // type
U32V_5(0xFFFFFFFF), // offset U32V_5(0xFFFFFFFF), // offset
...@@ -1497,17 +1495,17 @@ WASM_EXEC_TEST(LoadMemI32_alignment) { ...@@ -1497,17 +1495,17 @@ WASM_EXEC_TEST(LoadMemI32_alignment) {
} }
WASM_EXEC_TEST(LoadMemI32_oob) { WASM_EXEC_TEST(LoadMemI32_oob) {
// TODO(eholk): Fix this test for the trap handler.
if (trap_handler::IsTrapHandlerEnabled()) return;
WasmRunner<int32_t, uint32_t> r(execution_mode); WasmRunner<int32_t, uint32_t> r(execution_mode);
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8); int32_t* memory =
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
r.builder().RandomizeMemory(1111); r.builder().RandomizeMemory(1111);
BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0))); BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0)));
r.builder().WriteMemory(&memory[0], 88888888); r.builder().WriteMemory(&memory[0], 88888888);
CHECK_EQ(88888888, r.Call(0u)); CHECK_EQ(88888888, r.Call(0u));
for (uint32_t offset = 29; offset < 40; ++offset) { for (uint32_t offset = kWasmPageSize - 3; offset < kWasmPageSize + 40;
++offset) {
CHECK_TRAP(r.Call(offset)); CHECK_TRAP(r.Call(offset));
} }
...@@ -1517,22 +1515,24 @@ WASM_EXEC_TEST(LoadMemI32_oob) { ...@@ -1517,22 +1515,24 @@ WASM_EXEC_TEST(LoadMemI32_oob) {
} }
WASM_EXEC_TEST(LoadMem_offset_oob) { WASM_EXEC_TEST(LoadMem_offset_oob) {
// TODO(eholk): Fix this test for the trap handler.
if (trap_handler::IsTrapHandlerEnabled()) return;
static const MachineType machineTypes[] = { static const MachineType machineTypes[] = {
MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(), MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(),
MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(), MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(),
MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(), MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(),
MachineType::Float64()}; MachineType::Float64()};
constexpr size_t num_bytes = kWasmPageSize;
for (size_t m = 0; m < arraysize(machineTypes); ++m) { for (size_t m = 0; m < arraysize(machineTypes); ++m) {
WasmRunner<int32_t, uint32_t> r(execution_mode); WasmRunner<int32_t, uint32_t> r(execution_mode);
r.builder().AddMemoryElems<int32_t>(8); r.builder().AddMemoryElems<byte>(num_bytes);
r.builder().RandomizeMemory(1116 + static_cast<int>(m)); r.builder().RandomizeMemory(1116 + static_cast<int>(m));
uint32_t boundary = 24 - WasmOpcodes::MemSize(machineTypes[m]); constexpr byte offset = 8;
uint32_t boundary =
num_bytes - offset - WasmOpcodes::MemSize(machineTypes[m]);
BUILD(r, WASM_LOAD_MEM_OFFSET(machineTypes[m], 8, WASM_GET_LOCAL(0)), BUILD(r, WASM_LOAD_MEM_OFFSET(machineTypes[m], offset, WASM_GET_LOCAL(0)),
WASM_DROP, WASM_ZERO); WASM_DROP, WASM_ZERO);
CHECK_EQ(0, r.Call(boundary)); // in bounds. CHECK_EQ(0, r.Call(boundary)); // in bounds.
...@@ -1568,20 +1568,21 @@ WASM_EXEC_TEST(LoadMemI32_offset) { ...@@ -1568,20 +1568,21 @@ WASM_EXEC_TEST(LoadMemI32_offset) {
} }
WASM_EXEC_TEST(LoadMemI32_const_oob_misaligned) { WASM_EXEC_TEST(LoadMemI32_const_oob_misaligned) {
// TODO(eholk): Fix this test for the trap handler. // This test accesses memory starting at kRunwayLength bytes before the end of
if (trap_handler::IsTrapHandlerEnabled()) return; // the memory until a few bytes beyond.
constexpr byte kMemSize = 12; constexpr byte kRunwayLength = 12;
// TODO(titzer): Fix misaligned accesses on MIPS and re-enable. // TODO(titzer): Fix misaligned accesses on MIPS and re-enable.
for (byte offset = 0; offset < kMemSize + 5; ++offset) { for (byte offset = 0; offset < kRunwayLength + 5; ++offset) {
for (byte index = 0; index < kMemSize + 5; ++index) { for (uint32_t index = kWasmPageSize - kRunwayLength;
index < kWasmPageSize + 5; ++index) {
WasmRunner<int32_t> r(execution_mode); WasmRunner<int32_t> r(execution_mode);
r.builder().AddMemoryElems<byte>(kMemSize); r.builder().AddMemoryElems<byte>(kWasmPageSize);
r.builder().RandomizeMemory(); r.builder().RandomizeMemory();
BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset, BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset,
WASM_I32V_2(index))); WASM_I32V_3(index)));
if (offset + index <= (kMemSize - sizeof(int32_t))) { if (offset + index + sizeof(int32_t) <= kWasmPageSize) {
CHECK_EQ(r.builder().raw_val_at<int32_t>(offset + index), r.Call()); CHECK_EQ(r.builder().raw_val_at<int32_t>(offset + index), r.Call());
} else { } else {
CHECK_TRAP(r.Call()); CHECK_TRAP(r.Call());
...@@ -1591,19 +1592,20 @@ WASM_EXEC_TEST(LoadMemI32_const_oob_misaligned) { ...@@ -1591,19 +1592,20 @@ WASM_EXEC_TEST(LoadMemI32_const_oob_misaligned) {
} }
WASM_EXEC_TEST(LoadMemI32_const_oob) { WASM_EXEC_TEST(LoadMemI32_const_oob) {
// TODO(eholk): Fix this test for the trap handler. // This test accesses memory starting at kRunwayLength bytes before the end of
if (trap_handler::IsTrapHandlerEnabled()) return; // the memory until a few bytes beyond.
constexpr byte kMemSize = 24; constexpr byte kRunwayLength = 24;
for (byte offset = 0; offset < kMemSize + 5; offset += 4) { for (byte offset = 0; offset < kRunwayLength + 5; offset += 4) {
for (byte index = 0; index < kMemSize + 5; index += 4) { for (uint32_t index = kWasmPageSize - kRunwayLength;
index < kWasmPageSize + 5; index += 4) {
WasmRunner<int32_t> r(execution_mode); WasmRunner<int32_t> r(execution_mode);
r.builder().AddMemoryElems<byte>(kMemSize); r.builder().AddMemoryElems<byte>(kWasmPageSize);
r.builder().RandomizeMemory(); r.builder().RandomizeMemory();
BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset, BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), offset,
WASM_I32V_2(index))); WASM_I32V_3(index)));
if (offset + index <= (kMemSize - sizeof(int32_t))) { if (offset + index + sizeof(int32_t) <= kWasmPageSize) {
CHECK_EQ(r.builder().raw_val_at<int32_t>(offset + index), r.Call()); CHECK_EQ(r.builder().raw_val_at<int32_t>(offset + index), r.Call());
} else { } else {
CHECK_TRAP(r.Call()); CHECK_TRAP(r.Call());
...@@ -1653,17 +1655,17 @@ WASM_EXEC_TEST(StoreMemI32_offset) { ...@@ -1653,17 +1655,17 @@ WASM_EXEC_TEST(StoreMemI32_offset) {
} }
WASM_EXEC_TEST(StoreMem_offset_oob) { WASM_EXEC_TEST(StoreMem_offset_oob) {
// TODO(eholk): Fix this test for the trap handler.
if (trap_handler::IsTrapHandlerEnabled()) return;
// 64-bit cases are handled in test-run-wasm-64.cc // 64-bit cases are handled in test-run-wasm-64.cc
static const MachineType machineTypes[] = { static const MachineType machineTypes[] = {
MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(), MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(),
MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(), MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(),
MachineType::Float32(), MachineType::Float64()}; MachineType::Float32(), MachineType::Float64()};
constexpr size_t num_bytes = kWasmPageSize;
for (size_t m = 0; m < arraysize(machineTypes); ++m) { for (size_t m = 0; m < arraysize(machineTypes); ++m) {
WasmRunner<int32_t, uint32_t> r(execution_mode); WasmRunner<int32_t, uint32_t> r(execution_mode);
byte* memory = r.builder().AddMemoryElems<byte>(32); byte* memory = r.builder().AddMemoryElems<byte>(num_bytes);
r.builder().RandomizeMemory(1119 + static_cast<int>(m)); r.builder().RandomizeMemory(1119 + static_cast<int>(m));
...@@ -1672,7 +1674,7 @@ WASM_EXEC_TEST(StoreMem_offset_oob) { ...@@ -1672,7 +1674,7 @@ WASM_EXEC_TEST(StoreMem_offset_oob) {
WASM_ZERO); WASM_ZERO);
byte memsize = WasmOpcodes::MemSize(machineTypes[m]); byte memsize = WasmOpcodes::MemSize(machineTypes[m]);
uint32_t boundary = 24 - memsize; uint32_t boundary = num_bytes - 8 - memsize;
CHECK_EQ(0, r.Call(boundary)); // in bounds. CHECK_EQ(0, r.Call(boundary)); // in bounds.
CHECK_EQ(0, memcmp(&memory[0], &memory[8 + boundary], memsize)); CHECK_EQ(0, memcmp(&memory[0], &memory[8 + boundary], memsize));
......
...@@ -514,22 +514,6 @@ class WasmRunner : public WasmRunnerBase { ...@@ -514,22 +514,6 @@ class WasmRunner : public WasmRunnerBase {
TEST(RunWasmLiftoff_##name) { RunWasm_##name(kExecuteLiftoff); } \ TEST(RunWasmLiftoff_##name) { RunWasm_##name(kExecuteLiftoff); } \
void RunWasm_##name(WasmExecutionMode execution_mode) void RunWasm_##name(WasmExecutionMode execution_mode)
#define WASM_EXEC_TEST_WITH_TRAP(name) \
void RunWasm_##name(WasmExecutionMode execution_mode); \
TEST(RunWasmTurbofan_##name) { \
if (trap_handler::UseTrapHandler()) return; \
RunWasm_##name(kExecuteTurbofan); \
} \
TEST(RunWasmLiftoff_##name) { \
if (trap_handler::UseTrapHandler()) return; \
RunWasm_##name(kExecuteLiftoff); \
} \
TEST(RunWasmInterpreter_##name) { \
if (trap_handler::UseTrapHandler()) return; \
RunWasm_##name(kExecuteInterpreter); \
} \
void RunWasm_##name(WasmExecutionMode execution_mode)
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment