RFR: 8335662: [AArch64] C1: guarantee(val < (1ULL << nbits)) failed: Field too big for insn [v2]
Evgeny Astigeevich
eastigeevich at openjdk.org
Wed Nov 20 14:55:25 UTC 2024
On Tue, 15 Oct 2024 19:32:27 GMT, Andrew Haley <aph at openjdk.org> wrote:
> One thing for you to think about if you are interested in some further work in this area..
>
> This is a generic problem. It might be very beneficial to look for every base + immediate offset instruction, see if there is a possibility that there may be an overflow, and insert a `form_address()`.
Hi @theRealAph,
https://bugs.openjdk.org/browse/JDK-8342736
We found there are around ~400 ldr calls and ~180 str calls that would need to be manually updated.
I found that we use offsets in C++ classes a lot:
$ cpu/aarch64 % grep _offset() *.* | grep ldr | wc -l
250
$ cpu/aarch64 % grep _offset() *.* | grep str | wc -l
94
$ cpu/aarch64 % grep _offset() *.* | grep lea | wc -l
27
IMO, we can use `static_assert` for them. The problem is that the macro `offset_of` is not `constexpr`. Making it `constexpr` is not simple. The standard macro `offsetof` requires classes to have the standard layout. Most of our classes don't have the standard layout. We'll get warnings about this. As you wrote in the macro comments, we can disable warnings.
I think we can have something like this:
ldr(dst, Address(rmethod, create_mem_op_imm(Method, const_offset)));
#define create_mem_op_imm(klass, field_offset_func) \
([]() { \
constexpr max_possible_offset = sizeof(klass);
static_assert(Address::offset_ok_for_immed(max_possible_offset, 0)); \
return klass::field_offset_func(); \
}())
If the size of a class fits into a memory instructions then any offset in it will fit. Class sizes greater than 32760 look insane to me.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21473#issuecomment-2488792792
More information about the hotspot-compiler-dev
mailing list