[Mono-list] mcs compiles on linux. Now what?

Serge serge@wildwestsoftware.com
Fri, 8 Mar 2002 18:25:52 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_001D_01C1C6CE.ADB57EC0
Content-Type: text/plain;
	charset="koi8-r"
Content-Transfer-Encoding: 7bit

Some follow-up.
It seems that .NET GetHashCode is implemented in a very similar manner to
ORP.
See the attached program. The code is unnecessary complex, it's just because
I already had similar code, simply changed it for this demo.
The code obtains object handles as they passed to native code and reads
value from
 ((int32) object_handle) [-1]
As you can see it's equal to object's hashcode.
Adding the same code fragment before the calls to GetHashCode for o1 and o2
shows that before GetHashCode is called this value is 0, and initialized
after the first call to GetHashCode.

Sergey


----- Original Message -----
From: "Serge" <serge@wildwestsoftware.com>
To: <mono-list@ximian.com>
Sent: Friday, March 08, 2002 5:15 PM
Subject: Re: [Mono-list] mcs compiles on linux. Now what?


> If I understand it correctly this is how Object.GetHashCode is implemented
> in ORP.
> Each object has special 32-bit header stored in memory just before the
> object itself.
> Say if p_obj is java_lang_Object* then
>     uint32* p_header = (uint32*) p_obj;
>     --p_header;
>
> Upper bits of *p_header contain the hashcode.
> This hashcode calculated on demand and only once when Object.getHashCode()
> is called the first time. Special value 0 indicates not yet calculated (0
> also returned for null objects). It makes sure that calculated hashcode
> won't be 0.
> Hashcode calculated based on the current object's address (p_obj), but
> since it's calculated only once moving GC is not a problem.
>
> This is how it looks from the code, also I remember this is described in
ORP
> presentation slides.
> The header has other purposes as well not only hashcode.
>
> Sergey
>




------=_NextPart_000_001D_01C1C6CE.ADB57EC0
Content-Type: application/x-gzip;
	name="hash_test.tar.gz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="hash_test.tar.gz"

H4sIALT9iDwADu1aTXAcRxV+s1qtdteWHNkhWRwFtzehsiuJ1f5JsuMf9GtZiX8US/6JHcWe3W1J
E83ObGZmhRTjlMkBkkqA5OITB7gBFzhQkKIIVYGCU1LFgWOq8CEcKFKVoiguVJHwXvfM/kgr2QmW
nZB5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