LibWasm: Avoid frequent re/deallocations while validating expressions

Freeing and reallocating these vectors was ~6% of runtime when
validating some web-based game.
This commit is contained in:
Ali Mohammad Pur 2025-09-09 15:22:36 +02:00 committed by Ali Mohammad Pur
parent 80e5356853
commit c0223befe1
2 changed files with 9 additions and 7 deletions

View File

@ -622,7 +622,7 @@ public:
private:
ModuleInstance const& m_module;
Vector<Value> m_locals;
Vector<Value, 8> m_locals;
Expression const& m_expression;
size_t m_arity { 0 };
size_t m_label_index { 0 };

View File

@ -206,7 +206,9 @@ public:
friend struct AK::Formatter;
public:
explicit Stack(Vector<Frame> const& frames)
explicit Stack(Vector<Frame, 16>&&) = delete;
explicit Stack(Vector<Frame, 16> const& frames)
: m_frames(frames)
{
}
@ -261,17 +263,17 @@ public:
return {};
}
Vector<StackEntry> release_vector()
Vector<StackEntry, 8> release_vector()
{
m_max_known_size = 0;
return exchange(m_entries, Vector<StackEntry> {});
return exchange(m_entries, {});
}
size_t max_known_size() const { return m_max_known_size; }
private:
Vector<StackEntry> m_entries;
Vector<Frame> const& m_frames;
Vector<StackEntry, 8> m_entries;
Vector<Frame, 16> const& m_frames;
size_t m_max_known_size { 0 };
};
@ -360,7 +362,7 @@ private:
};
Context m_context;
Vector<Frame> m_frames;
Vector<Frame, 16> m_frames;
size_t m_max_frame_size { 0 };
COWVector<GlobalType> m_globals_without_internal_globals;
};