Java Reference
In-Depth Information
8. The ifeq instruction provisions only 2 bytes for the branch o
set. Unlike
goto, there is no corresponding goto w instruction for ifeq. Explain how
youwould generate code so that a successful outcome of ifeq could reach
atargetthatistoofartobereachedbya16bito
ff
ff
set.
9. Consider the C or Java ternary expression : ( a > b ) ? c : d ,whichleaves
either c or d on TOS depending on the outcome of the comparison.
Assume all variables are type int, but do not assume that any of them
are 0. Explain howyouwould generate code for the comparison that uses
only the ifne instruction for branching (no other if or goto instructions
are allowed).
10. A constructor call consumes the TOS reference to the class instance it
should initialize. All constructors are void, so they do not return any
kind of result. However, Java programs expect to obtain the result of the
constructor call on TOS after the constructor has finished. By what JVM
instruction sequence can this be accomplished?
11. The text includes a discussion of the dup_x1 instruction as applied to the
code fragment:
( this . x y ). Develop a code sequence that leaves
y 's value (431) on the stack after the embedded assignment, without
using any of the dup instructions. Note that 431 is not a constant here: it
happens to be the value that was loaded for y .
foo
12. Figure 10.5 shows a sequence of
φ
-functions before the call to the
print
method. Why is a
φ
-function not needed for i at that point?
13. Investigate how arrays are treated in SSA Form.
14. Investigate how heap-allocated storage is treated in SSA Form.
15. Investigate how method calls are treated in SSA Form.
16. What is the di
erence between a def of x and its L-value as described in
Section 7.6 on page 261?
ff
 
Search WWH ::




Custom Search