blob: 8135ca2805f8d46f013f22e49ad5d7923a265e3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
Object and VTable layout
========================
The first pointer inside an Object points to a MonoVtable structure. Objects
also contains a MonoThreadsSync structure which is used by the mono Thread
implementation.
typedef struct {
MonoVTable *vtable;
MonoThreadsSync synchronisation;
/* object specific data goes here */
} MonoObject;
The MonoVtable contains the vtable, interface offsets and a pointer to static
class data. Each object/vtable belongs to exactly one AppDomain.
typedef struct {
MonoClass *klass;
MonoDomain *domain;
gpointer *interface_offsets;
/* a pointer to static data */
gpointer data;
/* the variable sized vtable is included at the end */
gpointer vtable [0];
} MonoVTable;
The MonoClass contains domain independent Class infos.
typedef struct {
/* various class infos */
MonoClass *parent;
const char *name;
const char *name_space;
...
} MonoClass;
Calling virtual functions:
==========================
Each MonoMethod (if virtual) has an associated slot, which is an index into the
VTable. So we can use the following code to compute the address of a virtual
function:
method_addr = object->vtable->vtable [method->slot];
Calling interface methods:
==========================
Each interface class is associated with an unique ID. The following code
computes the address of an interface function:
method_addr = *(object->vtable->interface_offsets [interface_id] + method->slot*4);
|