CSE 401, Winter 2014
Robert R. Henry
Storage and Dispatch and Execution
Due via dropbox Monday March 3 by the end of the day (midnight).
By the end of this assignment you will be able to load and store to memory, and call functions indirectly. This is a fairly large piece of work, so get started early.
- Implement a visitor (or use a previous visitor phase for this) that models the storage layout for the stack frame (activation record) to hold local variables. Don’t forget the “this” pointer! Everything requiring storage in Mini Java is 8 bytes long: longs (which we call ints), doubles and pointers.
- Implement a model of the storage layout for data members in objects. Don’t forget the pointer to the vtbl in slot 0! You should be able to use much of the same code for modelling stack frames as you use for modelling the storage layout of objects.
- Implement a storage model for method pointers in the vtbls. Be careful with the semantics of “extends”, function overriding, etc.
- Implement a storage model that supports the array new and array length operators.
Scalar Loads and Stores
- Implement load and store of scalars. These are always done as offsets from the base pointer to the activation record, or from the “this” pointer, or from a computed pointer (an expression) to another object.
Array Loads and Stores
- Implement code generation and/or library utilities for computing the address of a value held in an array, and also for doing bounds checking.
- Implement array loads and stores using the above primitives.
- Implement the array length operator.
Dynamic memory allocation
- Implement the array new operator. Don’t forget to initialize the data for array length (a degenerate array descriptor), and follow the Java semantics for initializing the rest of the array.
- Implement the object new operator. Don’t forget to initialize the vtbl pointer in slot 0, and initialize the rest of the object per Java semantics.
- Implement activation record allocation, and initialization. At this point you can transfer incoming parameters, held in registers, into the appropriate slot in the activation record.
- Implement statically initialized vtbl arrays held in data space that hold pointers to method functions, as well as the chain to the vtbl of the immediate base class.
- Using the array load primitives, change all calls to call indirect through the appropriate slot in the vtbl.
- By now you should have implemented all of the basic Mini Java.
- You should be able to compile and execute all of the sample programs we supplied at the beginning of the quarter. Watch those digits of Pi come churning out!
- You should be able to compile and execute your test programs, with the exception of those that manipulate doubles.
What to turn in
- Submit the assembly code you produce for TreeVisitor.java (found in the SamplePrograms/SampleMiniJavaPrograms directory), plus the results of executing that program.
- As common, submit a tar file holding your entire source tree.