CSE 401, Winter 2014

Robert R. Henry

Assignment 8

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.

Storage Model

  1. 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.
  2. 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.
  3. Implement a storage model for method pointers in the vtbls.  Be careful with the semantics of “extends”, function overriding, etc.
  4. Implement a storage model that supports the array new and array length operators.

Scalar Loads and Stores

  1. 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

  1. Implement code generation and/or library utilities for computing the address of a value held in an array, and also for doing bounds checking.
  2. Implement array loads and stores using the above primitives.
  3. Implement the array length operator.

Dynamic memory allocation

  1. 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.
  2. 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.
  3. 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.

Vtbl Creation

  1. 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.
  2. Using the array load primitives, change all calls to call indirect through the appropriate slot in the vtbl.


  1. By now you should have implemented all of the basic Mini Java.
  2. 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!
  3. You should be able to compile and execute your test programs, with the exception of those that manipulate doubles.

What to turn in

  1. Submit the assembly code you produce for TreeVisitor.java (found in the SamplePrograms/SampleMiniJavaPrograms directory), plus the results of executing that program.
  2. As common, submit a tar file holding your entire source tree.