RFR: 8344880: AArch64: Add compile time check for class offsets

Andrew Haley aph at openjdk.org
Fri Dec 13 15:32:39 UTC 2024


On Fri, 6 Dec 2024 23:57:41 GMT, Chad Rakoczy <duke at openjdk.org> wrote:

> [JDK-8344880](https://bugs.openjdk.org/browse/JDK-8344880)
> 
> Adds compile time checks for str/ldr instructions to verify that the immediate offset will fit. This adds static_assert for constant offsets that are checked at compile time. The macro offset_of is not constexpr so instead the class size is checked. If the size of a class fits into a memory instructions then any offset in it will fit.

We could instead add a few static_asserts that the size of a native structure which is accessed by the runtime code (there are not many of these, and we know what they are) is less than an `ldr`/`str` will reach. It's a simple-enough thing to do, and such a change has a much smaller blast radius than this PR would have.
It really would be useful to make sure we can generate correct code for variable-sized field offsets, as is the case for Java statics at some offset from the Klass base. C2 is already fine, C1 might need a few more calls to `form_address()`.

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

PR Comment: https://git.openjdk.org/jdk/pull/22623#issuecomment-2541704444


More information about the shenandoah-dev mailing list