1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

LibWasm: Use the current configuration to run call ops

This should make it easier to implement multiple types of interpreters
on top of a configuration, and also give a small speed boost in not
initialising as many Stack objects.
This commit is contained in:
Ali Mohammad Pur 2021-05-24 01:28:02 +04:30 committed by Ali Mohammad Pur
parent b2bd5132c4
commit f91fa79fc5
3 changed files with 40 additions and 5 deletions

View file

@ -22,6 +22,16 @@ Optional<Label> Configuration::nth_label(size_t i)
return {};
}
void Configuration::unwind(Badge<CallFrameHandle>, const CallFrameHandle& frame_handle)
{
VERIFY(m_stack.size() > frame_handle.stack_size);
m_stack.entries().remove(frame_handle.stack_size, m_stack.size() - frame_handle.stack_size);
m_current_frame_index = frame_handle.frame_index;
m_depth--;
m_ip = frame_handle.ip;
VERIFY(m_stack.size() == frame_handle.stack_size);
}
Result Configuration::call(FunctionAddress address, Vector<Value> arguments)
{
auto* function = m_store.get(address);
@ -41,6 +51,7 @@ Result Configuration::call(FunctionAddress address, Vector<Value> arguments)
wasm_function->code().body(),
wasm_function->type().results().size(),
});
m_ip = 0;
return execute();
}