Files
acceptance-tests
data
debian
docs
HtmlAgilityPack
deploy
sources
svgs
Makefile.am
Makefile.in
README
TODO
abc-removal.txt
api-style.css
check-coverage
check-exports
convert.cs
docs.make
embedded-api
exdoc
file-share-modes
gc-issues
gc-variables-in-c
glossary.txt
ignore
internal-calls
ir-desc
jit-imt
jit-thoughts
jit-trampolines
mini-doc.txt
mono-api-metadata.html
mono-file-formats.config
mono-file-formats.source
mono-tools.config
mono-tools.source
monoapi.source
object-layout
precise-gc
produce-lists
remoting
ssapre.txt
stack-overflow.txt
threading
toc.xml
unmanaged-calls
external
ikvm-native
libgc
llvm
m4
man
mcs
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
linux-packaging-mono/docs/object-layout

64 lines
1.5 KiB
Plaintext
Raw Normal View History

Author: Dietmar Maurer (dietmar@ximian.com)
(C) 2001 Ximian, Inc.
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);