MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / loadUniversalWASM

Method loadUniversalWASM

lib/loader/ast/module.cpp:214–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214Expect<void> Loader::loadUniversalWASM(AST::Module &Mod) {
215 if (Conf.getRuntimeConfigure().getRunMode() == RunMode::AOT) {
216 auto Exec = std::make_shared<AOTSection>();
217 if (auto Res = Exec->load(Mod.getAOTSection()); unlikely(!Res)) {
218 spdlog::warn("AOT was requested but loading the AOT section failed: "
219 "{}, falling back to interpreter."sv,
220 Res.error());
221 } else {
222 if (loadExecutable(Mod, Exec)) {
223 return {};
224 }
225 spdlog::warn("AOT was requested but linking the AOT executable failed, "
226 "falling back to interpreter."sv);
227 }
228 }
229
230 // Fallback to the interpreter mode case: Re-read the code section.
231 WASMType = InputType::WASM;
232 FMgr.seek(Mod.getCodeSection().getStartOffset());
233 return loadSection(Mod.getCodeSection()).map_error([](auto E) {
234 spdlog::error(ErrInfo::InfoAST(ASTNodeAttr::Module));
235 return E;
236 });
237}
238
239Expect<void> Loader::loadModuleAOT(AST::AOTSection &AOTSection) {
240 // Find and read the AOT custom section first. Jump over the others.

Callers

nothing calls this directly

Calls 7

unlikelyFunction · 0.85
InfoASTClass · 0.85
getRunModeMethod · 0.80
getStartOffsetMethod · 0.80
errorFunction · 0.50
loadMethod · 0.45
seekMethod · 0.45

Tested by

no test coverage detected