[wasm] Cover some more traps in test-run-wasm-exceptions.
R=clemensh@chromium.org TEST=cctest/test-run-wasm-exceptions BUG=v8:8729 Change-Id: I3751599bd72aaae1a9816e728437c64daf465f41 Reviewed-on: https://chromium-review.googlesource.com/c/1477733 Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#59691}
This commit is contained in:
parent
ef3505cbb0
commit
a9a5196594
@ -158,20 +158,23 @@ WASM_EXEC_TEST(TryCatchTrapTypeError) {
|
||||
r.CheckCallViaJS(kResult1, 1);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// TODO(8729): The semantics of this are not yet specified and might change,
|
||||
// this test aims at keeping semantics of various execution tiers consistent.
|
||||
// TODO(mstarzinger): Add further tests for different kinds of traps.
|
||||
WASM_EXEC_TEST(TryCatchTrapUnreachable) {
|
||||
void TestTryCatchTrap(byte* code, size_t code_size,
|
||||
ExecutionTier execution_tier) {
|
||||
TestSignatures sigs;
|
||||
EXPERIMENTAL_FLAG_SCOPE(eh);
|
||||
WasmRunner<uint32_t, uint32_t> r(execution_tier, nullptr, "main",
|
||||
kRuntimeExceptionSupport);
|
||||
r.builder().AddMemory(kWasmPageSize);
|
||||
constexpr uint32_t kResult0 = 23;
|
||||
constexpr uint32_t kResult1 = 42;
|
||||
|
||||
// Build a trapping helper function.
|
||||
WasmFunctionCompiler& trap_func = r.NewFunction(sigs.i_ii());
|
||||
BUILD(trap_func, WASM_UNREACHABLE);
|
||||
trap_func.Build(code, code + code_size);
|
||||
|
||||
// Build the main test function.
|
||||
BUILD(r, WASM_TRY_CATCH_T(
|
||||
@ -189,6 +192,28 @@ WASM_EXEC_TEST(TryCatchTrapUnreachable) {
|
||||
r.CheckCallViaJS(kResult1, 1);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
WASM_EXEC_TEST(TryCatchTrapUnreachable) {
|
||||
byte code[] = {WASM_UNREACHABLE};
|
||||
TestTryCatchTrap(code, arraysize(code), execution_tier);
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(TryCatchTrapMemOutOfBounds) {
|
||||
byte code[] = {WASM_LOAD_MEM(MachineType::Int32(), WASM_I32V_1(-1))};
|
||||
TestTryCatchTrap(code, arraysize(code), execution_tier);
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(TryCatchTrapDivByZero) {
|
||||
byte code[] = {WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_I32V_1(0))};
|
||||
TestTryCatchTrap(code, arraysize(code), execution_tier);
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(TryCatchTrapRemByZero) {
|
||||
byte code[] = {WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_I32V_1(0))};
|
||||
TestTryCatchTrap(code, arraysize(code), execution_tier);
|
||||
}
|
||||
|
||||
} // namespace test_run_wasm_exceptions
|
||||
} // namespace wasm
|
||||
} // namespace internal
|
||||
|
Loading…
Reference in New Issue
Block a user