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