[wasm] Remove redundant subclass from ModuleDecoder

Bug: v8:7748
Change-Id: I45726b178760c63ef77fa9d1c9cffce35cc6b8d0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4194719
Auto-Submit: Matthias Liedtke <mliedtke@chromium.org>
Reviewed-by: Manos Koukoutos <manoskouk@chromium.org>
Commit-Queue: Manos Koukoutos <manoskouk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85481}
This commit is contained in:
Matthias Liedtke 2023-01-25 17:23:53 +01:00 committed by V8 LUCI CQ
parent 8c8dfc75bb
commit 22bef706e1
4 changed files with 8 additions and 19 deletions

View File

@ -272,11 +272,11 @@ class WasmSectionIterator {
}; };
// The main logic for decoding the bytes of a module. // The main logic for decoding the bytes of a module.
class ModuleDecoderBase : public Decoder { class ModuleDecoderImpl : public Decoder {
public: public:
ModuleDecoderBase(WasmFeatures enabled_features, ModuleDecoderImpl(WasmFeatures enabled_features,
base::Vector<const uint8_t> wire_bytes, ModuleOrigin origin, base::Vector<const uint8_t> wire_bytes, ModuleOrigin origin,
ITracer* tracer) ITracer* tracer = ITracer::NoTrace)
: Decoder(wire_bytes), : Decoder(wire_bytes),
enabled_features_(enabled_features), enabled_features_(enabled_features),
module_(std::make_shared<WasmModule>(origin)), module_(std::make_shared<WasmModule>(origin)),
@ -2392,12 +2392,12 @@ class ModuleDecoderBase : public Decoder {
// We store next_ordered_section_ as uint8_t instead of SectionCode so that // We store next_ordered_section_ as uint8_t instead of SectionCode so that
// we can increment it. This static_assert should make sure that SectionCode // we can increment it. This static_assert should make sure that SectionCode
// does not get bigger than uint8_t accidentally. // does not get bigger than uint8_t accidentally.
static_assert(sizeof(ModuleDecoderBase::next_ordered_section_) == static_assert(sizeof(ModuleDecoderImpl::next_ordered_section_) ==
sizeof(SectionCode), sizeof(SectionCode),
"type mismatch"); "type mismatch");
uint32_t seen_unordered_sections_ = 0; uint32_t seen_unordered_sections_ = 0;
static_assert(kBitsPerByte * static_assert(kBitsPerByte *
sizeof(ModuleDecoderBase::seen_unordered_sections_) > sizeof(ModuleDecoderImpl::seen_unordered_sections_) >
kLastKnownModuleSection, kLastKnownModuleSection,
"not enough bits"); "not enough bits");
AccountingAllocator allocator_; AccountingAllocator allocator_;

View File

@ -69,17 +69,6 @@ const char* SectionName(SectionCode code) {
} }
} }
// TODO(mliedtke): Convert ModuleDecoderBase to ModuleDecoder[Impl] and get rid
// of this additional subclass. Then move the implementation from the impl
// header to the cc as it isn't a template any more.
class ModuleDecoderImpl : public ModuleDecoderBase {
public:
ModuleDecoderImpl(WasmFeatures enabled_features,
base::Vector<const uint8_t> wire_bytes, ModuleOrigin origin)
: ModuleDecoderBase(enabled_features, wire_bytes, origin,
ITracer::NoTrace) {}
};
ModuleResult DecodeWasmModule( ModuleResult DecodeWasmModule(
WasmFeatures enabled_features, base::Vector<const uint8_t> wire_bytes, WasmFeatures enabled_features, base::Vector<const uint8_t> wire_bytes,
bool validate_functions, ModuleOrigin origin, Counters* counters, bool validate_functions, ModuleOrigin origin, Counters* counters,

View File

@ -583,7 +583,7 @@ class OffsetsProvider : public ITracer {
element_offsets_.reserve(module->elem_segments.size()); element_offsets_.reserve(module->elem_segments.size());
data_offsets_.reserve(module->data_segments.size()); data_offsets_.reserve(module->data_segments.size());
ModuleDecoderBase decoder{WasmFeatures::All(), wire_bytes, kWasmOrigin, ModuleDecoderImpl decoder{WasmFeatures::All(), wire_bytes, kWasmOrigin,
this}; this};
constexpr bool kNoVerifyFunctions = false; constexpr bool kNoVerifyFunctions = false;
decoder.DecodeModule(kNoVerifyFunctions); decoder.DecodeModule(kNoVerifyFunctions);

View File

@ -358,7 +358,7 @@ class ExtendedFunctionDis : public FunctionBodyDisassembler {
// e.g.: // e.g.:
// 0x01, 0x70, 0x00, // table count 1: funcref no maximum // 0x01, 0x70, 0x00, // table count 1: funcref no maximum
class HexDumpModuleDis; class HexDumpModuleDis;
class DumpingModuleDecoder : public ModuleDecoderBase { class DumpingModuleDecoder : public ModuleDecoderImpl {
public: public:
DumpingModuleDecoder(ModuleWireBytes wire_bytes, DumpingModuleDecoder(ModuleWireBytes wire_bytes,
HexDumpModuleDis* module_dis); HexDumpModuleDis* module_dis);
@ -1054,7 +1054,7 @@ class FormatConverter {
DumpingModuleDecoder::DumpingModuleDecoder(ModuleWireBytes wire_bytes, DumpingModuleDecoder::DumpingModuleDecoder(ModuleWireBytes wire_bytes,
HexDumpModuleDis* module_dis) HexDumpModuleDis* module_dis)
: ModuleDecoderBase(WasmFeatures::All(), wire_bytes.module_bytes(), : ModuleDecoderImpl(WasmFeatures::All(), wire_bytes.module_bytes(),
kWasmOrigin, module_dis) {} kWasmOrigin, module_dis) {}
} // namespace wasm } // namespace wasm