org.jikesrvm.compilers.opt.hir2lir
Class DynamicTypeCheckExpansion

java.lang.Object
  extended by org.jikesrvm.compilers.opt.ir.IRTools
      extended by org.jikesrvm.compilers.opt.hir2lir.ConvertToLowLevelIR
          extended by org.jikesrvm.compilers.opt.hir2lir.DynamicTypeCheckExpansion

abstract class DynamicTypeCheckExpansion
extends ConvertToLowLevelIR

Expansion of Dynamic Type Checking operations.

See Also:
DynamicTypeCheck

Field Summary
 
Fields inherited from class org.jikesrvm.compilers.opt.hir2lir.ConvertToLowLevelIR
LOWER_ARRAY_ACCESS
 
Constructor Summary
DynamicTypeCheckExpansion()
           
 
Method Summary
private static BasicBlock advanceBlock(int bcIndex, BasicBlock curBlock, IR ir)
           
(package private) static Instruction arrayStoreCheck(Instruction s, IR ir, boolean couldBeNull)
          Expand an object array store check into the LIR sequence that implements it.
(package private) static Instruction checkcast(Instruction s, IR ir)
          Expand a checkcast instruction into the LIR sequence that implements the dynamic type check, raising a ClassCastException when the type check fails.
(package private) static Instruction checkcastNotNull(Instruction s, IR ir)
          Expand a checkcast instruction into the LIR sequence that implements the dynamic type check, raising a ClassCastException when the type check fails.
private static Instruction convertToBranchingTypeCheck(Instruction s, IR ir, Operand RHSobj, TypeReference LHStype, Operand RHStib, RegisterOperand result)
          Generate wrapper around branching type check to get a value producing type check.
private static BasicBlock fallThroughBB(Instruction s, IR ir)
           
private static Instruction generateBranchingTypeCheck(Instruction s, IR ir, Operand RHSobj, TypeReference LHStype, Operand RHStib, BasicBlock trueBlock, BasicBlock falseBlock, RegisterOperand oldGuard, BranchProfileOperand falseProb)
          Generate a branching dynamic type check.
private static Instruction generateValueProducingTypeCheck(Instruction s, IR ir, Operand RHSobj, TypeReference LHStype, Operand RHStib, RegisterOperand result)
          Generate a value-producing dynamic type check.
(package private) static Instruction instanceOf(Instruction s, IR ir)
          Expand an instanceof instruction into the LIR sequence that implements the dynamic type check.
(package private) static Instruction instanceOfNotNull(Instruction s, IR ir)
          Expand an instanceof instruction into the LIR sequence that implements the dynamic type check.
(package private) static Instruction mustImplementInterface(Instruction s, IR ir)
          Expand a checkcastInterface instruction into the LIR sequence that implements the dynamic type check, raising an IncompataibleClassChangeError if the type check fails.
 
Methods inherited from class org.jikesrvm.compilers.opt.hir2lir.ConvertToLowLevelIR
callHelper, convert, doArrayLoad, doArrayStore, expandSysCallTarget, getField, getField, getInstanceMethod, getSpecialMethod, getStatic, getTIB, getTIB, getTIB, insertBinary, InsertGuardedUnary, InsertLoadOffset, InsertLoadOffset, InsertLoadOffset, InsertLoadOffset, InsertLoadOffsetJTOC, InsertLoadOffsetJTOC, InsertUnary, lookup, tableswitch
 
Methods inherited from class org.jikesrvm.compilers.opt.ir.IRTools
A, AC, AC, CPOS, CR, D, DC, defDoublesAsUse, definedIn, F, FC, getCondMoveOp, getDefaultOperand, getLoadOp, getLoadOp, getMoveOp, getStoreOp, getStoreOp, I, IC, insertInstructionsAfter, L, LC, makeBlockOnEdge, mayBeVolatileFieldLoad, moveInstruction, moveIntoRegister, moveIntoRegister, nonPEIGC, TG, usedIn, useDoublesAsDef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DynamicTypeCheckExpansion

DynamicTypeCheckExpansion()
Method Detail

instanceOf

static Instruction instanceOf(Instruction s,
                              IR ir)
Expand an instanceof instruction into the LIR sequence that implements the dynamic type check. Ref may contain a null ptr at runtime.

Parameters:
s - an INSTANCEOF or INSTANCEOF_UNRESOLVED instruction to expand
ir - the enclosing IR
Returns:
the last Instruction in the generated LIR sequence.

instanceOfNotNull

static Instruction instanceOfNotNull(Instruction s,
                                     IR ir)
Expand an instanceof instruction into the LIR sequence that implements the dynamic type check. Ref is known to never contain a null ptr at runtime.

