[wasm] [test] [cleanup] Add missing undefs

Cleanup before enabling the presubmit check:
https://chromium-review.googlesource.com/c/v8/v8/+/657104

Bug: v8:6811
R=ahaas@chromium.org
CC=​​mstarzinger@chromium.org

Change-Id: Ifbf9210464b46dfdb5e04fbedc41d30e11536f74
Reviewed-on: https://chromium-review.googlesource.com/657422
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47943}
This commit is contained in:
Clemens Hammacher 2017-09-08 15:59:05 +02:00 committed by Commit Bot
parent b8f144ec4f
commit f9efb571ab
21 changed files with 218 additions and 56 deletions

View File

@ -31,13 +31,6 @@ namespace wasm {
CHECK_EQ(0xdeadbeef, (bit_cast<uint32_t>(x)) & 0xFFFFFFFF) CHECK_EQ(0xdeadbeef, (bit_cast<uint32_t>(x)) & 0xFFFFFFFF)
#define CHECK_TRAP64(x) \ #define CHECK_TRAP64(x) \
CHECK_EQ(0xdeadbeefdeadbeef, (bit_cast<uint64_t>(x)) & 0xFFFFFFFFFFFFFFFF) CHECK_EQ(0xdeadbeefdeadbeef, (bit_cast<uint64_t>(x)) & 0xFFFFFFFFFFFFFFFF)
#define CHECK_TRAP(x) CHECK_TRAP32(x)
#define asi64(x) static_cast<int64_t>(x)
#define asu64(x) static_cast<uint64_t>(x)
#define B2(a, b) kExprBlock, a, b, kExprEnd
// Can't bridge macro land with nested macros. // Can't bridge macro land with nested macros.
#if V8_TARGET_ARCH_MIPS #if V8_TARGET_ARCH_MIPS
@ -99,6 +92,8 @@ namespace wasm {
FOREACH_I64_OPERATOR(DECLARE_CONST) FOREACH_I64_OPERATOR(DECLARE_CONST)
#undef DECLARE_CONST #undef DECLARE_CONST
#undef FOREACH_I64_OPERATOR
#define REQUIRE(name) \ #define REQUIRE(name) \
if (!WASM_64 && !kSupported_##name) return if (!WASM_64 && !kSupported_##name) return
@ -278,11 +273,11 @@ WASM_EXEC_TEST(I64DivS_Trap) {
REQUIRE(I64DivS); REQUIRE(I64DivS);
WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); WasmRunner<int64_t, int64_t, int64_t> r(execution_mode);
BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
CHECK_EQ(0, r.Call(asi64(0), asi64(100))); CHECK_EQ(0, r.Call(int64_t{0}, int64_t{100}));
CHECK_TRAP64(r.Call(asi64(100), asi64(0))); CHECK_TRAP64(r.Call(int64_t{100}, int64_t{0}));
CHECK_TRAP64(r.Call(asi64(-1001), asi64(0))); CHECK_TRAP64(r.Call(int64_t{-1001}, int64_t{0}));
CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(-1))); CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), int64_t{-1}));
CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(0))); CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), int64_t{0}));
} }
WASM_EXEC_TEST(I64DivS_Byzero_Const) { WASM_EXEC_TEST(I64DivS_Byzero_Const) {
@ -319,10 +314,10 @@ WASM_EXEC_TEST(I64DivU_Trap) {
REQUIRE(I64DivU); REQUIRE(I64DivU);
WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode);
BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
CHECK_EQ(0, r.Call(asu64(0), asu64(100))); CHECK_EQ(0, r.Call(uint64_t{0}, uint64_t{100}));
CHECK_TRAP64(r.Call(asu64(100), asu64(0))); CHECK_TRAP64(r.Call(uint64_t{100}, uint64_t{0}));
CHECK_TRAP64(r.Call(asu64(1001), asu64(0))); CHECK_TRAP64(r.Call(uint64_t{1001}, uint64_t{0}));
CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0))); CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), uint64_t{0}));
} }
WASM_EXEC_TEST(I64DivU_Byzero_Const) { WASM_EXEC_TEST(I64DivU_Byzero_Const) {
@ -360,11 +355,11 @@ WASM_EXEC_TEST(I64RemS_Trap) {
REQUIRE(I64RemS); REQUIRE(I64RemS);
WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); WasmRunner<int64_t, int64_t, int64_t> r(execution_mode);
BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
CHECK_EQ(33, r.Call(asi64(133), asi64(100))); CHECK_EQ(33, r.Call(int64_t{133}, int64_t{100}));
CHECK_EQ(0, r.Call(std::numeric_limits<int64_t>::min(), asi64(-1))); CHECK_EQ(0, r.Call(std::numeric_limits<int64_t>::min(), int64_t{-1}));
CHECK_TRAP64(r.Call(asi64(100), asi64(0))); CHECK_TRAP64(r.Call(int64_t{100}, int64_t{0}));
CHECK_TRAP64(r.Call(asi64(-1001), asi64(0))); CHECK_TRAP64(r.Call(int64_t{-1001}, int64_t{0}));
CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(0))); CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), int64_t{0}));
} }
WASM_EXEC_TEST(I64RemU) { WASM_EXEC_TEST(I64RemU) {
@ -386,10 +381,10 @@ WASM_EXEC_TEST(I64RemU_Trap) {
REQUIRE(I64RemU); REQUIRE(I64RemU);
WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode);
BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
CHECK_EQ(17, r.Call(asu64(217), asu64(100))); CHECK_EQ(17, r.Call(uint64_t{217}, uint64_t{100}));
CHECK_TRAP64(r.Call(asu64(100), asu64(0))); CHECK_TRAP64(r.Call(uint64_t{100}, uint64_t{0}));
CHECK_TRAP64(r.Call(asu64(1001), asu64(0))); CHECK_TRAP64(r.Call(uint64_t{1001}, uint64_t{0}));
CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0))); CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), uint64_t{0}));
} }
WASM_EXEC_TEST(I64And) { WASM_EXEC_TEST(I64And) {
@ -1002,6 +997,8 @@ WASM_EXEC_TEST(I64Binops) {
TEST_I64_BINOP(I64Rol, 8728493013947314237, 0xe07af243ac4d219d, 15); TEST_I64_BINOP(I64Rol, 8728493013947314237, 0xe07af243ac4d219d, 15);
} }
#undef TEST_I64_BINOP
#define TEST_I64_CMP(name, expected, a, b) \ #define TEST_I64_CMP(name, expected, a, b) \
do { \ do { \
if (WASM_64 || kSupported_##name) \ if (WASM_64 || kSupported_##name) \
@ -1021,6 +1018,8 @@ WASM_EXEC_TEST(I64Compare) {
TEST_I64_CMP(I64GeU, 0, 0x0886A0C58C7AA224, 0x5DDBE5A81FD7EE47); TEST_I64_CMP(I64GeU, 0, 0x0886A0C58C7AA224, 0x5DDBE5A81FD7EE47);
} }
#undef TEST_I64_CMP
WASM_EXEC_TEST(I64Clz) { WASM_EXEC_TEST(I64Clz) {
REQUIRE(I64Clz); REQUIRE(I64Clz);
struct { struct {
@ -1523,7 +1522,7 @@ WASM_EXEC_TEST(StoreMem_offset_oob_i64) {
CHECK_EQ(0, memcmp(&memory[0], &memory[8 + boundary], memsize)); CHECK_EQ(0, memcmp(&memory[0], &memory[8 + boundary], memsize));
for (uint32_t offset = boundary + 1; offset < boundary + 19; offset++) { for (uint32_t offset = boundary + 1; offset < boundary + 19; offset++) {
CHECK_TRAP(r.Call(offset)); // out of bounds. CHECK_TRAP32(r.Call(offset)); // out of bounds.
} }
} }
} }
@ -1673,6 +1672,13 @@ WASM_EXEC_TEST(Regress5874) {
r.Call(); r.Call();
} }
#undef WASM_64
#undef CHECK_TRAP32
#undef CHECK_TRAP64
#undef MIPS
#undef REQUIRE
#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

View File

@ -19,12 +19,6 @@ namespace v8 {
namespace internal { namespace internal {
namespace wasm { namespace wasm {
// for even shorter tests.
#define B2(a, b) kExprBlock, a, b, kExprEnd
#define B1(a) kExprBlock, a, kExprEnd
#define RET(x) x, kExprReturn, 1
#define RET_I8(x) kExprI8Const, x, kExprReturn, 1
namespace { namespace {
uint32_t GetMatchingRelocInfoCount(Handle<Code> code, RelocInfo::Mode rmode) { uint32_t GetMatchingRelocInfoCount(Handle<Code> code, RelocInfo::Mode rmode) {
int filter = 1 << rmode; int filter = 1 << rmode;
@ -238,6 +232,8 @@ WASM_EXEC_TEST(StoreMemI32_oob_asm) {
FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST) FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST)
#undef INT_LOAD_TEST
#define INT_STORE_TEST(OP_TYPE) \ #define INT_STORE_TEST(OP_TYPE) \
TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteCompiled); \ WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteCompiled); \
@ -252,6 +248,11 @@ FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST)
FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST) FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST)
#undef INT_STORE_TEST
#undef FOREACH_INT_CHECKED_LOAD_OP
#undef FOREACH_INT_CHECKED_STORE_OP
TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) { TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) {
WasmRunner<float, uint32_t> r(kExecuteCompiled); WasmRunner<float, uint32_t> r(kExecuteCompiled);
r.builder().ChangeOriginToAsmjs(); r.builder().ChangeOriginToAsmjs();

View File

@ -191,6 +191,10 @@ WASM_EXEC_TEST(I32CompareExchange8U) {
} }
} }
#undef WASM_ATOMICS_OP
#undef WASM_ATOMICS_BINOP
#undef WASM_ATOMICS_TERNARY_OP
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8

View File

@ -512,6 +512,9 @@ TEST(Run_JSSelectAlign_10) {
RunJSSelectAlignTest(10, 10); RunJSSelectAlignTest(10, 10);
} }
#undef BUILD
#undef ADD_CODE
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8

View File

@ -1170,6 +1170,8 @@ TEST(Run_WasmModule_Buffer_Externalized_Detach) {
Cleanup(); Cleanup();
} }
#undef EMIT_CODE_WITH_END
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8

View File

@ -62,6 +62,9 @@ namespace wasm {
FOREACH_TYPE(LOAD_SET_GLOBAL_TEST_BODY) FOREACH_TYPE(LOAD_SET_GLOBAL_TEST_BODY)
#undef FOREACH_TYPE
#undef LOAD_SET_GLOBAL_TEST_BODY
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8

View File

@ -2199,6 +2199,47 @@ WASM_SIMD_TEST(SimdLoadStoreLoad) {
#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET || #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || SIMD_LOWERING_TARGET ||
// V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
#undef SIMD_LOWERING_TARGET
#undef WASM_SIMD_TEST
#undef WASM_SIMD_CHECK_LANE
#undef WASM_SIMD_CHECK4
#undef WASM_SIMD_CHECK_SPLAT4
#undef WASM_SIMD_CHECK8
#undef WASM_SIMD_CHECK_SPLAT8
#undef WASM_SIMD_CHECK16
#undef WASM_SIMD_CHECK_SPLAT16
#undef WASM_SIMD_CHECK_F32_LANE
#undef WASM_SIMD_CHECK_F32x4
#undef WASM_SIMD_CHECK_SPLAT_F32x4
#undef WASM_SIMD_CHECK_F32_LANE_ESTIMATE
#undef WASM_SIMD_CHECK_SPLAT_F32x4_ESTIMATE
#undef TO_BYTE
#undef WASM_SIMD_OP
#undef WASM_SIMD_SPLAT
#undef WASM_SIMD_UNOP
#undef WASM_SIMD_BINOP
#undef WASM_SIMD_SHIFT_OP
#undef WASM_SIMD_CONCAT_OP
#undef WASM_SIMD_SELECT
#undef WASM_SIMD_F32x4_SPLAT
#undef WASM_SIMD_F32x4_EXTRACT_LANE
#undef WASM_SIMD_F32x4_REPLACE_LANE
#undef WASM_SIMD_I32x4_SPLAT
#undef WASM_SIMD_I32x4_EXTRACT_LANE
#undef WASM_SIMD_I32x4_REPLACE_LANE
#undef WASM_SIMD_I16x8_SPLAT
#undef WASM_SIMD_I16x8_EXTRACT_LANE
#undef WASM_SIMD_I16x8_REPLACE_LANE
#undef WASM_SIMD_I8x16_SPLAT
#undef WASM_SIMD_I8x16_EXTRACT_LANE
#undef WASM_SIMD_I8x16_REPLACE_LANE
#undef WASM_SIMD_S8x16_SHUFFLE_OP
#undef WASM_SIMD_LOAD_MEM
#undef WASM_SIMD_STORE_MEM
#undef WASM_SIMD_SELECT_TEST
#undef WASM_SIMD_NON_CANONICAL_SELECT_TEST
#undef WASM_SIMD_BOOL_REDUCTION_TEST
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8

View File

@ -22,7 +22,6 @@ namespace wasm {
// for even shorter tests. // for even shorter tests.
#define B1(a) WASM_BLOCK(a) #define B1(a) WASM_BLOCK(a)
#define B2(a, b) WASM_BLOCK(a, b) #define B2(a, b) WASM_BLOCK(a, b)
#define B3(a, b, c) WASM_BLOCK(a, b, c)
#define RET(x) x, kExprReturn #define RET(x) x, kExprReturn
#define RET_I8(x) WASM_I32V_2(x), kExprReturn #define RET_I8(x) WASM_I32V_2(x), kExprReturn
@ -649,7 +648,6 @@ WASM_EXEC_TEST(IfElse_P) {
CHECK_EQ(expected, r.Call(*i)); CHECK_EQ(expected, r.Call(*i));
} }
} }
#define EMPTY
WASM_EXEC_TEST(If_empty1) { WASM_EXEC_TEST(If_empty1) {
WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode); WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode);
@ -3093,6 +3091,12 @@ WASM_EXEC_TEST(IfInsideUnreachable) {
CHECK_EQ(17, r.Call()); CHECK_EQ(17, r.Call());
} }
#undef B1
#undef B2
#undef RET
#undef RET_I8
#undef ADD_CODE
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8

