Strict long type casting
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Wed Apr 8 14:42:49 UTC 2020
On 07/04/2020 22:30, Ty Young wrote:
>
> On 4/7/20 3:54 PM, Maurizio Cimadamore wrote:
>>
>> On 07/04/2020 20:38, Ty Young wrote:
>>> Question: can the JIT compiler still perform these optimizations if
>>> the VarHandle(s) are stored in a Map so long as the references are
>>> final? Currently(as shown in the code), I'm doing just that to cut
>>> down on the amount of wasted memory on the exact same VarHandle(s)
>>> as I'd otherwise have 60+ instances.
>>
>> I would expect a Map to obfuscate things too much for the JIT. Rather
>> than having a Map, if you care about performances, I'd suggest to
>> just declare all the common (final static) constants you need
>> somewhere - and fetch them from that single place. That's at least
>> how code typically operate with MethodHandle and VarHandle.
>>
>> Even storing them into arrays is not great in the absence of the
>> @Stable annotation (which is only available to JDK code).
>
>
> Thanks for the clarification. Is there any chance for this being done
> on FMA's end?
I don't think we can cache instances e.g. in a map in a way that is
completely transparent to C2; also, caching of VarHandles doesn't happen
for other var handles either. I think here we should follow the lay of
the land - if in the future, some way to reduce VarHandle instances is
added, it should be applied to _all_ var handles, not just memory access
handles.
Maurizio
>
>
>>
>> Maurizio
>>
More information about the panama-dev
mailing list