[kaffe] Object Allocation in the heap
    Timothy Stack 
    stack at cs.utah.edu
       
    Fri Apr 25 08:08:01 PDT 2003
    
    
  
> Hello All,
hi,
>   I was trying to trace through the life-time of an object: what calls the 
> vm makes to allocate an object, and where the object is actually placed 
> etc... one thing that puzzles me is this:
>   in gc_heap_malloc(), essentially a block (small or large depending on 
> size) is removed from the freelist, memset-ted to zero, and returned.
correct
> but 
> from the object data structure in java_lang_Object.h, i thought that the 
> object was supposed to look like
>    typedef struct Hjava_lang_Object {
>      struct _dispatchTable*  dtable;
>      struct _iLock*               lock;
>      /* Data follows on immediately */
>    } Hjava_lang_Object;
The allocator is used for non-Java objects as well, so this structure is 
only overlayed on the memory if it is meant to be used by java code.
> and there's a macro in object.h
> #define OBJECT_DATA(OBJ) ((void*)((Hjava_lang_Object*)(OBJ)+1))
The Hjava_lang_Object structure is just a header, the actual data 
contained within the object would start at the address returned by this 
macro.
>   so in essence, if we just take a block from the heap, and allocate it with 
> just enough memory for the object data, 
Well, the actual size needs to contain the object data + the 
Hjava_lang_Object header + a GC internal header.
> and memset the whole of it to zero,
> then where does the metadata(the dtable and the lock) go?
In the header, which is setup by the newObject functions in 
kaffe/kaffevm/object.c.
> or even 
> alternatively, given just a heap block how would i find the metadata for 
> that object? i would be very grateful if someone could give me some pointers 
> here!
> cheers!
> --xubacs
tim stack
    
    
More information about the kaffe
mailing list