CSC448: Code Generation: Run-Time Storage for Objects I [75/133] Previous pageContentsNext page

Corin did not show

In order to generate code for ExpConstructorCall, ExpFieldAccess, and ExpMethodCall, we need to understand the run-time storage of objects.

Objects are stored on the heap. The stack only contains pointers to objects.

We are not concerned with memory deallocation or garbage collection. CSC548 covers garbage collection for OO languages.

If register eax contains the address of an object on the heap, then an object of a clazz with 3 fields has the following structure (using 4 words on the heap):

Location Value
12(%eax) field 3
8(%eax) field 2
4(%eax) field 1
0(%eax) vtable for this object's clazz

Previous pageContentsNext page