RFR: 8328306: AArch64: MacOS lazy JIT "write xor execute" switching [v4]

Andrew Haley aph at openjdk.org
Thu Aug 21 17:38:55 UTC 2025


On Thu, 21 Aug 2025 00:27:48 GMT, David Holmes <dholmes at openjdk.org> wrote:

> My concern is that if we have code that needs a specific mode, but it is not obvious at that piece of code that this is the case, then things will work fine if somewhere on the path to that code we set the right mode.

The places where transition markers are placed may appear arbitrary, but that's not so.

The process for determining the right place to put them goes as follows:

Find a point where there is a write into the code cache which causes a trap. In the control-flow graph, this is a node in the dominator tree.
Walk up the dominator tree (i.e. walk up the stack in GDB) towards the root until you find the highest node _N_ such that the majority of nodes dominated by _N_ also write into the code cache. Place a write-enable marker at the start of the function.
Repeat this process until there are no more traps.

 "The majority" is a judgement call, but it's not difficult in most cases. For example, any function constructing an instance of `Assembler` is almost certain to dominate a write to the code cache, and likewise any function that patches code. 

While this process doesn't guarantee an optimal solution, in practice it works pretty well, and removes 99% of W^X mode switches.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/26562#issuecomment-3211520068


More information about the hotspot-dev mailing list