[wasm] Fix more -Wsign-compare warnings.
BUG=v8:5614 Review-Url: https://codereview.chromium.org/2492793005 Cr-Commit-Position: refs/heads/master@{#40914}
This commit is contained in:
parent
fa9c25cebf
commit
9c25d5dc6e
@ -94,7 +94,7 @@ class AsmValueType {
|
||||
}
|
||||
|
||||
static AsmType* New(bitset_t bits) {
|
||||
DCHECK_EQ((bits & kAsmValueTypeTag), 0);
|
||||
DCHECK_EQ((bits & kAsmValueTypeTag), 0u);
|
||||
return reinterpret_cast<AsmType*>(
|
||||
static_cast<uintptr_t>(bits | kAsmValueTypeTag));
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ class WasmFullDecoder : public WasmDecoder {
|
||||
|
||||
// Decodes the locals declarations, if any, populating {local_type_vec_}.
|
||||
void DecodeLocalDecls() {
|
||||
DCHECK_EQ(0, local_type_vec_.size());
|
||||
DCHECK_EQ(0u, local_type_vec_.size());
|
||||
// Initialize {local_type_vec} from signature.
|
||||
if (sig_) {
|
||||
local_type_vec_.reserve(sig_->parameter_count());
|
||||
|
@ -1698,7 +1698,7 @@ class ThreadImpl : public WasmInterpreter::Thread {
|
||||
|
||||
WasmVal PopArity(size_t arity) {
|
||||
if (arity == 0) return WasmVal();
|
||||
CHECK_EQ(1, arity);
|
||||
CHECK_EQ(1u, arity);
|
||||
return Pop();
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ TEST(WasmRelocationArmMemoryReference) {
|
||||
code->Print(os);
|
||||
::printf("f() = %d\n\n", ret_value);
|
||||
#endif
|
||||
size_t offset = 1234;
|
||||
int offset = 1234;
|
||||
|
||||
// Relocating references by offset
|
||||
int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE);
|
||||
@ -103,7 +103,7 @@ TEST(WasmRelocationArmMemorySizeReference) {
|
||||
CSignature0<int32_t> csig;
|
||||
CodeRunner<int32_t> runnable(isolate, code, &csig);
|
||||
int32_t ret_value = runnable.Call();
|
||||
CHECK_NE(ret_value, 0xdeadbeef);
|
||||
CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef));
|
||||
|
||||
#ifdef DEBUG
|
||||
OFStream os(stdout);
|
||||
@ -124,7 +124,7 @@ TEST(WasmRelocationArmMemorySizeReference) {
|
||||
}
|
||||
|
||||
ret_value = runnable.Call();
|
||||
CHECK_NE(ret_value, 0xdeadbeef);
|
||||
CHECK_NE(ret_value, bit_cast<int32_t>(0xdeadbeef));
|
||||
|
||||
#ifdef DEBUG
|
||||
code->Print(os);
|
||||
|
@ -52,7 +52,7 @@ TEST(WasmRelocationArm64MemoryReference) {
|
||||
code->Print(os);
|
||||
::printf("f() = %" PRIx64 "\n\n", ret_value);
|
||||
#endif
|
||||
size_t offset = 1234;
|
||||
int offset = 1234;
|
||||
|
||||
// Relocating reference by offset
|
||||
int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE);
|
||||
|
@ -52,7 +52,7 @@ TEST(WasmRelocationX64MemoryReference) {
|
||||
byte* end = begin + code->instruction_size();
|
||||
disasm::Disassembler::Disassemble(stdout, begin, end);
|
||||
#endif
|
||||
size_t offset = 1234;
|
||||
int offset = 1234;
|
||||
|
||||
// Relocating references by offset
|
||||
int mode_mask = (1 << RelocInfo::WASM_MEMORY_REFERENCE);
|
||||
|
@ -300,7 +300,7 @@ WASM_EXEC_TEST(I64DivU_Trap) {
|
||||
WasmRunner<uint64_t> r(execution_mode, MachineType::Uint64(),
|
||||
MachineType::Uint64());
|
||||
BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
|
||||
CHECK_EQ(0, r.Call(asu64(0), asu64(100)));
|
||||
CHECK_EQ(0u, r.Call(asu64(0), asu64(100)));
|
||||
CHECK_TRAP64(r.Call(asu64(100), asu64(0)));
|
||||
CHECK_TRAP64(r.Call(asu64(1001), asu64(0)));
|
||||
CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0)));
|
||||
@ -371,7 +371,7 @@ WASM_EXEC_TEST(I64RemU_Trap) {
|
||||
WasmRunner<uint64_t> r(execution_mode, MachineType::Uint64(),
|
||||
MachineType::Uint64());
|
||||
BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
|
||||
CHECK_EQ(17, r.Call(asu64(217), asu64(100)));
|
||||
CHECK_EQ(17u, r.Call(asu64(217), asu64(100)));
|
||||
CHECK_TRAP64(r.Call(asu64(100), asu64(0)));
|
||||
CHECK_TRAP64(r.Call(asu64(1001), asu64(0)));
|
||||
CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0)));
|
||||
|
@ -237,33 +237,33 @@ WASM_EXEC_TEST(StoreMemI32_oob_asm) {
|
||||
TEST_BODY(kExprI32AsmjsStoreMem16) \
|
||||
TEST_BODY(kExprI32AsmjsStoreMem)
|
||||
|
||||
#define INT_LOAD_TEST(OP_TYPE) \
|
||||
TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
|
||||
TestingModule module(kExecuteCompiled); \
|
||||
module.origin = kAsmJsOrigin; \
|
||||
WasmRunner<int32_t> r(&module, MachineType::Uint32()); \
|
||||
BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \
|
||||
CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], \
|
||||
RelocInfo::WASM_MEMORY_REFERENCE)); \
|
||||
CHECK_NE( \
|
||||
0, GetMatchingRelocInfoCount(module.instance->function_code[0], \
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
|
||||
#define INT_LOAD_TEST(OP_TYPE) \
|
||||
TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
|
||||
TestingModule module(kExecuteCompiled); \
|
||||
module.origin = kAsmJsOrigin; \
|
||||
WasmRunner<int32_t> r(&module, MachineType::Uint32()); \
|
||||
BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \
|
||||
CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], \
|
||||
RelocInfo::WASM_MEMORY_REFERENCE)); \
|
||||
CHECK_NE( \
|
||||
0u, GetMatchingRelocInfoCount(module.instance->function_code[0], \
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
|
||||
}
|
||||
|
||||
FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST)
|
||||
|
||||
#define INT_STORE_TEST(OP_TYPE) \
|
||||
TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
|
||||
TestingModule module(kExecuteCompiled); \
|
||||
module.origin = kAsmJsOrigin; \
|
||||
WasmRunner<int32_t> r(&module, MachineType::Uint32(), \
|
||||
MachineType::Uint32()); \
|
||||
BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \
|
||||
CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], \
|
||||
RelocInfo::WASM_MEMORY_REFERENCE)); \
|
||||
CHECK_NE( \
|
||||
0, GetMatchingRelocInfoCount(module.instance->function_code[0], \
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
|
||||
#define INT_STORE_TEST(OP_TYPE) \
|
||||
TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \
|
||||
TestingModule module(kExecuteCompiled); \
|
||||
module.origin = kAsmJsOrigin; \
|
||||
WasmRunner<int32_t> r(&module, MachineType::Uint32(), \
|
||||
MachineType::Uint32()); \
|
||||
BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \
|
||||
CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], \
|
||||
RelocInfo::WASM_MEMORY_REFERENCE)); \
|
||||
CHECK_NE( \
|
||||
0u, GetMatchingRelocInfoCount(module.instance->function_code[0], \
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \
|
||||
}
|
||||
|
||||
FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST)
|
||||
@ -274,10 +274,11 @@ TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) {
|
||||
WasmRunner<float> r(&module, MachineType::Uint32());
|
||||
BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0)));
|
||||
|
||||
CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_REFERENCE));
|
||||
CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
|
||||
CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_REFERENCE));
|
||||
CHECK_NE(0u,
|
||||
GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
|
||||
}
|
||||
|
||||
TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) {
|
||||
@ -287,10 +288,11 @@ TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) {
|
||||
BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0),
|
||||
WASM_GET_LOCAL(1)));
|
||||
|
||||
CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_REFERENCE));
|
||||
CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
|
||||
CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_REFERENCE));
|
||||
CHECK_NE(0u,
|
||||
GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
|
||||
}
|
||||
|
||||
TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) {
|
||||
@ -299,10 +301,11 @@ TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) {
|
||||
WasmRunner<double> r(&module, MachineType::Uint32());
|
||||
BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0)));
|
||||
|
||||
CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_REFERENCE));
|
||||
CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
|
||||
CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_REFERENCE));
|
||||
CHECK_NE(0u,
|
||||
GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
|
||||
}
|
||||
|
||||
TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) {
|
||||
@ -312,8 +315,9 @@ TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) {
|
||||
BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0),
|
||||
WASM_GET_LOCAL(1)));
|
||||
|
||||
CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_REFERENCE));
|
||||
CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
|
||||
CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_REFERENCE));
|
||||
CHECK_NE(0u,
|
||||
GetMatchingRelocInfoCount(module.instance->function_code[0],
|
||||
RelocInfo::WASM_MEMORY_SIZE_REFERENCE));
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ void RunJSSelectAlignTest(int num_args, int num_params) {
|
||||
HandleScope scope(isolate);
|
||||
TestingModule module;
|
||||
uint32_t js_index = AddJSSelector(&module, &sig, which);
|
||||
CHECK_EQ(0, js_index);
|
||||
CHECK_EQ(0u, js_index);
|
||||
WasmFunctionCompiler t(&sig, &module);
|
||||
t.Build(&code[0], &code[end]);
|
||||
|
||||
|
@ -31,7 +31,7 @@ using namespace v8::internal::compiler;
|
||||
/* global = global + p0 */ \
|
||||
BUILD(r, WASM_SET_GLOBAL(1, ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))), \
|
||||
WASM_GET_GLOBAL(0)); \
|
||||
CHECK_EQ(1, module.instance->function_code.size()); \
|
||||
CHECK_EQ(1u, module.instance->function_code.size()); \
|
||||
\
|
||||
int filter = 1 << RelocInfo::WASM_GLOBAL_REFERENCE; \
|
||||
\
|
||||
|
@ -1769,7 +1769,7 @@ WASM_EXEC_TEST(CheckMachIntsZero) {
|
||||
/**/ kExprI8Const, 0); // --
|
||||
|
||||
module.BlankMemory();
|
||||
CHECK_EQ(0, r.Call((kNumElems - 1) * 4));
|
||||
CHECK_EQ(0u, r.Call((kNumElems - 1) * 4));
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(MemF32_Sum) {
|
||||
@ -1944,7 +1944,7 @@ static void TestBuildGraphForSimpleExpression(WasmOpcode opcode) {
|
||||
TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code,
|
||||
code + arraysize(code));
|
||||
} else {
|
||||
CHECK_EQ(2, sig->parameter_count());
|
||||
CHECK_EQ(2u, sig->parameter_count());
|
||||
byte code[] = {WASM_NO_LOCALS, kExprGetLocal, 0, kExprGetLocal, 1,
|
||||
static_cast<byte>(opcode)};
|
||||
TestBuildingGraph(&zone, &jsgraph, nullptr, sig, nullptr, code,
|
||||
|
@ -100,7 +100,7 @@ class TestingModule : public ModuleEnv {
|
||||
|
||||
byte* AddMemory(uint32_t size) {
|
||||
CHECK_NULL(instance->mem_start);
|
||||
CHECK_EQ(0, instance->mem_size);
|
||||
CHECK_EQ(0u, instance->mem_size);
|
||||
instance->mem_start = reinterpret_cast<byte*>(malloc(size));
|
||||
CHECK(instance->mem_start);
|
||||
memset(instance->mem_start, 0, size);
|
||||
|
@ -155,7 +155,7 @@ TEST_F(AsmTypeTest, ValidateBits) {
|
||||
do { \
|
||||
++total_types; \
|
||||
if (AsmValueTypeParents::CamelName != 0) { \
|
||||
EXPECT_NE(0, ParentsOf(AsmType::CamelName()).size()) << #CamelName; \
|
||||
EXPECT_NE(0u, ParentsOf(AsmType::CamelName()).size()) << #CamelName; \
|
||||
} \
|
||||
seen_types.insert(Type::CamelName()); \
|
||||
seen_numbers.insert(number); \
|
||||
@ -163,7 +163,7 @@ TEST_F(AsmTypeTest, ValidateBits) {
|
||||
EXPECT_NE(0, number) << Type::CamelName()->Name(); \
|
||||
/* Inheritance cycles - unlikely, but we're paranoid and check for it */ \
|
||||
/* anyways.*/ \
|
||||
EXPECT_EQ(0, (1 << (number)) & AsmValueTypeParents::CamelName); \
|
||||
EXPECT_EQ(0u, (1 << (number)) & AsmValueTypeParents::CamelName); \
|
||||
} while (0);
|
||||
FOR_EACH_ASM_VALUE_TYPE_LIST(V)
|
||||
#undef V
|
||||
|
@ -2246,7 +2246,7 @@ class BranchTableIteratorTest : public TestWithZone {
|
||||
Decoder decoder(start, end);
|
||||
BranchTableOperand operand(&decoder, start);
|
||||
BranchTableIterator iterator(&decoder, operand);
|
||||
EXPECT_EQ(end - start - 1, iterator.length());
|
||||
EXPECT_EQ(end - start - 1u, iterator.length());
|
||||
EXPECT_TRUE(decoder.ok());
|
||||
}
|
||||
void CheckBrTableError(const byte* start, const byte* end) {
|
||||
@ -2304,16 +2304,18 @@ class WasmOpcodeLengthTest : public TestWithZone {
|
||||
WasmOpcodeLengthTest() : TestWithZone() {}
|
||||
};
|
||||
|
||||
#define EXPECT_LENGTH(expected, opcode) \
|
||||
{ \
|
||||
static const byte code[] = {opcode, 0, 0, 0, 0, 0, 0, 0, 0}; \
|
||||
EXPECT_EQ(expected, OpcodeLength(code, code + sizeof(code))); \
|
||||
#define EXPECT_LENGTH(expected, opcode) \
|
||||
{ \
|
||||
static const byte code[] = {opcode, 0, 0, 0, 0, 0, 0, 0, 0}; \
|
||||
EXPECT_EQ(static_cast<unsigned>(expected), \
|
||||
OpcodeLength(code, code + sizeof(code))); \
|
||||
}
|
||||
|
||||
#define EXPECT_LENGTH_N(expected, ...) \
|
||||
{ \
|
||||
static const byte code[] = {__VA_ARGS__}; \
|
||||
EXPECT_EQ(expected, OpcodeLength(code, code + sizeof(code))); \
|
||||
#define EXPECT_LENGTH_N(expected, ...) \
|
||||
{ \
|
||||
static const byte code[] = {__VA_ARGS__}; \
|
||||
EXPECT_EQ(static_cast<unsigned>(expected), \
|
||||
OpcodeLength(code, code + sizeof(code))); \
|
||||
}
|
||||
|
||||
TEST_F(WasmOpcodeLengthTest, Statements) {
|
||||
@ -2571,7 +2573,7 @@ TEST_F(LocalDeclDecoderTest, NoLocals) {
|
||||
AstLocalDecls decls(zone());
|
||||
bool result = DecodeLocalDecls(decls, data, data + sizeof(data));
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(0, decls.total_local_count);
|
||||
EXPECT_EQ(0u, decls.total_local_count);
|
||||
}
|
||||
|
||||
TEST_F(LocalDeclDecoderTest, OneLocal) {
|
||||
@ -2582,10 +2584,10 @@ TEST_F(LocalDeclDecoderTest, OneLocal) {
|
||||
AstLocalDecls decls(zone());
|
||||
bool result = DecodeLocalDecls(decls, data, data + sizeof(data));
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(1, decls.total_local_count);
|
||||
EXPECT_EQ(1u, decls.total_local_count);
|
||||
|
||||
LocalTypeMap map = Expand(decls);
|
||||
EXPECT_EQ(1, map.size());
|
||||
EXPECT_EQ(1u, map.size());
|
||||
EXPECT_EQ(type, map[0]);
|
||||
}
|
||||
}
|
||||
@ -2599,10 +2601,10 @@ TEST_F(LocalDeclDecoderTest, FiveLocals) {
|
||||
bool result = DecodeLocalDecls(decls, data, data + sizeof(data));
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(sizeof(data), decls.decls_encoded_size);
|
||||
EXPECT_EQ(5, decls.total_local_count);
|
||||
EXPECT_EQ(5u, decls.total_local_count);
|
||||
|
||||
LocalTypeMap map = Expand(decls);
|
||||
EXPECT_EQ(5, map.size());
|
||||
EXPECT_EQ(5u, map.size());
|
||||
ExpectRun(map, 0, type, 5);
|
||||
}
|
||||
}
|
||||
@ -2618,10 +2620,11 @@ TEST_F(LocalDeclDecoderTest, MixedLocals) {
|
||||
bool result = DecodeLocalDecls(decls, data, data + sizeof(data));
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(sizeof(data), decls.decls_encoded_size);
|
||||
EXPECT_EQ(a + b + c + d, decls.total_local_count);
|
||||
EXPECT_EQ(static_cast<uint32_t>(a + b + c + d),
|
||||
decls.total_local_count);
|
||||
|
||||
LocalTypeMap map = Expand(decls);
|
||||
EXPECT_EQ(a + b + c + d, map.size());
|
||||
EXPECT_EQ(static_cast<uint32_t>(a + b + c + d), map.size());
|
||||
|
||||
size_t pos = 0;
|
||||
pos = ExpectRun(map, pos, kAstI32, a);
|
||||
@ -2647,7 +2650,7 @@ TEST_F(LocalDeclDecoderTest, UseEncoder) {
|
||||
AstLocalDecls decls(zone());
|
||||
bool result = DecodeLocalDecls(decls, data, end);
|
||||
EXPECT_TRUE(result);
|
||||
EXPECT_EQ(5 + 1337 + 212, decls.total_local_count);
|
||||
EXPECT_EQ(5u + 1337u + 212u, decls.total_local_count);
|
||||
|
||||
LocalTypeMap map = Expand(decls);
|
||||
size_t pos = 0;
|
||||
@ -2699,8 +2702,8 @@ TEST_F(BytecodeIteratorTest, WithAstDecls) {
|
||||
AstLocalDecls decls(zone());
|
||||
BytecodeIterator iter(code, code + sizeof(code), &decls);
|
||||
|
||||
EXPECT_EQ(3, decls.decls_encoded_size);
|
||||
EXPECT_EQ(3, iter.pc_offset());
|
||||
EXPECT_EQ(3u, decls.decls_encoded_size);
|
||||
EXPECT_EQ(3u, iter.pc_offset());
|
||||
EXPECT_TRUE(iter.has_next());
|
||||
EXPECT_EQ(kExprI8Const, iter.current());
|
||||
iter.next();
|
||||
|
@ -19,18 +19,18 @@ class DecoderTest : public TestWithZone {
|
||||
Decoder decoder;
|
||||
};
|
||||
|
||||
#define CHECK_UINT32V_INLINE(expected, expected_length, ...) \
|
||||
do { \
|
||||
const byte data[] = {__VA_ARGS__}; \
|
||||
decoder.Reset(data, data + sizeof(data)); \
|
||||
unsigned length; \
|
||||
EXPECT_EQ(expected, \
|
||||
decoder.checked_read_u32v(decoder.start(), 0, &length)); \
|
||||
EXPECT_EQ(expected_length, length); \
|
||||
EXPECT_EQ(data, decoder.pc()); \
|
||||
EXPECT_TRUE(decoder.ok()); \
|
||||
EXPECT_EQ(expected, decoder.consume_u32v()); \
|
||||
EXPECT_EQ(data + expected_length, decoder.pc()); \
|
||||
#define CHECK_UINT32V_INLINE(expected, expected_length, ...) \
|
||||
do { \
|
||||
const byte data[] = {__VA_ARGS__}; \
|
||||
decoder.Reset(data, data + sizeof(data)); \
|
||||
unsigned length; \
|
||||
EXPECT_EQ(static_cast<uint32_t>(expected), \
|
||||
decoder.checked_read_u32v(decoder.start(), 0, &length)); \
|
||||
EXPECT_EQ(static_cast<unsigned>(expected_length), length); \
|
||||
EXPECT_EQ(data, decoder.pc()); \
|
||||
EXPECT_TRUE(decoder.ok()); \
|
||||
EXPECT_EQ(static_cast<uint32_t>(expected), decoder.consume_u32v()); \
|
||||
EXPECT_EQ(data + expected_length, decoder.pc()); \
|
||||
} while (false)
|
||||
|
||||
#define CHECK_INT32V_INLINE(expected, expected_length, ...) \
|
||||
@ -40,7 +40,7 @@ class DecoderTest : public TestWithZone {
|
||||
unsigned length; \
|
||||
EXPECT_EQ(expected, \
|
||||
decoder.checked_read_i32v(decoder.start(), 0, &length)); \
|
||||
EXPECT_EQ(expected_length, length); \
|
||||
EXPECT_EQ(static_cast<unsigned>(expected_length), length); \
|
||||
EXPECT_EQ(data, decoder.pc()); \
|
||||
EXPECT_TRUE(decoder.ok()); \
|
||||
EXPECT_EQ(expected, decoder.consume_i32v()); \
|
||||
@ -52,9 +52,9 @@ class DecoderTest : public TestWithZone {
|
||||
const byte data[] = {__VA_ARGS__}; \
|
||||
decoder.Reset(data, data + sizeof(data)); \
|
||||
unsigned length; \
|
||||
EXPECT_EQ(expected, \
|
||||
EXPECT_EQ(static_cast<uint64_t>(expected), \
|
||||
decoder.checked_read_u64v(decoder.start(), 0, &length)); \
|
||||
EXPECT_EQ(expected_length, length); \
|
||||
EXPECT_EQ(static_cast<unsigned>(expected_length), length); \
|
||||
} while (false)
|
||||
|
||||
#define CHECK_INT64V_INLINE(expected, expected_length, ...) \
|
||||
@ -64,7 +64,7 @@ class DecoderTest : public TestWithZone {
|
||||
unsigned length; \
|
||||
EXPECT_EQ(expected, \
|
||||
decoder.checked_read_i64v(decoder.start(), 0, &length)); \
|
||||
EXPECT_EQ(expected_length, length); \
|
||||
EXPECT_EQ(static_cast<unsigned>(expected_length), length); \
|
||||
} while (false)
|
||||
|
||||
TEST_F(DecoderTest, ReadU32v_OneByte) {
|
||||
@ -377,7 +377,7 @@ TEST_F(DecoderTest, ReadU32v_off_end1) {
|
||||
unsigned length = 0;
|
||||
decoder.Reset(data, data);
|
||||
decoder.checked_read_u32v(decoder.start(), 0, &length);
|
||||
EXPECT_EQ(0, length);
|
||||
EXPECT_EQ(0u, length);
|
||||
EXPECT_FALSE(decoder.ok());
|
||||
}
|
||||
|
||||
@ -432,7 +432,7 @@ TEST_F(DecoderTest, ReadU32v_extra_bits) {
|
||||
unsigned length = 0;
|
||||
decoder.Reset(data, data + sizeof(data));
|
||||
decoder.checked_read_u32v(decoder.start(), 0, &length);
|
||||
EXPECT_EQ(5, length);
|
||||
EXPECT_EQ(5u, length);
|
||||
EXPECT_FALSE(decoder.ok());
|
||||
}
|
||||
}
|
||||
@ -443,7 +443,7 @@ TEST_F(DecoderTest, ReadI32v_extra_bits_negative) {
|
||||
byte data[] = {0xff, 0xff, 0xff, 0xff, 0x7f};
|
||||
decoder.Reset(data, data + sizeof(data));
|
||||
decoder.checked_read_i32v(decoder.start(), 0, &length);
|
||||
EXPECT_EQ(5, length);
|
||||
EXPECT_EQ(5u, length);
|
||||
EXPECT_TRUE(decoder.ok());
|
||||
}
|
||||
|
||||
@ -453,7 +453,7 @@ TEST_F(DecoderTest, ReadI32v_extra_bits_positive) {
|
||||
byte data[] = {0x80, 0x80, 0x80, 0x80, 0x77};
|
||||
decoder.Reset(data, data + sizeof(data));
|
||||
decoder.checked_read_i32v(decoder.start(), 0, &length);
|
||||
EXPECT_EQ(5, length);
|
||||
EXPECT_EQ(5u, length);
|
||||
EXPECT_FALSE(decoder.ok());
|
||||
}
|
||||
|
||||
@ -475,16 +475,16 @@ TEST_F(DecoderTest, ReadU32v_Bits) {
|
||||
uint32_t val = kVals[v];
|
||||
if (i < 32) val &= ((1 << i) - 1);
|
||||
|
||||
int length = 1 + i / 7;
|
||||
for (int j = 0; j < kMaxSize; j++) {
|
||||
unsigned length = 1 + i / 7;
|
||||
for (unsigned j = 0; j < kMaxSize; j++) {
|
||||
data[j] = static_cast<byte>((val >> (7 * j)) & MASK_7);
|
||||
}
|
||||
for (int j = 0; j < length - 1; j++) {
|
||||
for (unsigned j = 0; j < length - 1; j++) {
|
||||
data[j] |= 0x80;
|
||||
}
|
||||
|
||||
// foreach buffer size 0...5
|
||||
for (int limit = 0; limit <= kMaxSize; limit++) {
|
||||
for (unsigned limit = 0; limit <= kMaxSize; limit++) {
|
||||
decoder.Reset(data, data + limit);
|
||||
unsigned rlen;
|
||||
uint32_t result = decoder.checked_read_u32v(data, 0, &rlen);
|
||||
@ -534,13 +534,13 @@ TEST_F(DecoderTest, ReadU64v_PowerOf2) {
|
||||
const int kMaxSize = 10;
|
||||
byte data[kMaxSize];
|
||||
|
||||
for (int i = 0; i < 64; i++) {
|
||||
for (unsigned i = 0; i < 64; i++) {
|
||||
const uint64_t val = 1ull << i;
|
||||
int index = i / 7;
|
||||
unsigned index = i / 7;
|
||||
data[index] = 1 << (i % 7);
|
||||
memset(data, 0x80, index);
|
||||
|
||||
for (int limit = 0; limit <= kMaxSize; limit++) {
|
||||
for (unsigned limit = 0; limit <= kMaxSize; limit++) {
|
||||
decoder.Reset(data, data + limit);
|
||||
unsigned length;
|
||||
uint64_t result = decoder.checked_read_u64v(data, 0, &length);
|
||||
@ -572,16 +572,16 @@ TEST_F(DecoderTest, ReadU64v_Bits) {
|
||||
uint64_t val = kVals[v];
|
||||
if (i < 64) val &= ((1ull << i) - 1);
|
||||
|
||||
int length = 1 + i / 7;
|
||||
for (int j = 0; j < kMaxSize; j++) {
|
||||
unsigned length = 1 + i / 7;
|
||||
for (unsigned j = 0; j < kMaxSize; j++) {
|
||||
data[j] = static_cast<byte>((val >> (7 * j)) & MASK_7);
|
||||
}
|
||||
for (int j = 0; j < length - 1; j++) {
|
||||
for (unsigned j = 0; j < length - 1; j++) {
|
||||
data[j] |= 0x80;
|
||||
}
|
||||
|
||||
// foreach buffer size 0...10
|
||||
for (int limit = 0; limit <= kMaxSize; limit++) {
|
||||
for (unsigned limit = 0; limit <= kMaxSize; limit++) {
|
||||
decoder.Reset(data, data + limit);
|
||||
unsigned rlen;
|
||||
uint64_t result = decoder.checked_read_u64v(data, 0, &rlen);
|
||||
@ -614,16 +614,16 @@ TEST_F(DecoderTest, ReadI64v_Bits) {
|
||||
for (int i = 1; i <= 64; i++) {
|
||||
const int64_t val = bit_cast<int64_t>(kVals[v] << (64 - i)) >> (64 - i);
|
||||
|
||||
int length = 1 + i / 7;
|
||||
for (int j = 0; j < kMaxSize; j++) {
|
||||
unsigned length = 1 + i / 7;
|
||||
for (unsigned j = 0; j < kMaxSize; j++) {
|
||||
data[j] = static_cast<byte>((val >> (7 * j)) & MASK_7);
|
||||
}
|
||||
for (int j = 0; j < length - 1; j++) {
|
||||
for (unsigned j = 0; j < length - 1; j++) {
|
||||
data[j] |= 0x80;
|
||||
}
|
||||
|
||||
// foreach buffer size 0...10
|
||||
for (int limit = 0; limit <= kMaxSize; limit++) {
|
||||
for (unsigned limit = 0; limit <= kMaxSize; limit++) {
|
||||
decoder.Reset(data, data + limit);
|
||||
unsigned rlen;
|
||||
int64_t result = decoder.checked_read_i64v(data, 0, &rlen);
|
||||
@ -646,7 +646,7 @@ TEST_F(DecoderTest, ReadU64v_extra_bits) {
|
||||
unsigned length = 0;
|
||||
decoder.Reset(data, data + sizeof(data));
|
||||
decoder.checked_read_u64v(decoder.start(), 0, &length);
|
||||
EXPECT_EQ(10, length);
|
||||
EXPECT_EQ(10u, length);
|
||||
EXPECT_FALSE(decoder.ok());
|
||||
}
|
||||
}
|
||||
@ -657,7 +657,7 @@ TEST_F(DecoderTest, ReadI64v_extra_bits_negative) {
|
||||
byte data[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f};
|
||||
decoder.Reset(data, data + sizeof(data));
|
||||
decoder.checked_read_i64v(decoder.start(), 0, &length);
|
||||
EXPECT_EQ(10, length);
|
||||
EXPECT_EQ(10u, length);
|
||||
EXPECT_TRUE(decoder.ok());
|
||||
}
|
||||
|
||||
@ -667,7 +667,7 @@ TEST_F(DecoderTest, ReadI64v_extra_bits_positive) {
|
||||
byte data[] = {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x77};
|
||||
decoder.Reset(data, data + sizeof(data));
|
||||
decoder.checked_read_i64v(decoder.start(), 0, &length);
|
||||
EXPECT_EQ(10, length);
|
||||
EXPECT_EQ(10u, length);
|
||||
EXPECT_FALSE(decoder.ok());
|
||||
}
|
||||
|
||||
|
@ -15,76 +15,76 @@ namespace wasm {
|
||||
class LEBHelperTest : public TestWithZone {};
|
||||
|
||||
TEST_F(LEBHelperTest, sizeof_u32v) {
|
||||
EXPECT_EQ(1, LEBHelper::sizeof_u32v(0));
|
||||
EXPECT_EQ(1, LEBHelper::sizeof_u32v(1));
|
||||
EXPECT_EQ(1, LEBHelper::sizeof_u32v(3));
|
||||
EXPECT_EQ(1u, LEBHelper::sizeof_u32v(0));
|
||||
EXPECT_EQ(1u, LEBHelper::sizeof_u32v(1));
|
||||
EXPECT_EQ(1u, LEBHelper::sizeof_u32v(3));
|
||||
|
||||
for (uint32_t i = 4; i < 128; i++) {
|
||||
EXPECT_EQ(1, LEBHelper::sizeof_u32v(i));
|
||||
EXPECT_EQ(1u, LEBHelper::sizeof_u32v(i));
|
||||
}
|
||||
|
||||
for (uint32_t i = (1u << 7); i < (1u << 9); i++) {
|
||||
EXPECT_EQ(2, LEBHelper::sizeof_u32v(i));
|
||||
EXPECT_EQ(2u, LEBHelper::sizeof_u32v(i));
|
||||
}
|
||||
|
||||
for (uint32_t i = (1u << 14); i < (1u << 16); i += 33) {
|
||||
EXPECT_EQ(3, LEBHelper::sizeof_u32v(i));
|
||||
EXPECT_EQ(3u, LEBHelper::sizeof_u32v(i));
|
||||
}
|
||||
|
||||
for (uint32_t i = (1u << 21); i < (1u << 24); i += 33999) {
|
||||
EXPECT_EQ(4, LEBHelper::sizeof_u32v(i));
|
||||
EXPECT_EQ(4u, LEBHelper::sizeof_u32v(i));
|
||||
}
|
||||
|
||||
for (uint32_t i = (1u << 28); i < (1u << 31); i += 33997779u) {
|
||||
EXPECT_EQ(5, LEBHelper::sizeof_u32v(i));
|
||||
EXPECT_EQ(5u, LEBHelper::sizeof_u32v(i));
|
||||
}
|
||||
|
||||
EXPECT_EQ(5, LEBHelper::sizeof_u32v(0xFFFFFFFF));
|
||||
EXPECT_EQ(5u, LEBHelper::sizeof_u32v(0xFFFFFFFF));
|
||||
}
|
||||
|
||||
TEST_F(LEBHelperTest, sizeof_i32v) {
|
||||
EXPECT_EQ(1, LEBHelper::sizeof_i32v(0));
|
||||
EXPECT_EQ(1, LEBHelper::sizeof_i32v(1));
|
||||
EXPECT_EQ(1, LEBHelper::sizeof_i32v(3));
|
||||
EXPECT_EQ(1u, LEBHelper::sizeof_i32v(0));
|
||||
EXPECT_EQ(1u, LEBHelper::sizeof_i32v(1));
|
||||
EXPECT_EQ(1u, LEBHelper::sizeof_i32v(3));
|
||||
|
||||
for (int32_t i = 0; i < (1 << 6); i++) {
|
||||
EXPECT_EQ(1, LEBHelper::sizeof_i32v(i));
|
||||
EXPECT_EQ(1u, LEBHelper::sizeof_i32v(i));
|
||||
}
|
||||
|
||||
for (int32_t i = (1 << 6); i < (1 << 8); i++) {
|
||||
EXPECT_EQ(2, LEBHelper::sizeof_i32v(i));
|
||||
EXPECT_EQ(2u, LEBHelper::sizeof_i32v(i));
|
||||
}
|
||||
|
||||
for (int32_t i = (1 << 13); i < (1 << 15); i += 31) {
|
||||
EXPECT_EQ(3, LEBHelper::sizeof_i32v(i));
|
||||
EXPECT_EQ(3u, LEBHelper::sizeof_i32v(i));
|
||||
}
|
||||
|
||||
for (int32_t i = (1 << 20); i < (1 << 22); i += 31991) {
|
||||
EXPECT_EQ(4, LEBHelper::sizeof_i32v(i));
|
||||
EXPECT_EQ(4u, LEBHelper::sizeof_i32v(i));
|
||||
}
|
||||
|
||||
for (int32_t i = (1 << 27); i < (1 << 29); i += 3199893) {
|
||||
EXPECT_EQ(5, LEBHelper::sizeof_i32v(i));
|
||||
EXPECT_EQ(5u, LEBHelper::sizeof_i32v(i));
|
||||
}
|
||||
|
||||
for (int32_t i = -(1 << 6); i <= 0; i++) {
|
||||
EXPECT_EQ(1, LEBHelper::sizeof_i32v(i));
|
||||
EXPECT_EQ(1u, LEBHelper::sizeof_i32v(i));
|
||||
}
|
||||
|
||||
for (int32_t i = -(1 << 13); i < -(1 << 6); i++) {
|
||||
EXPECT_EQ(2, LEBHelper::sizeof_i32v(i));
|
||||
EXPECT_EQ(2u, LEBHelper::sizeof_i32v(i));
|
||||
}
|
||||
|
||||
for (int32_t i = -(1 << 20); i < -(1 << 18); i += 11) {
|
||||
EXPECT_EQ(3, LEBHelper::sizeof_i32v(i));
|
||||
EXPECT_EQ(3u, LEBHelper::sizeof_i32v(i));
|
||||
}
|
||||
|
||||
for (int32_t i = -(1 << 27); i < -(1 << 25); i += 11999) {
|
||||
EXPECT_EQ(4, LEBHelper::sizeof_i32v(i));
|
||||
EXPECT_EQ(4u, LEBHelper::sizeof_i32v(i));
|
||||
}
|
||||
|
||||
for (int32_t i = -(1 << 30); i < -(1 << 28); i += 1199999) {
|
||||
EXPECT_EQ(5, LEBHelper::sizeof_i32v(i));
|
||||
EXPECT_EQ(5u, LEBHelper::sizeof_i32v(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -192,14 +192,14 @@ TEST_F(WasmModuleVerifyTest, OneGlobal) {
|
||||
// Should decode to exactly one global.
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
EXPECT_EQ(1, result.val->globals.size());
|
||||
EXPECT_EQ(0, result.val->functions.size());
|
||||
EXPECT_EQ(0, result.val->data_segments.size());
|
||||
EXPECT_EQ(1u, result.val->globals.size());
|
||||
EXPECT_EQ(0u, result.val->functions.size());
|
||||
EXPECT_EQ(0u, result.val->data_segments.size());
|
||||
|
||||
const WasmGlobal* global = &result.val->globals.back();
|
||||
|
||||
EXPECT_EQ(kAstI32, global->type);
|
||||
EXPECT_EQ(0, global->offset);
|
||||
EXPECT_EQ(0u, global->offset);
|
||||
EXPECT_FALSE(global->mutability);
|
||||
EXPECT_EQ(WasmInitExpr::kI32Const, global->init.kind);
|
||||
EXPECT_EQ(13, global->init.val.i32_const);
|
||||
@ -353,21 +353,21 @@ TEST_F(WasmModuleVerifyTest, TwoGlobals) {
|
||||
// Should decode to exactly two globals.
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
EXPECT_EQ(2, result.val->globals.size());
|
||||
EXPECT_EQ(0, result.val->functions.size());
|
||||
EXPECT_EQ(0, result.val->data_segments.size());
|
||||
EXPECT_EQ(2u, result.val->globals.size());
|
||||
EXPECT_EQ(0u, result.val->functions.size());
|
||||
EXPECT_EQ(0u, result.val->data_segments.size());
|
||||
|
||||
const WasmGlobal* g0 = &result.val->globals[0];
|
||||
|
||||
EXPECT_EQ(kAstF32, g0->type);
|
||||
EXPECT_EQ(0, g0->offset);
|
||||
EXPECT_EQ(0u, g0->offset);
|
||||
EXPECT_FALSE(g0->mutability);
|
||||
EXPECT_EQ(WasmInitExpr::kF32Const, g0->init.kind);
|
||||
|
||||
const WasmGlobal* g1 = &result.val->globals[1];
|
||||
|
||||
EXPECT_EQ(kAstF64, g1->type);
|
||||
EXPECT_EQ(8, g1->offset);
|
||||
EXPECT_EQ(8u, g1->offset);
|
||||
EXPECT_TRUE(g1->mutability);
|
||||
EXPECT_EQ(WasmInitExpr::kF64Const, g1->init.kind);
|
||||
|
||||
@ -402,15 +402,15 @@ TEST_F(WasmModuleVerifyTest, MultipleSignatures) {
|
||||
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
EXPECT_EQ(3, result.val->signatures.size());
|
||||
EXPECT_EQ(3u, result.val->signatures.size());
|
||||
if (result.val->signatures.size() == 3) {
|
||||
EXPECT_EQ(0, result.val->signatures[0]->return_count());
|
||||
EXPECT_EQ(1, result.val->signatures[1]->return_count());
|
||||
EXPECT_EQ(1, result.val->signatures[2]->return_count());
|
||||
EXPECT_EQ(0u, result.val->signatures[0]->return_count());
|
||||
EXPECT_EQ(1u, result.val->signatures[1]->return_count());
|
||||
EXPECT_EQ(1u, result.val->signatures[2]->return_count());
|
||||
|
||||
EXPECT_EQ(0, result.val->signatures[0]->parameter_count());
|
||||
EXPECT_EQ(1, result.val->signatures[1]->parameter_count());
|
||||
EXPECT_EQ(2, result.val->signatures[2]->parameter_count());
|
||||
EXPECT_EQ(0u, result.val->signatures[0]->parameter_count());
|
||||
EXPECT_EQ(1u, result.val->signatures[1]->parameter_count());
|
||||
EXPECT_EQ(2u, result.val->signatures[2]->parameter_count());
|
||||
}
|
||||
if (result.val) delete result.val;
|
||||
|
||||
@ -454,7 +454,7 @@ TEST_F(WasmModuleVerifyTest, DataSegmentWithImmutableImportedGlobal) {
|
||||
EXPECT_OK(result);
|
||||
WasmInitExpr expr = result.val->data_segments.back().dest_addr;
|
||||
EXPECT_EQ(WasmInitExpr::kGlobalIndex, expr.kind);
|
||||
EXPECT_EQ(1, expr.val.global_index);
|
||||
EXPECT_EQ(1u, expr.val.global_index);
|
||||
if (result.val) delete result.val;
|
||||
}
|
||||
|
||||
@ -533,16 +533,16 @@ TEST_F(WasmModuleVerifyTest, OneDataSegment) {
|
||||
EXPECT_VERIFIES(data);
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
EXPECT_EQ(0, result.val->globals.size());
|
||||
EXPECT_EQ(0, result.val->functions.size());
|
||||
EXPECT_EQ(1, result.val->data_segments.size());
|
||||
EXPECT_EQ(0u, result.val->globals.size());
|
||||
EXPECT_EQ(0u, result.val->functions.size());
|
||||
EXPECT_EQ(1u, result.val->data_segments.size());
|
||||
|
||||
const WasmDataSegment* segment = &result.val->data_segments.back();
|
||||
|
||||
EXPECT_EQ(WasmInitExpr::kI32Const, segment->dest_addr.kind);
|
||||
EXPECT_EQ(0x9bbaa, segment->dest_addr.val.i32_const);
|
||||
EXPECT_EQ(kDataSegmentSourceOffset, segment->source_offset);
|
||||
EXPECT_EQ(3, segment->source_size);
|
||||
EXPECT_EQ(3u, segment->source_size);
|
||||
|
||||
if (result.val) delete result.val;
|
||||
}
|
||||
@ -587,9 +587,9 @@ TEST_F(WasmModuleVerifyTest, TwoDataSegments) {
|
||||
{
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
EXPECT_EQ(0, result.val->globals.size());
|
||||
EXPECT_EQ(0, result.val->functions.size());
|
||||
EXPECT_EQ(2, result.val->data_segments.size());
|
||||
EXPECT_EQ(0u, result.val->globals.size());
|
||||
EXPECT_EQ(0u, result.val->functions.size());
|
||||
EXPECT_EQ(2u, result.val->data_segments.size());
|
||||
|
||||
const WasmDataSegment* s0 = &result.val->data_segments[0];
|
||||
const WasmDataSegment* s1 = &result.val->data_segments[1];
|
||||
@ -597,12 +597,12 @@ TEST_F(WasmModuleVerifyTest, TwoDataSegments) {
|
||||
EXPECT_EQ(WasmInitExpr::kI32Const, s0->dest_addr.kind);
|
||||
EXPECT_EQ(0x7ffee, s0->dest_addr.val.i32_const);
|
||||
EXPECT_EQ(kDataSegment0SourceOffset, s0->source_offset);
|
||||
EXPECT_EQ(4, s0->source_size);
|
||||
EXPECT_EQ(4u, s0->source_size);
|
||||
|
||||
EXPECT_EQ(WasmInitExpr::kI32Const, s1->dest_addr.kind);
|
||||
EXPECT_EQ(0x6ddcc, s1->dest_addr.val.i32_const);
|
||||
EXPECT_EQ(kDataSegment1SourceOffset, s1->source_offset);
|
||||
EXPECT_EQ(10, s1->source_size);
|
||||
EXPECT_EQ(10u, s1->source_size);
|
||||
|
||||
if (result.val) delete result.val;
|
||||
}
|
||||
@ -673,10 +673,10 @@ TEST_F(WasmModuleVerifyTest, OneIndirectFunction) {
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
if (result.ok()) {
|
||||
EXPECT_EQ(1, result.val->signatures.size());
|
||||
EXPECT_EQ(1, result.val->functions.size());
|
||||
EXPECT_EQ(1, result.val->function_tables.size());
|
||||
EXPECT_EQ(1, result.val->function_tables[0].min_size);
|
||||
EXPECT_EQ(1u, result.val->signatures.size());
|
||||
EXPECT_EQ(1u, result.val->functions.size());
|
||||
EXPECT_EQ(1u, result.val->function_tables.size());
|
||||
EXPECT_EQ(1u, result.val->function_tables[0].min_size);
|
||||
}
|
||||
if (result.val) delete result.val;
|
||||
}
|
||||
@ -699,10 +699,10 @@ TEST_F(WasmModuleVerifyTest, OneIndirectFunction_one_entry) {
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
if (result.ok()) {
|
||||
EXPECT_EQ(1, result.val->signatures.size());
|
||||
EXPECT_EQ(1, result.val->functions.size());
|
||||
EXPECT_EQ(1, result.val->function_tables.size());
|
||||
EXPECT_EQ(1, result.val->function_tables[0].min_size);
|
||||
EXPECT_EQ(1u, result.val->signatures.size());
|
||||
EXPECT_EQ(1u, result.val->functions.size());
|
||||
EXPECT_EQ(1u, result.val->function_tables.size());
|
||||
EXPECT_EQ(1u, result.val->function_tables[0].min_size);
|
||||
}
|
||||
if (result.val) delete result.val;
|
||||
}
|
||||
@ -736,10 +736,10 @@ TEST_F(WasmModuleVerifyTest, MultipleIndirectFunctions) {
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
if (result.ok()) {
|
||||
EXPECT_EQ(2, result.val->signatures.size());
|
||||
EXPECT_EQ(4, result.val->functions.size());
|
||||
EXPECT_EQ(1, result.val->function_tables.size());
|
||||
EXPECT_EQ(8, result.val->function_tables[0].min_size);
|
||||
EXPECT_EQ(2u, result.val->signatures.size());
|
||||
EXPECT_EQ(4u, result.val->functions.size());
|
||||
EXPECT_EQ(1u, result.val->function_tables.size());
|
||||
EXPECT_EQ(8u, result.val->function_tables[0].min_size);
|
||||
}
|
||||
if (result.val) delete result.val;
|
||||
}
|
||||
@ -778,8 +778,8 @@ TEST_F(WasmSignatureDecodeTest, Ok_v_v) {
|
||||
DecodeWasmSignatureForTesting(&zone, data, data + sizeof(data));
|
||||
|
||||
EXPECT_TRUE(sig != nullptr);
|
||||
EXPECT_EQ(0, sig->parameter_count());
|
||||
EXPECT_EQ(0, sig->return_count());
|
||||
EXPECT_EQ(0u, sig->parameter_count());
|
||||
EXPECT_EQ(0u, sig->return_count());
|
||||
}
|
||||
|
||||
TEST_F(WasmSignatureDecodeTest, Ok_t_v) {
|
||||
@ -790,8 +790,8 @@ TEST_F(WasmSignatureDecodeTest, Ok_t_v) {
|
||||
DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data));
|
||||
|
||||
EXPECT_TRUE(sig != nullptr);
|
||||
EXPECT_EQ(0, sig->parameter_count());
|
||||
EXPECT_EQ(1, sig->return_count());
|
||||
EXPECT_EQ(0u, sig->parameter_count());
|
||||
EXPECT_EQ(1u, sig->return_count());
|
||||
EXPECT_EQ(ret_type.type, sig->GetReturn());
|
||||
}
|
||||
}
|
||||
@ -804,8 +804,8 @@ TEST_F(WasmSignatureDecodeTest, Ok_v_t) {
|
||||
DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data));
|
||||
|
||||
EXPECT_TRUE(sig != nullptr);
|
||||
EXPECT_EQ(1, sig->parameter_count());
|
||||
EXPECT_EQ(0, sig->return_count());
|
||||
EXPECT_EQ(1u, sig->parameter_count());
|
||||
EXPECT_EQ(0u, sig->return_count());
|
||||
EXPECT_EQ(param_type.type, sig->GetParam(0));
|
||||
}
|
||||
}
|
||||
@ -820,8 +820,8 @@ TEST_F(WasmSignatureDecodeTest, Ok_t_t) {
|
||||
DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data));
|
||||
|
||||
EXPECT_TRUE(sig != nullptr);
|
||||
EXPECT_EQ(1, sig->parameter_count());
|
||||
EXPECT_EQ(1, sig->return_count());
|
||||
EXPECT_EQ(1u, sig->parameter_count());
|
||||
EXPECT_EQ(1u, sig->return_count());
|
||||
EXPECT_EQ(param_type.type, sig->GetParam(0));
|
||||
EXPECT_EQ(ret_type.type, sig->GetReturn());
|
||||
}
|
||||
@ -839,8 +839,8 @@ TEST_F(WasmSignatureDecodeTest, Ok_i_tt) {
|
||||
DecodeWasmSignatureForTesting(zone(), data, data + sizeof(data));
|
||||
|
||||
EXPECT_TRUE(sig != nullptr);
|
||||
EXPECT_EQ(2, sig->parameter_count());
|
||||
EXPECT_EQ(1, sig->return_count());
|
||||
EXPECT_EQ(2u, sig->parameter_count());
|
||||
EXPECT_EQ(1u, sig->return_count());
|
||||
EXPECT_EQ(p0_type.type, sig->GetParam(0));
|
||||
EXPECT_EQ(p1_type.type, sig->GetParam(1));
|
||||
}
|
||||
@ -916,10 +916,11 @@ TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) {
|
||||
|
||||
if (result.val && result.ok()) {
|
||||
WasmFunction* function = result.val;
|
||||
EXPECT_EQ(0, function->sig->parameter_count());
|
||||
EXPECT_EQ(0, function->sig->return_count());
|
||||
EXPECT_EQ(0, function->name_offset);
|
||||
EXPECT_EQ(SIZEOF_SIG_ENTRY_v_v, function->code_start_offset);
|
||||
EXPECT_EQ(0u, function->sig->parameter_count());
|
||||
EXPECT_EQ(0u, function->sig->return_count());
|
||||
EXPECT_EQ(0u, function->name_offset);
|
||||
EXPECT_EQ(static_cast<uint32_t>(SIZEOF_SIG_ENTRY_v_v),
|
||||
function->code_start_offset);
|
||||
EXPECT_EQ(sizeof(data), function->code_end_offset);
|
||||
// TODO(titzer): verify encoding of local declarations
|
||||
}
|
||||
@ -1021,14 +1022,14 @@ TEST_F(WasmModuleVerifyTest, UnknownSectionSkipped) {
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
|
||||
EXPECT_EQ(1, result.val->globals.size());
|
||||
EXPECT_EQ(0, result.val->functions.size());
|
||||
EXPECT_EQ(0, result.val->data_segments.size());
|
||||
EXPECT_EQ(1u, result.val->globals.size());
|
||||
EXPECT_EQ(0u, result.val->functions.size());
|
||||
EXPECT_EQ(0u, result.val->data_segments.size());
|
||||
|
||||
const WasmGlobal* global = &result.val->globals.back();
|
||||
|
||||
EXPECT_EQ(kAstI32, global->type);
|
||||
EXPECT_EQ(0, global->offset);
|
||||
EXPECT_EQ(0u, global->offset);
|
||||
|
||||
if (result.val) delete result.val;
|
||||
}
|
||||
@ -1155,8 +1156,8 @@ TEST_F(WasmModuleVerifyTest, ExportTable_empty1) {
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
|
||||
EXPECT_EQ(1, result.val->functions.size());
|
||||
EXPECT_EQ(0, result.val->export_table.size());
|
||||
EXPECT_EQ(1u, result.val->functions.size());
|
||||
EXPECT_EQ(0u, result.val->export_table.size());
|
||||
|
||||
if (result.val) delete result.val;
|
||||
}
|
||||
@ -1186,8 +1187,8 @@ TEST_F(WasmModuleVerifyTest, ExportTableOne) {
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
|
||||
EXPECT_EQ(1, result.val->functions.size());
|
||||
EXPECT_EQ(1, result.val->export_table.size());
|
||||
EXPECT_EQ(1u, result.val->functions.size());
|
||||
EXPECT_EQ(1u, result.val->export_table.size());
|
||||
|
||||
if (result.val) delete result.val;
|
||||
}
|
||||
@ -1230,8 +1231,8 @@ TEST_F(WasmModuleVerifyTest, ExportTableTwo) {
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
|
||||
EXPECT_EQ(1, result.val->functions.size());
|
||||
EXPECT_EQ(2, result.val->export_table.size());
|
||||
EXPECT_EQ(1u, result.val->functions.size());
|
||||
EXPECT_EQ(2u, result.val->export_table.size());
|
||||
|
||||
if (result.val) delete result.val;
|
||||
}
|
||||
@ -1258,8 +1259,8 @@ TEST_F(WasmModuleVerifyTest, ExportTableThree) {
|
||||
ModuleResult result = DecodeModule(data, data + sizeof(data));
|
||||
EXPECT_OK(result);
|
||||
|
||||
EXPECT_EQ(3, result.val->functions.size());
|
||||
EXPECT_EQ(3, result.val->export_table.size());
|
||||
EXPECT_EQ(3u, result.val->functions.size());
|
||||
EXPECT_EQ(3u, result.val->export_table.size());
|
||||
|
||||
if (result.val) delete result.val;
|
||||
}
|
||||
|
@ -12,10 +12,10 @@ namespace wasm {
|
||||
|
||||
class WasmMacroGenTest : public TestWithZone {};
|
||||
|
||||
#define EXPECT_SIZE(size, ...) \
|
||||
do { \
|
||||
byte code[] = {__VA_ARGS__}; \
|
||||
EXPECT_EQ(size, sizeof(code)); \
|
||||
#define EXPECT_SIZE(size, ...) \
|
||||
do { \
|
||||
byte code[] = {__VA_ARGS__}; \
|
||||
EXPECT_EQ(static_cast<size_t>(size), sizeof(code)); \
|
||||
} while (false)
|
||||
|
||||
TEST_F(WasmMacroGenTest, Constants) {
|
||||
|
Loading…
Reference in New Issue
Block a user