From 22bef706e164b636df778124c792dc27805240e8 Mon Sep 17 00:00:00 2001 From: Matthias Liedtke Date: Wed, 25 Jan 2023 17:23:53 +0100 Subject: [PATCH] [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 Reviewed-by: Manos Koukoutos Commit-Queue: Manos Koukoutos Cr-Commit-Position: refs/heads/main@{#85481} --- src/wasm/module-decoder-impl.h | 10 +++++----- src/wasm/module-decoder.cc | 11 ----------- src/wasm/wasm-disassembler.cc | 2 +- tools/wasm/module-inspector.cc | 4 ++-- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/wasm/module-decoder-impl.h b/src/wasm/module-decoder-impl.h index a7c596ce44..5e21c0a438 100644 --- a/src/wasm/module-decoder-impl.h +++ b/src/wasm/module-decoder-impl.h @@ -272,11 +272,11 @@ class WasmSectionIterator { }; // The main logic for decoding the bytes of a module. -class ModuleDecoderBase : public Decoder { +class ModuleDecoderImpl : public Decoder { public: - ModuleDecoderBase(WasmFeatures enabled_features, + ModuleDecoderImpl(WasmFeatures enabled_features, base::Vector wire_bytes, ModuleOrigin origin, - ITracer* tracer) + ITracer* tracer = ITracer::NoTrace) : Decoder(wire_bytes), enabled_features_(enabled_features), module_(std::make_shared(origin)), @@ -2392,12 +2392,12 @@ class ModuleDecoderBase : public Decoder { // 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 // does not get bigger than uint8_t accidentally. - static_assert(sizeof(ModuleDecoderBase::next_ordered_section_) == + static_assert(sizeof(ModuleDecoderImpl::next_ordered_section_) == sizeof(SectionCode), "type mismatch"); uint32_t seen_unordered_sections_ = 0; static_assert(kBitsPerByte * - sizeof(ModuleDecoderBase::seen_unordered_sections_) > + sizeof(ModuleDecoderImpl::seen_unordered_sections_) > kLastKnownModuleSection, "not enough bits"); AccountingAllocator allocator_; diff --git a/src/wasm/module-decoder.cc b/src/wasm/module-decoder.cc index 5878198c8e..2fb8e86c6c 100644 --- a/src/wasm/module-decoder.cc +++ b/src/wasm/module-decoder.cc @@ -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 wire_bytes, ModuleOrigin origin) - : ModuleDecoderBase(enabled_features, wire_bytes, origin, - ITracer::NoTrace) {} -}; - ModuleResult DecodeWasmModule( WasmFeatures enabled_features, base::Vector wire_bytes, bool validate_functions, ModuleOrigin origin, Counters* counters, diff --git a/src/wasm/wasm-disassembler.cc b/src/wasm/wasm-disassembler.cc index 1c04902e71..a7bb922f59 100644 --- a/src/wasm/wasm-disassembler.cc +++ b/src/wasm/wasm-disassembler.cc @@ -583,7 +583,7 @@ class OffsetsProvider : public ITracer { element_offsets_.reserve(module->elem_segments.size()); data_offsets_.reserve(module->data_segments.size()); - ModuleDecoderBase decoder{WasmFeatures::All(), wire_bytes, kWasmOrigin, + ModuleDecoderImpl decoder{WasmFeatures::All(), wire_bytes, kWasmOrigin, this}; constexpr bool kNoVerifyFunctions = false; decoder.DecodeModule(kNoVerifyFunctions); diff --git a/tools/wasm/module-inspector.cc b/tools/wasm/module-inspector.cc index 7c0e32096a..723341715d 100644 --- a/tools/wasm/module-inspector.cc +++ b/tools/wasm/module-inspector.cc @@ -358,7 +358,7 @@ class ExtendedFunctionDis : public FunctionBodyDisassembler { // e.g.: // 0x01, 0x70, 0x00, // table count 1: funcref no maximum class HexDumpModuleDis; -class DumpingModuleDecoder : public ModuleDecoderBase { +class DumpingModuleDecoder : public ModuleDecoderImpl { public: DumpingModuleDecoder(ModuleWireBytes wire_bytes, HexDumpModuleDis* module_dis); @@ -1054,7 +1054,7 @@ class FormatConverter { DumpingModuleDecoder::DumpingModuleDecoder(ModuleWireBytes wire_bytes, HexDumpModuleDis* module_dis) - : ModuleDecoderBase(WasmFeatures::All(), wire_bytes.module_bytes(), + : ModuleDecoderImpl(WasmFeatures::All(), wire_bytes.module_bytes(), kWasmOrigin, module_dis) {} } // namespace wasm