public class CallGraph
extends java.lang.Object
The construction of the call graph is in the spirit of the "Program Virtual-call Graph" presented in [Bacon97]. However, certain changes have been made to tailor it to BLOAT and Java and to make the overall representation smaller.
Rapid type analysis is integrated into the construction of the call graph. A virtual method is not examined until we know that its declaring class has been instantiated.
Some classes are created internally by the VM and are missed by our analysis. So, we maintain a set of "pre-live" classes. We consider all of their constructors to be live.
| Modifier and Type | Field and Description |
|---|---|
static boolean |
DEBUG |
static boolean |
USE1_2 |
static boolean |
USEPRELIVE |
| Constructor and Description |
|---|
CallGraph(InlineContext context,
java.util.Set roots)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addPreLive(java.lang.String name)
Adds (the name of) a class to the set of classes that are considered to
be "pre-live"
|
java.util.Set |
liveClasses()
Returns the set of classes (Types) that are instantiated in
the program.
|
java.util.Set |
liveMethods()
Returns the set of methods (MemberRefs) that the
construction algorithm has deemed to be live.
|
void |
print(java.io.PrintWriter out,
boolean printLeaves)
Prints a textual prepresentation of the CallGraph to a
PrintWriter.
|
void |
printSummary(java.io.PrintWriter out)
Prints a summary of the call graph.
|
static boolean |
removePreLive(java.lang.String name)
Removes a class from the set of "pre-live" classes
|
java.util.Set |
resolvesTo(MemberRef method)
Returns the methods (MemberRefs) to which a given method
could resolve.
|
java.util.Set |
resolvesTo(MemberRef method,
java.util.Set rTypes)
Returns the methods (MemberRefs) to which a given method
could resolve given that the receiver is in a certain set of types.
|
java.util.Set |
roots()
Returns the root methods (MemberRefs) of the call graph.
|
public static boolean DEBUG
public static boolean USEPRELIVE
public static boolean USE1_2
public CallGraph(InlineContext context, java.util.Set roots)
context - InlineContext used to examine classes and methods.roots - The methods (represented as MemberRefs) considered
to the roots (that is, the "main" methods) of the call graph.
Presumably, only static methods or constructors can be root
methods.public static void addPreLive(java.lang.String name)
public static boolean removePreLive(java.lang.String name)
public java.util.Set resolvesTo(MemberRef method)
public java.util.Set resolvesTo(MemberRef method, java.util.Set rTypes)
public java.util.Set liveMethods()
public java.util.Set roots()
public java.util.Set liveClasses()
public void print(java.io.PrintWriter out,
boolean printLeaves)
out - To where we printprintLeaves - If true, leaf methods (methods that do not call
any other methods) are printedpublic void printSummary(java.io.PrintWriter out)