mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 22:35:07 +00:00
LibJS: Make basic block size customizable
And keep the default 4 KiB for the code generator.
This commit is contained in:
parent
f7f88adc78
commit
e73b142a97
2 changed files with 7 additions and 6 deletions
|
@ -11,18 +11,18 @@
|
|||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
NonnullOwnPtr<BasicBlock> BasicBlock::create(String name)
|
||||
NonnullOwnPtr<BasicBlock> BasicBlock::create(String name, size_t size)
|
||||
{
|
||||
return adopt_own(*new BasicBlock(move(name)));
|
||||
return adopt_own(*new BasicBlock(move(name), max(size, static_cast<size_t>(4 * KiB))));
|
||||
}
|
||||
|
||||
BasicBlock::BasicBlock(String name)
|
||||
BasicBlock::BasicBlock(String name, size_t size)
|
||||
: m_name(move(name))
|
||||
{
|
||||
// FIXME: This is not the smartest solution ever. Find something cleverer!
|
||||
// The main issue we're working around here is that we don't want pointers into the bytecode stream to become invalidated
|
||||
// during code generation due to dynamic buffer resizing. Otherwise we could just use a Vector.
|
||||
m_buffer_capacity = 4 * KiB;
|
||||
m_buffer_capacity = size;
|
||||
m_buffer = (u8*)mmap(nullptr, m_buffer_capacity, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
|
||||
VERIFY(m_buffer != MAP_FAILED);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue