mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibJS/JIT: Consider compilation failed if mprotect(PROT_EXEC) fails
This commit is contained in:
parent
8c745ca223
commit
17657d012f
1 changed files with 6 additions and 2 deletions
|
@ -958,7 +958,7 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
||||||
|
|
||||||
auto* executable_memory = mmap(nullptr, compiler.m_output.size(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
|
auto* executable_memory = mmap(nullptr, compiler.m_output.size(), PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
|
||||||
if (executable_memory == MAP_FAILED) {
|
if (executable_memory == MAP_FAILED) {
|
||||||
perror("mmap");
|
dbgln("mmap: {}", strerror(errno));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,7 +986,11 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(executable_memory, compiler.m_output.data(), compiler.m_output.size());
|
memcpy(executable_memory, compiler.m_output.data(), compiler.m_output.size());
|
||||||
mprotect(executable_memory, compiler.m_output.size(), PROT_READ | PROT_EXEC);
|
|
||||||
|
if (mprotect(executable_memory, compiler.m_output.size(), PROT_READ | PROT_EXEC) < 0) {
|
||||||
|
dbgln("mprotect: {}", strerror(errno));
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if constexpr (LOG_JIT_SUCCESS) {
|
if constexpr (LOG_JIT_SUCCESS) {
|
||||||
dbgln("\033[32;1mJIT compilation succeeded!\033[0m {}", bytecode_executable.name);
|
dbgln("\033[32;1mJIT compilation succeeded!\033[0m {}", bytecode_executable.name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue