mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-03 04:52:06 +02:00
LibJS/Bytecode: Store labels as basic block index during compilation
Instead of storing a BasicBlock* and forcing the size of Label to be sizeof(BasicBlock*), we now store the basic block index as a u32. This means the final version of the bytecode is able to keep labels at sizeof(u32), shrinking the size of many instructions. :^)
This commit is contained in:
Notes:
sideshowbarker
2024-07-16 21:42:29 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/3a73eb99ac Pull-request: https://github.com/SerenityOS/serenity/pull/24240 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/trflynn89 ✅
@@ -25,9 +25,11 @@ class BasicBlock {
|
||||
AK_MAKE_NONCOPYABLE(BasicBlock);
|
||||
|
||||
public:
|
||||
static NonnullOwnPtr<BasicBlock> create(String name);
|
||||
static NonnullOwnPtr<BasicBlock> create(u32 index, String name);
|
||||
~BasicBlock();
|
||||
|
||||
u32 index() const { return m_index; }
|
||||
|
||||
ReadonlyBytes instruction_stream() const { return m_buffer.span(); }
|
||||
u8* data() { return m_buffer.data(); }
|
||||
u8 const* data() const { return m_buffer.data(); }
|
||||
@@ -50,8 +52,9 @@ public:
|
||||
void add_source_map_entry(size_t bytecode_offset, SourceRecord const& source_record) { m_source_map.set(bytecode_offset, source_record); }
|
||||
|
||||
private:
|
||||
explicit BasicBlock(String name);
|
||||
explicit BasicBlock(u32 index, String name);
|
||||
|
||||
u32 m_index { 0 };
|
||||
Vector<u8> m_buffer;
|
||||
BasicBlock const* m_handler { nullptr };
|
||||
BasicBlock const* m_finalizer { nullptr };
|
||||
|
||||
Reference in New Issue
Block a user