Commit 156b2409 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm][test] Cleanup macros

Some macros are redundant or unused.
- WASM_RETURN1 is identical to WASM_RETURN.
- WASM_RETURNN has an unused {count} parameter, and is otherwise
  identical to WASM_RETURN.
- WASM_IFB is identical to WASM_IF.
- WASM_CASE and WASM_CASE_BR are unused.
- WASM_BR_TABLEV is unused.

R=thibaudm@chromium.org

Bug: v8:12244
Change-Id: Ie7be00351f2dfe38d6e84d80e157a85df37233a9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3178860Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77056}
parent 22713850
...@@ -45,7 +45,7 @@ WASM_EXEC_TEST(I64Const_many) { ...@@ -45,7 +45,7 @@ WASM_EXEC_TEST(I64Const_many) {
WASM_EXEC_TEST(Return_I64) { WASM_EXEC_TEST(Return_I64) {
WasmRunner<int64_t, int64_t> r(execution_tier); WasmRunner<int64_t, int64_t> r(execution_tier);
BUILD(r, WASM_RETURN1(WASM_LOCAL_GET(0))); BUILD(r, WASM_RETURN(WASM_LOCAL_GET(0)));
FOR_INT64_INPUTS(i) { CHECK_EQ(i, r.Call(i)); } FOR_INT64_INPUTS(i) { CHECK_EQ(i, r.Call(i)); }
} }
...@@ -67,9 +67,10 @@ const int64_t kHasBit33On = 0x100000000; ...@@ -67,9 +67,10 @@ const int64_t kHasBit33On = 0x100000000;
WASM_EXEC_TEST(Regress5800_Add) { WASM_EXEC_TEST(Regress5800_Add) {
WasmRunner<int32_t> r(execution_tier); WasmRunner<int32_t> r(execution_tier);
BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_I64_EQZ(WASM_I64_ADD( BUILD(r,
WASM_I64V(0), WASM_I64V(kHasBit33On)))), WASM_BLOCK(WASM_BR_IF(0, WASM_I64_EQZ(WASM_I64_ADD(
WASM_RETURN1(WASM_I32V(0))), WASM_I64V(0), WASM_I64V(kHasBit33On)))),
WASM_RETURN(WASM_I32V(0))),
WASM_I32V(0)); WASM_I32V(0));
CHECK_EQ(0, r.Call()); CHECK_EQ(0, r.Call());
} }
...@@ -86,9 +87,10 @@ WASM_EXEC_TEST(I64Sub) { ...@@ -86,9 +87,10 @@ WASM_EXEC_TEST(I64Sub) {
WASM_EXEC_TEST(Regress5800_Sub) { WASM_EXEC_TEST(Regress5800_Sub) {
WasmRunner<int32_t> r(execution_tier); WasmRunner<int32_t> r(execution_tier);
BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_I64_EQZ(WASM_I64_SUB( BUILD(r,
WASM_I64V(0), WASM_I64V(kHasBit33On)))), WASM_BLOCK(WASM_BR_IF(0, WASM_I64_EQZ(WASM_I64_SUB(
WASM_RETURN1(WASM_I32V(0))), WASM_I64V(0), WASM_I64V(kHasBit33On)))),
WASM_RETURN(WASM_I32V(0))),
WASM_I32V(0)); WASM_I32V(0));
CHECK_EQ(0, r.Call()); CHECK_EQ(0, r.Call());
} }
......
...@@ -38,7 +38,7 @@ TEST(Run_WasmIfElse) { ...@@ -38,7 +38,7 @@ TEST(Run_WasmIfElse) {
TEST(Run_WasmIfReturn) { TEST(Run_WasmIfReturn) {
WasmRunner<int32_t, int32_t> r(TestExecutionTier::kInterpreter); WasmRunner<int32_t, int32_t> r(TestExecutionTier::kInterpreter);
BUILD(r, WASM_IF(WASM_LOCAL_GET(0), WASM_RETURN1(WASM_I32V_2(77))), BUILD(r, WASM_IF(WASM_LOCAL_GET(0), WASM_RETURN(WASM_I32V_2(77))),
WASM_I32V_2(65)); WASM_I32V_2(65));
CHECK_EQ(65, r.Call(0)); CHECK_EQ(65, r.Call(0));
CHECK_EQ(77, r.Call(1)); CHECK_EQ(77, r.Call(1));
......
...@@ -435,7 +435,7 @@ TEST(Run_WasmModule_Global) { ...@@ -435,7 +435,7 @@ TEST(Run_WasmModule_Global) {
ExportAsMain(f2); ExportAsMain(f2);
byte code2[] = {WASM_GLOBAL_SET(global1, WASM_I32V_1(56)), byte code2[] = {WASM_GLOBAL_SET(global1, WASM_I32V_1(56)),
WASM_GLOBAL_SET(global2, WASM_I32V_1(41)), WASM_GLOBAL_SET(global2, WASM_I32V_1(41)),
WASM_RETURN1(WASM_CALL_FUNCTION0(f1->func_index()))}; WASM_RETURN(WASM_CALL_FUNCTION0(f1->func_index()))};
EMIT_CODE_WITH_END(f2, code2); EMIT_CODE_WITH_END(f2, code2);
TestModule(&zone, builder, 97); TestModule(&zone, builder, 97);
} }
...@@ -555,12 +555,12 @@ TEST(TestInterruptLoop) { ...@@ -555,12 +555,12 @@ TEST(TestInterruptLoop) {
ExportAsMain(f); ExportAsMain(f);
byte code[] = { byte code[] = {
WASM_LOOP( WASM_LOOP(
WASM_IFB(WASM_NOT(WASM_LOAD_MEM( WASM_IF(WASM_NOT(WASM_LOAD_MEM(
MachineType::Int32(), MachineType::Int32(),
WASM_I32V(InterruptThread::interrupt_location_ * 4))), WASM_I32V(InterruptThread::interrupt_location_ * 4))),
WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO,
WASM_I32V(InterruptThread::signal_value_)), WASM_I32V(InterruptThread::signal_value_)),
WASM_BR(1))), WASM_BR(1))),
WASM_I32V(121)}; WASM_I32V(121)};
EMIT_CODE_WITH_END(f, code); EMIT_CODE_WITH_END(f, code);
ZoneBuffer buffer(&zone); ZoneBuffer buffer(&zone);
......
...@@ -250,14 +250,14 @@ T Abs(T a) { ...@@ -250,14 +250,14 @@ T Abs(T a) {
WASM_IF(WASM_##LANE_TYPE##_NE(WASM_LOCAL_GET(lane_value), \ WASM_IF(WASM_##LANE_TYPE##_NE(WASM_LOCAL_GET(lane_value), \
WASM_SIMD_##TYPE##_EXTRACT_LANE( \ WASM_SIMD_##TYPE##_EXTRACT_LANE( \
lane_index, WASM_LOCAL_GET(value))), \ lane_index, WASM_LOCAL_GET(value))), \
WASM_RETURN1(WASM_ZERO)) WASM_RETURN(WASM_ZERO))
// Unsigned Extracts are only available for I8x16, I16x8 types // Unsigned Extracts are only available for I8x16, I16x8 types
#define WASM_SIMD_CHECK_LANE_U(TYPE, value, LANE_TYPE, lane_value, lane_index) \ #define WASM_SIMD_CHECK_LANE_U(TYPE, value, LANE_TYPE, lane_value, lane_index) \
WASM_IF(WASM_##LANE_TYPE##_NE(WASM_LOCAL_GET(lane_value), \ WASM_IF(WASM_##LANE_TYPE##_NE(WASM_LOCAL_GET(lane_value), \
WASM_SIMD_##TYPE##_EXTRACT_LANE_U( \ WASM_SIMD_##TYPE##_EXTRACT_LANE_U( \
lane_index, WASM_LOCAL_GET(value))), \ lane_index, WASM_LOCAL_GET(value))), \
WASM_RETURN1(WASM_ZERO)) WASM_RETURN(WASM_ZERO))
WASM_SIMD_TEST(S128Globals) { WASM_SIMD_TEST(S128Globals) {
WasmRunner<int32_t> r(execution_tier); WasmRunner<int32_t> r(execution_tier);
...@@ -2621,28 +2621,28 @@ WASM_SIMD_TEST(S8x16MultiShuffleFuzz) { ...@@ -2621,28 +2621,28 @@ WASM_SIMD_TEST(S8x16MultiShuffleFuzz) {
WASM_LOCAL_GET(zero), \ WASM_LOCAL_GET(zero), \
WASM_LOCAL_GET(zero)))), \ WASM_LOCAL_GET(zero)))), \
WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN(WASM_ZERO)), \
WASM_LOCAL_SET( \ WASM_LOCAL_SET( \
reduced, WASM_SIMD_UNOP(kExprV128AnyTrue, \ reduced, WASM_SIMD_UNOP(kExprV128AnyTrue, \
WASM_SIMD_BINOP(kExprI##format##Ne, \ WASM_SIMD_BINOP(kExprI##format##Ne, \
WASM_LOCAL_GET(zero), \ WASM_LOCAL_GET(zero), \
WASM_LOCAL_GET(zero)))), \ WASM_LOCAL_GET(zero)))), \
WASM_IF(WASM_I32_NE(WASM_LOCAL_GET(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_NE(WASM_LOCAL_GET(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN(WASM_ZERO)), \
WASM_LOCAL_SET( \ WASM_LOCAL_SET( \
reduced, WASM_SIMD_UNOP(kExprI##format##AllTrue, \ reduced, WASM_SIMD_UNOP(kExprI##format##AllTrue, \
WASM_SIMD_BINOP(kExprI##format##Eq, \ WASM_SIMD_BINOP(kExprI##format##Eq, \
WASM_LOCAL_GET(zero), \ WASM_LOCAL_GET(zero), \
WASM_LOCAL_GET(zero)))), \ WASM_LOCAL_GET(zero)))), \
WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN(WASM_ZERO)), \
WASM_LOCAL_SET( \ WASM_LOCAL_SET( \
reduced, WASM_SIMD_UNOP(kExprI##format##AllTrue, \ reduced, WASM_SIMD_UNOP(kExprI##format##AllTrue, \
WASM_SIMD_BINOP(kExprI##format##Ne, \ WASM_SIMD_BINOP(kExprI##format##Ne, \
WASM_LOCAL_GET(zero), \ WASM_LOCAL_GET(zero), \
WASM_LOCAL_GET(zero)))), \ WASM_LOCAL_GET(zero)))), \
WASM_IF(WASM_I32_NE(WASM_LOCAL_GET(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_NE(WASM_LOCAL_GET(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN(WASM_ZERO)), \
WASM_LOCAL_SET(one_one, \ WASM_LOCAL_SET(one_one, \
WASM_SIMD_I##format##_REPLACE_LANE( \ WASM_SIMD_I##format##_REPLACE_LANE( \
lanes - 1, WASM_LOCAL_GET(zero), int_type(1))), \ lanes - 1, WASM_LOCAL_GET(zero), int_type(1))), \
...@@ -2652,28 +2652,28 @@ WASM_SIMD_TEST(S8x16MultiShuffleFuzz) { ...@@ -2652,28 +2652,28 @@ WASM_SIMD_TEST(S8x16MultiShuffleFuzz) {
WASM_LOCAL_GET(one_one), \ WASM_LOCAL_GET(one_one), \
WASM_LOCAL_GET(zero)))), \ WASM_LOCAL_GET(zero)))), \
WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN(WASM_ZERO)), \
WASM_LOCAL_SET( \ WASM_LOCAL_SET( \
reduced, WASM_SIMD_UNOP(kExprV128AnyTrue, \ reduced, WASM_SIMD_UNOP(kExprV128AnyTrue, \
WASM_SIMD_BINOP(kExprI##format##Ne, \ WASM_SIMD_BINOP(kExprI##format##Ne, \
WASM_LOCAL_GET(one_one), \ WASM_LOCAL_GET(one_one), \
WASM_LOCAL_GET(zero)))), \ WASM_LOCAL_GET(zero)))), \
WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN(WASM_ZERO)), \
WASM_LOCAL_SET( \ WASM_LOCAL_SET( \
reduced, WASM_SIMD_UNOP(kExprI##format##AllTrue, \ reduced, WASM_SIMD_UNOP(kExprI##format##AllTrue, \
WASM_SIMD_BINOP(kExprI##format##Eq, \ WASM_SIMD_BINOP(kExprI##format##Eq, \
WASM_LOCAL_GET(one_one), \ WASM_LOCAL_GET(one_one), \
WASM_LOCAL_GET(zero)))), \ WASM_LOCAL_GET(zero)))), \
WASM_IF(WASM_I32_NE(WASM_LOCAL_GET(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_NE(WASM_LOCAL_GET(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN(WASM_ZERO)), \
WASM_LOCAL_SET( \ WASM_LOCAL_SET( \
reduced, WASM_SIMD_UNOP(kExprI##format##AllTrue, \ reduced, WASM_SIMD_UNOP(kExprI##format##AllTrue, \
WASM_SIMD_BINOP(kExprI##format##Ne, \ WASM_SIMD_BINOP(kExprI##format##Ne, \
WASM_LOCAL_GET(one_one), \ WASM_LOCAL_GET(one_one), \
WASM_LOCAL_GET(zero)))), \ WASM_LOCAL_GET(zero)))), \
WASM_IF(WASM_I32_NE(WASM_LOCAL_GET(reduced), WASM_ZERO), \ WASM_IF(WASM_I32_NE(WASM_LOCAL_GET(reduced), WASM_ZERO), \
WASM_RETURN1(WASM_ZERO)), \ WASM_RETURN(WASM_ZERO)), \
WASM_ONE); \ WASM_ONE); \
CHECK_EQ(1, r.Call()); \ CHECK_EQ(1, r.Call()); \
} }
......
...@@ -920,7 +920,7 @@ WASM_EXEC_TEST(Br_height) { ...@@ -920,7 +920,7 @@ WASM_EXEC_TEST(Br_height) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, WASM_BLOCK_I( BUILD(r, WASM_BLOCK_I(
WASM_BLOCK(WASM_BRV_IFD(0, WASM_LOCAL_GET(0), WASM_LOCAL_GET(0)), WASM_BLOCK(WASM_BRV_IFD(0, WASM_LOCAL_GET(0), WASM_LOCAL_GET(0)),
WASM_RETURN1(WASM_I32V_1(9))), WASM_RETURN(WASM_I32V_1(9))),
WASM_BRV(0, WASM_I32V_1(8)))); WASM_BRV(0, WASM_I32V_1(8))));
for (int32_t i = 0; i < 5; i++) { for (int32_t i = 0; i < 5; i++) {
...@@ -1473,7 +1473,7 @@ WASM_EXEC_TEST(ExprIf_P) { ...@@ -1473,7 +1473,7 @@ WASM_EXEC_TEST(ExprIf_P) {
WASM_EXEC_TEST(CountDown) { WASM_EXEC_TEST(CountDown) {
WasmRunner<int32_t, int32_t> r(execution_tier); WasmRunner<int32_t, int32_t> r(execution_tier);
BUILD(r, BUILD(r,
WASM_LOOP(WASM_IFB( WASM_LOOP(WASM_IF(
WASM_LOCAL_GET(0), WASM_LOCAL_GET(0),
WASM_LOCAL_SET(0, WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_I32V_1(1))), WASM_LOCAL_SET(0, WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_I32V_1(1))),
WASM_BR(1))), WASM_BR(1))),
...@@ -3581,7 +3581,7 @@ WASM_EXEC_TEST(InvalidStackAfterBr) { ...@@ -3581,7 +3581,7 @@ WASM_EXEC_TEST(InvalidStackAfterBr) {
WASM_EXEC_TEST(InvalidStackAfterReturn) { WASM_EXEC_TEST(InvalidStackAfterReturn) {
WasmRunner<int32_t> r(execution_tier); WasmRunner<int32_t> r(execution_tier);
BUILD(r, WASM_RETURN1(WASM_I32V_1(17)), kExprI32Add); BUILD(r, WASM_RETURN(WASM_I32V_1(17)), kExprI32Add);
CHECK_EQ(17, r.Call()); CHECK_EQ(17, r.Call());
} }
...@@ -3639,15 +3639,14 @@ WASM_EXEC_TEST(BranchOverUnreachableCodeInLoop2) { ...@@ -3639,15 +3639,14 @@ WASM_EXEC_TEST(BranchOverUnreachableCodeInLoop2) {
WASM_EXEC_TEST(BlockInsideUnreachable) { WASM_EXEC_TEST(BlockInsideUnreachable) {
WasmRunner<int32_t> r(execution_tier); WasmRunner<int32_t> r(execution_tier);
BUILD(r, WASM_RETURN1(WASM_I32V_1(17)), WASM_BLOCK(WASM_BR(0))); BUILD(r, WASM_RETURN(WASM_I32V_1(17)), WASM_BLOCK(WASM_BR(0)));
CHECK_EQ(17, r.Call()); CHECK_EQ(17, r.Call());
} }
WASM_EXEC_TEST(IfInsideUnreachable) { WASM_EXEC_TEST(IfInsideUnreachable) {
WasmRunner<int32_t> r(execution_tier); WasmRunner<int32_t> r(execution_tier);
BUILD( BUILD(r, WASM_RETURN(WASM_I32V_1(17)),
r, WASM_RETURN1(WASM_I32V_1(17)), WASM_IF_ELSE_I(WASM_ONE, WASM_BRV(0, WASM_ONE), WASM_RETURN(WASM_ONE)));
WASM_IF_ELSE_I(WASM_ONE, WASM_BRV(0, WASM_ONE), WASM_RETURN1(WASM_ONE)));
CHECK_EQ(17, r.Call()); CHECK_EQ(17, r.Call());
} }
......
...@@ -328,7 +328,7 @@ WASM_COMPILED_EXEC_TEST(WasmNonBreakablePosition) { ...@@ -328,7 +328,7 @@ WASM_COMPILED_EXEC_TEST(WasmNonBreakablePosition) {
WasmRunner<int> runner(execution_tier); WasmRunner<int> runner(execution_tier);
Isolate* isolate = runner.main_isolate(); Isolate* isolate = runner.main_isolate();
BUILD(runner, WASM_RETURN1(WASM_I32V_2(1024))); BUILD(runner, WASM_RETURN(WASM_I32V_2(1024)));
Handle<JSFunction> main_fun_wrapper = Handle<JSFunction> main_fun_wrapper =
runner.builder().WrapCode(runner.function_index()); runner.builder().WrapCode(runner.function_index());
...@@ -377,7 +377,7 @@ WASM_COMPILED_EXEC_TEST(WasmStepInAndOut) { ...@@ -377,7 +377,7 @@ WASM_COMPILED_EXEC_TEST(WasmStepInAndOut) {
// functions in the code section matches the function indexes. // functions in the code section matches the function indexes.
// return arg0 // return arg0
BUILD(runner, WASM_RETURN1(WASM_LOCAL_GET(0))); BUILD(runner, WASM_RETURN(WASM_LOCAL_GET(0)));
// for (int i = 0; i < 10; ++i) { f2(i); } // for (int i = 0; i < 10; ++i) { f2(i); }
BUILD(f2, WASM_LOOP( BUILD(f2, WASM_LOOP(
WASM_BR_IF(0, WASM_BINOP(kExprI32GeU, WASM_LOCAL_GET(0), WASM_BR_IF(0, WASM_BINOP(kExprI32GeU, WASM_LOCAL_GET(0),
......
...@@ -214,10 +214,6 @@ ...@@ -214,10 +214,6 @@
#define WASM_SELECT_A(tval, fval, cond) \ #define WASM_SELECT_A(tval, fval, cond) \
tval, fval, cond, kExprSelectWithType, U32V_1(1), kFuncRefCode tval, fval, cond, kExprSelectWithType, U32V_1(1), kFuncRefCode
#define WASM_RETURN0 kExprReturn
#define WASM_RETURN1(val) val, kExprReturn
#define WASM_RETURNN(count, ...) __VA_ARGS__, kExprReturn
#define WASM_BR(depth) kExprBr, static_cast<byte>(depth) #define WASM_BR(depth) kExprBr, static_cast<byte>(depth)
#define WASM_BR_IF(depth, cond) cond, kExprBrIf, static_cast<byte>(depth) #define WASM_BR_IF(depth, cond) cond, kExprBrIf, static_cast<byte>(depth)
#define WASM_BR_IFD(depth, val, cond) \ #define WASM_BR_IFD(depth, val, cond) \
...@@ -225,13 +221,11 @@ ...@@ -225,13 +221,11 @@
#define WASM_CONTINUE(depth) kExprBr, static_cast<byte>(depth) #define WASM_CONTINUE(depth) kExprBr, static_cast<byte>(depth)
#define WASM_UNREACHABLE kExprUnreachable #define WASM_UNREACHABLE kExprUnreachable
#define WASM_RETURN(...) __VA_ARGS__, kExprReturn #define WASM_RETURN(...) __VA_ARGS__, kExprReturn
#define WASM_RETURN0 kExprReturn
#define WASM_BR_TABLE(key, count, ...) \ #define WASM_BR_TABLE(key, count, ...) \
key, kExprBrTable, U32V_1(count), __VA_ARGS__ key, kExprBrTable, U32V_1(count), __VA_ARGS__
#define WASM_CASE(x) static_cast<byte>(x), static_cast<byte>(x >> 8)
#define WASM_CASE_BR(x) static_cast<byte>(x), static_cast<byte>(0x80 | (x) >> 8)
#define WASM_THROW(index) kExprThrow, static_cast<byte>(index) #define WASM_THROW(index) kExprThrow, static_cast<byte>(index)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
...@@ -876,9 +870,6 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) { ...@@ -876,9 +870,6 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
val, cond, kExprBrIf, static_cast<byte>(depth) val, cond, kExprBrIf, static_cast<byte>(depth)
#define WASM_BRV_IFD(depth, val, cond) \ #define WASM_BRV_IFD(depth, val, cond) \
val, cond, kExprBrIf, static_cast<byte>(depth), kExprDrop val, cond, kExprBrIf, static_cast<byte>(depth), kExprDrop
#define WASM_IFB(cond, ...) cond, kExprIf, kVoidCode, __VA_ARGS__, kExprEnd
#define WASM_BR_TABLEV(val, key, count, ...) \
val, key, kExprBrTable, U32V_1(count), __VA_ARGS__
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Atomic Operations. // Atomic Operations.
......
...@@ -753,7 +753,7 @@ TEST_F(FunctionBodyDecoderTest, Block3_continue) { ...@@ -753,7 +753,7 @@ TEST_F(FunctionBodyDecoderTest, Block3_continue) {
} }
TEST_F(FunctionBodyDecoderTest, NestedBlock_return) { TEST_F(FunctionBodyDecoderTest, NestedBlock_return) {
ExpectValidates(sigs.i_i(), {B1(B1(WASM_RETURN1(WASM_ZERO))), WASM_ZERO}); ExpectValidates(sigs.i_i(), {B1(B1(WASM_RETURN(WASM_ZERO))), WASM_ZERO});
} }
TEST_F(FunctionBodyDecoderTest, BlockBrBinop) { TEST_F(FunctionBodyDecoderTest, BlockBrBinop) {
...@@ -1369,13 +1369,13 @@ TEST_F(FunctionBodyDecoderTest, MultipleReturn) { ...@@ -1369,13 +1369,13 @@ TEST_F(FunctionBodyDecoderTest, MultipleReturn) {
static ValueType kIntTypes5[] = {kWasmI32, kWasmI32, kWasmI32, kWasmI32, static ValueType kIntTypes5[] = {kWasmI32, kWasmI32, kWasmI32, kWasmI32,
kWasmI32}; kWasmI32};
FunctionSig sig_ii_v(2, 0, kIntTypes5); FunctionSig sig_ii_v(2, 0, kIntTypes5);
ExpectValidates(&sig_ii_v, {WASM_RETURNN(2, WASM_ZERO, WASM_ONE)}); ExpectValidates(&sig_ii_v, {WASM_RETURN(WASM_ZERO, WASM_ONE)});
ExpectFailure(&sig_ii_v, {WASM_RETURNN(1, WASM_ZERO)}); ExpectFailure(&sig_ii_v, {WASM_RETURN(WASM_ZERO)});
FunctionSig sig_iii_v(3, 0, kIntTypes5); FunctionSig sig_iii_v(3, 0, kIntTypes5);
ExpectValidates(&sig_iii_v, ExpectValidates(&sig_iii_v,
{WASM_RETURNN(3, WASM_ZERO, WASM_ONE, WASM_I32V_1(44))}); {WASM_RETURN(WASM_ZERO, WASM_ONE, WASM_I32V_1(44))});
ExpectFailure(&sig_iii_v, {WASM_RETURNN(2, WASM_ZERO, WASM_ONE)}); ExpectFailure(&sig_iii_v, {WASM_RETURN(WASM_ZERO, WASM_ONE)});
} }
TEST_F(FunctionBodyDecoderTest, MultipleReturn_fallthru) { TEST_F(FunctionBodyDecoderTest, MultipleReturn_fallthru) {
...@@ -3160,17 +3160,17 @@ TEST_F(FunctionBodyDecoderTest, BlockParam) { ...@@ -3160,17 +3160,17 @@ TEST_F(FunctionBodyDecoderTest, BlockParam) {
ExpectValidates(sigs.i_ii(), {WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), ExpectValidates(sigs.i_ii(), {WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_BLOCK_X(sig1, WASM_NOP), WASM_BLOCK_X(sig1, WASM_NOP),
WASM_I32_ADD(WASM_NOP, WASM_NOP)}); WASM_I32_ADD(WASM_NOP, WASM_NOP)});
ExpectFailure(sigs.i_ii(), {WASM_BLOCK_X(sig1, WASM_NOP), ExpectFailure(sigs.i_ii(),
WASM_RETURN1(WASM_LOCAL_GET(0))}); {WASM_BLOCK_X(sig1, WASM_NOP), WASM_RETURN(WASM_LOCAL_GET(0))});
ExpectFailure(sigs.i_ii(), {WASM_BLOCK_X(sig1, WASM_LOCAL_GET(0)), ExpectFailure(sigs.i_ii(), {WASM_BLOCK_X(sig1, WASM_LOCAL_GET(0)),
WASM_RETURN1(WASM_LOCAL_GET(0))}); WASM_RETURN(WASM_LOCAL_GET(0))});
ExpectFailure( ExpectFailure(
sigs.i_ii(), sigs.i_ii(),
{WASM_LOCAL_GET(0), WASM_BLOCK_X(sig2, WASM_I32_ADD(WASM_NOP, WASM_NOP)), {WASM_LOCAL_GET(0), WASM_BLOCK_X(sig2, WASM_I32_ADD(WASM_NOP, WASM_NOP)),
WASM_RETURN1(WASM_LOCAL_GET(0))}); WASM_RETURN(WASM_LOCAL_GET(0))});
ExpectFailure(sigs.i_ii(), ExpectFailure(sigs.i_ii(),
{WASM_LOCAL_GET(0), WASM_BLOCK_X(sig1, WASM_F32_NEG(WASM_NOP)), {WASM_LOCAL_GET(0), WASM_BLOCK_X(sig1, WASM_F32_NEG(WASM_NOP)),
WASM_RETURN1(WASM_LOCAL_GET(0))}); WASM_RETURN(WASM_LOCAL_GET(0))});
} }
TEST_F(FunctionBodyDecoderTest, LoopParam) { TEST_F(FunctionBodyDecoderTest, LoopParam) {
...@@ -3186,16 +3186,16 @@ TEST_F(FunctionBodyDecoderTest, LoopParam) { ...@@ -3186,16 +3186,16 @@ TEST_F(FunctionBodyDecoderTest, LoopParam) {
WASM_LOOP_X(sig1, WASM_NOP), WASM_LOOP_X(sig1, WASM_NOP),
WASM_I32_ADD(WASM_NOP, WASM_NOP)}); WASM_I32_ADD(WASM_NOP, WASM_NOP)});
ExpectFailure(sigs.i_ii(), ExpectFailure(sigs.i_ii(),
{WASM_LOOP_X(sig1, WASM_NOP), WASM_RETURN1(WASM_LOCAL_GET(0))}); {WASM_LOOP_X(sig1, WASM_NOP), WASM_RETURN(WASM_LOCAL_GET(0))});
ExpectFailure(sigs.i_ii(), {WASM_LOOP_X(sig1, WASM_LOCAL_GET(0)), ExpectFailure(sigs.i_ii(), {WASM_LOOP_X(sig1, WASM_LOCAL_GET(0)),
WASM_RETURN1(WASM_LOCAL_GET(0))}); WASM_RETURN(WASM_LOCAL_GET(0))});
ExpectFailure( ExpectFailure(
sigs.i_ii(), sigs.i_ii(),
{WASM_LOCAL_GET(0), WASM_LOOP_X(sig2, WASM_I32_ADD(WASM_NOP, WASM_NOP)), {WASM_LOCAL_GET(0), WASM_LOOP_X(sig2, WASM_I32_ADD(WASM_NOP, WASM_NOP)),
WASM_RETURN1(WASM_LOCAL_GET(0))}); WASM_RETURN(WASM_LOCAL_GET(0))});
ExpectFailure(sigs.i_ii(), ExpectFailure(sigs.i_ii(),
{WASM_LOCAL_GET(0), WASM_LOOP_X(sig1, WASM_F32_NEG(WASM_NOP)), {WASM_LOCAL_GET(0), WASM_LOOP_X(sig1, WASM_F32_NEG(WASM_NOP)),
WASM_RETURN1(WASM_LOCAL_GET(0))}); WASM_RETURN(WASM_LOCAL_GET(0))});
} }
TEST_F(FunctionBodyDecoderTest, LoopParamBr) { TEST_F(FunctionBodyDecoderTest, LoopParamBr) {
...@@ -3213,10 +3213,10 @@ TEST_F(FunctionBodyDecoderTest, LoopParamBr) { ...@@ -3213,10 +3213,10 @@ TEST_F(FunctionBodyDecoderTest, LoopParamBr) {
{WASM_LOCAL_GET(0), WASM_LOOP_X(sig1, WASM_BLOCK_X(sig1, WASM_BR(1)))}); {WASM_LOCAL_GET(0), WASM_LOOP_X(sig1, WASM_BLOCK_X(sig1, WASM_BR(1)))});
ExpectFailure(sigs.i_ii(), ExpectFailure(sigs.i_ii(),
{WASM_LOCAL_GET(0), WASM_LOOP_X(sig1, WASM_BLOCK(WASM_BR(1))), {WASM_LOCAL_GET(0), WASM_LOOP_X(sig1, WASM_BLOCK(WASM_BR(1))),
WASM_RETURN1(WASM_LOCAL_GET(0))}); WASM_RETURN(WASM_LOCAL_GET(0))});
ExpectFailure(sigs.i_ii(), {WASM_LOCAL_GET(0), WASM_LOCAL_GET(1), ExpectFailure(sigs.i_ii(), {WASM_LOCAL_GET(0), WASM_LOCAL_GET(1),
WASM_LOOP_X(sig2, WASM_BLOCK_X(sig1, WASM_BR(1))), WASM_LOOP_X(sig2, WASM_BLOCK_X(sig1, WASM_BR(1))),
WASM_RETURN1(WASM_LOCAL_GET(0))}); WASM_RETURN(WASM_LOCAL_GET(0))});
} }
TEST_F(FunctionBodyDecoderTest, IfParam) { TEST_F(FunctionBodyDecoderTest, IfParam) {
......
...@@ -80,7 +80,7 @@ TEST_F(WasmMacroGenTest, Statements) { ...@@ -80,7 +80,7 @@ TEST_F(WasmMacroGenTest, Statements) {
EXPECT_SIZE(7, WASM_LOOP(WASM_BR_IF(0, WASM_ZERO))); EXPECT_SIZE(7, WASM_LOOP(WASM_BR_IF(0, WASM_ZERO)));
EXPECT_SIZE(1, WASM_RETURN0); EXPECT_SIZE(1, WASM_RETURN0);
EXPECT_SIZE(3, WASM_RETURN1(WASM_ZERO)); EXPECT_SIZE(3, WASM_RETURN(WASM_ZERO));
EXPECT_SIZE(1, WASM_UNREACHABLE); EXPECT_SIZE(1, WASM_UNREACHABLE);
} }
......
...@@ -137,11 +137,11 @@ TEST_F(WasmCapiTest, Recursion) { ...@@ -137,11 +137,11 @@ TEST_F(WasmCapiTest, Recursion) {
builder()->AddImport(base::CStrVector("fibonacci_c"), wasm_i_i_sig()); builder()->AddImport(base::CStrVector("fibonacci_c"), wasm_i_i_sig());
byte code_fibo[] = { byte code_fibo[] = {
WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(0), WASM_ZERO), WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(0), WASM_ZERO),
WASM_RETURN1(WASM_ZERO)), WASM_RETURN(WASM_ZERO)),
WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(0), WASM_ONE), WASM_RETURN1(WASM_ONE)), WASM_IF(WASM_I32_EQ(WASM_LOCAL_GET(0), WASM_ONE), WASM_RETURN(WASM_ONE)),
// Muck with the parameter to ensure callers don't depend on its value. // Muck with the parameter to ensure callers don't depend on its value.
WASM_LOCAL_SET(0, WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_ONE)), WASM_LOCAL_SET(0, WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_ONE)),
WASM_RETURN1(WASM_I32_ADD( WASM_RETURN(WASM_I32_ADD(
WASM_CALL_FUNCTION(fibo_c_index, WASM_LOCAL_GET(0)), WASM_CALL_FUNCTION(fibo_c_index, WASM_LOCAL_GET(0)),
WASM_CALL_FUNCTION(fibo_c_index, WASM_CALL_FUNCTION(fibo_c_index,
WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_ONE))))}; WASM_I32_SUB(WASM_LOCAL_GET(0), WASM_ONE))))};
......
...@@ -65,7 +65,7 @@ void RunInStore(Store* store, ZoneBuffer* wire_bytes, int iterations) { ...@@ -65,7 +65,7 @@ void RunInStore(Store* store, ZoneBuffer* wire_bytes, int iterations) {
TEST_F(WasmCapiTest, InstanceFinalization) { TEST_F(WasmCapiTest, InstanceFinalization) {
// Add a dummy function: f(x) { return x; } // Add a dummy function: f(x) { return x; }
byte code[] = {WASM_RETURN1(WASM_LOCAL_GET(0))}; byte code[] = {WASM_RETURN(WASM_LOCAL_GET(0))};
AddExportedFunction(base::CStrVector("f"), code, sizeof(code), AddExportedFunction(base::CStrVector("f"), code, sizeof(code),
wasm_i_i_sig()); wasm_i_i_sig());
Compile(); Compile();
......
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