Java Reference
In-Depth Information
}
See Chapter 7 for hints on providing run-time representational support for objects,
strings, and arrays.
Converting additional JVM instructions, in addition to the ones that already are, into
SPIM code, involves the following steps:
Adding/modifying the HIR representation: This is done in $j/j--/src/jminusminus
/NHIRInstruction.java . Each class that represents an HIR instruction inherits from
the base class NHIRInstruction . The additions will be to the constructor of the HIR
instruction; the inherited toLir() method that converts and returns the low-level
(LIR) representation; and the inherited toString() method that returns a string
representation for the HIR instruction.
Adding/modifying the LIR representation: This is done in $j/j--/src/jminusminus
/NLIRInstruction.java . Each class representing an LIR instruction inherits from
the base class NLIRInstruction . The additions will be to the constructor of the LIR
instruction; the inherited allocatePhysicalRegisters() method that replaces ref-
erences to virtual registers in the LIR instruction with references to physical registers
and generates LIR spill instructions where needed; the toSpim() method that emits
SPIM instructions to an output stream (a .s file); and the toString() method that
returns a string representation for the LIR instruction.
Both NHIRInstruction and NLIRInstruction have plenty of code in place that can
serve as a guideline in implementing the above steps for the new JVM instructions being
translated to SPIM code.
E.5 Further Readings
The website [Larus, 2010] for the SPIM simulator provides a wealth of information about
the simulator, especially on how to obtain, compile, install, and run the simulator.
For a detailed description of the SPIM simulator, its memory usage, procedure call
convention, exceptions and interrupts, input and output, and the MIPS assembly language,
see [Larus, 2009].
 
Search WWH ::




Custom Search