Commit 4c8cc64e authored by Ng Zhi An's avatar Ng Zhi An Committed by V8 LUCI CQ

[cleanup] Fix -Wshadow warnings in cctest/wasm

Drive-by clean-up to move ADD_CODE, which is defined the same way in
multiple files, into wasm-run-utils.h.

R=adamk@chromium.org

Bug: v8:12244
Change-Id: I61d54cf2c589c3f8b69950fba097d8754bb99c5a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3183524Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77065}
parent c9ddba2b
...@@ -213,7 +213,7 @@ class WasmGCTester { ...@@ -213,7 +213,7 @@ class WasmGCTester {
void CallFunctionImpl(uint32_t function_index, const FunctionSig* sig, void CallFunctionImpl(uint32_t function_index, const FunctionSig* sig,
CWasmArgumentsPacker* packer) { CWasmArgumentsPacker* packer) {
WasmCodeRefScope scope; WasmCodeRefScope code_ref_scope;
NativeModule* native_module = instance_->module_object().native_module(); NativeModule* native_module = instance_->module_object().native_module();
WasmCode* code = native_module->GetCode(function_index); WasmCode* code = native_module->GetCode(function_index);
Address wasm_call_target = code->instruction_start(); Address wasm_call_target = code->instruction_start();
......
...@@ -1481,12 +1481,6 @@ WASM_EXEC_TEST(UnalignedInt64Store) { ...@@ -1481,12 +1481,6 @@ WASM_EXEC_TEST(UnalignedInt64Store) {
r.Call(); r.Call();
} }
#define ADD_CODE(vec, ...) \
do { \
byte __buf[] = {__VA_ARGS__}; \
for (size_t i = 0; i < sizeof(__buf); i++) vec.push_back(__buf[i]); \
} while (false)
static void CompileCallIndirectMany(TestExecutionTier tier, ValueType param) { static void CompileCallIndirectMany(TestExecutionTier tier, ValueType param) {
// Make sure we don't run out of registers when compiling indirect calls // Make sure we don't run out of registers when compiling indirect calls
// with many many parameters. // with many many parameters.
...@@ -1545,8 +1539,8 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) { ...@@ -1545,8 +1539,8 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) {
for (int i = 0; i < num_params; i++) { for (int i = 0; i < num_params; i++) {
b.AddParam(ValueType::For(memtypes[i])); b.AddParam(ValueType::For(memtypes[i]));
} }
WasmFunctionCompiler& t = r.NewFunction(b.Build()); WasmFunctionCompiler& f = r.NewFunction(b.Build());
BUILD(t, WASM_LOCAL_GET(which)); BUILD(f, WASM_LOCAL_GET(which));
// ========================================================================= // =========================================================================
// Build the calling function. // Build the calling function.
...@@ -1560,7 +1554,7 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) { ...@@ -1560,7 +1554,7 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) {
} }
// Call the selector function. // Call the selector function.
ADD_CODE(code, WASM_CALL_FUNCTION0(t.function_index())); ADD_CODE(code, WASM_CALL_FUNCTION0(f.function_index()));
// Store the result in a local. // Store the result in a local.
byte local_index = r.AllocateLocal(ValueType::For(result)); byte local_index = r.AllocateLocal(ValueType::For(result));
...@@ -1584,8 +1578,8 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) { ...@@ -1584,8 +1578,8 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
int base = (which + 1) * kElemSize; int base = (which + 1) * kElemSize;
byte expected = r.builder().raw_mem_at<byte>(base + i); byte expected = r.builder().raw_mem_at<byte>(base + i);
byte result = r.builder().raw_mem_at<byte>(i); byte actual = r.builder().raw_mem_at<byte>(i);
CHECK_EQ(expected, result); CHECK_EQ(expected, actual);
} }
} }
} }
...@@ -1619,8 +1613,6 @@ WASM_EXEC_TEST(Regression_6858) { ...@@ -1619,8 +1613,6 @@ WASM_EXEC_TEST(Regression_6858) {
CHECK_TRAP64(r.Call(dividend, divisor, filler, filler)); CHECK_TRAP64(r.Call(dividend, divisor, filler, filler));
} }
#undef ADD_CODE
// clang-format gets confused about these closing parentheses (wants to change // clang-format gets confused about these closing parentheses (wants to change
// the first comment to "// namespace v8". Disable it. // the first comment to "// namespace v8". Disable it.
// clang-format off // clang-format off
......
...@@ -21,12 +21,6 @@ namespace v8 { ...@@ -21,12 +21,6 @@ namespace v8 {
namespace internal { namespace internal {
namespace wasm { namespace wasm {
#define ADD_CODE(vec, ...) \
do { \
byte __buf[] = {__VA_ARGS__}; \
for (size_t i = 0; i < sizeof(__buf); i++) vec.push_back(__buf[i]); \
} while (false)
namespace { namespace {
// A helper for generating predictable but unique argument values that // A helper for generating predictable but unique argument values that
// are easy to debug (e.g. with misaligned stacks). // are easy to debug (e.g. with misaligned stacks).
...@@ -571,8 +565,6 @@ WASM_COMPILED_EXEC_TEST(Run_ReturnCallIndirectImportedFunction) { ...@@ -571,8 +565,6 @@ WASM_COMPILED_EXEC_TEST(Run_ReturnCallIndirectImportedFunction) {
RunPickerTest(execution_tier, true); RunPickerTest(execution_tier, true);
} }
#undef ADD_CODE
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
...@@ -1648,10 +1648,10 @@ WASM_EXEC_TEST(LoadMem_offset_oob) { ...@@ -1648,10 +1648,10 @@ WASM_EXEC_TEST(LoadMem_offset_oob) {
r.builder().AddMemoryElems<byte>(num_bytes); r.builder().AddMemoryElems<byte>(num_bytes);
r.builder().RandomizeMemory(1116 + static_cast<int>(m)); r.builder().RandomizeMemory(1116 + static_cast<int>(m));
constexpr byte offset = 8; constexpr byte kOffset = 8;
uint32_t boundary = num_bytes - offset - machineTypes[m].MemSize(); uint32_t boundary = num_bytes - kOffset - machineTypes[m].MemSize();
BUILD(r, WASM_LOAD_MEM_OFFSET(machineTypes[m], offset, WASM_LOCAL_GET(0)), BUILD(r, WASM_LOAD_MEM_OFFSET(machineTypes[m], kOffset, WASM_LOCAL_GET(0)),
WASM_DROP, WASM_ZERO); WASM_DROP, WASM_ZERO);
CHECK_EQ(0, r.Call(boundary)); // in bounds. CHECK_EQ(0, r.Call(boundary)); // in bounds.
...@@ -2743,12 +2743,6 @@ UNINITIALIZED_WASM_EXEC_TEST(ReturnCall_Bounce_Sum) { ...@@ -2743,12 +2743,6 @@ UNINITIALIZED_WASM_EXEC_TEST(ReturnCall_Bounce_Sum) {
} }
} }
#define ADD_CODE(vec, ...) \
do { \
byte __buf[] = {__VA_ARGS__}; \
for (size_t i = 0; i < sizeof(__buf); ++i) vec.push_back(__buf[i]); \
} while (false)
static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) { static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) {
const int kExpected = 6333; const int kExpected = 6333;
const int kElemSize = 8; const int kElemSize = 8;
...@@ -2778,8 +2772,8 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) { ...@@ -2778,8 +2772,8 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) {
for (int i = 0; i < num_params; ++i) { for (int i = 0; i < num_params; ++i) {
b.AddParam(ValueType::For(memtypes[i])); b.AddParam(ValueType::For(memtypes[i]));
} }
WasmFunctionCompiler& t = r.NewFunction(b.Build()); WasmFunctionCompiler& f = r.NewFunction(b.Build());
BUILD(t, WASM_LOCAL_GET(which)); BUILD(f, WASM_LOCAL_GET(which));
// ========================================================================= // =========================================================================
// Build the calling function. // Build the calling function.
...@@ -2793,7 +2787,7 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) { ...@@ -2793,7 +2787,7 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) {
} }
// Call the selector function. // Call the selector function.
ADD_CODE(code, WASM_CALL_FUNCTION0(t.function_index())); ADD_CODE(code, WASM_CALL_FUNCTION0(f.function_index()));
// Store the result in a local. // Store the result in a local.
byte local_index = r.AllocateLocal(ValueType::For(result)); byte local_index = r.AllocateLocal(ValueType::For(result));
...@@ -2817,8 +2811,8 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) { ...@@ -2817,8 +2811,8 @@ static void Run_WasmMixedCall_N(TestExecutionTier execution_tier, int start) {
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
int base = (which + 1) * kElemSize; int base = (which + 1) * kElemSize;
byte expected = r.builder().raw_mem_at<byte>(base + i); byte expected = r.builder().raw_mem_at<byte>(base + i);
byte result = r.builder().raw_mem_at<byte>(i); byte actual = r.builder().raw_mem_at<byte>(i);
CHECK_EQ(expected, result); CHECK_EQ(expected, actual);
} }
} }
} }
...@@ -3990,7 +3984,6 @@ TEST(Regression_1185323_1185492) { ...@@ -3990,7 +3984,6 @@ TEST(Regression_1185323_1185492) {
#undef B2 #undef B2
#undef RET #undef RET
#undef RET_I8 #undef RET_I8
#undef ADD_CODE
} // namespace test_run_wasm } // namespace test_run_wasm
} // namespace wasm } // namespace wasm
......
...@@ -84,10 +84,17 @@ using compiler::Node; ...@@ -84,10 +84,17 @@ using compiler::Node;
#define WASM_WRAPPER_RETURN_VALUE 8754 #define WASM_WRAPPER_RETURN_VALUE 8754
#define BUILD(r, ...) \ #define BUILD(r, ...) \
do { \ do { \
byte code[] = {__VA_ARGS__}; \ byte __code[] = {__VA_ARGS__}; \
r.Build(code, code + arraysize(code)); \ r.Build(__code, __code + arraysize(__code)); \
} while (false)
#define ADD_CODE(vec, ...) \
do { \
byte __buf[] = {__VA_ARGS__}; \
for (size_t __i = 0; __i < sizeof(__buf); __i++) \
vec.push_back(__buf[__i]); \
} while (false) } while (false)
// For tests that must manually import a JSFunction with source code. // For tests that must manually import a JSFunction with source code.
......
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