mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibJS/JIT: Consider compilation failed if mprotect(PROT_EXEC) fails
This commit is contained in:
parent
8c745ca223
commit
17657d012f
Notes:
sideshowbarker
2024-07-17 05:21:12 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/17657d012f Pull-request: https://github.com/SerenityOS/serenity/pull/21619 Reviewed-by: https://github.com/Hendiadyoin1
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);
|
||||
if (executable_memory == MAP_FAILED) {
|
||||
perror("mmap");
|
||||
dbgln("mmap: {}", strerror(errno));
|
||||
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());
|
||||
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) {
|
||||
dbgln("\033[32;1mJIT compilation succeeded!\033[0m {}", bytecode_executable.name);
|
||||
|
|
Loading…
Reference in a new issue