5 #ifndef V8_WASM_MODULE_DECODER_H_ 6 #define V8_WASM_MODULE_DECODER_H_ 8 #include "src/globals.h" 9 #include "src/wasm/function-body-decoder.h" 10 #include "src/wasm/wasm-constants.h" 11 #include "src/wasm/wasm-features.h" 12 #include "src/wasm/wasm-module.h" 13 #include "src/wasm/wasm-result.h" 22 struct CompilationEnv;
24 inline bool IsValidSectionCode(uint8_t byte) {
25 return kTypeSectionCode <= byte && byte <= kLastKnownModuleSection;
28 const char* SectionName(SectionCode code);
30 typedef Result<std::shared_ptr<WasmModule>> ModuleResult;
31 typedef Result<std::unique_ptr<WasmFunction>> FunctionResult;
32 typedef std::vector<std::pair<int, int>> FunctionOffsets;
33 typedef Result<FunctionOffsets> FunctionOffsetsResult;
37 int source_position_call;
38 int source_position_number_conversion;
40 typedef std::vector<std::vector<AsmJsOffsetEntry>> AsmJsOffsets;
47 : local_index(local_index), name(name) {}
51 int max_local_index = -1;
52 std::vector<LocalName> names;
54 : function_index(function_index) {}
57 int max_function_index = -1;
58 std::vector<LocalNamesPerFunction> names;
64 const byte* module_end,
bool verify_functions, ModuleOrigin origin,
69 V8_EXPORT_PRIVATE
FunctionSig* DecodeWasmSignatureForTesting(
77 const WasmModule* module,
const byte* function_start,
78 const byte* function_end,
Counters* counters);
80 V8_EXPORT_PRIVATE
WasmInitExpr DecodeWasmInitExprForTesting(
81 const WasmFeatures& enabled,
const byte* start,
const byte* end);
89 V8_EXPORT_PRIVATE std::vector<CustomSectionOffset> DecodeCustomSections(
90 const byte* start,
const byte* end);
98 const byte* module_end);
103 void DecodeFunctionNames(
const byte* module_start,
const byte* module_end,
104 std::unordered_map<uint32_t, WireBytesRef>* names);
110 void DecodeLocalNames(
const byte* module_start,
const byte* module_end,
121 ModuleOrigin origin = ModuleOrigin::kWasmOrigin);
126 uint32_t offset,
bool verify_functions =
true);
131 bool verify_functions =
true);
133 ModuleResult FinishDecoding(
bool verify_functions =
true);
135 const std::shared_ptr<WasmModule>& shared_module()
const;
136 WasmModule* module()
const {
return shared_module().get(); }
148 static SectionCode IdentifyUnknownSection(
Decoder& decoder,
const byte* end);
152 std::unique_ptr<ModuleDecoderImpl> impl_;
159 #endif // V8_WASM_MODULE_DECODER_H_