Commit 2a71b320 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Rename {ValidateFlag} constants

As a preparation to add a "boolean validation" mode, rename the existing
flags. This removes many unrelated changes from the follow-up change and
makes it easier to review.

R=thibaudm@chromium.org

Bug: v8:10969
Change-Id: I5f71405b525a7caa91be46c035e31d4d960e4e4c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2440036Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70224}
parent 7b24b139
......@@ -258,7 +258,7 @@ class DebugSideTableBuilder {
class LiftoffCompiler {
public:
// TODO(clemensb): Make this a template parameter.
static constexpr Decoder::ValidateFlag validate = Decoder::kValidate;
static constexpr Decoder::ValidateFlag validate = Decoder::kFullValidation;
using Value = ValueBase;
......@@ -843,7 +843,8 @@ class LiftoffCompiler {
#ifdef DEBUG
SLOW_DCHECK(__ ValidateCacheState());
if (WasmOpcodes::IsPrefixOpcode(opcode)) {
opcode = decoder->read_prefixed_opcode<Decoder::kValidate>(decoder->pc());
opcode = decoder->read_prefixed_opcode<Decoder::kFullValidation>(
decoder->pc());
}
DEBUG_CODE_COMMENT(WasmOpcodes::OpcodeName(opcode));
#endif
......@@ -4115,7 +4116,7 @@ WasmCompilationResult ExecuteLiftoffCompilation(
if (debug_sidetable) {
debug_sidetable_builder = std::make_unique<DebugSideTableBuilder>();
}
WasmFullDecoder<Decoder::kValidate, LiftoffCompiler> decoder(
WasmFullDecoder<Decoder::kFullValidation, LiftoffCompiler> decoder(
&zone, env->module, env->enabled_features, detected, func_body,
call_descriptor, env, &zone, instruction_buffer->CreateView(),
debug_sidetable_builder.get(), for_debugging, func_index, breakpoints,
......@@ -4172,7 +4173,7 @@ std::unique_ptr<DebugSideTable> GenerateLiftoffDebugSideTable(
auto call_descriptor = compiler::GetWasmCallDescriptor(&zone, func_body.sig);
DebugSideTableBuilder debug_sidetable_builder;
WasmFeatures detected;
WasmFullDecoder<Decoder::kValidate, LiftoffCompiler> decoder(
WasmFullDecoder<Decoder::kFullValidation, LiftoffCompiler> decoder(
&zone, env->module, env->enabled_features, &detected, func_body,
call_descriptor, env, &zone,
NewAssemblerBuffer(AssemblerBase::kDefaultBufferSize),
......
......@@ -39,7 +39,13 @@ using DecodeResult = VoidResult;
// a buffer of bytes.
class Decoder {
public:
enum ValidateFlag : bool { kValidate = true, kNoValidate = false };
// {ValidateFlag} can be used in a boolean manner ({if (!validate) ...}).
// TODO(clemensb): Introduce a "boolean validation" mode where error messages
// are locations are not tracked.
enum ValidateFlag : int8_t {
kNoValidation = 0, // Don't run validation, assume valid input.
kFullValidation // Run full validation with error message and location.
};
enum AdvancePCFlag : bool { kAdvancePc = true, kNoAdvancePc = false };
......@@ -160,7 +166,7 @@ class Decoder {
index = *(pc + 1);
*length = 1;
} else {
// If kValidate and size validation fails.
// If size validation fails.
index = 0;
*length = 0;
}
......@@ -186,21 +192,22 @@ class Decoder {
// Reads a LEB128 variable-length unsigned 32-bit integer and advances {pc_}.
uint32_t consume_u32v(const char* name = nullptr) {
uint32_t length = 0;
return read_leb<uint32_t, kValidate, kAdvancePc, kTrace>(pc_, &length,
name);
return read_leb<uint32_t, kFullValidation, kAdvancePc, kTrace>(pc_, &length,
name);
}
// Reads a LEB128 variable-length signed 32-bit integer and advances {pc_}.
int32_t consume_i32v(const char* name = nullptr) {
uint32_t length = 0;
return read_leb<int32_t, kValidate, kAdvancePc, kTrace>(pc_, &length, name);
return read_leb<int32_t, kFullValidation, kAdvancePc, kTrace>(pc_, &length,
name);
}
// Reads a LEB128 variable-length unsigned 64-bit integer and advances {pc_}.
uint64_t consume_u64v(const char* name = nullptr) {
uint32_t length = 0;
return read_leb<uint64_t, kValidate, kAdvancePc, kTrace>(pc_, &length,
name);
return read_leb<uint64_t, kFullValidation, kAdvancePc, kTrace>(pc_, &length,
name);
}
// Consume {size} bytes and send them to the bit bucket, advancing {pc_}.
......
......@@ -1035,7 +1035,8 @@ class WasmDecoder : public Decoder {
: local_types_.begin();
// Decode local declarations, if any.
uint32_t entries = read_u32v<kValidate>(pc, &length, "local decls count");
uint32_t entries =
read_u32v<kFullValidation>(pc, &length, "local decls count");
if (!VALIDATE(ok())) {
error(pc + *total_length, "invalid local decls count");
return false;
......@@ -1049,8 +1050,8 @@ class WasmDecoder : public Decoder {
error(end(), "expected more local decls but reached end of input");
return false;
}
uint32_t count =
read_u32v<kValidate>(pc + *total_length, &length, "local count");
uint32_t count = read_u32v<kFullValidation>(pc + *total_length, &length,
"local count");
if (!VALIDATE(ok())) {
error(pc + *total_length, "invalid local count");
return false;
......@@ -1062,7 +1063,7 @@ class WasmDecoder : public Decoder {
}
*total_length += length;
ValueType type = value_type_reader::read_value_type<kValidate>(
ValueType type = value_type_reader::read_value_type<kFullValidation>(
this, pc + *total_length, &length, enabled_);
if (!VALIDATE(type != kWasmBottom)) {
error(pc + *total_length, "invalid local type");
......@@ -2006,7 +2007,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
if (!WasmOpcodes::IsPrefixOpcode(opcode)) {
return WasmOpcodes::OpcodeName(static_cast<WasmOpcode>(opcode));
}
opcode = this->template read_prefixed_opcode<Decoder::kValidate>(pc);
opcode = this->template read_prefixed_opcode<Decoder::kFullValidation>(pc);
return WasmOpcodes::OpcodeName(opcode);
}
......@@ -2157,7 +2158,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
WasmOpcode val_opcode = static_cast<WasmOpcode>(*val.pc);
if (WasmOpcodes::IsPrefixOpcode(val_opcode)) {
val_opcode =
decoder_->template read_prefixed_opcode<Decoder::kNoValidate>(
decoder_->template read_prefixed_opcode<Decoder::kNoValidation>(
val.pc);
}
Append(" %c@%d:%s", val.type.short_name(),
......@@ -2168,21 +2169,22 @@ class WasmFullDecoder : public WasmDecoder<validate> {
if (decoder_->failed()) continue;
switch (val_opcode) {
case kExprI32Const: {
ImmI32Immediate<Decoder::kNoValidate> imm(decoder_, val.pc + 1);
ImmI32Immediate<Decoder::kNoValidation> imm(decoder_, val.pc + 1);
Append("[%d]", imm.value);
break;
}
case kExprLocalGet:
case kExprLocalSet:
case kExprLocalTee: {
LocalIndexImmediate<Decoder::kNoValidate> imm(decoder_, val.pc + 1);
LocalIndexImmediate<Decoder::kNoValidation> imm(decoder_,
val.pc + 1);
Append("[%u]", imm.index);
break;
}
case kExprGlobalGet:
case kExprGlobalSet: {
GlobalIndexImmediate<Decoder::kNoValidate> imm(decoder_,
val.pc + 1);
GlobalIndexImmediate<Decoder::kNoValidation> imm(decoder_,
val.pc + 1);
Append("[%u]", imm.index);
break;
}
......@@ -4350,7 +4352,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
class EmptyInterface {
public:
static constexpr Decoder::ValidateFlag validate = Decoder::kValidate;
static constexpr Decoder::ValidateFlag validate = Decoder::kFullValidation;
using Value = ValueBase;
using Control = ControlBase<Value>;
using FullDecoder = WasmFullDecoder<validate, EmptyInterface>;
......
......@@ -23,8 +23,8 @@ bool DecodeLocalDecls(const WasmFeatures& enabled, BodyLocalDecls* decls,
const byte* start, const byte* end) {
WasmFeatures no_features = WasmFeatures::None();
Zone* zone = decls->type_list.get_allocator().zone();
WasmDecoder<Decoder::kValidate> decoder(zone, nullptr, enabled, &no_features,
nullptr, start, end, 0);
WasmDecoder<Decoder::kFullValidation> decoder(
zone, nullptr, enabled, &no_features, nullptr, start, end, 0);
uint32_t length;
if (!decoder.DecodeLocals(decoder.pc(), &length, 0)) {
decls->encoded_size = 0;
......@@ -54,7 +54,7 @@ DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
const WasmModule* module, WasmFeatures* detected,
const FunctionBody& body) {
Zone zone(allocator, ZONE_NAME);
WasmFullDecoder<Decoder::kValidate, EmptyInterface> decoder(
WasmFullDecoder<Decoder::kFullValidation, EmptyInterface> decoder(
&zone, module, enabled, detected, body);
decoder.Decode();
return decoder.toResult(nullptr);
......@@ -65,9 +65,9 @@ unsigned OpcodeLength(const byte* pc, const byte* end) {
Zone* no_zone = nullptr;
WasmModule* no_module = nullptr;
FunctionSig* no_sig = nullptr;
WasmDecoder<Decoder::kNoValidate> decoder(no_zone, no_module, no_features,
&no_features, no_sig, pc, end, 0);
return WasmDecoder<Decoder::kNoValidate>::OpcodeLength(&decoder, pc);
WasmDecoder<Decoder::kNoValidation> decoder(no_zone, no_module, no_features,
&no_features, no_sig, pc, end, 0);
return WasmDecoder<Decoder::kNoValidation>::OpcodeLength(&decoder, pc);
}
std::pair<uint32_t, uint32_t> StackEffect(const WasmModule* module,
......@@ -75,7 +75,7 @@ std::pair<uint32_t, uint32_t> StackEffect(const WasmModule* module,
const byte* pc, const byte* end) {
WasmFeatures unused_detected_features = WasmFeatures::None();
Zone* no_zone = nullptr;
WasmDecoder<Decoder::kNoValidate> decoder(
WasmDecoder<Decoder::kNoValidation> decoder(
no_zone, module, WasmFeatures::All(), &unused_detected_features, sig, pc,
end);
return decoder.StackEffect(pc);
......@@ -124,9 +124,9 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
std::ostream& os, std::vector<int>* line_numbers) {
Zone zone(allocator, ZONE_NAME);
WasmFeatures unused_detected_features = WasmFeatures::None();
WasmDecoder<Decoder::kNoValidate> decoder(&zone, module, WasmFeatures::All(),
&unused_detected_features, body.sig,
body.start, body.end);
WasmDecoder<Decoder::kNoValidation> decoder(
&zone, module, WasmFeatures::All(), &unused_detected_features, body.sig,
body.start, body.end);
int line_nr = 0;
constexpr int kNoByteCode = -1;
......@@ -174,7 +174,7 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
unsigned control_depth = 0;
for (; i.has_next(); i.next()) {
unsigned length =
WasmDecoder<Decoder::kNoValidate>::OpcodeLength(&decoder, i.pc());
WasmDecoder<Decoder::kNoValidation>::OpcodeLength(&decoder, i.pc());
unsigned offset = 1;
WasmOpcode opcode = i.current();
......@@ -243,8 +243,8 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
case kExprIf:
case kExprBlock:
case kExprTry: {
BlockTypeImmediate<Decoder::kNoValidate> imm(WasmFeatures::All(), &i,
i.pc() + 1);
BlockTypeImmediate<Decoder::kNoValidation> imm(WasmFeatures::All(), &i,
i.pc() + 1);
os << " @" << i.pc_offset();
if (decoder.Complete(imm)) {
for (uint32_t i = 0; i < imm.out_arity(); i++) {
......@@ -259,23 +259,23 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
control_depth--;
break;
case kExprBr: {
BranchDepthImmediate<Decoder::kNoValidate> imm(&i, i.pc() + 1);
BranchDepthImmediate<Decoder::kNoValidation> imm(&i, i.pc() + 1);
os << " depth=" << imm.depth;
break;
}
case kExprBrIf: {
BranchDepthImmediate<Decoder::kNoValidate> imm(&i, i.pc() + 1);
BranchDepthImmediate<Decoder::kNoValidation> imm(&i, i.pc() + 1);
os << " depth=" << imm.depth;
break;
}
case kExprBrTable: {
BranchTableImmediate<Decoder::kNoValidate> imm(&i, i.pc() + 1);
BranchTableImmediate<Decoder::kNoValidation> imm(&i, i.pc() + 1);
os << " entries=" << imm.table_count;
break;
}
case kExprCallIndirect: {
CallIndirectImmediate<Decoder::kNoValidate> imm(WasmFeatures::All(), &i,
i.pc() + 1);
CallIndirectImmediate<Decoder::kNoValidation> imm(WasmFeatures::All(),
&i, i.pc() + 1);
os << " sig #" << imm.sig_index;
if (decoder.Complete(imm)) {
os << ": " << *imm.sig;
......@@ -283,7 +283,7 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
break;
}
case kExprCallFunction: {
CallFunctionImmediate<Decoder::kNoValidate> imm(&i, i.pc() + 1);
CallFunctionImmediate<Decoder::kNoValidation> imm(&i, i.pc() + 1);
os << " function #" << imm.index;
if (decoder.Complete(imm)) {
os << ": " << *imm.sig;
......@@ -304,9 +304,9 @@ bool PrintRawWasmCode(AccountingAllocator* allocator, const FunctionBody& body,
BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
const byte* start, const byte* end) {
WasmFeatures no_features = WasmFeatures::None();
WasmDecoder<Decoder::kValidate> decoder(zone, nullptr, no_features,
&no_features, nullptr, start, end, 0);
return WasmDecoder<Decoder::kValidate>::AnalyzeLoopAssignment(
WasmDecoder<Decoder::kFullValidation> decoder(
zone, nullptr, no_features, &no_features, nullptr, start, end, 0);
return WasmDecoder<Decoder::kFullValidation>::AnalyzeLoopAssignment(
&decoder, start, static_cast<uint32_t>(num_locals), zone);
}
......
......@@ -163,7 +163,7 @@ class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) {
WasmOpcode current() {
return static_cast<WasmOpcode>(
read_u8<Decoder::kNoValidate>(pc_, "expected bytecode"));
read_u8<Decoder::kNoValidation>(pc_, "expected bytecode"));
}
void next() {
......@@ -176,7 +176,7 @@ class V8_EXPORT_PRIVATE BytecodeIterator : public NON_EXPORTED_BASE(Decoder) {
bool has_next() { return pc_ < end_; }
WasmOpcode prefixed_opcode() {
return read_prefixed_opcode<Decoder::kNoValidate>(pc_);
return read_prefixed_opcode<Decoder::kNoValidation>(pc_);
}
};
......
......@@ -74,7 +74,7 @@ constexpr uint32_t kNullCatch = static_cast<uint32_t>(-1);
class WasmGraphBuildingInterface {
public:
static constexpr Decoder::ValidateFlag validate = Decoder::kValidate;
static constexpr Decoder::ValidateFlag validate = Decoder::kFullValidation;
using FullDecoder = WasmFullDecoder<validate, WasmGraphBuildingInterface>;
using CheckForNull = compiler::WasmGraphBuilder::CheckForNull;
......@@ -1200,7 +1200,7 @@ DecodeResult BuildTFGraph(AccountingAllocator* allocator,
WasmFeatures* detected, const FunctionBody& body,
compiler::NodeOriginTable* node_origins) {
Zone zone(allocator, ZONE_NAME);
WasmFullDecoder<Decoder::kValidate, WasmGraphBuildingInterface> decoder(
WasmFullDecoder<Decoder::kFullValidation, WasmGraphBuildingInterface> decoder(
&zone, module, enabled, detected, body, builder);
if (node_origins) {
builder->AddBytecodePositionDecorator(node_origins, &decoder);
......
......@@ -1618,7 +1618,8 @@ class ModuleDecoderImpl : public Decoder {
// TODO(manoskouk): This is copy-modified from function-body-decoder-impl.h.
// We should find a way to share this code.
V8_INLINE bool Validate(const byte* pc, HeapTypeImmediate<kValidate>& imm) {
V8_INLINE bool Validate(const byte* pc,
HeapTypeImmediate<kFullValidation>& imm) {
if (V8_UNLIKELY(imm.type.is_bottom())) {
error(pc, "invalid heap type");
return false;
......@@ -1633,7 +1634,7 @@ class ModuleDecoderImpl : public Decoder {
WasmInitExpr consume_init_expr(WasmModule* module, ValueType expected,
size_t current_global_index) {
constexpr Decoder::ValidateFlag validate = Decoder::kValidate;
constexpr Decoder::ValidateFlag validate = Decoder::kFullValidation;
WasmOpcode opcode = kExprNop;
std::vector<WasmInitExpr> stack;
while (pc() < end() && opcode != kExprEnd) {
......@@ -1670,25 +1671,25 @@ class ModuleDecoderImpl : public Decoder {
break;
}
case kExprI32Const: {
ImmI32Immediate<Decoder::kValidate> imm(this, pc() + 1);
ImmI32Immediate<Decoder::kFullValidation> imm(this, pc() + 1);
stack.emplace_back(imm.value);
len = 1 + imm.length;
break;
}
case kExprF32Const: {
ImmF32Immediate<Decoder::kValidate> imm(this, pc() + 1);
ImmF32Immediate<Decoder::kFullValidation> imm(this, pc() + 1);
stack.emplace_back(imm.value);
len = 1 + imm.length;
break;
}
case kExprI64Const: {
ImmI64Immediate<Decoder::kValidate> imm(this, pc() + 1);
ImmI64Immediate<Decoder::kFullValidation> imm(this, pc() + 1);
stack.emplace_back(imm.value);
len = 1 + imm.length;
break;
}
case kExprF64Const: {
ImmF64Immediate<Decoder::kValidate> imm(this, pc() + 1);
ImmF64Immediate<Decoder::kFullValidation> imm(this, pc() + 1);
stack.emplace_back(imm.value);
len = 1 + imm.length;
break;
......@@ -1702,8 +1703,8 @@ class ModuleDecoderImpl : public Decoder {
kExprRefNull);
return {};
}
HeapTypeImmediate<Decoder::kValidate> imm(enabled_features_, this,
pc() + 1);
HeapTypeImmediate<Decoder::kFullValidation> imm(enabled_features_,
this, pc() + 1);
len = 1 + imm.length;
if (!Validate(pc() + 1, imm)) return {};
stack.push_back(
......@@ -1719,7 +1720,7 @@ class ModuleDecoderImpl : public Decoder {
return {};
}
FunctionIndexImmediate<Decoder::kValidate> imm(this, pc() + 1);
FunctionIndexImmediate<Decoder::kFullValidation> imm(this, pc() + 1);
len = 1 + imm.length;
if (V8_UNLIKELY(module->functions.size() <= imm.index)) {
errorf(pc(), "invalid function index: %u", imm.index);
......@@ -1836,7 +1837,7 @@ class ModuleDecoderImpl : public Decoder {
ValueType consume_value_type() {
uint32_t type_length;
ValueType result = value_type_reader::read_value_type<kValidate>(
ValueType result = value_type_reader::read_value_type<kFullValidation>(
this, this->pc(), &type_length,
origin_ == kWasmOrigin ? enabled_features_ : WasmFeatures::None());
if (result == kWasmBottom) error(pc_, "invalid value type");
......@@ -1850,7 +1851,7 @@ class ModuleDecoderImpl : public Decoder {
}
ValueType consume_storage_type() {
uint8_t opcode = read_u8<kValidate>(this->pc());
uint8_t opcode = read_u8<kFullValidation>(this->pc());
switch (opcode) {
case kI8Code:
consume_bytes(1, "i8");
......@@ -2133,7 +2134,8 @@ class ModuleDecoderImpl : public Decoder {
if (failed()) return index;
switch (opcode) {
case kExprRefNull: {
HeapTypeImmediate<kValidate> imm(WasmFeatures::All(), this, this->pc());
HeapTypeImmediate<kFullValidation> imm(WasmFeatures::All(), this,
this->pc());
consume_bytes(imm.length, "ref.null immediate");
index = WasmElemSegment::kNullIndex;
break;
......
This diff is collapsed.
This diff is collapsed.
......@@ -4258,15 +4258,15 @@ class BranchTableIteratorTest : public TestWithZone {
BranchTableIteratorTest() : TestWithZone() {}
void CheckBrTableSize(const byte* start, const byte* end) {
Decoder decoder(start, end);
BranchTableImmediate<Decoder::kValidate> operand(&decoder, start + 1);
BranchTableIterator<Decoder::kValidate> iterator(&decoder, operand);
BranchTableImmediate<Decoder::kFullValidation> operand(&decoder, start + 1);
BranchTableIterator<Decoder::kFullValidation> iterator(&decoder, operand);
EXPECT_EQ(end - start - 1u, iterator.length());
EXPECT_OK(decoder);
}
void CheckBrTableError(const byte* start, const byte* end) {
Decoder decoder(start, end);
BranchTableImmediate<Decoder::kValidate> operand(&decoder, start + 1);
BranchTableIterator<Decoder::kValidate> iterator(&decoder, operand);
BranchTableImmediate<Decoder::kFullValidation> operand(&decoder, start + 1);
BranchTableIterator<Decoder::kFullValidation> iterator(&decoder, operand);
iterator.length();
EXPECT_FALSE(decoder.ok());
}
......@@ -4360,10 +4360,10 @@ class WasmOpcodeLengthTest : public TestWithZone {
void ExpectFailure(Bytes... bytes) {
const byte code[] = {bytes..., 0, 0, 0, 0, 0, 0, 0, 0};
WasmFeatures no_features = WasmFeatures::None();
WasmDecoder<Decoder::kValidate> decoder(this->zone(), nullptr, no_features,
&no_features, nullptr, code,
code + sizeof(code), 0);
WasmDecoder<Decoder::kValidate>::OpcodeLength(&decoder, code);
WasmDecoder<Decoder::kFullValidation> decoder(
this->zone(), nullptr, no_features, &no_features, nullptr, code,
code + sizeof(code), 0);
WasmDecoder<Decoder::kFullValidation>::OpcodeLength(&decoder, code);
EXPECT_EQ(decoder.failed(), true);
}
};
......
......@@ -88,19 +88,20 @@ TEST_F(LEBHelperTest, sizeof_i32v) {
}
}
#define DECLARE_ENCODE_DECODE_CHECKER(ctype, name) \
static void CheckEncodeDecode_##name(ctype val) { \
static const int kSize = 16; \
static byte buffer[kSize]; \
byte* ptr = buffer; \
LEBHelper::write_##name(&ptr, val); \
EXPECT_EQ(LEBHelper::sizeof_##name(val), \
static_cast<size_t>(ptr - buffer)); \
Decoder decoder(buffer, buffer + kSize); \
unsigned length = 0; \
ctype result = decoder.read_##name<Decoder::kNoValidate>(buffer, &length); \
EXPECT_EQ(val, result); \
EXPECT_EQ(LEBHelper::sizeof_##name(val), static_cast<size_t>(length)); \
#define DECLARE_ENCODE_DECODE_CHECKER(ctype, name) \
static void CheckEncodeDecode_##name(ctype val) { \
static const int kSize = 16; \
static byte buffer[kSize]; \
byte* ptr = buffer; \
LEBHelper::write_##name(&ptr, val); \
EXPECT_EQ(LEBHelper::sizeof_##name(val), \
static_cast<size_t>(ptr - buffer)); \
Decoder decoder(buffer, buffer + kSize); \
unsigned length = 0; \
ctype result = \
decoder.read_##name<Decoder::kNoValidation>(buffer, &length); \
EXPECT_EQ(val, result); \
EXPECT_EQ(LEBHelper::sizeof_##name(val), static_cast<size_t>(length)); \
}
DECLARE_ENCODE_DECODE_CHECKER(int32_t, i32v)
......
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