To support these features, the following has been added:
Class instance layouts
Constructor bodies
Constructor calling
Instance field initialization
Field addressing
Field value fetching
In the constructor body, the first action that happens is the space for
the instance layout is allocated with malloc. After that, a field
initialization function is called which will execute all of the field
initializers, in order. This is because fields can have arbitrary
expressions within them. After all of this, the remainder of the
constructor is run.
Hereon out, the register ESI is dedicated to storing this for the
purposes of constructors and instance methods. Hence, any implicit or
explicit reference to this is simply accessing the ESI register.
Constructor calling is done in the same manner as method invocation,
where a safe call is made that does a backup and restore of the method
context. This now includes the ESI register.
A class, ClassInstance, is created for building interfaces codegen
will use involving an instance. In particular, it is tracking the layout
of the object in memory.
Using the ClassInstance, addressing and value fetching for fields was
added.
To support these features, the following has been added:
In the constructor body, the first action that happens is the space for the instance layout is allocated with
malloc
. After that, a field initialization function is called which will execute all of the field initializers, in order. This is because fields can have arbitrary expressions within them. After all of this, the remainder of the constructor is run.Hereon out, the register
ESI
is dedicated to storingthis
for the purposes of constructors and instance methods. Hence, any implicit or explicit reference tothis
is simply accessing theESI
register.Constructor calling is done in the same manner as method invocation, where a safe call is made that does a backup and restore of the method context. This now includes the ESI register.
A class,
ClassInstance
, is created for building interfaces codegen will use involving an instance. In particular, it is tracking the layout of the object in memory.Using the
ClassInstance
, addressing and value fetching for fields was added.