Commit 7beb93cd authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[rwx][mac] Fix jitless mode

In some cases we were still trying to change permissions of RWX pages
which is not allowed.

Bug: v8:12797
Change-Id: I9f4ca319d842c524fc6f60bfd3bb3726f8d3029d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3635719
Auto-Submit: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80442}
parent 9a6a76bf
......@@ -131,7 +131,8 @@ bool CodeRange::InitReservation(v8::PageAllocator* page_allocator,
params.page_size = MemoryChunk::kPageSize;
params.requested_start_hint =
GetCodeRangeAddressHint()->GetAddressHint(requested, allocate_page_size);
params.jit = JitPermission::kMapAsJittable;
params.jit =
FLAG_jitless ? JitPermission::kNoJit : JitPermission::kMapAsJittable;
if (!VirtualMemoryCage::InitReservation(params)) return false;
......
......@@ -163,21 +163,23 @@ TEST(MemoryChunk) {
v8::PageAllocator* page_allocator = GetPlatformPageAllocator();
size_t area_size;
bool jitless = isolate->jitless();
for (int i = 0; i < 100; i++) {
area_size =
RoundUp(PseudorandomAreaSize(), page_allocator->CommitPageSize());
// With CodeRange.
const size_t code_range_size = 32 * MB;
VirtualMemory code_range_reservation(page_allocator, code_range_size,
nullptr, MemoryChunk::kAlignment,
JitPermission::kMapAsJittable);
VirtualMemory code_range_reservation(
page_allocator, code_range_size, nullptr, MemoryChunk::kAlignment,
jitless ? JitPermission::kNoJit : JitPermission::kMapAsJittable);
base::PageFreeingMode page_freeing_mode =
base::PageFreeingMode::kMakeInaccessible;
// On MacOS on ARM64 the code range reservation must be committed as RWX.
if (V8_HEAP_USE_PTHREAD_JIT_WRITE_PROTECT) {
if (V8_HEAP_USE_PTHREAD_JIT_WRITE_PROTECT && !jitless) {
page_freeing_mode = base::PageFreeingMode::kDiscard;
void* base = reinterpret_cast<void*>(code_range_reservation.address());
CHECK(page_allocator->SetPermissions(base, code_range_size,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment