Skip to content

Commit

Permalink
Merge pull request #1455 from AntelopeIO/leap_parsing_wasm_once_for_jit
Browse files Browse the repository at this point in the history
Update Leap to parse WASM code only once for JIT
  • Loading branch information
linh2931 authored Aug 7, 2023
2 parents 47db353 + 7ec713f commit 2491418
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions libraries/chain/webassembly/runtimes/eos-vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,12 @@ std::unique_ptr<wasm_instantiated_module_interface> eos_vm_runtime<Impl>::instan
wasm_code_ptr code((uint8_t*)code_bytes, code_size);
apply_options options = { .max_pages = 65536,
.max_call_depth = 0 };
std::unique_ptr<backend_t> bkend = std::make_unique<backend_t>(code, code_size, nullptr, options, false); // uses 2-passes parsing
std::unique_ptr<backend_t> bkend = nullptr;
if constexpr (std::is_same_v<Impl, eosio::vm::jit>) {
bkend = std::make_unique<backend_t>(code, code_size, nullptr, options, true); // true -- JIT uses single parsing
} else {
bkend = std::make_unique<backend_t>(code, code_size, nullptr, options, false); // false -- Interpreter uses 2-passes parsing
}
eos_vm_host_functions_t::resolve(bkend->get_module());
return std::make_unique<eos_vm_instantiated_module<Impl>>(this, std::move(bkend));
} catch(eosio::vm::exception& e) {
Expand All @@ -260,7 +265,7 @@ std::unique_ptr<wasm_instantiated_module_interface> eos_vm_profile_runtime::inst
wasm_code_ptr code((uint8_t*)code_bytes, code_size);
apply_options options = { .max_pages = 65536,
.max_call_depth = 0 };
std::unique_ptr<backend_t> bkend = std::make_unique<backend_t>(code, code_size, nullptr, options, false); // uses 2-passes parsing
std::unique_ptr<backend_t> bkend = std::make_unique<backend_t>(code, code_size, nullptr, options, true); // true -- JIT uses single parsing
eos_vm_host_functions_t::resolve(bkend->get_module());
return std::make_unique<eos_vm_profiling_module>(std::move(bkend), code_bytes, code_size);
} catch(eosio::vm::exception& e) {
Expand Down

0 comments on commit 2491418

Please sign in to comment.