Java Reference
In-Depth Information
6.4 Further Readings
James Larus' SPIM simulator [Larus, 2010] may be freely obtained on the WWW at http://
sourceforge.net/projects/spimsimulator/files/ . QtSpim is the interpreter of choice
these days and is easily installed on Windows R , Linux R , and Mac OS X. Larus maintains
a resource page at http://pages.cs.wisc.edu/~larus/spim.html . Finally, an excellent
introduction to SPIM and the MIPS may be found at [Larus, 2009].
Our JVM-to-SPIM translator is based on that described in Christian Wimmer's Master's
thesis [Wimmer, 2004]; this is a good overview of the Oracle HotSpot compiler. Another
report on a register allocator for the HotSpot compiler is [Mossenbock, 2000].
Our proposed layout of objects is based on that of [Corliss and Lewis, 2007].
For comprehensive coverage of code optimization techniques, see [Morgan, 1998], [Much-
nick, 1997], [Allen and Kennedy, 2002], and [Cooper and Torczon, 2011].
[Wilson, 1994] is a good introduction to classical garbage collection techniques. [Jones
and Lins, 1996] also presents many memory management strategies.
6.5 Exercises
As we have stated in the narrative, we implement enough of the JVM-to-SPIM translator
to implement a small subset of the JVM. The following exercises ask one to expand on this.
Exercise 6.1. Implement all of the relational and equality JVM instructions in the HIR,
the LIR, and SPIM. (Notice that some of this has been done.) Test these.
Exercise 6.2. Assuming you have implemented / and % in your j-- compiler, implement
them in the HIR, LIR, and SPIM. Test these.
Exercise 6.3. Implement the bitwise JVM instructions in the HIR, LIR and SPIM. Test
these.
Exercise 6.4. In many places in the HIR, we refer to the instruction 0 , which means 0
is an operand to some computation. In generating the LIR, that constant 0 is loaded into
some virtual register. But SPIM has the register $zero, which always contains the constant
0 and so may replace the virtual register in the LIR code. Modify the translation of HIR to
LIR to take advantage of this special case.
Exercise 6.5. The JVM instructions getstatic and putstatic are implemented in the
HIR and LIR but not in SPIM. Implement these instructions in SPIM and test them.
Exercise 6.6. Implement the Object type, supporting the methods clone() , equals() ,
and toString() .
Exercise 6.7. Implement the String type, which is a subclass of Object and implements
the methods charAt() , concat() , length() , and substring() with two arguments.
Exercise 6.8. In Section 6.3.5, we came up with a naming convention for the SPIM routines
for methods that does not deal with overloaded method names, that is, methods having the
same name but different signatures. Propose an extension to our convention that deals with
overloaded methods.
 
Search WWH ::




Custom Search