Commit a183b8be authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Clean up WASM_CALL_INDIRECT macros

Fix a TODO from Ben to change the macro argument order to match the
actual order in wasm code.
After this fix, we can remove the individual {WASM_CALL_INDIRECT[0-5]}
macros and implement them via a common variadic macro.

Also, rename {WASM_CALL_INDIRECT_TABLE0} to {WASM_CALL_INDIRECT_TABLE}.
The name was confusing, because this macro explictly allows to set a
table index different from 0. Thus, just drop the "0" in the name.

The individual test changes were done via a vim macro, to avoid manual
errors.

R=mstarzinger@chromium.org

Bug: v8:10021
Change-Id: I9f0f31511c5c6e20a0b07524bf75fe9cf1598eba
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1940265Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65242}
parent 3ec1d591
......@@ -84,7 +84,7 @@ TEST(Liftoff_deterministic_call) {
TEST(Liftoff_deterministic_indirect_call) {
CheckDeterministicCompilation(
{kWasmI32}, {kWasmI32},
{WASM_I32_ADD(WASM_CALL_INDIRECT1(0, WASM_I32V_1(47), WASM_GET_LOCAL(0)),
{WASM_I32_ADD(WASM_CALL_INDIRECT(0, WASM_GET_LOCAL(0), WASM_I32V_1(47)),
WASM_GET_LOCAL(0))});
}
......
......@@ -438,7 +438,7 @@ void TestTableInitElems(ExecutionTier execution_tier, int table_index) {
WasmFunctionCompiler& call = r.NewFunction(sigs.i_i(), "call");
BUILD(call,
WASM_CALL_INDIRECT_TABLE0(table_index, sig_index, WASM_GET_LOCAL(0)));
WASM_CALL_INDIRECT_TABLE(table_index, sig_index, WASM_GET_LOCAL(0)));
const uint32_t call_index = call.function_index();
BUILD(r,
......@@ -510,7 +510,7 @@ void TestTableInitOob(ExecutionTier execution_tier, int table_index) {
WasmFunctionCompiler& call = r.NewFunction(sigs.i_i(), "call");
BUILD(call,
WASM_CALL_INDIRECT_TABLE0(table_index, sig_index, WASM_GET_LOCAL(0)));
WASM_CALL_INDIRECT_TABLE(table_index, sig_index, WASM_GET_LOCAL(0)));
const uint32_t call_index = call.function_index();
BUILD(r,
......@@ -671,7 +671,7 @@ void TestTableCopyCalls(ExecutionTier execution_tier, int table_dst,
WasmFunctionCompiler& call = r.NewFunction(sigs.i_i(), "call");
BUILD(call,
WASM_CALL_INDIRECT_TABLE0(table_dst, sig_index, WASM_GET_LOCAL(0)));
WASM_CALL_INDIRECT_TABLE(table_dst, sig_index, WASM_GET_LOCAL(0)));
const uint32_t call_index = call.function_index();
BUILD(r,
......
......@@ -81,13 +81,14 @@ WASM_EXEC_TEST(TryCatchCallIndirect) {
arraysize(indirect_function_table));
// Build the main test function.
BUILD(r, WASM_TRY_CATCH_T(
BUILD(r,
WASM_TRY_CATCH_T(
kWasmI32,
WASM_STMTS(WASM_I32V(kResult1),
WASM_IF(WASM_I32_EQZ(WASM_GET_LOCAL(0)),
WASM_STMTS(WASM_CALL_INDIRECT2(
sig_index, WASM_GET_LOCAL(0),
WASM_I32V(7), WASM_I32V(9)),
WASM_STMTS(WASM_CALL_INDIRECT(
sig_index, WASM_I32V(7),
WASM_I32V(9), WASM_GET_LOCAL(0)),
WASM_DROP))),
WASM_STMTS(WASM_DROP, WASM_I32V(kResult0))));
......
......@@ -229,16 +229,16 @@ TEST(Run_Wasm_returnCallIndirectFactorial) {
r.builder().AddIndirectFunctionTable(indirect_function_table,
arraysize(indirect_function_table));
BUILD(r, WASM_RETURN_CALL_INDIRECT(sig_index, WASM_I32V(0), WASM_GET_LOCAL(0),
WASM_I32V(1)));
BUILD(r, WASM_RETURN_CALL_INDIRECT(sig_index, WASM_GET_LOCAL(0), WASM_I32V(1),
WASM_ZERO));
BUILD(fact_aux_fn,
BUILD(
fact_aux_fn,
WASM_IF_ELSE_I(
WASM_I32_EQ(WASM_I32V(1), WASM_GET_LOCAL(0)), WASM_GET_LOCAL(1),
WASM_RETURN_CALL_INDIRECT(
sig_index, WASM_I32V(0),
WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I32V(1)),
WASM_I32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))));
sig_index, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I32V(1)),
WASM_I32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO)));
uint32_t test_values[] = {1, 2, 5, 10, 20};
......
......@@ -147,9 +147,8 @@ WASM_EXEC_TEST(Run_IndirectCallJSFunction) {
r.builder().AddIndirectFunctionTable(indirect_function_table,
arraysize(indirect_function_table));
BUILD(rc_fn,
WASM_CALL_INDIRECT3(sig_index, WASM_I32V(js_index), WASM_I32V(left),
WASM_I32V(right), WASM_GET_LOCAL(0)));
BUILD(rc_fn, WASM_CALL_INDIRECT(sig_index, WASM_I32V(left), WASM_I32V(right),
WASM_GET_LOCAL(0), WASM_I32V(js_index)));
Handle<Object> args_left[] = {isolate->factory()->NewNumber(1)};
r.CheckCallApplyViaJS(left, rc_fn.function_index(), args_left, 1);
......@@ -545,9 +544,9 @@ void RunPickerTest(ExecutionTier tier, bool indirect) {
r.builder().AddIndirectFunctionTable(indirect_function_table,
arraysize(indirect_function_table));
BUILD(rc_fn, WASM_RETURN_CALL_INDIRECT(sig_index, WASM_I32V(js_index),
WASM_I32V(left), WASM_I32V(right),
WASM_GET_LOCAL(0)));
BUILD(rc_fn, WASM_RETURN_CALL_INDIRECT(sig_index, WASM_I32V(left),
WASM_I32V(right), WASM_GET_LOCAL(0),
WASM_I32V(js_index)));
} else {
BUILD(rc_fn,
WASM_RETURN_CALL_FUNCTION(js_index, WASM_I32V(left), WASM_I32V(right),
......
......@@ -2508,13 +2508,12 @@ WASM_EXEC_TEST(ReturnCall_IndirectFactorial) {
WASM_I32V(1), WASM_I32V(f_ind_index)));
BUILD(f_ind_fn,
WASM_IF_ELSE_I(WASM_I32_LES(WASM_GET_LOCAL(0), WASM_I32V(1)),
WASM_GET_LOCAL(1),
WASM_IF_ELSE_I(
WASM_I32_LES(WASM_GET_LOCAL(0), WASM_I32V(1)), WASM_GET_LOCAL(1),
WASM_RETURN_CALL_INDIRECT(
sig_index, WASM_GET_LOCAL(2),
WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I32V(1)),
sig_index, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I32V(1)),
WASM_I32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)),
WASM_GET_LOCAL(2))));
WASM_GET_LOCAL(2), WASM_GET_LOCAL(2))));
uint32_t test_values[] = {1, 2, 5, 10, 10000};
......@@ -2944,8 +2943,8 @@ WASM_EXEC_TEST(SimpleCallIndirect) {
arraysize(indirect_function_table));
// Build the caller function.
BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I32V_2(66),
WASM_I32V_1(22)));
BUILD(r, WASM_CALL_INDIRECT(1, WASM_I32V_2(66), WASM_I32V_1(22),
WASM_GET_LOCAL(0)));
CHECK_EQ(88, r.Call(0));
CHECK_EQ(44, r.Call(1));
......@@ -2977,11 +2976,11 @@ WASM_EXEC_TEST(MultipleCallIndirect) {
arraysize(indirect_function_table));
// Build the caller function.
BUILD(r, WASM_I32_ADD(
WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1),
WASM_GET_LOCAL(2)),
WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(1), WASM_GET_LOCAL(2),
WASM_GET_LOCAL(0))));
BUILD(r,
WASM_I32_ADD(WASM_CALL_INDIRECT(1, WASM_GET_LOCAL(1), WASM_GET_LOCAL(2),
WASM_GET_LOCAL(0)),
WASM_CALL_INDIRECT(1, WASM_GET_LOCAL(2), WASM_GET_LOCAL(0),
WASM_GET_LOCAL(1))));
CHECK_EQ(5, r.Call(0, 1, 2));
CHECK_EQ(19, r.Call(0, 1, 9));
......@@ -3009,8 +3008,8 @@ WASM_EXEC_TEST(CallIndirect_EmptyTable) {
r.builder().AddIndirectFunctionTable(nullptr, 0);
// Build the caller function.
BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I32V_2(66),
WASM_I32V_1(22)));
BUILD(r, WASM_CALL_INDIRECT(1, WASM_I32V_2(66), WASM_I32V_1(22),
WASM_GET_LOCAL(0)));
CHECK_TRAP(r.Call(0));
CHECK_TRAP(r.Call(1));
......@@ -3048,8 +3047,8 @@ WASM_EXEC_TEST(CallIndirect_canonical) {
arraysize(indirect_function_table));
// Build the caller function.
BUILD(r, WASM_CALL_INDIRECT2(1, WASM_GET_LOCAL(0), WASM_I32V_2(77),
WASM_I32V_1(11)));
BUILD(r, WASM_CALL_INDIRECT(1, WASM_I32V_2(77), WASM_I32V_1(11),
WASM_GET_LOCAL(0)));
CHECK_EQ(88, r.Call(0));
CHECK_EQ(66, r.Call(1));
......
......@@ -410,31 +410,14 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
#define TABLE_ZERO 0
// TODO(titzer): change usages of these macros to put func last.
#define WASM_CALL_INDIRECT0(sig_index, func) \
func, kExprCallIndirect, static_cast<byte>(sig_index), TABLE_ZERO
#define WASM_CALL_INDIRECT1(sig_index, func, a) \
a, func, kExprCallIndirect, static_cast<byte>(sig_index), TABLE_ZERO
#define WASM_CALL_INDIRECT2(sig_index, func, a, b) \
a, b, func, kExprCallIndirect, static_cast<byte>(sig_index), TABLE_ZERO
#define WASM_CALL_INDIRECT3(sig_index, func, a, b, c) \
a, b, c, func, kExprCallIndirect, static_cast<byte>(sig_index), TABLE_ZERO
#define WASM_CALL_INDIRECT4(sig_index, func, a, b, c, d) \
a, b, c, d, func, kExprCallIndirect, static_cast<byte>(sig_index), TABLE_ZERO
#define WASM_CALL_INDIRECT5(sig_index, func, a, b, c, d, e) \
a, b, c, d, e, func, kExprCallIndirect, static_cast<byte>(sig_index), \
TABLE_ZERO
#define WASM_CALL_INDIRECTN(arity, sig_index, func, ...) \
__VA_ARGS__, func, kExprCallIndirect, static_cast<byte>(sig_index), TABLE_ZERO
#define WASM_CALL_INDIRECT_TABLE0(table, sig_index, func) \
func, kExprCallIndirect, static_cast<byte>(sig_index), \
// Pass: sig_index, ...args, func_index
#define WASM_CALL_INDIRECT(sig_index, ...) \
__VA_ARGS__, kExprCallIndirect, static_cast<byte>(sig_index), TABLE_ZERO
#define WASM_CALL_INDIRECT_TABLE(table, sig_index, ...) \
__VA_ARGS__, kExprCallIndirect, static_cast<byte>(sig_index), \
static_cast<byte>(table)
#define WASM_RETURN_CALL_INDIRECT0(sig_index, func) \
func, kExprReturnCallIndirect, static_cast<byte>(sig_index), TABLE_ZERO
#define WASM_RETURN_CALL_INDIRECT(sig_index, func, ...) \
__VA_ARGS__, func, kExprReturnCallIndirect, static_cast<byte>(sig_index), \
TABLE_ZERO
#define WASM_RETURN_CALL_INDIRECT(sig_index, ...) \
__VA_ARGS__, kExprReturnCallIndirect, static_cast<byte>(sig_index), TABLE_ZERO
#define WASM_NOT(x) x, kExprI32Eqz
#define WASM_SEQ(...) __VA_ARGS__
......
......@@ -1618,11 +1618,11 @@ TEST_F(FunctionBodyDecoderTest, SimpleIndirectReturnCalls) {
byte sig1 = builder.AddSignature(sigs.i_i());
byte sig2 = builder.AddSignature(sigs.i_ii());
ExpectValidates(sig, {WASM_RETURN_CALL_INDIRECT0(sig0, WASM_ZERO)});
ExpectValidates(sig, {WASM_RETURN_CALL_INDIRECT(sig0, WASM_ZERO)});
ExpectValidates(
sig, {WASM_RETURN_CALL_INDIRECT(sig1, WASM_ZERO, WASM_I32V_1(22))});
ExpectValidates(sig, {WASM_RETURN_CALL_INDIRECT(
sig2, WASM_ZERO, WASM_I32V_1(32), WASM_I32V_2(72))});
sig, {WASM_RETURN_CALL_INDIRECT(sig1, WASM_I32V_1(22), WASM_ZERO)});
ExpectValidates(sig, {WASM_RETURN_CALL_INDIRECT(sig2, WASM_I32V_1(32),
WASM_I32V_2(72), WASM_ZERO)});
}
TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsOutOfBounds) {
......@@ -1633,18 +1633,18 @@ TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsOutOfBounds) {
builder.AddTable(kWasmFuncRef, 20, false, 20);
module = builder.module();
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT0(0, WASM_ZERO)});
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT(0, WASM_ZERO)});
builder.AddSignature(sigs.i_v());
ExpectValidates(sig, {WASM_RETURN_CALL_INDIRECT0(0, WASM_ZERO)});
ExpectValidates(sig, {WASM_RETURN_CALL_INDIRECT(0, WASM_ZERO)});
ExpectFailure(sig,
{WASM_RETURN_CALL_INDIRECT(1, WASM_ZERO, WASM_I32V_1(22))});
{WASM_RETURN_CALL_INDIRECT(1, WASM_I32V_1(22), WASM_ZERO)});
builder.AddSignature(sigs.i_i());
ExpectValidates(sig,
{WASM_RETURN_CALL_INDIRECT(1, WASM_ZERO, WASM_I32V_1(27))});
{WASM_RETURN_CALL_INDIRECT(1, WASM_I32V_1(27), WASM_ZERO)});
ExpectFailure(sig,
{WASM_RETURN_CALL_INDIRECT(2, WASM_ZERO, WASM_I32V_1(27))});
{WASM_RETURN_CALL_INDIRECT(2, WASM_I32V_1(27), WASM_ZERO)});
}
TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsWithMismatchedSigs3) {
......@@ -1658,24 +1658,24 @@ TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsWithMismatchedSigs3) {
byte sig0 = builder.AddSignature(sigs.i_f());
ExpectFailure(sig,
{WASM_RETURN_CALL_INDIRECT(sig0, WASM_ZERO, WASM_I32V_1(17))});
{WASM_RETURN_CALL_INDIRECT(sig0, WASM_I32V_1(17), WASM_ZERO)});
ExpectFailure(sig,
{WASM_RETURN_CALL_INDIRECT(sig0, WASM_ZERO, WASM_I64V_1(27))});
{WASM_RETURN_CALL_INDIRECT(sig0, WASM_I64V_1(27), WASM_ZERO)});
ExpectFailure(sig,
{WASM_RETURN_CALL_INDIRECT(sig0, WASM_ZERO, WASM_F64(37.2))});
{WASM_RETURN_CALL_INDIRECT(sig0, WASM_F64(37.2), WASM_ZERO)});
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT0(sig0, WASM_I32V_1(17))});
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT0(sig0, WASM_I64V_1(27))});
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT0(sig0, WASM_F64(37.2))});
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT(sig0, WASM_I32V_1(17))});
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT(sig0, WASM_I64V_1(27))});
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT(sig0, WASM_F64(37.2))});
byte sig1 = builder.AddFunction(sigs.i_d());
ExpectFailure(sig,
{WASM_RETURN_CALL_INDIRECT(sig1, WASM_ZERO, WASM_I32V_1(16))});
{WASM_RETURN_CALL_INDIRECT(sig1, WASM_I32V_1(16), WASM_ZERO)});
ExpectFailure(sig,
{WASM_RETURN_CALL_INDIRECT(sig1, WASM_ZERO, WASM_I64V_1(16))});
{WASM_RETURN_CALL_INDIRECT(sig1, WASM_I64V_1(16), WASM_ZERO)});
ExpectFailure(sig,
{WASM_RETURN_CALL_INDIRECT(sig1, WASM_ZERO, WASM_F32(17.6))});
{WASM_RETURN_CALL_INDIRECT(sig1, WASM_F32(17.6), WASM_ZERO)});
}
TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsWithoutTableCrash) {
......@@ -1689,11 +1689,11 @@ TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsWithoutTableCrash) {
byte sig1 = builder.AddSignature(sigs.i_i());
byte sig2 = builder.AddSignature(sigs.i_ii());
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT0(sig0, WASM_ZERO)});
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT(sig0, WASM_ZERO)});
ExpectFailure(sig,
{WASM_RETURN_CALL_INDIRECT(sig1, WASM_ZERO, WASM_I32V_1(22))});
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT(
sig2, WASM_ZERO, WASM_I32V_1(32), WASM_I32V_2(72))});
{WASM_RETURN_CALL_INDIRECT(sig1, WASM_I32V_1(22), WASM_ZERO)});
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT(sig2, WASM_I32V_1(32),
WASM_I32V_2(72), WASM_ZERO)});
}
TEST_F(FunctionBodyDecoderTest, IncompleteIndirectReturnCall) {
......@@ -1760,10 +1760,10 @@ TEST_F(FunctionBodyDecoderTest, SimpleIndirectCalls) {
byte sig1 = builder.AddSignature(sigs.i_i());
byte sig2 = builder.AddSignature(sigs.i_ii());
ExpectValidates(sig, {WASM_CALL_INDIRECT0(sig0, WASM_ZERO)});
ExpectValidates(sig, {WASM_CALL_INDIRECT1(sig1, WASM_ZERO, WASM_I32V_1(22))});
ExpectValidates(sig, {WASM_CALL_INDIRECT2(sig2, WASM_ZERO, WASM_I32V_1(32),
WASM_I32V_2(72))});
ExpectValidates(sig, {WASM_CALL_INDIRECT(sig0, WASM_ZERO)});
ExpectValidates(sig, {WASM_CALL_INDIRECT(sig1, WASM_I32V_1(22), WASM_ZERO)});
ExpectValidates(sig, {WASM_CALL_INDIRECT(sig2, WASM_I32V_1(32),
WASM_I32V_2(72), WASM_ZERO)});
}
TEST_F(FunctionBodyDecoderTest, IndirectCallsOutOfBounds) {
......@@ -1772,15 +1772,15 @@ TEST_F(FunctionBodyDecoderTest, IndirectCallsOutOfBounds) {
builder.AddTable(kWasmFuncRef, 20, false, 20);
module = builder.module();
ExpectFailure(sig, {WASM_CALL_INDIRECT0(0, WASM_ZERO)});
ExpectFailure(sig, {WASM_CALL_INDIRECT(0, WASM_ZERO)});
builder.AddSignature(sigs.i_v());
ExpectValidates(sig, {WASM_CALL_INDIRECT0(0, WASM_ZERO)});
ExpectValidates(sig, {WASM_CALL_INDIRECT(0, WASM_ZERO)});
ExpectFailure(sig, {WASM_CALL_INDIRECT1(1, WASM_ZERO, WASM_I32V_1(22))});
ExpectFailure(sig, {WASM_CALL_INDIRECT(1, WASM_I32V_1(22), WASM_ZERO)});
builder.AddSignature(sigs.i_i());
ExpectValidates(sig, {WASM_CALL_INDIRECT1(1, WASM_ZERO, WASM_I32V_1(27))});
ExpectValidates(sig, {WASM_CALL_INDIRECT(1, WASM_I32V_1(27), WASM_ZERO)});
ExpectFailure(sig, {WASM_CALL_INDIRECT1(2, WASM_ZERO, WASM_I32V_1(27))});
ExpectFailure(sig, {WASM_CALL_INDIRECT(2, WASM_I32V_1(27), WASM_ZERO)});
}
TEST_F(FunctionBodyDecoderTest, IndirectCallsWithMismatchedSigs3) {
......@@ -1791,19 +1791,19 @@ TEST_F(FunctionBodyDecoderTest, IndirectCallsWithMismatchedSigs3) {
byte sig0 = builder.AddSignature(sigs.i_f());
ExpectFailure(sig, {WASM_CALL_INDIRECT1(sig0, WASM_ZERO, WASM_I32V_1(17))});
ExpectFailure(sig, {WASM_CALL_INDIRECT1(sig0, WASM_ZERO, WASM_I64V_1(27))});
ExpectFailure(sig, {WASM_CALL_INDIRECT1(sig0, WASM_ZERO, WASM_F64(37.2))});
ExpectFailure(sig, {WASM_CALL_INDIRECT(sig0, WASM_I32V_1(17), WASM_ZERO)});
ExpectFailure(sig, {WASM_CALL_INDIRECT(sig0, WASM_I64V_1(27), WASM_ZERO)});
ExpectFailure(sig, {WASM_CALL_INDIRECT(sig0, WASM_F64(37.2), WASM_ZERO)});
ExpectFailure(sig, {WASM_CALL_INDIRECT0(sig0, WASM_I32V_1(17))});
ExpectFailure(sig, {WASM_CALL_INDIRECT0(sig0, WASM_I64V_1(27))});
ExpectFailure(sig, {WASM_CALL_INDIRECT0(sig0, WASM_F64(37.2))});
ExpectFailure(sig, {WASM_CALL_INDIRECT(sig0, WASM_I32V_1(17))});
ExpectFailure(sig, {WASM_CALL_INDIRECT(sig0, WASM_I64V_1(27))});
ExpectFailure(sig, {WASM_CALL_INDIRECT(sig0, WASM_F64(37.2))});
byte sig1 = builder.AddFunction(sigs.i_d());
ExpectFailure(sig, {WASM_CALL_INDIRECT1(sig1, WASM_ZERO, WASM_I32V_1(16))});
ExpectFailure(sig, {WASM_CALL_INDIRECT1(sig1, WASM_ZERO, WASM_I64V_1(16))});
ExpectFailure(sig, {WASM_CALL_INDIRECT1(sig1, WASM_ZERO, WASM_F32(17.6))});
ExpectFailure(sig, {WASM_CALL_INDIRECT(sig1, WASM_I32V_1(16), WASM_ZERO)});
ExpectFailure(sig, {WASM_CALL_INDIRECT(sig1, WASM_I64V_1(16), WASM_ZERO)});
ExpectFailure(sig, {WASM_CALL_INDIRECT(sig1, WASM_F32(17.6), WASM_ZERO)});
}
TEST_F(FunctionBodyDecoderTest, IndirectCallsWithoutTableCrash) {
......@@ -1815,10 +1815,10 @@ TEST_F(FunctionBodyDecoderTest, IndirectCallsWithoutTableCrash) {
byte sig1 = builder.AddSignature(sigs.i_i());
byte sig2 = builder.AddSignature(sigs.i_ii());
ExpectFailure(sig, {WASM_CALL_INDIRECT0(sig0, WASM_ZERO)});
ExpectFailure(sig, {WASM_CALL_INDIRECT1(sig1, WASM_ZERO, WASM_I32V_1(22))});
ExpectFailure(sig, {WASM_CALL_INDIRECT2(sig2, WASM_ZERO, WASM_I32V_1(32),
WASM_I32V_2(72))});
ExpectFailure(sig, {WASM_CALL_INDIRECT(sig0, WASM_ZERO)});
ExpectFailure(sig, {WASM_CALL_INDIRECT(sig1, WASM_I32V_1(22), WASM_ZERO)});
ExpectFailure(sig, {WASM_CALL_INDIRECT(sig2, WASM_I32V_1(32), WASM_I32V_2(72),
WASM_ZERO)});
}
TEST_F(FunctionBodyDecoderTest, IncompleteIndirectCall) {
......
......@@ -133,12 +133,12 @@ TEST_F(WasmMacroGenTest, CallFunction) {
}
TEST_F(WasmMacroGenTest, CallIndirect) {
EXPECT_SIZE(5, WASM_CALL_INDIRECT0(0, WASM_ZERO));
EXPECT_SIZE(5, WASM_CALL_INDIRECT0(1, WASM_ZERO));
EXPECT_SIZE(5, WASM_CALL_INDIRECT0(11, WASM_ZERO));
EXPECT_SIZE(5, WASM_CALL_INDIRECT(0, WASM_ZERO));
EXPECT_SIZE(5, WASM_CALL_INDIRECT(1, WASM_ZERO));
EXPECT_SIZE(5, WASM_CALL_INDIRECT(11, WASM_ZERO));
EXPECT_SIZE(7, WASM_CALL_INDIRECT1(0, WASM_ZERO, WASM_ZERO));
EXPECT_SIZE(9, WASM_CALL_INDIRECT2(1, WASM_ZERO, WASM_ZERO, WASM_ZERO));
EXPECT_SIZE(7, WASM_CALL_INDIRECT(0, WASM_ZERO, WASM_ZERO));
EXPECT_SIZE(9, WASM_CALL_INDIRECT(1, WASM_ZERO, WASM_ZERO, WASM_ZERO));
}
TEST_F(WasmMacroGenTest, Int32Ops) {
......
......@@ -44,7 +44,7 @@ TEST_F(WasmCapiTest, Table) {
ValueType reps[] = {kWasmI32, kWasmI32, kWasmI32};
FunctionSig call_sig(1, 2, reps);
byte call_code[] = {
WASM_CALL_INDIRECT1(sig_i_i_index, WASM_GET_LOCAL(1), WASM_GET_LOCAL(0))};
WASM_CALL_INDIRECT(sig_i_i_index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))};
AddExportedFunction(CStrVector("call_indirect"), call_code, sizeof(call_code),
&call_sig);
byte f_code[] = {WASM_GET_LOCAL(0)};
......
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