RFR: 8261137: Optimization of Box nodes in uncommon_trap [v4]
Vladimir Kozlov
kvn at openjdk.java.net
Wed Feb 10 23:21:43 UTC 2021
On Wed, 10 Feb 2021 21:26:17 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
> The improvement you are proposing is not specific to uncommon traps, but can be generalized to any debug usage at safepoints.
>
> The downside is that, in general, rematerialization logic has to use the corresponding pure function in order to materialize the eliminated instance. In this particular case (primitive boxing), it has to take into account the caching effects of primitive box factories. Otherwise, user code can encounter identity paradoxes with rematerialized primitive box instances.
>
> I don't see how the scalarization logic you propose preserves identity constraints imposed by `valueOf` factories.
Yes, it seems this optimization introduces the issue we had with Graal (8223320):
"C2 doesn't model Integer.valueOf() as anything special. It just inlines it. So the check that determines whether to allocate a new Integer or take one from the cache always happens at runtime. Graal models it as a BoxNode. It is correctly lowered, however, if it needs to be present in a JVM state, it is described as an allocation. So the decision whether to allocate or take the cached value has to happen during the deopt."
There is code in deoptimizer for JVMCI which looks for cached Boxed values. We may need to adopt it for C2 EA for this optimization to work.
-------------
PR: https://git.openjdk.java.net/jdk/pull/2401
More information about the hotspot-compiler-dev
mailing list