RFC (round 1), JEP draft: Low-level Object layout introspection methods
Aleksey Shipilev
shade at redhat.com
Wed Aug 26 05:31:39 UTC 2020
On 8/25/20 7:54 PM, Florian Weimer wrote:
>>> Are there JVMs out there where naive implementation of deepSizeOf
>>> (with something like IdentityHashMap in the background) would itself
>>> change object layout and sizes?
>>>
>>> A theoretical implementation of System.identityHashCode() might
>>> allocate a word for the identity hash only after the method has been
>>> applied to the object and the object has been moved.
>>
>> yes, i believe IBM OpenJ9 use/used this exact trick.
>> I remember reading a paper about that.
>
> Is this an argument for or against providing an interface like
> deepSizeOf? 8-)
Au contraire: since interaction with IHC is runtime-specific, it should be in the hands of internal
API to figure out the answer. That is, if Hotspot ever implements off-band identity hash code, then
it would be a good time to switch the deepSizeOf internals to either avoid IdentityHashSet by doing
something else, or accept the interaction whole-sale. This would be an awkward thing to do in a 3rd
party library that does not need detecting and handling even more VM quirks.
--
Thanks,
-Aleksey
More information about the jdk-dev
mailing list