[Vm-dev] Is it important to fill identity-hash for Floats?

Chris Muller asqueaker at gmail.com
Tue Jul 30 21:37:36 UTC 2013

On Mon, Jul 29, 2013 at 5:23 PM, Bert Freudenberg <bert at freudenbergs.de> wrote:
> On 2013-07-29, at 23:59, Igor Stasenko <siguctua at gmail.com> wrote:
>> just a thought..
>> imo using identity hash field for instances of Float while probable,
>> but in fact really impractical.
>> in that sense, what you think about removing filling the identity hash field
>> and leave it always == 0.. saving some instructions to make float
>> allocation a bit faster?
>> i am talking about
>> genAllocFloatValue: dpreg into: resultReg scratchReg: scratch1
>> scratchReg: scratch2
> IMHO, turning Floats into the only objects in the system that cause severe collisions in IdentitySets / Dictionaries should not be done lightly. It's a step away from "every object is equal" which I think is an important principle.

+1.  I recently was investigating memory consumption in a large
application image and discovered > 100MB in Float instances..!!  But
guess what, many many of them were the same number (0.0, 1.0, 100.0,
-100.0, and several others had many occurrences) -- prompting me to
wonder whether I should try to canonicalize them upon materialization,
via an IdentityDictionary..

I haven't tried it yet but.. if their identityHash'es were all 0 then
it'd be pointless to try.

So I like your other idea about using the float itself as the
identityHash, however that would be done, at least they'd be unique
and consistent.

More information about the Vm-dev mailing list