harpoon.Analysis.Quads.DeepInliner
Class InlineChain

java.lang.Object
  extended by harpoon.Analysis.Quads.DeepInliner.InlineChain

public abstract class InlineChain
extends Object

InlineChain models an arbitrary-length call path that needs to be inlined. Basically, an InlineChain is a list of CALLs: cs1, cs2, ..., csk (where cs(i+1) is part of the method called by csi, forall i). Inlining such a chain mutates only the body of the method that contains cs1: if mi is the method called by csi, cs1 is replaced with a copy of m1, inside which cs2 has been replaced with a copy of m2, inside which cs3 has been replaced with a copy of m3, and so on.

Intuitively, the outcome of inlining a chain is similar to the result of inlining cs1, next inlining the copy of cs2 from the copy of m1 that replaced cs1, and so on.

The programmer may subclass InlineChain to specify an action to be performed after each individual call is inlined (action(harpoon.IR.Quads.CALL, harpoon.IR.Quads.Code, java.util.Map)) and an action to be performed after the entire call chain was inlined (finalAction()). The method DeepInliner.inline is able to inline all the inlining chains generated for the compiled program.

Version:
$Id: InlineChain.java,v 1.1 2005/08/09 22:40:35 salcianu Exp $
Author:
Alexandru Salcianu <salcianu@alum.mit.edu>
See Also:
DeepInliner.inline(harpoon.ClassFile.CachingCodeFactory, java.util.Collection, harpoon.Analysis.Quads.CallGraph)

Constructor Summary
InlineChain(List<CALL> calls)
           
 
Method Summary
 void action(CALL cs, Code calleeCode, Map<Quad,Quad> oldQuad2newQuad)
           
 Collection<CALL> calls()
           
static String callsToString(LinkedList<CALL> calls)
           
 void finalAction()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InlineChain

public InlineChain(List<CALL> calls)
Method Detail

calls

public final Collection<CALL> calls()
Returns:
Unmodifiable view of the CALLs from this inline chain.

action

public void action(CALL cs,
                   Code calleeCode,
                   Map<Quad,Quad> oldQuad2newQuad)
Parameters:
cs - The last call that has been inlined.
calleeCode - The code of the callee. This is the original code, NOT its copy that was inlined in cs's place. The quads from caleeCode are the keys of the map passed as the oldQuad2newQuad param; still, calleeCode is not redundant, as it may contain other information besides the instructions (ex: the AllocationInformation map).
oldQuad2newQuad - A map from the original quads (instructions) of the last to be inlined method to their copies that are now part of the new body (HCode) of the target method.

finalAction

public void finalAction()

toString

public String toString()
Overrides:
toString in class Object

callsToString

public static String callsToString(LinkedList<CALL> calls)