mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
LibWasm: Make Frame a value type as well
This means stack operations will no longer do extra allocations.
This commit is contained in:
parent
73eb0785e0
commit
bc936a5fac
6 changed files with 53 additions and 54 deletions
|
@ -18,14 +18,15 @@ public:
|
|||
}
|
||||
|
||||
Optional<Label> nth_label(size_t);
|
||||
void set_frame(NonnullOwnPtr<Frame> frame)
|
||||
void set_frame(Frame&& frame)
|
||||
{
|
||||
m_current_frame = frame.ptr();
|
||||
m_current_frame_index = m_stack.size();
|
||||
Label label(frame.arity(), frame.expression().instructions().size());
|
||||
m_stack.push(move(frame));
|
||||
m_stack.push(Label(m_current_frame->arity(), m_current_frame->expression().instructions().size()));
|
||||
m_stack.push(label);
|
||||
}
|
||||
auto& frame() const { return m_current_frame; }
|
||||
auto& frame() { return m_current_frame; }
|
||||
auto& frame() const { return m_stack.entries()[m_current_frame_index].get<Frame>(); }
|
||||
auto& frame() { return m_stack.entries()[m_current_frame_index].get<Frame>(); }
|
||||
auto& ip() const { return m_ip; }
|
||||
auto& ip() { return m_ip; }
|
||||
auto& depth() const { return m_depth; }
|
||||
|
@ -45,7 +46,7 @@ public:
|
|||
|
||||
private:
|
||||
Store& m_store;
|
||||
Frame* m_current_frame { nullptr };
|
||||
size_t m_current_frame_index { 0 };
|
||||
Stack m_stack;
|
||||
size_t m_depth { 0 };
|
||||
InstructionPointer m_ip;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue