[wasm] Use getter for WasmResult::value

Previously, this was just a field on the WasmResult, which is not
allowed according to the style guide.
A special r-value accessor for the value is needed for the cases where
the contained type is not copyable, e.g. unique_ptr.

R=titzer@chromium.org

Bug: v8:8238
Change-Id: Ia3c14c4c62c3c2e07f1dc4594f1bc9d1da88f91e
Reviewed-on: https://chromium-review.googlesource.com/c/1290974
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Ben Titzer <titzer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56823}
This commit is contained in:
Clemens Hammacher 2018-10-19 14:35:56 +02:00 committed by Commit Bot
parent f8d6c4c003
commit 7921b73afb
10 changed files with 117 additions and 105 deletions

View File

@ -2429,7 +2429,7 @@ class AsyncCompileJob::DecodeModule : public AsyncCompileJob::CompileStep {
job_->DoSync<DecodeFail>(std::move(result));
} else {
// Decode passed.
job_->DoSync<PrepareAndStartCompile>(std::move(result.val), true);
job_->DoSync<PrepareAndStartCompile>(std::move(result).value(), true);
}
}
};
@ -2797,7 +2797,8 @@ void AsyncStreamingProcessor::OnFinishedStream(OwnedVector<uint8_t> bytes) {
// prepare compilation first before we can finish it.
// {PrepareAndStartCompile} will call {FinishCompile} by itself if there
// is no code section.
job_->DoSync<AsyncCompileJob::PrepareAndStartCompile>(result.val, true);
job_->DoSync<AsyncCompileJob::PrepareAndStartCompile>(
std::move(result).value(), true);
} else {
HandleScope scope(job_->isolate_);
SaveContext saved_context(job_->isolate_);

View File

@ -1485,7 +1485,7 @@ ModuleResult DecodeWasmModule(const WasmFeatures& enabled,
auto peak_counter = SELECT_WASM_COUNTER(counters, origin, wasm_decode,
module_peak_memory_bytes);
peak_counter->AddSample(
static_cast<int>(result.val->signature_zone->allocation_size()));
static_cast<int>(result.value()->signature_zone->allocation_size()));
}
return result;
}

View File

