RFR: 8289060: Undefined Behaviour in class VMReg

Jorn Vernee jvernee at openjdk.org
Mon Jun 27 13:09:42 UTC 2022


On Fri, 24 Jun 2022 13:58:29 GMT, Andrew Haley <aph at openjdk.org> wrote:

> We could instead make `VMReg` instances objects with a single numeric field rather than pointers, but some C++ compilers pass all such objects by reference, so I don't think we should.

I've been thinking about this some more after you fixed the same issue for `Register` on AArch64 [1]. I think the issue is out-of-line calls to member functions. Since `this` is a pointer, the compiler is forced to spill the value on the stack to comply with the ABI. i.e. what we'd really want is some way to say "pass `this` by value". (On x64 Windows, as long as a struct fits in a register, it is not passed by reference).

To avoid that, I think we could theoretically convert every member function to a static function that takes a `VMReg` as it's first argument. That's _an_ option, but not a very nice one... (just mentioning it for the record).

[1] : https://urldefense.com/v3/__https://github.com/openjdk/jdk/pull/6280*issuecomment-964069801__;Iw!!ACWV5N9M2RV99hQ!LcK6oiVlpFwjMC7na7Jv1Cr_ZsLCknDBWRAKpwLEUjhMCUqmffnGzXsausrVHVcKnEDldQOuHUladpWofy0FN8IZDHUqwOw$ 

---

I think the patch looks good overall, but it looks like there are some failures in some of the SA tests.

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

PR: https://git.openjdk.org/jdk/pull/9276


More information about the hotspot-compiler-dev mailing list