[Mono-devel-list] about Metada

Paolo Molaro lupus at ximian.com
Thu Jul 24 08:35:29 EDT 2003


On 07/24/03 Fernando Diaz wrote:
> Can anybody relate me the use of the fields of these structs?
> 
> typedef struct {
>         MonoType        *type;

Type of the field.

>         int              offset;

Offset where field is stored: if it is an instance field, it's the
offset from the start of the object, if it's static, it's from the
start of the memory chunk allocated for statics for the class
(the data pointer in MonoVTable).

>         const char      *name;

Obvious.

>         const char      *data;

Pointer to the data (from the RVA address, valid only for fields with
the has rva flag).

>         MonoClass       *parent;

Type where the field was defined.

>         MonoConstant    *def_value;

If the field is constant, pointer to the metadata where the constant
value can be loaded.

> } MonoClassField;
> 
> Where is the data of objects storage? In data of this struct or in data
> of MonoVTable struct? Or are the same pointers?

MonoClassField is just a runtime representation of the metadata for
field, it doesn't contain the data directly.
Static fields are stored in MonoVTable->data.
Instance fields are allocated in the objects after the object header:


-----		<----- start of object
vtable 		<----- pointer for MonoVTable for the object's class
syncblock	<----- lock/unlock support
first field
second field
...

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list