On Fri, 6 Mar 2026 04:30:26 GMT, Chen Liang <[email protected]> wrote:
>> Hi, >> >> Reflective construction of value object triggers assert in C2 because it >> does not follow the normal object construction pattern and is technically UB >> because we try to return a larval object from a method. I was told that this >> is required for the construction of hidden classes, but to me it seems like >> we put those restrictions on ourselves and shoot ourselves in the foot by >> using these `Unsafe` hacks. >> >> This PR tries to fix this issue by letting the compiler know of these >> methods which can return or accept larval objects. Note that this is pretty >> fragile, and seemingly harmless changes to the code shape generated by the >> `MethodHandle` mechanism can break it, which is a usual symptom of undefined >> behaviour. >> >> Please take a look and leave your review, thanks a lot. > > The recognition of "may be larval" seems sufficient. Is it okay if it > recognizes non-larval calls like invokespecial on private methods as "may be > larval"? Would that create potential regressions? @liach I think it is okay, values are scalarized when they are pushed onto the stack, so when we invoke a call, the arguments are scalarized already. In addition, `linkToSpecial` is a link method, that means what we inline/call is often the target of the link, not the link itself. ------------- PR Comment: https://git.openjdk.org/valhalla/pull/2204#issuecomment-4009540177
