org.jikesrvm.compilers.opt.ssa
Class PiNodes

java.lang.Object
  extended by org.jikesrvm.compilers.opt.driver.CompilerPhase
      extended by org.jikesrvm.compilers.opt.ssa.PiNodes

public final class PiNodes
extends CompilerPhase

This pass inserts PI nodes (Effectively copies) on branch edges, to introduce new names for analysis


Field Summary
(package private) static boolean CHECK_REF_PI
          Should we insert PI nodes for array references after bounds-checks and null-checks?
private static Constructor<CompilerPhase> constructor
          Constructor for this compiler phase
(package private)  boolean insertion
          Should we insert (true) or delete (false) PI nodes?
(package private)  boolean typeChecks
          Are we adding pi nodes for type checks only?
 
Fields inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase
container
 
Constructor Summary
PiNodes(boolean insert)
          Create the phase.
PiNodes(boolean insert, boolean typeChecks)
          Create the phase.
 
Method Summary
(package private) static void cleanUp(IR ir)
          Change all PI nodes to INT_MOVE instructions Side effect: invalidates SSA state
 Constructor<CompilerPhase> getClassConstructor()
          Get a constructor object for this compiler phase
static Instruction getGenerator(Instruction def)
          Get the instruction a Pi node is linked to.
 String getName()
          A String representation of this phase
private  void insertPiBcNodes(IR ir)
          Insert Pi nodes for boundchecks.
private  void insertPiCheckCastNodes(IR ir)
          Insert Pi nodes for checkcast operations.
private  void insertPiIfNodes(IR ir)
          Insert PI nodes corresponding to compare operations.
private  void insertPiNullCheckNodes(IR ir)
          Insert Pi nodes for null check operations.
static boolean isBoundsCheckPi(Instruction def)
          Is an instruction a Pi node linked to a bounds-check?
static boolean isNotTakenPi(Instruction def)
          Is an instruction a Pi node linked to the not taken edge of a conditional branch instruction?
static boolean isNullCheckPi(Instruction def)
          Is an instruction a Pi node linked to a null-check?
static boolean isTakenPi(Instruction def)
          Is an instruction a Pi node linked to the taken edge of a conditional branch instruction?
 void perform(IR ir)
          This is the method that actually does the work of the phase.
 boolean printingEnabled(OptOptions options, boolean before)
          Should we print the IR either before or after this phase?
 boolean shouldPerform(OptOptions options)
          Should this phase be performed?
 
Methods inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase
dumpIR, dumpIR, getCompilerPhaseConstructor, getCompilerPhaseConstructor, newExecution, performPhase, reportAdditionalStats, setContainer, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHECK_REF_PI

static final boolean CHECK_REF_PI
Should we insert PI nodes for array references after bounds-checks and null-checks?

TODO: if this is false, then null-check elimination will be ineffective.

TODO: prove that null-check elimination is sound before turning this on again.

See Also:
Constant Field Values

insertion

final boolean insertion
Should we insert (true) or delete (false) PI nodes?


typeChecks

final boolean typeChecks
Are we adding pi nodes for type checks only? This is for GNOSYS analysis right now.


constructor

private static final Constructor<CompilerPhase> constructor
Constructor for this compiler phase

Constructor Detail

PiNodes

public PiNodes(boolean insert)
Create the phase.

Parameters:
insert - If true, we insert PI nodes, If false, we remove them.

PiNodes

public PiNodes(boolean insert,
               boolean typeChecks)
Create the phase.

Parameters:
insert - If true, we insert PI nodes, If false, we remove them.
typeChecks - If true, we insert PI nodes only for type checks.
Method Detail

shouldPerform

public boolean shouldPerform(OptOptions options)
Should this phase be performed? Only perform this when we are doing an SSA-based optimization that can benefit from PI nodes.

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

getClassConstructor

public Constructor<CompilerPhase> getClassConstructor()
Get a constructor object for this compiler phase

Overrides:
getClassConstructor in class CompilerPhase
Returns:
compiler phase constructor

getName

public String getName()
A String representation of this phase

Specified by:
getName in class CompilerPhase
Returns:
a string representation

printingEnabled

public boolean printingEnabled(OptOptions options,
                               boolean before)
Should we print the IR either before or after this phase?

Overrides:
printingEnabled in class CompilerPhase
Parameters:
options - controlling compiler options
before - control for the query
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

insertPiIfNodes

private void insertPiIfNodes(IR ir)
Insert PI nodes corresponding to compare operations. Pi-nodes are represented as dummy assignments with a single argument inserted along each outedge of the conditional.

Parameters:
ir - the governing IR

insertPiBcNodes

private void insertPiBcNodes(IR ir)
Insert Pi nodes for boundchecks.

Each boundcheck Arr, Index will be followed by

 PI Index, Index 

Parameters:
ir - the governing IR

insertPiNullCheckNodes

private void insertPiNullCheckNodes(IR ir)
Insert Pi nodes for null check operations.

Each checkcast obj will be followed by

 PI obj, obj 

Parameters:
ir - the governing IR

insertPiCheckCastNodes

private void insertPiCheckCastNodes(IR ir)
Insert Pi nodes for checkcast operations.

Each checkcast obj will be followed by

 ref_move obj, obj 

Parameters:
ir - the governing IR

cleanUp

static void cleanUp(IR ir)
Change all PI nodes to INT_MOVE instructions

Side effect: invalidates SSA state

Parameters:
ir - the governing IR

getGenerator

public static Instruction getGenerator(Instruction def)
Get the instruction a Pi node is linked to. PRECONDITION: register lists computed and valid.


isNotTakenPi

public static boolean isNotTakenPi(Instruction def)
Is an instruction a Pi node linked to the not taken edge of a conditional branch instruction?


isTakenPi

public static boolean isTakenPi(Instruction def)
Is an instruction a Pi node linked to the taken edge of a conditional branch instruction?


isBoundsCheckPi

public static boolean isBoundsCheckPi(Instruction def)
Is an instruction a Pi node linked to a bounds-check?


isNullCheckPi

public static boolean isNullCheckPi(Instruction def)
Is an instruction a Pi node linked to a null-check?