Java Reference
In-Depth Information
11. Following the example of doubleSum (page 515), convert the stringSum
function (page 499) into a form that makes explicit register assignments
for temporaries, live ranges, parameters, and return values. Then, create
the interference graph for stringSum. Use this interference graph and
GCR
to assign registers to stringSum, assuming three registers
are available (including $a0, the parameter register, and $vo (the return
value register)).
eg
A
lloc
12. Assume we have the following method:
int f(int i) {
g(1,i);
}
At the point where the second parameter of g is loaded, we have a
conflict if we require that parameters be passed in registers. In particular,
i is passed in using the first parameter register. But when the second
parameter of g is loaded, the first parameter register is already loaded
with the value 1, possibly making i inaccessible. How can a register
allocator deal with the problemof reuse of dedicatedparameter registers?
That is, what rules should be followed in determining where a parameter
value is to be allocated throughout a subprogram or method?
13. InGCR
, we spill a live range if we are unable to color it. An alter-
native to spilling a live range is to split it, as is done in P
eg
A
lloc
riority
R
eg
A
lloc
.
What changes are needed in GCR
eg
A
lloc
if we split an uncolorable live
range rather than spill it?
14. At the site of amethod call, we may need to save registers currently in use
(lest they be overwritten by the method about to be executed). Assume
we allocate registers using GCR
. Explain how to determine
which registers are in use at a particular method call.
eg
A
lloc
15. Assume we have n registers available to allocate to a subprogram. Ex-
plain how, using either GCR
,wecanesti-
mate the total cost of register spills within the subprogram. How could
this cost estimate be used in deciding how many registers to allocate to
asubprogram?
eg
A
lloc
or P
riority
R
eg
A
lloc
Search WWH ::




Custom Search