Commit 6dafd4a9 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Consider unknown sections as valid sections

This is just a minor refactoring: We include the kUnknownSectionCode in
the set of valid sections. There are only two uses of that function: The
first one already checks for kUnknownSectionCode in a separate
condition, the second one can be simplified with this refactoring.

R=ahaas@chromium.org

Bug: chromium:1335023
Change-Id: Ie1ae316db41f8111fff0af0d97a6c775f527156c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3698556
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81101}
parent 25fa9fcf
......@@ -29,7 +29,9 @@ namespace wasm {
struct CompilationEnv;
inline bool IsValidSectionCode(uint8_t byte) {
return kTypeSectionCode <= byte && byte <= kLastKnownModuleSection;
// Allow everything within [kUnknownSectionCode, kLastKnownModuleSection].
static_assert(kUnknownSectionCode == 0);
return byte <= kLastKnownModuleSection;
}
const char* SectionName(SectionCode code);
......
......@@ -588,9 +588,7 @@ std::unique_ptr<AsyncStreamingDecoder::DecodingState>
AsyncStreamingDecoder::DecodeSectionID::Next(AsyncStreamingDecoder* streaming) {
TRACE_STREAMING("DecodeSectionID: %u (%s)\n", id_,
SectionName(static_cast<SectionCode>(id_)));
if (id_ != kUnknownSectionCode && !IsValidSectionCode(id_)) {
return streaming->Error("invalid section code");
}
if (!IsValidSectionCode(id_)) return streaming->Error("invalid section code");
if (id_ == SectionCode::kCodeSectionCode) {
// Explicitly check for multiple code sections as module decoder never
// sees the code section and hence cannot track this section.
......
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