Parameters:
s - an INSTANCEOF_NOTNULL instruction to expand
ir - the enclosing IR
Returns:
the last Instruction in the generated LIR sequence.

checkcast

static Instruction checkcast(Instruction s,
                             IR ir)
Expand a checkcast instruction into the LIR sequence that implements the dynamic type check, raising a ClassCastException when the type check fails. Ref may contain a null ptr at runtime.

Parameters:
s - a CHECKCAST or CHECKCAST_UNRESOLVED instruction to expand
ir - the enclosing IR
Returns:
the last Instruction in the generated LIR sequence.

checkcastNotNull

static Instruction checkcastNotNull(Instruction s,
                                    IR ir)
Expand a checkcast instruction into the LIR sequence that implements the dynamic type check, raising a ClassCastException when the type check fails. Ref is known to never contain a null ptr at runtime.

Parameters:
s - a CHECKCAST_NOTNULL instruction to expand
ir - the enclosing IR
Returns:
the last Instruction in the generated LIR sequence.

mustImplementInterface

static Instruction mustImplementInterface(Instruction s,
                                          IR ir)
Expand a checkcastInterface instruction into the LIR sequence that implements the dynamic type check, raising an IncompataibleClassChangeError if the type check fails. Ref is known to never contain a null ptr at runtime.

Parameters:
s - a MUST_IMPLEMENT_INTERFACE instruction to expand
ir - the enclosing IR
Returns:
the last Instruction in the generated LIR sequence.

arrayStoreCheck

static Instruction arrayStoreCheck(Instruction s,
                                   IR ir,
                                   boolean couldBeNull)
Expand an object array store check into the LIR sequence that implements it.

Parameters:
s - an OBJARRAY_STORE_CHECK instruction to expand
ir - the enclosing IR
couldBeNull - is it possible that the element being stored is null?
Returns:
the last Instruction in the generated LIR sequence.

generateValueProducingTypeCheck

private static Instruction generateValueProducingTypeCheck(Instruction s,
                                                           IR ir,
                                                           Operand RHSobj,
                                                           TypeReference LHStype,
                                                           Operand RHStib,
                                                           RegisterOperand result)
Generate a value-producing dynamic type check. This routine assumes that the CFG and code order are already correctly established. This routine must either remove s or mutuate it.

Parameters:
s - The Instruction that is to be replaced by a value producing type check
ir - The IR containing the instruction to be expanded.
RHSobj - The RegisterOperand containing the rhs object.
LHStype - The RVMType to be tested against.
RHStib - The Operand containing the TIB of the rhs.
result - The RegisterOperand that the result of dynamic type check is to be stored in.
Returns:
the opt instruction immediately before the instruction to continue expansion.

convertToBranchingTypeCheck

private static Instruction convertToBranchingTypeCheck(Instruction s,
                                                       IR ir,
                                                       Operand RHSobj,
                                                       TypeReference LHStype,
                                                       Operand RHStib,
                                                       RegisterOperand result)
Generate wrapper around branching type check to get a value producing type check.

Parameters:
s - The Instruction that is to be replaced by a value producing type check
ir - The IR containing the instruction to be expanded.
RHSobj - The RegisterOperand containing the rhs object.
LHStype - The TypeReference to be tested against.
RHStib - The Operand containing the TIB of the rhs.
result - The RegisterOperand that the result of dynamic
Returns:
the opt instruction immediately before the instruction to continue expansion.

generateBranchingTypeCheck

private static Instruction generateBranchingTypeCheck(Instruction s,
                                                      IR ir,
                                                      Operand RHSobj,
                                                      TypeReference LHStype,
                                                      Operand RHStib,
                                                      BasicBlock trueBlock,
                                                      BasicBlock falseBlock,
                                                      RegisterOperand oldGuard,
                                                      BranchProfileOperand falseProb)
Generate a branching dynamic type check. This routine assumes that the CFG and code order are already correctly established. This routine must either remove s or mutuate it.

Parameters:
s - The Instruction that is to be replaced by a branching type check
ir - The IR containing the instruction to be expanded.
RHSobj - The RegisterOperand containing the rhs object.
LHStype - The TypeReference to be tested against.
RHStib - The Operand containing the TIB of the rhs.
trueBlock - The BasicBlock to continue at if the typecheck evaluates to true
falseBlock - The BasicBlock to continue at if the typecheck evaluates to false.
falseProb - The probability that typecheck will branch to the falseBlock
Returns:
the opt instruction immediately before the instruction to continue expansion.

fallThroughBB

private static BasicBlock fallThroughBB(Instruction s,
                                        IR ir)

advanceBlock

private static BasicBlock advanceBlock(int bcIndex,
                                       BasicBlock curBlock,
                                       IR ir)