diff options
author | Andreas Kling <kling@serenityos.org> | 2021-06-08 21:39:50 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-08 21:39:50 +0200 |
commit | 949ceedaedbe271d347669d3a189580e16b420e4 (patch) | |
tree | 06698420a31b474521b41b50c1a4b283080e738b /Userland/Libraries | |
parent | 9bed2e4f4a90ce2d82d8f6122db2d0cfbad48b49 (diff) | |
download | serenity-949ceedaedbe271d347669d3a189580e16b420e4.zip |
LibJS: Remove the seal/unseal of Bytecode::Block again
This partially reverts c6ce7c9326f8e745e29ede503ea011f10c76fc5f.
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.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Block.cpp | 19 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Block.h | 3 |
2 files changed, 6 insertions, 16 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Block.cpp b/Userland/Libraries/LibJS/Bytecode/Block.cpp index 28d042b21d..ef0add31a1 100644 --- a/Userland/Libraries/LibJS/Bytecode/Block.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Block.cpp @@ -28,7 +28,6 @@ Block::Block() Block::~Block() { - unseal(); Bytecode::InstructionStreamIterator it(instruction_stream()); while (!it.at_end()) { auto& to_destroy = (*it); @@ -39,20 +38,12 @@ Block::~Block() munmap(m_buffer, m_buffer_capacity); } -void Block::seal() const +void Block::seal() { - if (mprotect(m_buffer, m_buffer_capacity, PROT_READ) < 0) { - perror("ByteCode::Block::seal: mprotect"); - VERIFY_NOT_REACHED(); - } -} - -void Block::unseal() -{ - if (mprotect(m_buffer, m_buffer_capacity, PROT_READ | PROT_WRITE) < 0) { - perror("ByteCode::Block::unseal: mprotect"); - VERIFY_NOT_REACHED(); - } + // FIXME: mprotect the instruction stream as PROT_READ + // This is currently not possible because instructions can have destructors (that clean up strings) + // 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::dump() const diff --git a/Userland/Libraries/LibJS/Bytecode/Block.h b/Userland/Libraries/LibJS/Bytecode/Block.h index 2c45cb2db5..4e81d2b1d3 100644 --- a/Userland/Libraries/LibJS/Bytecode/Block.h +++ b/Userland/Libraries/LibJS/Bytecode/Block.h @@ -42,8 +42,7 @@ public: static NonnullOwnPtr<Block> create(); ~Block(); - void seal() const; - void unseal(); + void seal(); void dump() const; ReadonlyBytes instruction_stream() const { return ReadonlyBytes { m_buffer, m_buffer_size }; } |