Commit 6dfa47b6 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[test][cleanup] Rename WASM_*_GLOBAL to WASM_GLOBAL_*

The opcodes were renamed long ago, but the macros were still using the
old syntax.

This CL was created using the following script (for WASM_GET_GLOBAL and
WASM_SET_GLOBAL):
ag -l WASM_GET_GLOBAL | xargs -L 1 sed -i 's/\bWASM_GET_GLOBAL\b/WASM_GLOBAL_GET/g'

R=ahaas@chromium.org

Bug: v8:11074
Change-Id: I3a9bd64f6e09ce97dae6d4132c224350dc079c0f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2597576
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71836}
parent 91b102c7
......@@ -289,14 +289,14 @@ WASM_COMPILED_EXEC_TEST(WasmRefAsNonNull) {
const byte field_index = 0;
const byte kFunc = tester.DefineFunction(
tester.sigs.i_v(), {},
{WASM_SET_GLOBAL(
{WASM_GLOBAL_SET(
global_index,
WASM_STRUCT_NEW_WITH_RTT(type_index, WASM_I32V(55), WASM_I32V(66),
WASM_RTT_CANON(type_index))),
WASM_STRUCT_GET(
type_index, field_index,
WASM_REF_AS_NON_NULL(WASM_IF_ELSE_R(kOptRefType, WASM_I32V(1),
WASM_GET_GLOBAL(global_index),
WASM_GLOBAL_GET(global_index),
WASM_REF_NULL(type_index)))),
kExprEnd});
......@@ -357,13 +357,13 @@ WASM_COMPILED_EXEC_TEST(BrOnCast) {
// as eqref.
WASM_LOCAL_SET(
1, WASM_STRUCT_NEW_WITH_RTT(type_index, WASM_I32V(1),
WASM_GET_GLOBAL(rtt_index))),
WASM_GLOBAL_GET(rtt_index))),
WASM_LOCAL_GET(1),
// The struct is not an i31, so this branch isn't taken.
WASM_BR_ON_CAST(0, WASM_RTT_CANON(kI31RefCode)),
WASM_LOCAL_SET(0, WASM_I32V(222)), // Final result.
// This branch is taken.
WASM_BR_ON_CAST(0, WASM_GET_GLOBAL(rtt_index)),
WASM_BR_ON_CAST(0, WASM_GLOBAL_GET(rtt_index)),
// Not executed due to the branch.
WASM_DROP, WASM_LOCAL_SET(0, WASM_I32V(333))),
WASM_LOCAL_GET(0), kExprEnd});
......@@ -376,7 +376,7 @@ WASM_COMPILED_EXEC_TEST(BrOnCast) {
WASM_LOCAL_SET(1, WASM_I31_NEW(WASM_I32V(42))),
WASM_LOCAL_GET(1),
// The i31 is not a struct, so this branch isn't taken.
WASM_BR_ON_CAST(0, WASM_GET_GLOBAL(rtt_index)),
WASM_BR_ON_CAST(0, WASM_GLOBAL_GET(rtt_index)),
WASM_LOCAL_SET(0, WASM_I32V(222)), // Final result.
// This branch is taken.
WASM_BR_ON_CAST(0, WASM_RTT_CANON(kI31RefCode)),
......@@ -391,14 +391,14 @@ WASM_COMPILED_EXEC_TEST(BrOnCast) {
// Neither of these branches is taken for nullref.
WASM_BR_ON_CAST(0, WASM_RTT_CANON(kI31RefCode)),
WASM_LOCAL_SET(0, WASM_I32V(222)),
WASM_BR_ON_CAST(0, WASM_GET_GLOBAL(rtt_index)), WASM_DROP,
WASM_BR_ON_CAST(0, WASM_GLOBAL_GET(rtt_index)), WASM_DROP,
WASM_LOCAL_SET(0, WASM_I32V(333))), // Final result.
WASM_LOCAL_GET(0), kExprEnd});
const byte kTypedAfterBranch = tester.DefineFunction(
tester.sigs.i_v(), {kWasmI32, kWasmEqRef},
{WASM_LOCAL_SET(1, WASM_STRUCT_NEW_WITH_RTT(type_index, WASM_I32V(42),
WASM_GET_GLOBAL(rtt_index))),
WASM_GLOBAL_GET(rtt_index))),
WASM_BLOCK(WASM_LOCAL_SET(
// The outer block catches the struct left behind by the inner block
// and reads its field.
......@@ -409,7 +409,7 @@ WASM_COMPILED_EXEC_TEST(BrOnCast) {
// on the stack.
WASM_BLOCK_R(ValueType::Ref(type_index, kNonNullable),
WASM_LOCAL_GET(1),
WASM_BR_ON_CAST(0, WASM_GET_GLOBAL(rtt_index)),
WASM_BR_ON_CAST(0, WASM_GLOBAL_GET(rtt_index)),
// Returning 123 is the unreachable failure case.
WASM_LOCAL_SET(0, WASM_I32V(123)), WASM_BR(1))))),
WASM_LOCAL_GET(0), kExprEnd});
......@@ -1128,10 +1128,10 @@ TEST(I31Casts) {
tester.sigs.i_v(), {kWasmEqRef},
{WASM_LOCAL_SET(0, WASM_I31_NEW(WASM_I32V(42))),
WASM_I32_ADD(WASM_REF_TEST(kEqRefCode, kI31RefCode, WASM_LOCAL_GET(0),
WASM_GET_GLOBAL(i31_rtt)),
WASM_GLOBAL_GET(i31_rtt)),
WASM_I31_GET_S(WASM_REF_CAST(kEqRefCode, kI31RefCode,
WASM_LOCAL_GET(0),
WASM_GET_GLOBAL(i31_rtt)))),
WASM_GLOBAL_GET(i31_rtt)))),
kExprEnd});
// Adds the results of two unsuccessful type checks (an i31ref is not a
// struct, nor the other way round).
......@@ -1140,10 +1140,10 @@ TEST(I31Casts) {
{WASM_I32_ADD(
WASM_REF_TEST(kEqRefCode, kI31RefCode,
WASM_STRUCT_NEW_WITH_RTT(struct_type, WASM_I32V(42),
WASM_GET_GLOBAL(struct_rtt)),
WASM_GET_GLOBAL(i31_rtt)),
WASM_GLOBAL_GET(struct_rtt)),
WASM_GLOBAL_GET(i31_rtt)),
WASM_REF_TEST(kEqRefCode, struct_type, WASM_I31_NEW(WASM_I32V(23)),
WASM_GET_GLOBAL(struct_rtt))),
WASM_GLOBAL_GET(struct_rtt))),
kExprEnd});
// Tries to cast an i31ref to a struct, which should trap.
const byte kCastI31ToStruct = tester.DefineFunction(
......@@ -1152,7 +1152,7 @@ TEST(I31Casts) {
{WASM_STRUCT_GET(
struct_type, 0,
WASM_REF_CAST(kEqRefCode, struct_type, WASM_I31_NEW(WASM_I32V(42)),
WASM_GET_GLOBAL(struct_rtt))),
WASM_GLOBAL_GET(struct_rtt))),
kExprEnd});
// Tries to cast a struct to i31ref, which should trap.
const byte kCastStructToI31 = tester.DefineFunction(
......@@ -1161,8 +1161,8 @@ TEST(I31Casts) {
{WASM_I31_GET_S(
WASM_REF_CAST(kEqRefCode, kI31RefCode,
WASM_STRUCT_NEW_WITH_RTT(struct_type, WASM_I32V(42),
WASM_GET_GLOBAL(struct_rtt)),
WASM_GET_GLOBAL(i31_rtt))),
WASM_GLOBAL_GET(struct_rtt)),
WASM_GLOBAL_GET(i31_rtt))),
kExprEnd});
tester.CompileModule();
tester.CheckResult(kTestAndCastSuccess, 43);
......@@ -1200,9 +1200,9 @@ TEST(CastsBenchmark) {
const byte Prepare = tester.DefineFunction(
tester.sigs.i_v(), {wasm::kWasmI32},
{// List = new eqref[kListLength];
WASM_SET_GLOBAL(List,
WASM_GLOBAL_SET(List,
WASM_ARRAY_NEW_DEFAULT(ListType, WASM_I32V(kListLength),
WASM_GET_GLOBAL(RttList))),
WASM_GLOBAL_GET(RttList))),
// for (int i = 0; i < kListLength; ) {
// List[i] = new Super(i);
// i++;
......@@ -1211,14 +1211,14 @@ TEST(CastsBenchmark) {
// }
WASM_LOCAL_SET(i, WASM_I32V_1(0)),
WASM_LOOP(
WASM_ARRAY_SET(ListType, WASM_GET_GLOBAL(List), WASM_LOCAL_GET(i),
WASM_ARRAY_SET(ListType, WASM_GLOBAL_GET(List), WASM_LOCAL_GET(i),
WASM_STRUCT_NEW_WITH_RTT(SuperType, WASM_LOCAL_GET(i),
WASM_GET_GLOBAL(RttSuper))),
WASM_GLOBAL_GET(RttSuper))),
WASM_LOCAL_SET(i, WASM_I32_ADD(WASM_LOCAL_GET(i), WASM_I32V_1(1))),
WASM_ARRAY_SET(ListType, WASM_GET_GLOBAL(List), WASM_LOCAL_GET(i),
WASM_ARRAY_SET(ListType, WASM_GLOBAL_GET(List), WASM_LOCAL_GET(i),
WASM_STRUCT_NEW_WITH_RTT(SubType, WASM_LOCAL_GET(i),
WASM_I32V_1(0),
WASM_GET_GLOBAL(RttSub))),
WASM_GLOBAL_GET(RttSub))),
WASM_LOCAL_SET(i, WASM_I32_ADD(WASM_LOCAL_GET(i), WASM_I32V_1(1))),
WASM_BR_IF(0,
WASM_I32_NE(WASM_LOCAL_GET(i), WASM_I32V(kListLength)))),
......@@ -1236,7 +1236,7 @@ TEST(CastsBenchmark) {
wasm::kWasmI32,
ValueType::Ref(ListType, kNullable),
},
{WASM_LOCAL_SET(list, WASM_GET_GLOBAL(List)),
{WASM_LOCAL_SET(list, WASM_GLOBAL_GET(List)),
// sum = 0;
WASM_LOCAL_SET(sum, WASM_I32V_1(0)),
// for (int i = 0; i < kIterations; i++) {
......@@ -1255,7 +1255,7 @@ TEST(CastsBenchmark) {
ListType, WASM_LOCAL_GET(list),
WASM_I32_AND(WASM_LOCAL_GET(i),
WASM_I32V(kListLength - 1))),
WASM_GET_GLOBAL(RttSuper))))),
WASM_GLOBAL_GET(RttSuper))))),
WASM_LOCAL_SET(i, WASM_I32_ADD(WASM_LOCAL_GET(i), WASM_I32V_1(1))),
WASM_BR_IF(0,
WASM_I32_LTS(WASM_LOCAL_GET(i), WASM_I32V(kIterations)))),
......@@ -1279,7 +1279,7 @@ WASM_COMPILED_EXEC_TEST(GlobalInitReferencingGlobal) {
tester.AddGlobal(kWasmI32, false, WasmInitExpr::GlobalGet(from));
const byte func = tester.DefineFunction(tester.sigs.i_v(), {},
{WASM_GET_GLOBAL(to), kExprEnd});
{WASM_GLOBAL_GET(to), kExprEnd});
tester.CompileModule();
......
......@@ -1356,8 +1356,8 @@ WASM_EXEC_TEST(I64Global) {
int64_t* global = r.builder().AddGlobal<int64_t>();
// global = global + p0
BUILD(r,
WASM_SET_GLOBAL(0,
WASM_I64_AND(WASM_GET_GLOBAL(0),
WASM_GLOBAL_SET(0,
WASM_I64_AND(WASM_GLOBAL_GET(0),
WASM_I64_SCONVERT_I32(WASM_LOCAL_GET(0)))),
WASM_ZERO);
......
......@@ -429,12 +429,12 @@ TEST(Run_WasmModule_Global) {
uint32_t global2 = builder->AddGlobal(kWasmI32);
WasmFunctionBuilder* f1 = builder->AddFunction(sigs.i_v());
byte code1[] = {
WASM_I32_ADD(WASM_GET_GLOBAL(global1), WASM_GET_GLOBAL(global2))};
WASM_I32_ADD(WASM_GLOBAL_GET(global1), WASM_GLOBAL_GET(global2))};
EMIT_CODE_WITH_END(f1, code1);
WasmFunctionBuilder* f2 = builder->AddFunction(sigs.i_v());
ExportAsMain(f2);
byte code2[] = {WASM_SET_GLOBAL(global1, WASM_I32V_1(56)),
WASM_SET_GLOBAL(global2, WASM_I32V_1(41)),
byte code2[] = {WASM_GLOBAL_SET(global1, WASM_I32V_1(56)),
WASM_GLOBAL_SET(global2, WASM_I32V_1(41)),
WASM_RETURN1(WASM_CALL_FUNCTION0(f1->func_index()))};
EMIT_CODE_WITH_END(f2, code2);
TestModule(&zone, builder, 97);
......@@ -746,7 +746,7 @@ TEST(Run_WasmModule_Global_init) {
builder->AddGlobal(kWasmI32, false, WasmInitExpr(222222));
WasmFunctionBuilder* f1 = builder->AddFunction(sigs.i_v());
byte code[] = {
WASM_I32_ADD(WASM_GET_GLOBAL(global1), WASM_GET_GLOBAL(global2))};
WASM_I32_ADD(WASM_GLOBAL_GET(global1), WASM_GLOBAL_GET(global2))};
EMIT_CODE_WITH_END(f1, code);
ExportAsMain(f1);
TestModule(&zone, builder, 999999);
......@@ -777,7 +777,7 @@ static void RunWasmModuleGlobalInitTest(ValueType type, CType expected) {
}
WasmFunctionBuilder* f1 = builder->AddFunction(&sig);
byte code[] = {WASM_GET_GLOBAL(global)};
byte code[] = {WASM_GLOBAL_GET(global)};
EMIT_CODE_WITH_END(f1, code);
ExportAsMain(f1);
TestModule(&zone, builder, expected);
......
......@@ -41,7 +41,7 @@ WASM_SIMD_LIFTOFF_TEST(S128Global) {
int32_t* g0 = r.builder().AddGlobal<int32_t>(kWasmS128);
int32_t* g1 = r.builder().AddGlobal<int32_t>(kWasmS128);
BUILD(r, WASM_SET_GLOBAL(1, WASM_GET_GLOBAL(0)), WASM_ONE);
BUILD(r, WASM_GLOBAL_SET(1, WASM_GLOBAL_GET(0)), WASM_ONE);
int32_t expected = 0x1234;
for (int i = 0; i < 4; i++) {
......@@ -133,11 +133,11 @@ WASM_SIMD_LIFTOFF_TEST(I8x16Shuffle) {
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 31}};
// Set up locals so shuffle is called with non-adjacent registers v2 and v0.
BUILD(r, WASM_LOCAL_SET(local0, WASM_GET_GLOBAL(1)), // local0 is in v0
WASM_LOCAL_SET(local1, WASM_GET_GLOBAL(0)), // local1 is in v1
WASM_GET_GLOBAL(0), // global0 is in v2
BUILD(r, WASM_LOCAL_SET(local0, WASM_GLOBAL_GET(1)), // local0 is in v0
WASM_LOCAL_SET(local1, WASM_GLOBAL_GET(0)), // local1 is in v1
WASM_GLOBAL_GET(0), // global0 is in v2
WASM_LOCAL_GET(local0), // local0 is in v0
WASM_SET_GLOBAL(2, WASM_SIMD_I8x16_SHUFFLE_OP(
WASM_GLOBAL_SET(2, WASM_SIMD_I8x16_SHUFFLE_OP(
kExprI8x16Shuffle, pattern, WASM_NOP, WASM_NOP)),
WASM_ONE);
......@@ -171,9 +171,9 @@ WASM_SIMD_LIFTOFF_TEST(I8x16Shuffle_SingleOperand) {
{31, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}};
// Set up locals so shuffle is called with non-adjacent registers v2 and v0.
BUILD(r, WASM_LOCAL_SET(local0, WASM_GET_GLOBAL(0)), WASM_LOCAL_GET(local0),
BUILD(r, WASM_LOCAL_SET(local0, WASM_GLOBAL_GET(0)), WASM_LOCAL_GET(local0),
WASM_LOCAL_GET(local0),
WASM_SET_GLOBAL(1, WASM_SIMD_I8x16_SHUFFLE_OP(
WASM_GLOBAL_SET(1, WASM_SIMD_I8x16_SHUFFLE_OP(
kExprI8x16Shuffle, pattern, WASM_NOP, WASM_NOP)),
WASM_ONE);
......
......@@ -30,7 +30,7 @@ WASM_SIMD_TEST(I8x16ToF32x4) {
float* g = r.builder().AddGlobal<float>(kWasmS128);
byte param1 = 0;
BUILD(r,
WASM_SET_GLOBAL(
WASM_GLOBAL_SET(
0, WASM_SIMD_UNOP(kExprF32x4Sqrt,
WASM_SIMD_I8x16_SPLAT(WASM_LOCAL_GET(param1)))),
WASM_ONE);
......
This diff is collapsed.
......@@ -735,7 +735,7 @@ WASM_EXEC_TEST(Select_s128_parameters) {
WriteLittleEndianValue<int32_t>(&g1[i], i + 4);
}
BUILD(r,
WASM_SET_GLOBAL(2, WASM_SELECT(WASM_GET_GLOBAL(0), WASM_GET_GLOBAL(1),
WASM_GLOBAL_SET(2, WASM_SELECT(WASM_GLOBAL_GET(0), WASM_GLOBAL_GET(1),
WASM_LOCAL_GET(0))),
WASM_ONE);
r.Call(1);
......@@ -2120,7 +2120,7 @@ WASM_EXEC_TEST(Int32Global) {
int32_t* global = r.builder().AddGlobal<int32_t>();
// global = global + p0
BUILD(r,
WASM_SET_GLOBAL(0, WASM_I32_ADD(WASM_GET_GLOBAL(0), WASM_LOCAL_GET(0))),
WASM_GLOBAL_SET(0, WASM_I32_ADD(WASM_GLOBAL_GET(0), WASM_LOCAL_GET(0))),
WASM_ZERO);
WriteLittleEndianValue<int32_t>(global, 116);
......@@ -2142,8 +2142,8 @@ WASM_EXEC_TEST(Int32Globals_DontAlias) {
BUILD(
r,
WASM_SET_GLOBAL(g, WASM_I32_ADD(WASM_GET_GLOBAL(g), WASM_LOCAL_GET(0))),
WASM_GET_GLOBAL(g));
WASM_GLOBAL_SET(g, WASM_I32_ADD(WASM_GLOBAL_GET(g), WASM_LOCAL_GET(0))),
WASM_GLOBAL_GET(g));
// Check that reading/writing global number {g} doesn't alter the others.
WriteLittleEndianValue<int32_t>(globals[g], 116 * g);
......@@ -2167,8 +2167,8 @@ WASM_EXEC_TEST(Float32Global) {
float* global = r.builder().AddGlobal<float>();
// global = global + p0
BUILD(r,
WASM_SET_GLOBAL(0,
WASM_F32_ADD(WASM_GET_GLOBAL(0),
WASM_GLOBAL_SET(0,
WASM_F32_ADD(WASM_GLOBAL_GET(0),
WASM_F32_SCONVERT_I32(WASM_LOCAL_GET(0)))),
WASM_ZERO);
......@@ -2185,8 +2185,8 @@ WASM_EXEC_TEST(Float64Global) {
double* global = r.builder().AddGlobal<double>();
// global = global + p0
BUILD(r,
WASM_SET_GLOBAL(0,
WASM_F64_ADD(WASM_GET_GLOBAL(0),
WASM_GLOBAL_SET(0,
WASM_F64_ADD(WASM_GLOBAL_GET(0),
WASM_F64_SCONVERT_I32(WASM_LOCAL_GET(0)))),
WASM_ZERO);
......@@ -2209,10 +2209,10 @@ WASM_EXEC_TEST(MixedGlobals) {
float* var_float = r.builder().AddGlobal<float>();
double* var_double = r.builder().AddGlobal<double>();
BUILD(r, WASM_SET_GLOBAL(1, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
WASM_SET_GLOBAL(2, WASM_LOAD_MEM(MachineType::Uint32(), WASM_ZERO)),
WASM_SET_GLOBAL(3, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)),
WASM_SET_GLOBAL(4, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)),
BUILD(r, WASM_GLOBAL_SET(1, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)),
WASM_GLOBAL_SET(2, WASM_LOAD_MEM(MachineType::Uint32(), WASM_ZERO)),
WASM_GLOBAL_SET(3, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)),
WASM_GLOBAL_SET(4, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)),
WASM_ZERO);
memory[0] = 0xAA;
......
......@@ -475,8 +475,8 @@ WASM_COMPILED_EXEC_TEST(WasmDebugEvaluate_Globals) {
runner.builder().AddGlobal<int32_t>();
TestCode<void> code(&runner,
{WASM_SET_GLOBAL(0, WASM_I32V_1('4')),
WASM_SET_GLOBAL(1, WASM_I32V_1('5')), WASM_RETURN0},
{WASM_GLOBAL_SET(0, WASM_I32V_1('4')),
WASM_GLOBAL_SET(1, WASM_I32V_1('5')), WASM_RETURN0},
{});
code.BreakOnReturn(&runner);
......@@ -529,7 +529,7 @@ WASM_COMPILED_EXEC_TEST(WasmDebugEvaluate_JavaScript) {
TestCode<int64_t> code(
&runner,
{WASM_SET_GLOBAL(0, WASM_I32V_2('B')),
{WASM_GLOBAL_SET(0, WASM_I32V_2('B')),
WASM_LOCAL_SET(0, WASM_I64V_2('A')), WASM_RETURN1(WASM_LOCAL_GET(0))},
{ValueType::kI64});
code.BreakOnReturn(&runner);
......@@ -578,7 +578,7 @@ WASM_COMPILED_EXEC_TEST(WasmDebugEvaluate_JavaScript_Caching) {
TestCode<int32_t> code(
&runner,
{WASM_SET_GLOBAL(0, WASM_I32V_2('B')), WASM_RETURN1(WASM_GET_GLOBAL(0))},
{WASM_GLOBAL_SET(0, WASM_I32V_2('B')), WASM_RETURN1(WASM_GLOBAL_GET(0))},
{});
code.BreakOnReturn(&runner);
......
......@@ -433,8 +433,8 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) {
#define WASM_LOCAL_SET(index, val) val, kExprLocalSet, static_cast<byte>(index)
#define WASM_LOCAL_TEE(index, val) val, kExprLocalTee, static_cast<byte>(index)
#define WASM_DROP kExprDrop
#define WASM_GET_GLOBAL(index) kExprGlobalGet, static_cast<byte>(index)
#define WASM_SET_GLOBAL(index, val) \
#define WASM_GLOBAL_GET(index) kExprGlobalGet, static_cast<byte>(index)
#define WASM_GLOBAL_SET(index, val) \
val, kExprGlobalSet, static_cast<byte>(index)
#define WASM_TABLE_GET(table_index, index) \
index, kExprTableGet, static_cast<byte>(table_index)
......
......@@ -1990,9 +1990,9 @@ TEST_F(FunctionBodyDecoderTest, Int32Globals) {
builder.AddGlobal(kWasmI32);
ExpectValidates(sig, {WASM_GET_GLOBAL(0)});
ExpectFailure(sig, {WASM_SET_GLOBAL(0, WASM_LOCAL_GET(0))});
ExpectValidates(sig, {WASM_SET_GLOBAL(0, WASM_LOCAL_GET(0)), WASM_ZERO});
ExpectValidates(sig, {WASM_GLOBAL_GET(0)});
ExpectFailure(sig, {WASM_GLOBAL_SET(0, WASM_LOCAL_GET(0))});
ExpectValidates(sig, {WASM_GLOBAL_SET(0, WASM_LOCAL_GET(0)), WASM_ZERO});
}
TEST_F(FunctionBodyDecoderTest, ImmutableGlobal) {
......@@ -2001,8 +2001,8 @@ TEST_F(FunctionBodyDecoderTest, ImmutableGlobal) {
uint32_t g0 = builder.AddGlobal(kWasmI32, true);
uint32_t g1 = builder.AddGlobal(kWasmI32, false);
ExpectValidates(sig, {WASM_SET_GLOBAL(g0, WASM_ZERO)});
ExpectFailure(sig, {WASM_SET_GLOBAL(g1, WASM_ZERO)});
ExpectValidates(sig, {WASM_GLOBAL_SET(g0, WASM_ZERO)});
ExpectFailure(sig, {WASM_GLOBAL_SET(g1, WASM_ZERO)});
}
TEST_F(FunctionBodyDecoderTest, Int32Globals_fail) {
......@@ -2013,15 +2013,15 @@ TEST_F(FunctionBodyDecoderTest, Int32Globals_fail) {
builder.AddGlobal(kWasmF32);
builder.AddGlobal(kWasmF64);
ExpectFailure(sig, {WASM_GET_GLOBAL(0)});
ExpectFailure(sig, {WASM_GET_GLOBAL(1)});
ExpectFailure(sig, {WASM_GET_GLOBAL(2)});
ExpectFailure(sig, {WASM_GET_GLOBAL(3)});
ExpectFailure(sig, {WASM_GLOBAL_GET(0)});
ExpectFailure(sig, {WASM_GLOBAL_GET(1)});
ExpectFailure(sig, {WASM_GLOBAL_GET(2)});
ExpectFailure(sig, {WASM_GLOBAL_GET(3)});
ExpectFailure(sig, {WASM_SET_GLOBAL(0, WASM_LOCAL_GET(0)), WASM_ZERO});
ExpectFailure(sig, {WASM_SET_GLOBAL(1, WASM_LOCAL_GET(0)), WASM_ZERO});
ExpectFailure(sig, {WASM_SET_GLOBAL(2, WASM_LOCAL_GET(0)), WASM_ZERO});
ExpectFailure(sig, {WASM_SET_GLOBAL(3, WASM_LOCAL_GET(0)), WASM_ZERO});
ExpectFailure(sig, {WASM_GLOBAL_SET(0, WASM_LOCAL_GET(0)), WASM_ZERO});
ExpectFailure(sig, {WASM_GLOBAL_SET(1, WASM_LOCAL_GET(0)), WASM_ZERO});
ExpectFailure(sig, {WASM_GLOBAL_SET(2, WASM_LOCAL_GET(0)), WASM_ZERO});
ExpectFailure(sig, {WASM_GLOBAL_SET(3, WASM_LOCAL_GET(0)), WASM_ZERO});
}
TEST_F(FunctionBodyDecoderTest, Int64Globals) {
......@@ -2030,13 +2030,13 @@ TEST_F(FunctionBodyDecoderTest, Int64Globals) {
builder.AddGlobal(kWasmI64);
builder.AddGlobal(kWasmI64);
ExpectValidates(sig, {WASM_GET_GLOBAL(0)});
ExpectValidates(sig, {WASM_GET_GLOBAL(1)});
ExpectValidates(sig, {WASM_GLOBAL_GET(0)});
ExpectValidates(sig, {WASM_GLOBAL_GET(1)});
ExpectValidates(sig,
{WASM_SET_GLOBAL(0, WASM_LOCAL_GET(0)), WASM_LOCAL_GET(0)});
{WASM_GLOBAL_SET(0, WASM_LOCAL_GET(0)), WASM_LOCAL_GET(0)});
ExpectValidates(sig,
{WASM_SET_GLOBAL(1, WASM_LOCAL_GET(0)), WASM_LOCAL_GET(0)});
{WASM_GLOBAL_SET(1, WASM_LOCAL_GET(0)), WASM_LOCAL_GET(0)});
}
TEST_F(FunctionBodyDecoderTest, Float32Globals) {
......@@ -2044,9 +2044,9 @@ TEST_F(FunctionBodyDecoderTest, Float32Globals) {
builder.AddGlobal(kWasmF32);
ExpectValidates(sig, {WASM_GET_GLOBAL(0)});
ExpectValidates(sig, {WASM_GLOBAL_GET(0)});
ExpectValidates(sig,
{WASM_SET_GLOBAL(0, WASM_LOCAL_GET(0)), WASM_LOCAL_GET(0)});
{WASM_GLOBAL_SET(0, WASM_LOCAL_GET(0)), WASM_LOCAL_GET(0)});
}
TEST_F(FunctionBodyDecoderTest, Float64Globals) {
......@@ -2054,9 +2054,9 @@ TEST_F(FunctionBodyDecoderTest, Float64Globals) {
builder.AddGlobal(kWasmF64);
ExpectValidates(sig, {WASM_GET_GLOBAL(0)});
ExpectValidates(sig, {WASM_GLOBAL_GET(0)});
ExpectValidates(sig,
{WASM_SET_GLOBAL(0, WASM_LOCAL_GET(0)), WASM_LOCAL_GET(0)});
{WASM_GLOBAL_SET(0, WASM_LOCAL_GET(0)), WASM_LOCAL_GET(0)});
}
TEST_F(FunctionBodyDecoderTest, AllGetGlobalCombinations) {
......@@ -2069,7 +2069,7 @@ TEST_F(FunctionBodyDecoderTest, AllGetGlobalCombinations) {
module = builder.module();
builder.AddGlobal(global_type);
Validate(IsSubtypeOf(global_type, local_type, module), &sig,
{WASM_GET_GLOBAL(0)});
{WASM_GLOBAL_GET(0)});
}
}
}
......@@ -2084,7 +2084,7 @@ TEST_F(FunctionBodyDecoderTest, AllSetGlobalCombinations) {
module = builder.module();
builder.AddGlobal(global_type);
Validate(IsSubtypeOf(local_type, global_type, module), &sig,
{WASM_SET_GLOBAL(0, WASM_LOCAL_GET(0))});
{WASM_GLOBAL_SET(0, WASM_LOCAL_GET(0))});
}
}
}
......
......@@ -32,7 +32,7 @@ namespace module_decoder_unittest {
#define WASM_INIT_EXPR_EXTERN_REF_NULL WASM_REF_NULL(kExternRefCode), kExprEnd
#define WASM_INIT_EXPR_FUNC_REF_NULL WASM_REF_NULL(kFuncRefCode), kExprEnd
#define WASM_INIT_EXPR_REF_FUNC(val) WASM_REF_FUNC(val), kExprEnd
#define WASM_INIT_EXPR_GLOBAL(index) WASM_GET_GLOBAL(index), kExprEnd
#define WASM_INIT_EXPR_GLOBAL(index) WASM_GLOBAL_GET(index), kExprEnd
#define REF_NULL_ELEMENT kExprRefNull, kFuncRefCode, kExprEnd
#define REF_FUNC_ELEMENT(v) kExprRefFunc, U32V_1(v), kExprEnd
......@@ -540,7 +540,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
SECTION(Global, ENTRY_COUNT(1), // --
kI32Code, // type
1, // mutable
WASM_GET_GLOBAL(42), kExprEnd) // init value
WASM_GLOBAL_GET(42), kExprEnd) // init value
};
EXPECT_FAILURE_WITH_MSG(referencing_out_of_bounds_global,
"global index is out of bounds");
......@@ -549,7 +549,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
SECTION(Global, ENTRY_COUNT(2), // --
kI32Code, // type
0, // mutable
WASM_GET_GLOBAL(1), kExprEnd, // init value
WASM_GLOBAL_GET(1), kExprEnd, // init value
kI32Code, // type
0, // mutable
WASM_I32V(0), kExprEnd) // init value
......@@ -566,7 +566,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
WASM_RTT(2, kFuncRefCode), // type
0, // mutable
WASM_RTT_SUB(kFuncRefCode, // init value
WASM_GET_GLOBAL(1)), // --
WASM_GLOBAL_GET(1)), // --
kExprEnd, // --
WASM_RTT(1, kFuncRefCode), // type
0, // mutable
......@@ -583,7 +583,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
WASM_I32V(1), kExprEnd, // init value
kI32Code, // type
0, // mutable
WASM_GET_GLOBAL(0), kExprEnd) // init value
WASM_GLOBAL_GET(0), kExprEnd) // init value
};
EXPECT_FAILURE_WITH_MSG(
referencing_mutable_global,
......@@ -598,7 +598,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
SECTION(Global, ENTRY_COUNT(1), // --
kI32Code, // type
0, // mutable
WASM_GET_GLOBAL(0), kExprEnd) // init value
WASM_GLOBAL_GET(0), kExprEnd) // init value
};
EXPECT_FAILURE_WITH_MSG(
referencing_mutable_imported_global,
......@@ -613,7 +613,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
SECTION(Global, ENTRY_COUNT(1), // --
kI32Code, // type
0, // mutable
WASM_GET_GLOBAL(0), kExprEnd) // init value
WASM_GLOBAL_GET(0), kExprEnd) // init value
};
EXPECT_VERIFIES(referencing_immutable_imported_global);
......@@ -624,7 +624,7 @@ TEST_F(WasmModuleVerifyTest, GlobalInitializer) {
WASM_I32V(1), kExprEnd, // init value
kI32Code, // type
0, // mutable
WASM_GET_GLOBAL(0), kExprEnd) // init value
WASM_GLOBAL_GET(0), kExprEnd) // init value
};
EXPECT_FAILURE_WITH_MSG(
referencing_local_global,
......@@ -864,7 +864,7 @@ TEST_F(WasmModuleVerifyTest, GlobalRttSubOfGlobal) {
WASM_RTT(1, kEqRefCode), // type
0), // mutability
SECTION(Global, ENTRY_COUNT(1), WASM_RTT(2, kI31RefCode), 1,
WASM_RTT_SUB(kI31RefCode, WASM_GET_GLOBAL(0)), kExprEnd)};
WASM_RTT_SUB(kI31RefCode, WASM_GLOBAL_GET(0)), kExprEnd)};
ModuleResult result = DecodeModule(data, data + sizeof(data));
WasmInitExpr expected =
WasmInitExpr::RttSub(HeapType::kI31, WasmInitExpr::GlobalGet(0));
......@@ -885,7 +885,7 @@ TEST_F(WasmModuleVerifyTest, GlobalRttSubOfGlobalTypeError) {
kI32Code, // type
0), // mutability
SECTION(Global, ENTRY_COUNT(1), WASM_RTT(2, kExternRefCode), 1,
WASM_RTT_SUB(kExternRefCode, WASM_GET_GLOBAL(0)), kExprEnd)};
WASM_RTT_SUB(kExternRefCode, WASM_GLOBAL_GET(0)), kExprEnd)};
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_NOT_OK(result, "rtt.sub requires a supertype rtt on stack");
}
......
......@@ -54,7 +54,7 @@ TEST_F(WasmMacroGenTest, Statements) {
EXPECT_SIZE(4, WASM_LOCAL_SET(0, WASM_ZERO));
EXPECT_SIZE(4, WASM_SET_GLOBAL(0, WASM_ZERO));
EXPECT_SIZE(4, WASM_GLOBAL_SET(0, WASM_ZERO));
EXPECT_SIZE(7, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, WASM_ZERO));
......@@ -102,9 +102,9 @@ TEST_F(WasmMacroGenTest, Expressions) {
EXPECT_SIZE(2, WASM_LOCAL_GET(0));
EXPECT_SIZE(2, WASM_LOCAL_GET(1));
EXPECT_SIZE(2, WASM_LOCAL_GET(12));
EXPECT_SIZE(2, WASM_GET_GLOBAL(0));
EXPECT_SIZE(2, WASM_GET_GLOBAL(1));
EXPECT_SIZE(2, WASM_GET_GLOBAL(12));
EXPECT_SIZE(2, WASM_GLOBAL_GET(0));
EXPECT_SIZE(2, WASM_GLOBAL_GET(1));
EXPECT_SIZE(2, WASM_GLOBAL_GET(12));
EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO));
EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO));
EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO));
......
......@@ -47,45 +47,45 @@ TEST_F(WasmCapiTest, Globals) {
ValueType i64_type[] = {kWasmI64};
FunctionSig return_f32(1, 0, f32_type);
FunctionSig return_i64(1, 0, i64_type);
byte gcfi[] = {WASM_GET_GLOBAL(cfi_index)};
byte gcfi[] = {WASM_GLOBAL_GET(cfi_index)};
AddExportedFunction(CStrVector("get const f32 import"), gcfi, sizeof(gcfi),
&return_f32);
byte gcii[] = {WASM_GET_GLOBAL(cii_index)};
byte gcii[] = {WASM_GLOBAL_GET(cii_index)};
AddExportedFunction(CStrVector("get const i64 import"), gcii, sizeof(gcii),
&return_i64);
byte gvfi[] = {WASM_GET_GLOBAL(vfi_index)};
byte gvfi[] = {WASM_GLOBAL_GET(vfi_index)};
AddExportedFunction(CStrVector("get var f32 import"), gvfi, sizeof(gvfi),
&return_f32);
byte gvii[] = {WASM_GET_GLOBAL(vii_index)};
byte gvii[] = {WASM_GLOBAL_GET(vii_index)};
AddExportedFunction(CStrVector("get var i64 import"), gvii, sizeof(gvii),
&return_i64);
byte gcfe[] = {WASM_GET_GLOBAL(cfe_index)};
byte gcfe[] = {WASM_GLOBAL_GET(cfe_index)};
AddExportedFunction(CStrVector("get const f32 export"), gcfe, sizeof(gcfe),
&return_f32);
byte gcie[] = {WASM_GET_GLOBAL(cie_index)};
byte gcie[] = {WASM_GLOBAL_GET(cie_index)};
AddExportedFunction(CStrVector("get const i64 export"), gcie, sizeof(gcie),
&return_i64);
byte gvfe[] = {WASM_GET_GLOBAL(vfe_index)};
byte gvfe[] = {WASM_GLOBAL_GET(vfe_index)};
AddExportedFunction(CStrVector("get var f32 export"), gvfe, sizeof(gvfe),
&return_f32);
byte gvie[] = {WASM_GET_GLOBAL(vie_index)};
byte gvie[] = {WASM_GLOBAL_GET(vie_index)};
AddExportedFunction(CStrVector("get var i64 export"), gvie, sizeof(gvie),
&return_i64);
// Define functions for manipulating globals.
FunctionSig param_f32(0, 1, f32_type);
FunctionSig param_i64(0, 1, i64_type);
byte svfi[] = {WASM_SET_GLOBAL(vfi_index, WASM_LOCAL_GET(0))};
byte svfi[] = {WASM_GLOBAL_SET(vfi_index, WASM_LOCAL_GET(0))};
AddExportedFunction(CStrVector("set var f32 import"), svfi, sizeof(svfi),
&param_f32);
byte svii[] = {WASM_SET_GLOBAL(vii_index, WASM_LOCAL_GET(0))};
byte svii[] = {WASM_GLOBAL_SET(vii_index, WASM_LOCAL_GET(0))};
AddExportedFunction(CStrVector("set var i64 import"), svii, sizeof(svii),
&param_i64);
byte svfe[] = {WASM_SET_GLOBAL(vfe_index, WASM_LOCAL_GET(0))};
byte svfe[] = {WASM_GLOBAL_SET(vfe_index, WASM_LOCAL_GET(0))};
AddExportedFunction(CStrVector("set var f32 export"), svfe, sizeof(svfe),
&param_f32);
byte svie[] = {WASM_SET_GLOBAL(vie_index, WASM_LOCAL_GET(0))};
byte svie[] = {WASM_GLOBAL_SET(vie_index, WASM_LOCAL_GET(0))};
AddExportedFunction(CStrVector("set var i64 export"), svie, sizeof(svie),
&param_i64);
......
......@@ -39,10 +39,10 @@ TEST_F(WasmCapiTest, HostRef) {
CStrVector("global"));
uint32_t table_index = builder()->AddTable(kWasmExternRef, 10);
builder()->AddExport(CStrVector("table"), kExternalTable, table_index);
byte global_set_code[] = {WASM_SET_GLOBAL(global_index, WASM_LOCAL_GET(0))};
byte global_set_code[] = {WASM_GLOBAL_SET(global_index, WASM_LOCAL_GET(0))};
AddExportedFunction(CStrVector("global.set"), global_set_code,
sizeof(global_set_code), &v_r_sig);
byte global_get_code[] = {WASM_GET_GLOBAL(global_index)};
byte global_get_code[] = {WASM_GLOBAL_GET(global_index)};
AddExportedFunction(CStrVector("global.get"), global_get_code,
sizeof(global_get_code), &r_v_sig);
byte table_set_code[] = {
......
......@@ -66,7 +66,7 @@ TEST_F(WasmCapiTest, Threads) {
builder()->AddGlobalImport(CStrVector("id"), kWasmI32, false);
byte code[] = {
WASM_CALL_FUNCTION(callback_index, WASM_GET_GLOBAL(global_index))};
WASM_CALL_FUNCTION(callback_index, WASM_GLOBAL_GET(global_index))};
FunctionSig empty_sig(0, 0, nullptr);
AddExportedFunction(CStrVector("run"), code, sizeof(code), &empty_sig);
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