RFR: 8274527: Minimal VM build fails after JDK-8273459
Jie Fu
jiefu at openjdk.java.net
Thu Sep 30 03:10:30 UTC 2021
On Thu, 30 Sep 2021 01:26:45 GMT, Scott Gibbons <github.com+6704669+asgibbons at openjdk.org> wrote:
> Hi, Jie. With a value of 16 for `CodeEntryAlignment`, there is no way to ensure that the address of the byte following the `align(32)` is, in fact, 32-byte aligned. This is the exact case that I found that caused me to file the bug. I would suggest you verify this with an `assert` following your `align(32)` verifying that the alignment is correct. I think you'll discover that it will be unaligned ~50% of the time.
>
> This is because `align()` uses the **_offset_** from the beginning of the segment to determine the number of `nop`s to emit. If the segment has the starting address 0xXXXXXX10 (16-byte aligned), `align(32)` will calculate the `offset()` and align the pc to a multiple of 32 bytes from this starting address. This means that the address after the `align(32)` has the possibility of being 0xXXXXXX30 about half the time.
>
> I would suggest that if you absolutely require 32-byte alignment, you take a similar path that I took for 64-byte alignment. That is, to create `align32()` and have it call `align(32, pc())`. This will ensure (for stub code) that the alignment is correct.
Ah, you are right.
I missed that align is with the offset() not the pc().
So the assert should make sense.
Updated.
Thanks.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5764
More information about the hotspot-dev
mailing list