RFR: 8286636: MacroAssembler::post_call_nop should have InstructionMark
Aleksey Shipilev
shade at openjdk.java.net
Thu May 12 15:13:48 UTC 2022
On Thu, 12 May 2022 11:32:05 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> `InstructionMark` checks the instruction boundaries, which is important for relocatable instructions. Everywhere where we do any (?) sort of relocation, we do `InstructionMark`. I found that newly added `MacroAssembler::post_call_nop` does not have it, and thus some new code in x86_32 Loom prototype fails with missing instruction mark / instruction overlapping checks.
>
> If we add it to `InstructionMark` in AArch64 code, then "overlapping instructions" asserts start to fire, because Loom inserted `post_call_nops` when there was an active instruction mark. x86_64 solves this by [resetting the mark before the nop](https://github.com/openjdk/jdk/blob/40f43c6b1ffc88d55dd3223f5d0259ae73cf0356/src/hotspot/cpu/x86/x86_64.ad#L2084), this patch does the same.
>
> Additional testing:
> - [x] Linux x86_64 fastdebug `tier1`
> - [x] Linux AArch64 fastdebug `tier1`
> Pretty easy, this is what I had in x86_32 and AArch64: we expand the "instruction" through the .ad / macroAssembler, and then circle back to `MacroAssembler::post_call_nop`, which is a relocation-bearing instruction in its own right. `InstructionMark` in `post_call_nop` then rightfully asserts that we are in the middle of emitting another "instruction". AFAICS, this whole thing is an optional check that protects us from calling into `Assembler`/`MacroAssembler` haphazardly.
Oh, and to add to that, on x86_32 another thing also happens: calls to `relocate` [check](https://github.com/openjdk/jdk/blob/1904e9d280d1cce2deead4d4aa39dda1beb9dff1/src/hotspot/share/asm/assembler.hpp#L342-L344) there is an `InstructionMark` in place. So we either relax that assert (dubious), or we do `InstructionMark` everywhere we do `relocate()`. `MacroAssembler::post_call_nop` is a new place with `relocate()` without `InstructionMark`.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8678
More information about the hotspot-dev
mailing list