[v8] Where kNoAccessJitLater is used?

52 views
Skip to first unread message

chen chang

unread,
Feb 2, 2024, 3:15:11 AM2/2/24
to v8-dev
What I know or, understand the mechanic:

I know that ARM based Apple Silicon(I call it M1 in following) doesn't allow applications apply RWX memorys, so that v8 flag the codespace with kNoAccessWillJitLater, in which way when calling mmap(), the MAP_JIT bit is set, so that compiler can switch the memory between RW and RX. I try to borrow the method in my own project, so I change the code in v8/src/base/page-allocator.cc:47, where restrict the flag only work in M1 environment.

There are only two places where JitLater is used as param:
v8/src/utils/allocation.cc:221
v8/src/heap/code-range.cc:365
and both of them call page_allocator->AllocatePages()

but PageAllocator is a class with 5 different subclass, since in v8/src/base/page-allocator.cc v8 block the JitLater in not-M1 system(I remove the block, it is not its fault, I also  change the logic where judging access in platform-posix.cc GetFlagsForMemoryPermisson()), I thought it is where the call really goes.
And I write my code in v8/scr/base/platform/platform-posix.cc(I develop in linux), and listen in linux kernel, expecting browser make mmap() request with flag which has MAP_JIT bit, but no answer is got.

Potential answer: the caller is caling with other classes but not subclass  in src/base/page-allocator, but i figure this deeper need lots of time.

Hope someone can help me with this problem, after removing two bypassing about kNoAccessWillJitLater, why cant see my change in kernel log?
P.S. not sys/mman.h and MAP_JIT fault, i test it with fixed bit.

chen chang

unread,
Feb 5, 2024, 3:39:06 AM2/5/24
to v8-dev
Ok after discovering for several days i find out the real working code is not here, but in base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.h, but why there are so much complete logics and code in src/v8 but some logical branch is never reached?
Reply all
Reply to author
Forward
0 new messages