Commit e90623b6 authored by Zhi An Ng's avatar Zhi An Ng Committed by Commit Bot

[wasm-simd] Add OOB tests for v128.load and v128.store

We had some tests, but weren't checking for OOB. Add some tests.

Change-Id: I63d4d199fe8b7be51a8e0a5a2d9b3a328e5d7ab5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2546127Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71302}
parent 41811812
......@@ -3579,6 +3579,33 @@ WASM_SIMD_TEST(SimdLoadStoreLoad) {
r.builder().WriteMemory(&memory[1], expected);
CHECK_EQ(expected, r.Call());
}
{
// OOB tests for loads.
WasmRunner<int32_t, uint32_t> r(execution_tier, lower_simd);
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
BUILD(r, WASM_SIMD_I32x4_EXTRACT_LANE(
0, WASM_SIMD_LOAD_MEM(WASM_GET_LOCAL(0))));
for (uint32_t offset = kWasmPageSize - (kSimd128Size - 1);
offset < kWasmPageSize; ++offset) {
CHECK_TRAP(r.Call(offset));
}
}
{
// OOB tests for stores.
WasmRunner<int32_t, uint32_t> r(execution_tier, lower_simd);
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
BUILD(r,
WASM_SIMD_STORE_MEM(WASM_GET_LOCAL(0), WASM_SIMD_LOAD_MEM(WASM_ZERO)),
WASM_ONE);
for (uint32_t offset = kWasmPageSize - (kSimd128Size - 1);
offset < kWasmPageSize; ++offset) {
CHECK_TRAP(r.Call(offset));
}
}
}
WASM_SIMD_TEST(SimdLoadStoreLoadMemargOffset) {
......@@ -3602,6 +3629,32 @@ WASM_SIMD_TEST(SimdLoadStoreLoadMemargOffset) {
r.builder().WriteMemory(&memory[1], expected);
CHECK_EQ(expected, r.Call());
}
{
// OOB tests for loads with offsets.
for (uint32_t offset = kWasmPageSize - (kSimd128Size - 1);
offset < kWasmPageSize; ++offset) {
WasmRunner<int32_t> r(execution_tier, lower_simd);
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
BUILD(r, WASM_SIMD_I32x4_EXTRACT_LANE(
0, WASM_SIMD_LOAD_MEM_OFFSET(U32V_3(offset), WASM_ZERO)));
CHECK_TRAP(r.Call());
}
}
{
// OOB tests for stores with offsets
for (uint32_t offset = kWasmPageSize - (kSimd128Size - 1);
offset < kWasmPageSize; ++offset) {
WasmRunner<int32_t, uint32_t> r(execution_tier, lower_simd);
r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t));
BUILD(r,
WASM_SIMD_STORE_MEM_OFFSET(U32V_3(offset), WASM_ZERO,
WASM_SIMD_LOAD_MEM(WASM_ZERO)),
WASM_ONE);
CHECK_TRAP(r.Call(offset));
}
}
}
// Test a multi-byte opcode with offset values that encode into valid opcodes.
......
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