mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:48:11 +00:00
LibJS: Generate bytecode in basic blocks instead of one big block
This limits the size of each block (currently set to 1K), and gets us closer to a canonical, more easily analysable bytecode format. As a result of this, "Labels" are now simply entries to basic blocks. Since there is no more 'conditional' jump (as all jumps are always taken), JumpIf{True,False} are unified to JumpConditional, and JumpIfNullish is renamed to JumpNullish. Also fixes #7914 as a result of reimplementing the loop logic.
This commit is contained in:
parent
d7a25cdb82
commit
01e8f0889a
16 changed files with 392 additions and 174 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include "Generator.h"
|
||||
#include <LibJS/Bytecode/Label.h>
|
||||
#include <LibJS/Bytecode/Register.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
@ -28,12 +28,15 @@ public:
|
|||
GlobalObject& global_object() { return m_global_object; }
|
||||
VM& vm() { return m_vm; }
|
||||
|
||||
Value run(Bytecode::Block const&);
|
||||
Value run(Bytecode::ExecutionUnit const&);
|
||||
|
||||
ALWAYS_INLINE Value& accumulator() { return reg(Register::accumulator()); }
|
||||
Value& reg(Register const& r) { return registers()[r.index()]; }
|
||||
|
||||
void jump(Label const& label) { m_pending_jump = label.address(); }
|
||||
void jump(Label const& label)
|
||||
{
|
||||
m_pending_jump = &label.block();
|
||||
}
|
||||
void do_return(Value return_value) { m_return_value = return_value; }
|
||||
|
||||
private:
|
||||
|
@ -42,7 +45,7 @@ private:
|
|||
VM& m_vm;
|
||||
GlobalObject& m_global_object;
|
||||
NonnullOwnPtrVector<RegisterWindow> m_register_windows;
|
||||
Optional<size_t> m_pending_jump;
|
||||
Optional<BasicBlock const*> m_pending_jump;
|
||||
Value m_return_value;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue