mirror of
https://github.com/RGBCube/serenity
synced 2025-07-02 23:02:06 +00:00
LibJS: Use a Vector<u8> for BasicBlock instruction storage
This reduces the minimum size of a basic block from 4 KiB to 0 bytes. With this change, memory usage at the end of Speedometer is 1.2 GiB, down from 1.8 GiB.
This commit is contained in:
parent
89a86798a2
commit
d24e07579f
4 changed files with 20 additions and 67 deletions
|
@ -27,33 +27,28 @@ class BasicBlock {
|
|||
AK_MAKE_NONCOPYABLE(BasicBlock);
|
||||
|
||||
public:
|
||||
static NonnullOwnPtr<BasicBlock> create(DeprecatedString name, size_t size = 4 * KiB);
|
||||
static NonnullOwnPtr<BasicBlock> create(DeprecatedString name);
|
||||
~BasicBlock();
|
||||
|
||||
void seal();
|
||||
|
||||
void dump(Executable const&) const;
|
||||
ReadonlyBytes instruction_stream() const { return ReadonlyBytes { m_buffer, m_buffer_size }; }
|
||||
size_t size() const { return m_buffer_size; }
|
||||
ReadonlyBytes instruction_stream() const { return m_buffer.span(); }
|
||||
u8* data() { return m_buffer.data(); }
|
||||
u8 const* data() const { return m_buffer.data(); }
|
||||
size_t size() const { return m_buffer.size(); }
|
||||
|
||||
void* next_slot() { return m_buffer + m_buffer_size; }
|
||||
bool can_grow(size_t additional_size) const { return m_buffer_size + additional_size <= m_buffer_capacity; }
|
||||
void grow(size_t additional_size);
|
||||
|
||||
void terminate(Badge<Generator>, Instruction const* terminator) { m_terminator = terminator; }
|
||||
bool is_terminated() const { return m_terminator != nullptr; }
|
||||
Instruction const* terminator() const { return m_terminator; }
|
||||
void terminate(Badge<Generator>) { m_terminated = true; }
|
||||
bool is_terminated() const { return m_terminated; }
|
||||
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
|
||||
private:
|
||||
BasicBlock(DeprecatedString name, size_t size);
|
||||
explicit BasicBlock(DeprecatedString name);
|
||||
|
||||
u8* m_buffer { nullptr };
|
||||
Instruction const* m_terminator { nullptr };
|
||||
size_t m_buffer_capacity { 0 };
|
||||
size_t m_buffer_size { 0 };
|
||||
Vector<u8> m_buffer;
|
||||
DeprecatedString m_name;
|
||||
bool m_terminated { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue