mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 08:35:09 +00:00
LibJS: Add bytecode instruction handles
This change removes the mmap inside of Block in favor of a growing vector of bytes. This is favorable for two reasons: - We don't take more space than we need - There is no limit to the growth of the vector (previously, if the Block overstepped its 64kb boundary, it would just crash) However, if that vector happens to resize, any pointer pointing into that vector would become invalid. To avoid this, this commit adds an InstructionHandle<Op> class which just stores a block and an offset into that block.
This commit is contained in:
parent
83be39c91a
commit
a01bd35c67
8 changed files with 81 additions and 79 deletions
|
@ -10,7 +10,6 @@
|
|||
#include <LibJS/Bytecode/Generator.h>
|
||||
#include <LibJS/Bytecode/Instruction.h>
|
||||
#include <LibJS/Bytecode/Register.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
|
@ -28,20 +27,9 @@ OwnPtr<Block> Generator::generate(ASTNode const& node)
|
|||
Generator generator;
|
||||
node.generate_bytecode(generator);
|
||||
generator.m_block->set_register_count({}, generator.m_next_register);
|
||||
generator.m_block->seal();
|
||||
return move(generator.m_block);
|
||||
}
|
||||
|
||||
void Generator::grow(size_t additional_size)
|
||||
{
|
||||
m_block->grow(additional_size);
|
||||
}
|
||||
|
||||
void* Generator::next_slot()
|
||||
{
|
||||
return m_block->next_slot();
|
||||
}
|
||||
|
||||
Register Generator::allocate_register()
|
||||
{
|
||||
VERIFY(m_next_register != NumericLimits<u32>::max());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue