org.jikesrvm.adaptive.database.callgraph
Class PartialCallGraph

java.lang.Object
  extended by org.jikesrvm.adaptive.database.callgraph.PartialCallGraph
All Implemented Interfaces:
Decayable, Reportable

public final class PartialCallGraph
extends Object
implements Decayable, Reportable

A partial call graph (PCG) is a partial mapping from callsites to weighted targets.


Nested Class Summary
private  class PartialCallGraph.OrderByTotalWeight
          Used to compare two call sites by total weight.
 
Field Summary
private  HashMap<CallSite,WeightedCallTargets> callGraph
          The dynamic call graph, which is a mapping from CallSites to WeightedCallTargets.
private  double seedWeight
          Initial seed weight; saved for use in the reset method
private  double totalEdgeWeights
          sum of all edge weights in the call graph
private  HashMap<UnResolvedCallSite,UnResolvedWeightedCallTargets> unresolvedCallGraph
           
 
Constructor Summary
PartialCallGraph(double initialWeight)
          Create a partial call graph.
 
Method Summary
private  void augmentEdge(RVMMethod caller, int bcIndex, RVMMethod callee, double weight)
          Increment the edge represented by the input parameters, creating it if it is not already in the call graph.
 void decay()
          Visit the WeightedCallTargets for every call site send them the decay message.
 void dumpGraph()
          Dump all profile data to the given file
 void dumpGraph(String fn)
          Dump all profile data to the given file
 WeightedCallTargets getCallTargets(CallSite callSite)
           
 WeightedCallTargets getCallTargets(RVMMethod caller, int bcIndex)
           
 double getTotalEdgeWeights()
           
 void incrementEdge(RVMMethod caller, int bcIndex, RVMMethod callee)
          Increment the edge represented by the input parameters, creating it if it is not already in the call graph.
 void incrementEdge(RVMMethod caller, int bcIndex, RVMMethod callee, float weight)
          Increment the edge represented by the input parameters, creating it if it is not already in the call graph.
 void incrementUnResolvedEdge(MethodReference callerRef, int bcIndex, MethodReference calleeRef, float weight)
          For the calling edge we read from a profile, we may not have the methods loaded in yet.
 void report()
          Dump out set of edges in sorted order.
 void reset()
          reset (clear) data set being gathered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

callGraph

private final HashMap<CallSite,WeightedCallTargets> callGraph
The dynamic call graph, which is a mapping from CallSites to WeightedCallTargets.


unresolvedCallGraph

private final HashMap<UnResolvedCallSite,UnResolvedWeightedCallTargets> unresolvedCallGraph

totalEdgeWeights

private double totalEdgeWeights
sum of all edge weights in the call graph


seedWeight

private final double seedWeight
Initial seed weight; saved for use in the reset method

Constructor Detail

PartialCallGraph

public PartialCallGraph(double initialWeight)
Create a partial call graph.

Parameters:
initialWeight - an initial value for totalEdgeWeights. Used by AOS to cause inlining based in the dynamic call graph to initially be conservative until sufficient samples have accumulated that there is more confidence in the accuracy of the call graph.
Method Detail

reset

public void reset()
Description copied from interface: Reportable
reset (clear) data set being gathered

Specified by:
reset in interface Reportable

getTotalEdgeWeights

public double getTotalEdgeWeights()
Returns:
sum of all edge weights in the partial call graph

decay

public void decay()
Visit the WeightedCallTargets for every call site send them the decay message.

Specified by:
decay in interface Decayable

getCallTargets

public WeightedCallTargets getCallTargets(RVMMethod caller,
                                          int bcIndex)
Parameters:
caller - caller method
bcIndex - bytecode index in caller method
Returns:
the WeightedCallTargets currently associated with the given caller bytecodeIndex pair.

getCallTargets

public WeightedCallTargets getCallTargets(CallSite callSite)
Parameters:
callSite - the callsite to look for
Returns:
the WeightedCallTargets currently associated with callSite.

incrementEdge

public void incrementEdge(RVMMethod caller,
                          int bcIndex,
                          RVMMethod callee)
Increment the edge represented by the input parameters, creating it if it is not already in the call graph.

Parameters:
caller - method making the call
bcIndex - call site, if -1 then no call site is specified.
callee - method called

incrementEdge

public void incrementEdge(RVMMethod caller,
                          int bcIndex,
                          RVMMethod callee,
                          float weight)
Increment the edge represented by the input parameters, creating it if it is not already in the call graph.

Parameters:
caller - method making the call
bcIndex - call site, if -1 then no call site is specified.
callee - method called
weight - the frequency of this calling edge

incrementUnResolvedEdge

public void incrementUnResolvedEdge(MethodReference callerRef,
                                    int bcIndex,
                                    MethodReference calleeRef,
                                    float weight)
For the calling edge we read from a profile, we may not have the methods loaded in yet. Therefore, we will record the method reference information first, the next time we resolved the method, we will promote it into the regular call graph. Increment the edge represented by the input parameters, creating it if it is not already in the call graph.

Parameters:
callerRef - method making the call
bcIndex - call site, if -1 then no call site is specified.
calleeRef - method called
weight - the frequency of this calling edge

augmentEdge

private void augmentEdge(RVMMethod caller,
                         int bcIndex,
                         RVMMethod callee,
                         double weight)
Increment the edge represented by the input parameters, creating it if it is not already in the call graph.

Parameters:
caller - method making the call
bcIndex - call site, if -1 then no call site is specified.
callee - method called
weight - the frequency of this calling edge

report

public void report()
Dump out set of edges in sorted order.

Specified by:
report in interface Reportable

dumpGraph

public void dumpGraph()
Dump all profile data to the given file


dumpGraph

public void dumpGraph(String fn)
Dump all profile data to the given file

Parameters:
fn - output file name