RFR: 8276563: Undefined Behaviour in class Assembler
Jorn Vernee
jvernee at openjdk.java.net
Sat Nov 6 17:42:33 UTC 2021
On Sat, 6 Nov 2021 17:15:15 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> > It's not clear to me why `Register` is implemented as a pointer in the first place, instead of a class with a single `int` or `intptr_t` field for the encoding. There is a comment about that in register.hpp, but it doesn't offer an explanation:
>
> I believe the point is to encode the register number in the `this` pointer. If it were a member, you'd have to dereference the pointer to access the member value, so one more load instruction.
Yes, if we would keep using pointers we'd get a dereference, but I'm saying: let's get rid of the pointers and use straight up values. No dereferences. AFAIU compilers would treat this the same as the current scheme.
Or, perhaps even better: I've seen compiler constant folding be perturbed in the past by integer <-> pointer casts (I guess it just bails out in some cases), and also, using an `int` would halve the footprint of arrays of registers on platforms where pointers are 64-bits.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6280
More information about the hotspot-compiler-dev
mailing list