class SimpleEscape extends CompilerPhase
NOTE: The analysis is tailored to the optimizations that currently make use of it and NOT suited for general tasks that rely on escape analysis. In particular, the analysis may incorrectly classify uses as thread-local or method-local. This does not cause problems for the implemented optimizations because those will only be performed when the definition of the object in question is contained in the method that's being compiled.
TODO list:
Modifier and Type | Class and Description |
---|---|
private static class |
SimpleEscape.AnalysisResult
Utility class used to hold the result of the escape analysis.
|
Modifier and Type | Field and Description |
---|---|
private static OptimizationPlanElement |
escapePlan
This member represents the directions to the optimizing compiler to
perform escape analysis on a method, but do not generate
code.
|
container
Constructor and Description |
---|
SimpleEscape() |
Modifier and Type | Method and Description |
---|---|
private static void |
assertThatTypeIsNotNull(IR ir,
RegisterOperand useOrDef) |
private static SimpleEscape.AnalysisResult |
checkAllAppearances(Register reg,
IR ir)
Checks all appearances of a register, to see if any instruction in
this method causes the object pointed to by the register to escape
this thread and/or method.
|
private static boolean |
checkEscapesMethod(RegisterOperand use,
IR ir,
Set<Register> visited)
Checks a single use, to see if this use may cause the object
referenced to escape from this method.
|
private static boolean |
checkEscapesThread(RegisterOperand use,
IR ir,
Set<Register> visited)
Checks a single use, to see if this use may cause the object
referenced to escape from this thread.
|
private static boolean |
checkIfUseEscapesMethod(Register reg,
IR ir,
Set<Register> visited) |
private static boolean |
checkIfUseEscapesThread(Register reg,
IR ir,
Set<Register> visited) |
private static MethodSummary |
getMethodSummaryIfAvailable(RVMMethod m,
OptOptions options)
Returns a method summary if present.
|
String |
getName() |
private static int |
getParameterIndex(Operand op,
Instruction s)
Which parameter to a call instruction corresponds to op?
|
private static OptimizationPlanElement |
initEscapePlan() |
private static Iterator<Operand> |
iterateReturnValues(IR ir)
TODO: Move this utility elsewhere
|
CompilerPhase |
newExecution(IR ir)
Return this instance of this phase.
|
void |
perform(IR ir)
This is the method that actually does the work of the phase.
|
private static void |
performSimpleEscapeAnalysis(RVMMethod m,
OptOptions options) |
boolean |
printingEnabled(OptOptions options,
boolean before)
Returns true if the phase wants the IR dumped before and/or after it runs.
|
boolean |
shouldPerform(OptOptions options)
This method determines if the phase should be run, based on the
Options object it is passed.
|
FI_EscapeSummary |
simpleEscapeAnalysis(IR ir)
Performs the escape analysis for a method.
|
dumpIR, dumpIR, getClassConstructor, getCompilerPhaseConstructor, getCompilerPhaseConstructor, performPhase, reportAdditionalStats, setContainer, verify
private static final OptimizationPlanElement escapePlan
SimpleEscape()
public CompilerPhase newExecution(IR ir)
newExecution
in class CompilerPhase
ir
- not usedpublic final boolean shouldPerform(OptOptions options)
CompilerPhase
shouldPerform
in class CompilerPhase
options
- the compiler options for the compilationpublic final String getName()
getName
in class CompilerPhase
public final boolean printingEnabled(OptOptions options, boolean before)
CompilerPhase
printingEnabled
in class CompilerPhase
options
- the compiler options for the compilationbefore
- true when invoked before perform, false otherwise.public void perform(IR ir)
CompilerPhase
perform
in class CompilerPhase
ir
- the IR on which to apply the phasepublic FI_EscapeSummary simpleEscapeAnalysis(IR ir)
Side effect: updates method summary database to hold escape analysis result for parameters
ir
- IR for the target methodprivate static SimpleEscape.AnalysisResult checkAllAppearances(Register reg, IR ir)
reg
- the register to checkir
- the governing IRtrue
if it may escape this thread,
false
otherwiseprivate static boolean checkIfUseEscapesThread(Register reg, IR ir, Set<Register> visited)
private static boolean checkIfUseEscapesMethod(Register reg, IR ir, Set<Register> visited)
private static void assertThatTypeIsNotNull(IR ir, RegisterOperand useOrDef)
private static boolean checkEscapesThread(RegisterOperand use, IR ir, Set<Register> visited)
use
- the use to checkir
- the governing IRvisited
- visited registerstrue
if it may escape, false
otherwiseprivate static boolean checkEscapesMethod(RegisterOperand use, IR ir, Set<Register> visited)
use
- the use to checkir
- the governing IRvisited
- visited registerstrue
if it may escape, false
otherwiseprivate static int getParameterIndex(Operand op, Instruction s)
PRECONDITION: Call.conforms(s)
op
- the operand whose parameter is soughts
- the call instructionprivate static MethodSummary getMethodSummaryIfAvailable(RVMMethod m, OptOptions options)
In the special case of enabled eager method summary computation, this method will perform escape analysis for the requested method, which will create the method summary as a side effect.
m
- the method whose summary is soughtoptions
- options to determine whether to create a summary
if it does not existnull
.private static void performSimpleEscapeAnalysis(RVMMethod m, OptOptions options)
private static OptimizationPlanElement initEscapePlan()
private static Iterator<Operand> iterateReturnValues(IR ir)
ir
- the IR to search for the return values