mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 18:55:08 +00:00
LibJS: Remove the seal/unseal of Bytecode::Block again
This partially reverts c6ce7c9326
.
The munmap part of that change was good, but we can't seal the blocks
since that breaks NewString and other ops that have String members.
This commit is contained in:
parent
9bed2e4f4a
commit
949ceedaed
2 changed files with 6 additions and 16 deletions
|
@ -28,7 +28,6 @@ Block::Block()
|
||||||
|
|
||||||
Block::~Block()
|
Block::~Block()
|
||||||
{
|
{
|
||||||
unseal();
|
|
||||||
Bytecode::InstructionStreamIterator it(instruction_stream());
|
Bytecode::InstructionStreamIterator it(instruction_stream());
|
||||||
while (!it.at_end()) {
|
while (!it.at_end()) {
|
||||||
auto& to_destroy = (*it);
|
auto& to_destroy = (*it);
|
||||||
|
@ -39,20 +38,12 @@ Block::~Block()
|
||||||
munmap(m_buffer, m_buffer_capacity);
|
munmap(m_buffer, m_buffer_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Block::seal() const
|
void Block::seal()
|
||||||
{
|
{
|
||||||
if (mprotect(m_buffer, m_buffer_capacity, PROT_READ) < 0) {
|
// FIXME: mprotect the instruction stream as PROT_READ
|
||||||
perror("ByteCode::Block::seal: mprotect");
|
// This is currently not possible because instructions can have destructors (that clean up strings)
|
||||||
VERIFY_NOT_REACHED();
|
// Instructions should instead be destructor-less and refer to strings in a string table on the Bytecode::Block.
|
||||||
}
|
// It also doesn't work because instructions that have String members use RefPtr internally which must be in writable memory.
|
||||||
}
|
|
||||||
|
|
||||||
void Block::unseal()
|
|
||||||
{
|
|
||||||
if (mprotect(m_buffer, m_buffer_capacity, PROT_READ | PROT_WRITE) < 0) {
|
|
||||||
perror("ByteCode::Block::unseal: mprotect");
|
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Block::dump() const
|
void Block::dump() const
|
||||||
|
|
|
@ -42,8 +42,7 @@ public:
|
||||||
static NonnullOwnPtr<Block> create();
|
static NonnullOwnPtr<Block> create();
|
||||||
~Block();
|
~Block();
|
||||||
|
|
||||||
void seal() const;
|
void seal();
|
||||||
void unseal();
|
|
||||||
|
|
||||||
void dump() const;
|
void dump() const;
|
||||||
ReadonlyBytes instruction_stream() const { return ReadonlyBytes { m_buffer, m_buffer_size }; }
|
ReadonlyBytes instruction_stream() const { return ReadonlyBytes { m_buffer, m_buffer_size }; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue