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

Serge serge@wildwestsoftware.com
Fri, 8 Mar 2002 17:15:24 +0200


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