@@ -271,14 +271,16 @@ FrontendCompiler::FrontendCompiler(Config const &config)
271
271
if (config.ascWasmPath ) [[unlikely]] {
272
272
support::PerfRAII const r{support::PerfItemKind::CompilationHIR_PrepareWASMModule};
273
273
std::string const wasmBytes = readBinaryFile (*config.ascWasmPath );
274
- m.initFromBytecode (
275
- vb::Span<const uint8_t >{reinterpret_cast <uint8_t const *>(wasmBytes.data ()), wasmBytes.size ()},
276
- vb::Span<vb::NativeSymbol const >{warpo::frontend::linkedAPI.data (), warpo::frontend::linkedAPI.size ()}, true );
274
+ m.initFromBytecode (vb::Span<const uint8_t >{reinterpret_cast <uint8_t const *>(wasmBytes.data ()), wasmBytes.size ()},
275
+ vb::Span<vb::NativeSymbol const >{warpo::frontend::getLinkedAPI ().data (),
276
+ warpo::frontend::getLinkedAPI ().size ()},
277
+ true );
277
278
} else {
278
279
support::PerfRAII const r{support::PerfItemKind::CompilationHIR_PrepareWASMModule};
279
- static vb::WasmModule::CompileResult const embedJitCode = m.compile (
280
- vb::Span<const uint8_t >{embed_asc_wasm.data (), embed_asc_wasm.size ()},
281
- vb::Span<vb::NativeSymbol const >{warpo::frontend::linkedAPI.data (), warpo::frontend::linkedAPI.size ()});
280
+ static vb::WasmModule::CompileResult const embedJitCode =
281
+ m.compile (vb::Span<const uint8_t >{embed_asc_wasm.data (), embed_asc_wasm.size ()},
282
+ vb::Span<vb::NativeSymbol const >{warpo::frontend::getLinkedAPI ().data (),
283
+ warpo::frontend::getLinkedAPI ().size ()});
282
284
m.initFromCompiledBinary (
283
285
vb::Span<uint8_t const >{embedJitCode.getModule ().data (), embedJitCode.getModule ().size ()},
284
286
vb::Span<vb::NativeSymbol const >{},
@@ -365,10 +367,10 @@ warpo::frontend::CompilationResult FrontendCompiler::compile(std::vector<std::st
365
367
int32_t const compiled = m.callExportedFunctionWithName <1 >(stackTop, " compile" , program)[0 ].i32 ;
366
368
if (checkDiag (program, config.useColorfulDiagMessage ))
367
369
return {.m = {}, .errorMessage = errorMessage_};
368
- wasm::Module *binaryen_module = reinterpret_cast <wasm::Module *>(
369
- m.callExportedFunctionWithName <1 >(stackTop, " getBinaryenModuleRef" , compiled)[0 ].i64 );
370
+ asModule_. set (BinaryenModule{ reinterpret_cast <wasm::Module *>(
371
+ m.callExportedFunctionWithName <1 >(stackTop, " getBinaryenModuleRef" , compiled)[0 ].i64 )}) ;
370
372
compileStat.release ();
371
- return {.m = AsModule{binaryen_module} , .errorMessage = errorMessage_};
373
+ return {.m = std::move (asModule_) , .errorMessage = errorMessage_};
372
374
} catch (vb::TrapException const &e) {
373
375
logger << " Error: " << e.what () << vb::endStatement;
374
376
m.printStacktrace (logger);
0 commit comments