@ -50,7 +50,7 @@ MaybeHandle<WasmModuleObject> WasmEngine::SyncCompileTranslatedAsmJs(
// Transfer ownership of the WasmModule to the {Managed<WasmModule>} generated
// in {CompileToModuleObject}.
return CompileToModuleObject(isolate, kAsmjsWasmFeatures, thrower,
std::move(result.val), bytes, asm_js_script,
std::move(result).value(), bytes, asm_js_script,
asm_js_offset_table_bytes);
}
@ -67,8 +67,9 @@ MaybeHandle<WasmModuleObject> WasmEngine::SyncCompile(
// Transfer ownership of the WasmModule to the {Managed<WasmModule>} generated
// in {CompileToModuleObject}.
return CompileToModuleObject(isolate, enabled, thrower, std::move(result.val),
bytes, Handle<Script>(), Vector<const byte>());
return CompileToModuleObject(isolate, enabled, thrower,
std::move(result).value(), bytes,
Handle<Script>(), Vector<const byte>());
}
MaybeHandle<WasmInstanceObject> WasmEngine::SyncInstantiate(

View File

@ -412,25 +412,24 @@ Handle<ByteArray> GetDecodedAsmJsOffsetTable(
DCHECK(table_type == Encoded || table_type == Decoded);
if (table_type == Decoded) return offset_table;
wasm::AsmJsOffsetsResult asm_offsets;
wasm::AsmJsOffsets asm_offsets;
{
DisallowHeapAllocation no_gc;
byte* bytes_start = offset_table->GetDataStartAddress();
byte* bytes_end = reinterpret_cast<byte*>(
reinterpret_cast<Address>(bytes_start) + offset_table->length() - 1);
asm_offsets = wasm::DecodeAsmJsOffsets(bytes_start, bytes_end);
asm_offsets = wasm::DecodeAsmJsOffsets(bytes_start, bytes_end).value();
}
// Wasm bytes must be valid and must contain asm.js offset table.
DCHECK(asm_offsets.ok());
DCHECK_GE(kMaxInt, asm_offsets.val.size());
int num_functions = static_cast<int>(asm_offsets.val.size());
DCHECK_GE(kMaxInt, asm_offsets.size());
int num_functions = static_cast<int>(asm_offsets.size());
int num_imported_functions =
static_cast<int>(module_object->module()->num_imported_functions);
DCHECK_EQ(module_object->module()->functions.size(),
static_cast<size_t>(num_functions) + num_imported_functions);
int num_entries = 0;
for (int func = 0; func < num_functions; ++func) {
size_t new_size = asm_offsets.val[func].size();
size_t new_size = asm_offsets[func].size();
DCHECK_LE(new_size, static_cast<size_t>(kMaxInt) - num_entries);
num_entries += static_cast<int>(new_size);
}
@ -447,8 +446,7 @@ Handle<ByteArray> GetDecodedAsmJsOffsetTable(
const std::vector<WasmFunction>& wasm_funs =
module_object->module()->functions;
for (int func = 0; func < num_functions; ++func) {
std::vector<wasm::AsmJsOffsetEntry>& func_asm_offsets =
asm_offsets.val[func];
std::vector<wasm::AsmJsOffsetEntry>& func_asm_offsets = asm_offsets[func];
if (func_asm_offsets.empty()) continue;
int func_offset = wasm_funs[num_imported_functions + func].code.offset();
for (wasm::AsmJsOffsetEntry& e : func_asm_offsets) {

View File

@ -70,11 +70,11 @@ class Result : public ResultBase {
Result() = default;
template <typename S>
explicit Result(S&& value) : val(std::forward<S>(value)) {}
explicit Result(S&& value) : value_(std::forward<S>(value)) {}
template <typename S>
Result(Result<S>&& other) V8_NOEXCEPT : ResultBase(std::move(other)),
val(std::move(other.val)) {}
value_(std::move(other).value()) {}
Result& operator=(Result&& other) V8_NOEXCEPT = default;
@ -87,9 +87,22 @@ class Result : public ResultBase {
return result;
}
T val = T{};
// Accessor for the value. Returns const reference if {this} is l-value or
// const, and returns r-value reference if {this} is r-value. This allows to
// extract non-copyable values like {std::unique_ptr} by using
// {std::move(result).value()}.
const T& value() const & {
DCHECK(ok());
return value_;
}
T&& value() && {
DCHECK(ok());
return std::move(value_);
}
private:
T value_ = T{};
DISALLOW_COPY_AND_ASSIGN(Result);
};

View File

@ -549,9 +549,9 @@ MaybeHandle<WasmModuleObject> DeserializeNativeModule(
ModuleResult decode_result = DecodeWasmModule(
enabled_features, wire_bytes.start(), wire_bytes.end(), false,
i::wasm::kWasmOrigin, isolate->counters(), isolate->allocator());
if (!decode_result.ok()) return {};
CHECK_NOT_NULL(decode_result.val);
WasmModule* module = decode_result.val.get();
if (decode_result.failed()) return {};
CHECK_NOT_NULL(decode_result.value());
WasmModule* module = decode_result.value().get();
Handle<Script> script =
CreateWasmScript(isolate, wire_bytes, module->source_map_url);
@ -565,7 +565,7 @@ MaybeHandle<WasmModuleObject> DeserializeNativeModule(
OwnedVector<uint8_t> wire_bytes_copy = OwnedVector<uint8_t>::Of(wire_bytes);
Handle<WasmModuleObject> module_object = WasmModuleObject::New(
isolate, enabled_features, std::move(decode_result.val), env,
isolate, enabled_features, std::move(decode_result).value(), env,
std::move(wire_bytes_copy), script, Handle<ByteArray>::null());
NativeModule* native_module = module_object->native_module();

View File

@ -257,7 +257,7 @@ size_t GetFunctionOffset(i::Isolate* isolate, const uint8_t* buffer,
kAllWasmFeatures, buffer, buffer + size, false, ModuleOrigin::kWasmOrigin,
isolate->counters(), isolate->allocator());
CHECK(result.ok());
const WasmFunction* func = &result.val->functions[1];
const WasmFunction* func = &result.value()->functions[1];
return func->code.offset();
}

View File

@ -54,7 +54,7 @@ std::shared_ptr<WasmModule> DecodeWasmModuleForTesting(
decoding_result.error_msg().c_str());
}
return std::move(decoding_result.val);
return std::move(decoding_result).value();
}
bool InterpretWasmModuleForTesting(Isolate* isolate,

View File

@ -158,7 +158,7 @@ void GenerateTestCase(Isolate* isolate, ModuleWireBytes wire_bytes,
enabled_features, wire_bytes.start(), wire_bytes.end(), kVerifyFunctions,
ModuleOrigin::kWasmOrigin, isolate->counters(), isolate->allocator());
CHECK(module_res.ok());
WasmModule* module = module_res.val.get();
WasmModule* module = module_res.value().get();
CHECK_NOT_NULL(module);
StdoutStream os;

View File

@ -76,7 +76,6 @@ struct CheckLEB1 : std::integral_constant<size_t, num> {
do { \
ModuleResult result = DecodeModule((data), (data) + sizeof((data))); \
EXPECT_FALSE(result.ok()); \
EXPECT_EQ(0u, result.val->exceptions.size()); \
} while (false)
#define X1(...) __VA_ARGS__
@ -240,11 +239,11 @@ TEST_F(WasmModuleVerifyTest, OneGlobal) {
// Should decode to exactly one global.
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(1u, result.val->globals.size());
EXPECT_EQ(0u, result.val->functions.size());
EXPECT_EQ(0u, result.val->data_segments.size());
EXPECT_EQ(1u, result.value()->globals.size());
EXPECT_EQ(0u, result.value()->functions.size());
EXPECT_EQ(0u, result.value()->data_segments.size());
const WasmGlobal* global = &result.val->globals.back();
const WasmGlobal* global = &result.value()->globals.back();
EXPECT_EQ(kWasmI32, global->type);
EXPECT_EQ(0u, global->offset);
@ -270,11 +269,11 @@ TEST_F(WasmModuleVerifyTest, AnyRefGlobal) {
// Should decode to exactly one global.
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(1u, result.val->globals.size());
EXPECT_EQ(0u, result.val->functions.size());
EXPECT_EQ(0u, result.val->data_segments.size());
EXPECT_EQ(1u, result.value()->globals.size());
EXPECT_EQ(0u, result.value()->functions.size());
EXPECT_EQ(0u, result.value()->data_segments.size());
const WasmGlobal* global = &result.val->globals.back();
const WasmGlobal* global = &result.value()->globals.back();
EXPECT_EQ(kWasmAnyRef, global->type);
EXPECT_FALSE(global->mutability);
@ -303,11 +302,11 @@ TEST_F(WasmModuleVerifyTest, AnyRefGlobalWithGlobalInit) {
// Should decode to exactly one global.
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(2u, result.val->globals.size());
EXPECT_EQ(0u, result.val->functions.size());
EXPECT_EQ(0u, result.val->data_segments.size());
EXPECT_EQ(2u, result.value()->globals.size());
EXPECT_EQ(0u, result.value()->functions.size());
EXPECT_EQ(0u, result.value()->data_segments.size());
const WasmGlobal* global = &result.val->globals.back();
const WasmGlobal* global = &result.value()->globals.back();
EXPECT_EQ(kWasmAnyRef, global->type);
EXPECT_FALSE(global->mutability);
@ -441,18 +440,18 @@ TEST_F(WasmModuleVerifyTest, TwoGlobals) {
// Should decode to exactly two globals.
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(2u, result.val->globals.size());
EXPECT_EQ(0u, result.val->functions.size());
EXPECT_EQ(0u, result.val->data_segments.size());
EXPECT_EQ(2u, result.value()->globals.size());
EXPECT_EQ(0u, result.value()->functions.size());
EXPECT_EQ(0u, result.value()->data_segments.size());
const WasmGlobal* g0 = &result.val->globals[0];
const WasmGlobal* g0 = &result.value()->globals[0];
EXPECT_EQ(kWasmF32, g0->type);
EXPECT_EQ(0u, g0->offset);
EXPECT_FALSE(g0->mutability);
EXPECT_EQ(WasmInitExpr::kF32Const, g0->init.kind);
const WasmGlobal* g1 = &result.val->globals[1];
const WasmGlobal* g1 = &result.value()->globals[1];
EXPECT_EQ(kWasmF64, g1->type);
EXPECT_EQ(8u, g1->offset);
@ -470,7 +469,7 @@ TEST_F(WasmModuleVerifyTest, ZeroExceptions) {
WASM_FEATURE_SCOPE(eh);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(0u, result.val->exceptions.size());
EXPECT_EQ(0u, result.value()->exceptions.size());
}
TEST_F(WasmModuleVerifyTest, OneI32Exception) {
@ -482,9 +481,9 @@ TEST_F(WasmModuleVerifyTest, OneI32Exception) {
WASM_FEATURE_SCOPE(eh);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(1u, result.val->exceptions.size());
EXPECT_EQ(1u, result.value()->exceptions.size());
const WasmException& e0 = result.val->exceptions.front();
const WasmException& e0 = result.value()->exceptions.front();
EXPECT_EQ(1u, e0.sig->parameter_count());
EXPECT_EQ(kWasmI32, e0.sig->GetParam(0));
}
@ -502,12 +501,12 @@ TEST_F(WasmModuleVerifyTest, TwoExceptions) {
WASM_FEATURE_SCOPE(eh);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(2u, result.val->exceptions.size());
const WasmException& e0 = result.val->exceptions.front();
EXPECT_EQ(2u, result.value()->exceptions.size());
const WasmException& e0 = result.value()->exceptions.front();
EXPECT_EQ(2u, e0.sig->parameter_count());
EXPECT_EQ(kWasmF32, e0.sig->GetParam(0));
EXPECT_EQ(kWasmI64, e0.sig->GetParam(1));
const WasmException& e1 = result.val->exceptions.back();
const WasmException& e1 = result.value()->exceptions.back();
EXPECT_EQ(kWasmI32, e1.sig->GetParam(0));
}
@ -581,8 +580,8 @@ TEST_F(WasmModuleVerifyTest, ExceptionImport) {
WASM_FEATURE_SCOPE(eh);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(1u, result.val->exceptions.size());
EXPECT_EQ(1u, result.val->import_table.size());
EXPECT_EQ(1u, result.value()->exceptions.size());
EXPECT_EQ(1u, result.value()->import_table.size());
}
TEST_F(WasmModuleVerifyTest, ExceptionExport) {
@ -598,8 +597,8 @@ TEST_F(WasmModuleVerifyTest, ExceptionExport) {
WASM_FEATURE_SCOPE(eh);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(1u, result.val->exceptions.size());
EXPECT_EQ(1u, result.val->export_table.size());
EXPECT_EQ(1u, result.value()->exceptions.size());
EXPECT_EQ(1u, result.value()->export_table.size());
}
TEST_F(WasmModuleVerifyTest, OneSignature) {
@ -626,15 +625,15 @@ TEST_F(WasmModuleVerifyTest, MultipleSignatures) {
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(3u, result.val->signatures.size());
if (result.val->signatures.size() == 3) {
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(3u, result.value()->signatures.size());
if (result.value()->signatures.size() == 3) {
EXPECT_EQ(0u, result.value()->signatures[0]->return_count());
EXPECT_EQ(1u, result.value()->signatures[1]->return_count());
EXPECT_EQ(1u, result.value()->signatures[2]->return_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());
EXPECT_EQ(0u, result.value()->signatures[0]->parameter_count());
EXPECT_EQ(1u, result.value()->signatures[1]->parameter_count());
EXPECT_EQ(2u, result.value()->signatures[2]->parameter_count());
}
EXPECT_OFF_END_FAILURE(data, 1);
@ -663,7 +662,7 @@ TEST_F(WasmModuleVerifyTest, DataSegmentWithImmutableImportedGlobal) {
};
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
WasmInitExpr expr = result.val->data_segments.back().dest_addr;
WasmInitExpr expr = result.value()->data_segments.back().dest_addr;
EXPECT_EQ(WasmInitExpr::kGlobalIndex, expr.kind);
EXPECT_EQ(1u, expr.val.global_index);
}
@ -716,11 +715,11 @@ TEST_F(WasmModuleVerifyTest, OneDataSegment) {
EXPECT_VERIFIES(data);
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(0u, result.val->globals.size());
EXPECT_EQ(0u, result.val->functions.size());
EXPECT_EQ(1u, result.val->data_segments.size());
EXPECT_EQ(0u, result.value()->globals.size());
EXPECT_EQ(0u, result.value()->functions.size());
EXPECT_EQ(1u, result.value()->data_segments.size());
const WasmDataSegment* segment = &result.val->data_segments.back();
const WasmDataSegment* segment = &result.value()->data_segments.back();
EXPECT_EQ(WasmInitExpr::kI32Const, segment->dest_addr.kind);
EXPECT_EQ(0x9BBAA, segment->dest_addr.val.i32_const);
@ -752,12 +751,12 @@ TEST_F(WasmModuleVerifyTest, TwoDataSegments) {
{
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(0u, result.val->globals.size());
EXPECT_EQ(0u, result.val->functions.size());
EXPECT_EQ(2u, result.val->data_segments.size());
EXPECT_EQ(0u, result.value()->globals.size());
EXPECT_EQ(0u, result.value()->functions.size());
EXPECT_EQ(2u, result.value()->data_segments.size());
const WasmDataSegment* s0 = &result.val->data_segments[0];
const WasmDataSegment* s1 = &result.val->data_segments[1];
const WasmDataSegment* s0 = &result.value()->data_segments[0];
const WasmDataSegment* s1 = &result.value()->data_segments[1];
EXPECT_EQ(WasmInitExpr::kI32Const, s0->dest_addr.kind);
EXPECT_EQ(0x7FFEE, s0->dest_addr.val.i32_const);
@ -834,10 +833,10 @@ TEST_F(WasmModuleVerifyTest, OneIndirectFunction) {
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
if (result.ok()) {
EXPECT_EQ(1u, result.val->signatures.size());
EXPECT_EQ(1u, result.val->functions.size());
EXPECT_EQ(1u, result.val->tables.size());
EXPECT_EQ(1u, result.val->tables[0].initial_size);
EXPECT_EQ(1u, result.value()->signatures.size());
EXPECT_EQ(1u, result.value()->functions.size());
EXPECT_EQ(1u, result.value()->tables.size());
EXPECT_EQ(1u, result.value()->tables[0].initial_size);
}
}
@ -918,10 +917,10 @@ TEST_F(WasmModuleVerifyTest, OneIndirectFunction_one_entry) {
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(1u, result.val->signatures.size());
EXPECT_EQ(1u, result.val->functions.size());
EXPECT_EQ(1u, result.val->tables.size());
EXPECT_EQ(1u, result.val->tables[0].initial_size);
EXPECT_EQ(1u, result.value()->signatures.size());
EXPECT_EQ(1u, result.value()->functions.size());
EXPECT_EQ(1u, result.value()->tables.size());
EXPECT_EQ(1u, result.value()->tables[0].initial_size);
}
TEST_F(WasmModuleVerifyTest, MultipleIndirectFunctions) {
@ -946,10 +945,10 @@ TEST_F(WasmModuleVerifyTest, MultipleIndirectFunctions) {
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(2u, result.val->signatures.size());
EXPECT_EQ(4u, result.val->functions.size());
EXPECT_EQ(1u, result.val->tables.size());
EXPECT_EQ(8u, result.val->tables[0].initial_size);
EXPECT_EQ(2u, result.value()->signatures.size());
EXPECT_EQ(4u, result.value()->functions.size());
EXPECT_EQ(1u, result.value()->tables.size());
EXPECT_EQ(8u, result.value()->tables[0].initial_size);
}
TEST_F(WasmModuleVerifyTest, ElementSectionMultipleTables) {
@ -1248,13 +1247,13 @@ TEST_F(WasmModuleVerifyTest, MultipleTablesWithFlag) {
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(2u, result.val->tables.size());
EXPECT_EQ(2u, result.value()->tables.size());
EXPECT_EQ(10u, result.val->tables[0].initial_size);
EXPECT_EQ(kWasmAnyFunc, result.val->tables[0].type);
EXPECT_EQ(10u, result.value()->tables[0].initial_size);
EXPECT_EQ(kWasmAnyFunc, result.value()->tables[0].type);
EXPECT_EQ(11u, result.val->tables[1].initial_size);
EXPECT_EQ(kWasmAnyRef, result.val->tables[1].type);
EXPECT_EQ(11u, result.value()->tables[1].initial_size);
EXPECT_EQ(kWasmAnyRef, result.value()->tables[1].type);
}
class WasmSignatureDecodeTest : public TestWithZone {
@ -1479,8 +1478,8 @@ TEST_F(WasmFunctionVerifyTest, Ok_v_v_empty) {
DecodeWasmFunction(bytes, &module, data, data + sizeof(data));
EXPECT_OK(result);
if (result.val && result.ok()) {
WasmFunction* function = result.val.get();
if (result.value() && result.ok()) {
WasmFunction* function = result.value().get();
EXPECT_EQ(0u, function->sig->parameter_count());
EXPECT_EQ(0u, function->sig->return_count());
EXPECT_EQ(COUNT_ARGS(SIG_ENTRY_v_v), function->code.offset());
@ -1582,11 +1581,11 @@ TEST_F(WasmModuleVerifyTest, UnknownSectionSkipped) {
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(1u, result.val->globals.size());
EXPECT_EQ(0u, result.val->functions.size());
EXPECT_EQ(0u, result.val->data_segments.size());
EXPECT_EQ(1u, result.value()->globals.size());
EXPECT_EQ(0u, result.value()->functions.size());
EXPECT_EQ(0u, result.value()->data_segments.size());
const WasmGlobal* global = &result.val->globals.back();
const WasmGlobal* global = &result.value()->globals.back();
EXPECT_EQ(kWasmI32, global->type);
EXPECT_EQ(0u, global->offset);
@ -1721,8 +1720,8 @@ TEST_F(WasmModuleVerifyTest, ExportTable_empty1) {
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(1u, result.val->functions.size());
EXPECT_EQ(0u, result.val->export_table.size());
EXPECT_EQ(1u, result.value()->functions.size());
EXPECT_EQ(0u, result.value()->export_table.size());
}
TEST_F(WasmModuleVerifyTest, ExportTable_empty2) {
@ -1749,8 +1748,8 @@ TEST_F(WasmModuleVerifyTest, ExportTableOne) {
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(1u, result.val->functions.size());
EXPECT_EQ(1u, result.val->export_table.size());
EXPECT_EQ(1u, result.value()->functions.size());
EXPECT_EQ(1u, result.value()->export_table.size());
}
TEST_F(WasmModuleVerifyTest, ExportNameWithInvalidStringLength) {
@ -1786,8 +1785,8 @@ TEST_F(WasmModuleVerifyTest, ExportTableTwo) {
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(1u, result.val->functions.size());
EXPECT_EQ(2u, result.val->export_table.size());
EXPECT_EQ(1u, result.value()->functions.size());
EXPECT_EQ(2u, result.value()->export_table.size());
}
TEST_F(WasmModuleVerifyTest, ExportTableThree) {
@ -1809,8 +1808,8 @@ TEST_F(WasmModuleVerifyTest, ExportTableThree) {
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_OK(result);
EXPECT_EQ(3u, result.val->functions.size());
EXPECT_EQ(3u, result.val->export_table.size());
EXPECT_EQ(3u, result.value()->functions.size());
EXPECT_EQ(3u, result.value()->export_table.size());
}
TEST_F(WasmModuleVerifyTest, ExportTableThreeOne) {
@ -2154,7 +2153,7 @@ TEST_F(WasmModuleVerifyTest, SourceMappingURLSection) {
SECTION_SRC_MAP('s', 'r', 'c', '/', 'x', 'y', 'z', '.', 'c')};
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_TRUE(result.ok());
EXPECT_EQ("src/xyz.c", result.val->source_map_url);
EXPECT_EQ("src/xyz.c", result.value()->source_map_url);
}
TEST_F(WasmModuleVerifyTest, BadSourceMappingURLSection) {
@ -2162,7 +2161,7 @@ TEST_F(WasmModuleVerifyTest, BadSourceMappingURLSection) {
SECTION_SRC_MAP('s', 'r', 'c', '/', 'x', 0xff, 'z', '.', 'c')};
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_TRUE(result.ok());
EXPECT_EQ(0u, result.val->source_map_url.size());
EXPECT_EQ(0u, result.value()->source_map_url.size());
}
TEST_F(WasmModuleVerifyTest, MultipleSourceMappingURLSections) {
@ -2170,7 +2169,7 @@ TEST_F(WasmModuleVerifyTest, MultipleSourceMappingURLSections) {
SECTION_SRC_MAP('p', 'q', 'r')};
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_TRUE(result.ok());
EXPECT_EQ("abc", result.val->source_map_url);
EXPECT_EQ("abc", result.value()->source_map_url);
}
TEST_F(WasmModuleVerifyTest, MultipleNameSections) {
@ -2179,7 +2178,7 @@ TEST_F(WasmModuleVerifyTest, MultipleNameSections) {
SECTION_NAMES(0, ADD_COUNT(ADD_COUNT('p', 'q', 'r', 's')))};
ModuleResult result = DecodeModule(data, data + sizeof(data));
EXPECT_TRUE(result.ok());
EXPECT_EQ(3u, result.val->name.length());
EXPECT_EQ(3u, result.value()->name.length());
}
#undef WASM_FEATURE_SCOPE