Commit a9bb380c authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm][cleanup] Rename an "offset" parameter

From reading the code it was totally unclear what the purpose of the
"offset" parameter at ProcessCodeSectionHeader and CheckFunctionsCount
is. Actually, it's just there for setting an error position. Thus this
CL renames the field, and a related local variable to make the use more
clear.

Drive-by: Remove a confusing and unnecessary Decoder::Reset call.

R=ahaas@chromium.org

Change-Id: Iccde5ccb3b9e7e52976c47724157c184fd345ec4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2567709Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71563}
parent 03202a38
......@@ -1735,7 +1735,8 @@ class AsyncStreamingProcessor final : public StreamingProcessor {
bool ProcessSection(SectionCode section_code, Vector<const uint8_t> bytes,
uint32_t offset) override;
bool ProcessCodeSectionHeader(int num_functions, uint32_t offset,
bool ProcessCodeSectionHeader(int num_functions,
uint32_t functions_mismatch_error_offset,
std::shared_ptr<WireBytesStorage>,
int code_section_start,
int code_section_length) override;
......@@ -2471,7 +2472,7 @@ bool AsyncStreamingProcessor::ProcessSection(SectionCode section_code,
// Start the code section.
bool AsyncStreamingProcessor::ProcessCodeSectionHeader(
int num_functions, uint32_t offset,
int num_functions, uint32_t functions_mismatch_error_offset,
std::shared_ptr<WireBytesStorage> wire_bytes_storage,
int code_section_start, int code_section_length) {
DCHECK_LE(0, code_section_length);
......@@ -2480,7 +2481,7 @@ bool AsyncStreamingProcessor::ProcessCodeSectionHeader(
num_functions);
decoder_.StartCodeSection();
if (!decoder_.CheckFunctionsCount(static_cast<uint32_t>(num_functions),
offset)) {
functions_mismatch_error_offset)) {
FinishAsyncCompileJobWithError(decoder_.FinishDecoding(false).error());
return false;
}
......
......@@ -931,9 +931,9 @@ class ModuleDecoderImpl : public Decoder {
void DecodeCodeSection(bool verify_functions) {
StartCodeSection();
uint32_t pos = pc_offset();
uint32_t code_section_start = pc_offset();
uint32_t functions_count = consume_u32v("functions count");
CheckFunctionsCount(functions_count, pos);
CheckFunctionsCount(functions_count, code_section_start);
for (uint32_t i = 0; ok() && i < functions_count; ++i) {
const byte* pos = pc();
uint32_t size = consume_u32v("body size");
......@@ -947,8 +947,8 @@ class ModuleDecoderImpl : public Decoder {
if (failed()) break;
DecodeFunctionBody(i, size, offset, verify_functions);
}
DCHECK_GE(pc_offset(), pos);
set_code_section(pos, pc_offset() - pos);
DCHECK_GE(pc_offset(), code_section_start);
set_code_section(code_section_start, pc_offset() - code_section_start);
}
void StartCodeSection() {
......@@ -959,10 +959,9 @@ class ModuleDecoderImpl : public Decoder {
}
}
bool CheckFunctionsCount(uint32_t functions_count, uint32_t offset) {
bool CheckFunctionsCount(uint32_t functions_count, uint32_t error_offset) {
if (functions_count != module_->num_declared_functions) {
Reset(nullptr, nullptr, offset);
errorf(nullptr, "function body count %u mismatch (%u expected)",
errorf(error_offset, "function body count %u mismatch (%u expected)",
functions_count, module_->num_declared_functions);
return false;
}
......@@ -2267,8 +2266,8 @@ void ModuleDecoder::DecodeFunctionBody(uint32_t index, uint32_t length,
void ModuleDecoder::StartCodeSection() { impl_->StartCodeSection(); }
bool ModuleDecoder::CheckFunctionsCount(uint32_t functions_count,
uint32_t offset) {
return impl_->CheckFunctionsCount(functions_count, offset);
uint32_t error_offset) {
return impl_->CheckFunctionsCount(functions_count, error_offset);
}
ModuleResult ModuleDecoder::FinishDecoding(bool verify_functions) {
......
......@@ -212,7 +212,7 @@ class ModuleDecoder {
void StartCodeSection();
bool CheckFunctionsCount(uint32_t functions_count, uint32_t offset);
bool CheckFunctionsCount(uint32_t functions_count, uint32_t error_offset);
void DecodeFunctionBody(uint32_t index, uint32_t size, uint32_t offset,
bool verify_functions = true);
......
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