View File

@ -94,6 +94,8 @@ void CheckComputeLocation(v8::internal::Isolate* i_isolate, Handle<Object> exc,
CHECK_EQ(topLocation.column - 1, message->GetColumnNumber()); CHECK_EQ(topLocation.column - 1, message->GetColumnNumber());
} }
#undef CHECK_CSTREQ
} // namespace } // namespace
// Call from JS to wasm to JS and throw an Error from JS. // Call from JS to wasm to JS and throw an Error from JS.

View File

@ -60,6 +60,8 @@ void CheckExceptionInfos(v8::internal::Isolate* i_isolate, Handle<Object> exc,
} }
} }
#undef CHECK_CSTREQ
} // namespace } // namespace
// Trigger a trap for executing unreachable. // Trigger a trap for executing unreachable.

View File

@ -109,6 +109,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
return 0; return 0;
} }
#undef ASSIGN
} // namespace fuzzer } // namespace fuzzer
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal

View File

@ -18,14 +18,14 @@
#include "test/fuzzer/fuzzer-support.h" #include "test/fuzzer/fuzzer-support.h"
#include "test/fuzzer/wasm-fuzzer-common.h" #include "test/fuzzer/wasm-fuzzer-common.h"
#define MAX_NUM_FUNCTIONS 3
#define MAX_NUM_PARAMS 3
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace wasm { namespace wasm {
namespace fuzzer { namespace fuzzer {
static constexpr uint32_t kMaxNumFunctions = 3;
static constexpr uint32_t kMaxNumParams = 3;
class WasmCallFuzzer : public WasmExecutionFuzzer { class WasmCallFuzzer : public WasmExecutionFuzzer {
template <typename V> template <typename V>
static inline V read_value(const uint8_t** data, size_t* size, bool* ok) { static inline V read_value(const uint8_t** data, size_t* size, bool* ok) {
@ -78,7 +78,7 @@ class WasmCallFuzzer : public WasmExecutionFuzzer {
std::unique_ptr<Handle<Object>[]>& compiler_args) override { std::unique_ptr<Handle<Object>[]>& compiler_args) override {
bool ok = true; bool ok = true;
uint8_t num_functions = uint8_t num_functions =
(read_value<uint8_t>(&data, &size, &ok) % MAX_NUM_FUNCTIONS) + 1; (read_value<uint8_t>(&data, &size, &ok) % kMaxNumFunctions) + 1;
ValueType types[] = {kWasmF32, kWasmF64, kWasmI32, kWasmI64}; ValueType types[] = {kWasmF32, kWasmF64, kWasmI32, kWasmI64};
@ -88,7 +88,7 @@ class WasmCallFuzzer : public WasmExecutionFuzzer {
WasmModuleBuilder builder(zone); WasmModuleBuilder builder(zone);
for (int fun = 0; fun < num_functions; fun++) { for (int fun = 0; fun < num_functions; fun++) {
size_t num_params = static_cast<size_t>( size_t num_params = static_cast<size_t>(
(read_value<uint8_t>(&data, &size, &ok) % MAX_NUM_PARAMS) + 1); (read_value<uint8_t>(&data, &size, &ok) % kMaxNumParams) + 1);
FunctionSig::Builder sig_builder(zone, 1, num_params); FunctionSig::Builder sig_builder(zone, 1, num_params);
sig_builder.AddReturn(kWasmI32); sig_builder.AddReturn(kWasmI32);
for (size_t param = 0; param < num_params; param++) { for (size_t param = 0; param < num_params; param++) {

View File

@ -15,15 +15,15 @@
#include "test/common/wasm/wasm-module-runner.h" #include "test/common/wasm/wasm-module-runner.h"
#include "test/fuzzer/fuzzer-support.h" #include "test/fuzzer/fuzzer-support.h"
#define WASM_CODE_FUZZER_HASH_SEED 83
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace wasm { namespace wasm {
namespace fuzzer { namespace fuzzer {
static const char* kNameString = "name"; static constexpr uint32_t kWasmCodeFuzzerHashSeed = 83;
static const size_t kNameStringLength = 4;
static constexpr const char* kNameString = "name";
static constexpr size_t kNameStringLength = 4;
int FuzzWasmSection(SectionCode section, const uint8_t* data, size_t size) { int FuzzWasmSection(SectionCode section, const uint8_t* data, size_t size) {
v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get(); v8_fuzzer::FuzzerSupport* support = v8_fuzzer::FuzzerSupport::Get();
@ -171,7 +171,7 @@ int WasmExecutionFuzzer::FuzzWasmModule(
if (compiles != validates) { if (compiles != validates) {
uint32_t hash = StringHasher::HashSequentialString( uint32_t hash = StringHasher::HashSequentialString(
data, static_cast<int>(size), WASM_CODE_FUZZER_HASH_SEED); data, static_cast<int>(size), kWasmCodeFuzzerHashSeed);
V8_Fatal(__FILE__, __LINE__, V8_Fatal(__FILE__, __LINE__,
"compiles != validates (%d vs %d); WasmCodeFuzzerHash=%x", "compiles != validates (%d vs %d); WasmCodeFuzzerHash=%x",
compiles, validates, hash); compiles, validates, hash);
@ -227,7 +227,7 @@ int WasmExecutionFuzzer::FuzzWasmModule(
if (result_interpreted != result_compiled) { if (result_interpreted != result_compiled) {
V8_Fatal(__FILE__, __LINE__, "WasmCodeFuzzerHash=%x", V8_Fatal(__FILE__, __LINE__, "WasmCodeFuzzerHash=%x",
StringHasher::HashSequentialString(data, static_cast<int>(size), StringHasher::HashSequentialString(data, static_cast<int>(size),
WASM_CODE_FUZZER_HASH_SEED)); kWasmCodeFuzzerHashSeed));
} }
} }
return 0; return 0;

View File

@ -20,13 +20,6 @@ namespace v8 {
namespace internal { namespace internal {
namespace wasm { namespace wasm {
#define B1(a) kExprBlock, a, kExprEnd
#define B2(a, b) kExprBlock, a, b, kExprEnd
#define B3(a, b, c) kExprBlock, a, b, c, kExprEnd
#define TRANSFER_VOID 0
#define TRANSFER_ONE 1
struct ExpectedControlTransfer { struct ExpectedControlTransfer {
pc_t pc; pc_t pc;
pcdiff_t pc_diff; pcdiff_t pc_diff;

View File

@ -676,6 +676,11 @@ TEST_F(DecoderTest, FailOnNullData) {
EXPECT_FALSE(decoder.toResult(nullptr).ok()); EXPECT_FALSE(decoder.toResult(nullptr).ok());
} }
#undef CHECK_UINT32V_INLINE
#undef CHECK_INT32V_INLINE
#undef CHECK_UINT64V_INLINE
#undef CHECK_INT64V_INLINE
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8

View File

@ -523,6 +523,8 @@ TEST_F(FunctionBodyDecoderTest, Block0_end) {
EXPECT_FAILURE(v_v, WASM_EMPTY_BLOCK, kExprEnd); EXPECT_FAILURE(v_v, WASM_EMPTY_BLOCK, kExprEnd);
} }
#undef WASM_EMPTY_BLOCK
TEST_F(FunctionBodyDecoderTest, Block1) { TEST_F(FunctionBodyDecoderTest, Block1) {
byte code[] = {WASM_BLOCK_I(WASM_GET_LOCAL(0))}; byte code[] = {WASM_BLOCK_I(WASM_GET_LOCAL(0))};
EXPECT_VERIFIES_C(i_i, code); EXPECT_VERIFIES_C(i_i, code);
@ -1341,6 +1343,16 @@ TEST_F(FunctionBodyDecoderTest, StoreMemOffset_varint) {
VARINT4(0x44444444)); VARINT4(0x44444444));
} }
#undef BYTE0
#undef BYTE1
#undef BYTE2
#undef BYTE3
#undef VARINT1
#undef VARINT2
#undef VARINT3
#undef VARINT4
TEST_F(FunctionBodyDecoderTest, AllLoadMemCombinations) { TEST_F(FunctionBodyDecoderTest, AllLoadMemCombinations) {
TestModuleBuilder builder; TestModuleBuilder builder;
module = builder.module(); module = builder.module();
@ -2283,7 +2295,6 @@ TEST_F(FunctionBodyDecoderTest, ThrowUnreachable) {
} }
#define WASM_TRY_OP kExprTry, kLocalVoid #define WASM_TRY_OP kExprTry, kLocalVoid
#define WASM_CATCH(index) kExprCatch, static_cast<byte>(index) #define WASM_CATCH(index) kExprCatch, static_cast<byte>(index)
TEST_F(FunctionBodyDecoderTest, TryCatch) { TEST_F(FunctionBodyDecoderTest, TryCatch) {
@ -2308,6 +2319,9 @@ TEST_F(FunctionBodyDecoderTest, TryCatch) {
EXPECT_FAILURE(v_i, WASM_TRY_OP, WASM_CATCH(0), WASM_CATCH(1), kExprEnd); EXPECT_FAILURE(v_i, WASM_TRY_OP, WASM_CATCH(0), WASM_CATCH(1), kExprEnd);
} }
#undef WASM_TRY_OP
#undef WASM_CATCH
TEST_F(FunctionBodyDecoderTest, MultiValBlock1) { TEST_F(FunctionBodyDecoderTest, MultiValBlock1) {
EXPERIMENTAL_FLAG_SCOPE(mv); EXPERIMENTAL_FLAG_SCOPE(mv);
EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0), EXPECT_VERIFIES(i_ii, WASM_BLOCK_TT(kWasmI32, kWasmI32, WASM_GET_LOCAL(0),
@ -2429,6 +2443,9 @@ TEST_F(BranchTableIteratorTest, error0) {
CHECK_BR_TABLE_ERROR(1, U32V_1(33)); CHECK_BR_TABLE_ERROR(1, U32V_1(33));
} }
#undef CHECK_BR_TABLE_LENGTH
#undef CHECK_BR_TABLE_ERROR
class WasmOpcodeLengthTest : public TestWithZone { class WasmOpcodeLengthTest : public TestWithZone {
public: public:
WasmOpcodeLengthTest() : TestWithZone() {} WasmOpcodeLengthTest() : TestWithZone() {}
@ -2665,11 +2682,13 @@ TEST_F(WasmOpcodeLengthTest, SimdExpressions) {
FOREACH_SIMD_1_OPERAND_OPCODE(TEST_SIMD) FOREACH_SIMD_1_OPERAND_OPCODE(TEST_SIMD)
#undef TEST_SIMD #undef TEST_SIMD
EXPECT_LENGTH_N(18, kSimdPrefix, static_cast<byte>(kExprS8x16Shuffle & 0xff)); EXPECT_LENGTH_N(18, kSimdPrefix, static_cast<byte>(kExprS8x16Shuffle & 0xff));
#undef TEST_SIMD
// test for bad simd opcode // test for bad simd opcode
EXPECT_LENGTH_N(2, kSimdPrefix, 0xff); EXPECT_LENGTH_N(2, kSimdPrefix, 0xff);
} }
#undef EXPECT_LENGTH
#undef EXPECT_LENGTH_N
typedef ZoneVector<ValueType> TypesOfLocals; typedef ZoneVector<ValueType> TypesOfLocals;
class LocalDeclDecoderTest : public TestWithZone { class LocalDeclDecoderTest : public TestWithZone {
@ -2854,6 +2873,21 @@ TEST_F(BytecodeIteratorTest, WithLocalDecls) {
EXPECT_FALSE(iter.has_next()); EXPECT_FALSE(iter.has_next());
} }
#undef B1
#undef B2
#undef B3
#undef WASM_IF_OP
#undef WASM_LOOP_OP
#undef WASM_BRV_IF_ZERO
#undef EXPECT_VERIFIES_C
#undef EXPECT_FAILURE_C
#undef EXPECT_VERIFIES_SC
#undef EXPECT_FAILURE_SC
#undef EXPECT_VERIFIES_S
#undef EXPECT_FAILURE_S
#undef EXPECT_VERIFIES
#undef EXPECT_FAILURE
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8

View File

@ -108,6 +108,8 @@ DECLARE_ENCODE_DECODE_CHECKER(uint32_t, u32v)
DECLARE_ENCODE_DECODE_CHECKER(int64_t, i64v) DECLARE_ENCODE_DECODE_CHECKER(int64_t, i64v)
DECLARE_ENCODE_DECODE_CHECKER(uint64_t, u64v) DECLARE_ENCODE_DECODE_CHECKER(uint64_t, u64v)
#undef DECLARE_ENCODE_DECODE_CHECKER
TEST_F(LEBHelperTest, WriteAndDecode_u32v) { TEST_F(LEBHelperTest, WriteAndDecode_u32v) {
CheckEncodeDecode_u32v(0); CheckEncodeDecode_u32v(0);
CheckEncodeDecode_u32v(1); CheckEncodeDecode_u32v(1);

View File

@ -14,12 +14,12 @@
#include "test/common/wasm/test-signatures.h" #include "test/common/wasm/test-signatures.h"
#include "test/common/wasm/wasm-macro-gen.h" #include "test/common/wasm/wasm-macro-gen.h"
#define WASM_SET_ZERO(i) WASM_SET_LOCAL(i, WASM_ZERO)
namespace v8 { namespace v8 {
namespace internal { namespace internal {
namespace wasm { namespace wasm {
#define WASM_SET_ZERO(i) WASM_SET_LOCAL(i, WASM_ZERO)
class WasmLoopAssignmentAnalyzerTest : public TestWithZone { class WasmLoopAssignmentAnalyzerTest : public TestWithZone {
public: public:
WasmLoopAssignmentAnalyzerTest() : num_locals(0) {} WasmLoopAssignmentAnalyzerTest() : num_locals(0) {}
@ -191,6 +191,8 @@ TEST_F(WasmLoopAssignmentAnalyzerTest, regress_642867) {
Analyze(code, code + arraysize(code)); Analyze(code, code + arraysize(code));
} }
#undef WASM_SET_ZERO
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8

View File

@ -1649,6 +1649,8 @@ TEST_F(WasmModuleVerifyTest, InitExpr_f64) {
EXPECT_INIT_EXPR(F64, f64, 77999.1, WASM_F64(77999.1)); EXPECT_INIT_EXPR(F64, f64, 77999.1, WASM_F64(77999.1));
} }
#undef EXPECT_INIT_EXPR
#define EXPECT_INIT_EXPR_FAIL(...) \ #define EXPECT_INIT_EXPR_FAIL(...) \
{ \ { \
static const byte data[] = {__VA_ARGS__, kExprEnd}; \ static const byte data[] = {__VA_ARGS__, kExprEnd}; \
@ -1665,6 +1667,8 @@ TEST_F(WasmModuleVerifyTest, InitExpr_illegal) {
EXPECT_INIT_EXPR_FAIL(WASM_IF_ELSE(WASM_ZERO, WASM_ZERO, WASM_ZERO)); EXPECT_INIT_EXPR_FAIL(WASM_IF_ELSE(WASM_ZERO, WASM_ZERO, WASM_ZERO));
} }
#undef EXPECT_INIT_EXPR_FAIL
TEST_F(WasmModuleVerifyTest, Multiple_Named_Sections) { TEST_F(WasmModuleVerifyTest, Multiple_Named_Sections) {
static const byte data[] = { static const byte data[] = {
SECTION(Unknown, 4), 1, 'X', 17, 18, // -- SECTION(Unknown, 4), 1, 'X', 17, 18, // --
@ -1760,6 +1764,54 @@ TEST_F(WasmModuleCustomSectionTest, TwoKnownTwoUnknownSections) {
CheckSections(data, data + sizeof(data), expected, arraysize(expected)); CheckSections(data, data + sizeof(data), expected, arraysize(expected));
} }
#undef WASM_INIT_EXPR_I32V_1
#undef WASM_INIT_EXPR_I32V_2
#undef WASM_INIT_EXPR_I32V_3
#undef WASM_INIT_EXPR_I32V_4
#undef WASM_INIT_EXPR_I32V_5
#undef WASM_INIT_EXPR_F32
#undef WASM_INIT_EXPR_I64
#undef WASM_INIT_EXPR_F64
#undef WASM_INIT_EXPR_GLOBAL
#undef SIZEOF_EMPTY_FUNCTION
#undef EMPTY_BODY
#undef SIZEOF_EMPTY_BODY
#undef NOP_BODY
#undef SIZEOF_NOP_BODY
#undef SIG_ENTRY_i_i
#undef UNKNOWN_SECTION
#undef SECTION
#undef SIGNATURES_SECTION
#undef FUNCTION_SIGNATURES_SECTION
#undef FOO_STRING
#undef NO_LOCAL_NAMES
#undef EMPTY_SIGNATURES_SECTION
#undef EMPTY_FUNCTION_SIGNATURES_SECTION
#undef EMPTY_FUNCTION_BODIES_SECTION
#undef SECTION_NAMES
#undef SECTION_EXCEPTIONS
#undef EMPTY_NAMES_SECTION
#undef FAIL_IF_NO_EXPERIMENTAL_EH
#undef X1
#undef X2
#undef X3
#undef X4
#undef ONE_EMPTY_FUNCTION
#undef TWO_EMPTY_FUNCTIONS
#undef THREE_EMPTY_FUNCTIONS
#undef FOUR_EMPTY_FUNCTIONS
#undef ONE_EMPTY_BODY
#undef TWO_EMPTY_BODIES
#undef THREE_EMPTY_BODIES
#undef FOUR_EMPTY_BODIES
#undef SIGNATURES_SECTION_VOID_VOID
#undef LINEAR_MEMORY_INDEX_0
#undef EXPECT_VERIFIES
#undef EXPECT_FAILURE_LEN
#undef EXPECT_FAILURE
#undef EXPECT_OFF_END_FAILURE
#undef EXPECT_OK
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8

View File

@ -309,6 +309,9 @@ TEST_F(WasmMacroGenTest, LoadsAndStoresWithOffset) {
WASM_GET_LOCAL(0))); WASM_GET_LOCAL(0)));
} }
} }
#undef EXPECT_SIZE
} // namespace wasm } // namespace wasm
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8

View File

@ -19,6 +19,7 @@ TEST_F(WasmOpcodesTest, EveryOpcodeHasAName) {
} kValues[] = { } kValues[] = {
#define DECLARE_ELEMENT(name, opcode, sig) {kExpr##name, "kExpr" #name}, #define DECLARE_ELEMENT(name, opcode, sig) {kExpr##name, "kExpr" #name},
FOREACH_OPCODE(DECLARE_ELEMENT)}; FOREACH_OPCODE(DECLARE_ELEMENT)};
#undef DECLARE_ELEMENT
for (size_t i = 0; i < arraysize(kValues); i++) { for (size_t i = 0; i < arraysize(kValues); i++) {
const char* result = WasmOpcodes::OpcodeName(kValues[i].opcode); const char* result = WasmOpcodes::OpcodeName(kValues[i].opcode);