mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibJS/Bytecode: Flatten bytecode to a contiguous representation
Instead of keeping bytecode as a set of disjoint basic blocks on the
malloc heap, bytecode is now a contiguous sequence of bytes(!)
The transformation happens at the end of Bytecode::Generator::generate()
and the only really hairy part is rerouting jump labels.
This required solving a few problems:
- The interpreter execution loop had to change quite a bit, since we
were storing BasicBlock pointers all over the place, and control
transfer was done by redirecting the interpreter's current block.
- Exception handlers & finalizers are now stored per-bytecode-range
in a side table in Executable.
- The interpreter now has a plain program counter instead of a stream
iterator. This actually makes error stack generation a bit nicer
since we just have to deal with a number instead of reaching into
the iterator.
This yields a 25% performance improvement on this microbenchmark:
for (let i = 0; i < 1_000_000; ++i) { }
But basically everything gets faster. :^)
This commit is contained in:
@@ -27,7 +27,6 @@ public:
|
||||
static NonnullOwnPtr<BasicBlock> create(String name);
|
||||
~BasicBlock();
|
||||
|
||||
void dump(Executable const&) const;
|
||||
ReadonlyBytes instruction_stream() const { return m_buffer.span(); }
|
||||
u8* data() { return m_buffer.data(); }
|
||||
u8 const* data() const { return m_buffer.data(); }
|
||||
|
||||
Reference in New Issue
Block a user