Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDietmar Maurer <dietmar@mono-cvs.ximian.com>2001-10-11 08:25:07 +0400
committerDietmar Maurer <dietmar@mono-cvs.ximian.com>2001-10-11 08:25:07 +0400
commitbea5147eb23530d6b3a264168dbbf6e981008f62 (patch)
tree76238c1e3e3c39cbd71ea7cbfdaf9e34c722a701 /docs/object-layout
parenta3b0410b1e2b8e0a97b7a43cdda5fb346c2b505f (diff)
more documentation
svn path=/trunk/mono/; revision=1138
Diffstat (limited to 'docs/object-layout')
-rw-r--r--docs/object-layout58
1 files changed, 58 insertions, 0 deletions
diff --git a/docs/object-layout b/docs/object-layout
new file mode 100644
index 00000000000..1a066453ada
--- /dev/null
+++ b/docs/object-layout
@@ -0,0 +1,58 @@
+Object and VTable layout
+========================
+
+The first pointer inside an Object points to a MonoClass structure. Objects
+also contains a MonoThreadsSync structure which is used by the mono Thread
+implementation.
+
+typedef struct {
+ MonoClass *class;
+ MonoThreadsSync synchronisation;
+
+ /* object specific data goes here */
+} MonoObject;
+
+The MonoClass contains all Class infos, the VTable and a pointer to static
+class data.
+
+typedef struct {
+ /* various class infos */
+ MonoClass *parent;
+ const char *name;
+ const char *name_space;
+
+ ...
+
+ /* interface offset table */
+ gint *interface_offsets;
+
+ gpointer data; /* a pointer to static data */
+
+ /* the variable sized vtable is included at the end */
+ gpointer vtable [vtable_size];
+} 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->class->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:
+
+offset_into_vtable = object->class->interface_offsets [interface_id];
+method_addr = object->class->vtable [offset_into_vtable + method->slot];
+
+
+
+
+