org.jikesrvm.compilers.opt.escape
Class SimpleEscape

java.lang.Object
  extended by org.jikesrvm.compilers.opt.driver.CompilerPhase
      extended by org.jikesrvm.compilers.opt.escape.SimpleEscape

 class SimpleEscape
extends CompilerPhase

Simple flow-insensitive escape analysis

TODO: This would be more effective if formulated as a data-flow problem, and solved with iteration


Nested Class Summary
private static class SimpleEscape.AnalysisResult
          Utility class used to hold the result of the escape analysis.
 
Field Summary
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.
 
Fields inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase
container
 
Constructor Summary
SimpleEscape()
           
 
Method Summary
private static SimpleEscape.AnalysisResult checkAllAppearances(Register reg, IR ir)
          Check all appearances of a register, to see if any object pointed to by this register may escape this thread and/or method.
private static boolean checkEscapesMethod(RegisterOperand use, IR ir, Set<Register> visited)
          Check 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)
          Check 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 findOrCreateMethodSummary(RVMMethod m, OptOptions options)
          If a method summary exists for a method, get it.
 String getName()
           
private static int getParameterIndex(Operand op, Instruction s)
          Which parameter to a call instruction corresponds to op?
private static OptimizationPlanElement initEscapePlan()
          Static initializer: set up the compilation plan for simple escape analysis of a method.
private static Iterator<Operand> iterateReturnValues(IR ir)
          Return an iterator over the operands that serve as return values in an 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)
          Perform the simple escape analysis for a method.
 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)
          Perform the escape analysis for a method.
 
Methods inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase
dumpIR, dumpIR, getClassConstructor, getCompilerPhaseConstructor, getCompilerPhaseConstructor, performPhase, reportAdditionalStats, setContainer, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

escapePlan

private static final OptimizationPlanElement escapePlan
This member represents the directions to the optimizing compiler to perform escape analysis on a method, but do not generate code.

Constructor Detail

SimpleEscape

SimpleEscape()
Method Detail

newExecution

public CompilerPhase newExecution(IR ir)
Return this instance of this phase. This phase contains no per-compilation instance fields.

Overrides:
newExecution in class CompilerPhase
Parameters:
ir - not used
Returns:
this

shouldPerform

public final boolean shouldPerform(OptOptions options)
Description copied from class: CompilerPhase
This method determines if the phase should be run, based on the Options object it is passed. By default, phases are always performed. Subclasses should override this method if they only want to be performed conditionally.

Overrides:
shouldPerform in class CompilerPhase
Parameters:
options - the compiler options for the compilation
Returns:
true if the phase should be performed

getName

public final String getName()
Specified by:
getName in class CompilerPhase
Returns:
a String which is the name of the phase.

printingEnabled

public final boolean printingEnabled(OptOptions options,
                                     boolean before)
Description copied from class: CompilerPhase
Returns true if the phase wants the IR dumped before and/or after it runs. By default, printing is not enabled. Subclasses should override this method if they want to provide IR dumping.

Overrides:
printingEnabled in class CompilerPhase
Parameters:
options - the compiler options for the compilation
before - true when invoked before perform, false otherwise.
Returns:
true if the IR should be printed, false otherwise.

perform

public void perform(IR ir)
Description copied from class: CompilerPhase
This is the method that actually does the work of the phase.

Specified by:
perform in class CompilerPhase
Parameters:
ir - the IR on which to apply the phase

simpleEscapeAnalysis

public FI_EscapeSummary simpleEscapeAnalysis(IR ir)
Perform the escape analysis for a method. Returns an object holding the result of the analysis

Side effect: updates method summary database to hold escape analysis result for parameters

Parameters:
ir - IR for the target method

checkAllAppearances

private static SimpleEscape.AnalysisResult checkAllAppearances(Register reg,
                                                               IR ir)
Check all appearances of a register, to see if any object pointed to by this register may escape this thread and/or method.

Parameters:
reg - the register to check
ir - the governing IR
Returns:
true if it may escape this thread, false otherwise

checkIfUseEscapesThread

private static boolean checkIfUseEscapesThread(Register reg,
                                               IR ir,
                                               Set<Register> visited)

checkIfUseEscapesMethod

private static boolean checkIfUseEscapesMethod(Register reg,
                                               IR ir,
                                               Set<Register> visited)

checkEscapesThread

private static boolean checkEscapesThread(RegisterOperand use,
                                          IR ir,
                                          Set<Register> visited)
Check a single use, to see if this use may cause the object referenced to escape from this thread.

Parameters:
use - the use to check
ir - the governing IR
Returns:
true if it may escape, false otherwise

checkEscapesMethod

private static boolean checkEscapesMethod(RegisterOperand use,
                                          IR ir,
                                          Set<Register> visited)
Check a single use, to see if this use may cause the object referenced to escape from this method.

Parameters:
use - the use to check
ir - the governing IR
Returns:
true if it may escape, false otherwise

getParameterIndex

private static int getParameterIndex(Operand op,
                                     Instruction s)
Which parameter to a call instruction corresponds to op?

PRECONDITION: Call.conforms(s)


findOrCreateMethodSummary

private static MethodSummary findOrCreateMethodSummary(RVMMethod m,
                                                       OptOptions options)
If a method summary exists for a method, get it. Else, iff SIMPLE_ESCAPE_IPA, perform escape analysis, which will create the method summary as a side effect, and return the summary


performSimpleEscapeAnalysis

private static void performSimpleEscapeAnalysis(RVMMethod m,
                                                OptOptions options)
Perform the simple escape analysis for a method.


initEscapePlan

private static OptimizationPlanElement initEscapePlan()
Static initializer: set up the compilation plan for simple escape analysis of a method.


iterateReturnValues

private static Iterator<Operand> iterateReturnValues(IR ir)
Return an iterator over the operands that serve as return values in an IR

TODO: Move this utility elsewhere