1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

LibJS: Make basic block size customizable

And keep the default 4 KiB for the code generator.
This commit is contained in:
Ali Mohammad Pur 2021-06-12 20:36:39 +04:30 committed by Ali Mohammad Pur
parent f7f88adc78
commit e73b142a97
2 changed files with 7 additions and 6 deletions

View file

@ -47,13 +47,14 @@ class BasicBlock {
AK_MAKE_NONCOPYABLE(BasicBlock);
public:
static NonnullOwnPtr<BasicBlock> create(String name);
static NonnullOwnPtr<BasicBlock> create(String name, size_t size = 4 * KiB);
~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; }
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; }
@ -65,7 +66,7 @@ public:
String const& name() const { return m_name; }
private:
BasicBlock(String name);
BasicBlock(String name, size_t size);
u8* m_buffer { nullptr };
size_t m_buffer_capacity { 0 };