public final class GenerationContext extends Object
Modifier and Type | Field and Description |
---|---|
private HashMap<Register,RegisterOperand> |
_ncGuards |
private Register[] |
addressLocals |
private boolean |
allocFrame
Did BC2IR encounter a magic that requires us to allocate a stack frame?
|
private Operand[] |
arguments
The parameters which BC2IR should use to seed the local state
for the entry basic block.
|
private BranchProfiles |
branchProfiles
The BranchProfile data for method, if available
|
private ControlFlowGraph |
cfg
The CFG object into which instructions should be generated.
|
private Register[] |
doubleLocals |
private ExceptionHandlerBasicBlockBag |
enclosingHandlers
The enclosing exception handlers (null if there are none).
|
private BasicBlock |
epilogue
The basic block into which BC2IR's caller will generate an epilogue.
|
private BasicBlock |
exit
The exit node of the outermost CFG
(used by BC2IR for not-definitely caught athrows and by OSR_Yieldpoints)
|
private Register[] |
floatLocals |
private boolean |
generatedExceptionHandlers
Did BC2IR generate a reachable exception handler while generating
the IR for this method
|
private InlineOracle |
inlinePlan
The InlineOracle to be consulted for all inlining decisions during
the generation of this IR.
|
private InlineSequence |
inlineSequence
Inlining context of the method to be generated
|
private Map<Instruction,Instruction> |
instToOSRBarriers
Mapping of instructions to on-stack replacement (OSR) barriers.
|
private Register[] |
intLocals |
private Register[] |
longLocals |
private NormalMethod |
method
The method to be generated
|
private OptOptions |
options
The options to control the generation
|
private CompiledMethod |
original_cm
The compiled method assigned for this compilation of original_method
|
private GenerationContext |
parent
The parent of this context is the context that the method
createChildContext(ExceptionHandlerBasicBlockBag, NormalMethod, Instruction)
was called upon in order to create this context. |
private BasicBlock |
prologue
The basic block into which BC2IR's caller will generate a "prologue."
|
private Operand |
result
Used to communicate the meet of the return values back to the caller
Mainly useful when BC2IR is doing inlining....allows the caller
BC2IR object
to exploit knowledge the callee BC2IR object had about the result.
|
private Register |
resultReg
The Register to which BC2IR should assign the return value(s)
of the method.
|
private GenericRegisterPool |
temps
The register pool to be used during generation
|
private BasicBlock |
unlockAndRethrow
A catch, unlock, and rethrow exception handler used for
synchronized methods.
|
Modifier | Constructor and Description |
---|---|
private |
GenerationContext()
for internal use only (in createInlinedContext)
|
(package private) |
GenerationContext(NormalMethod meth,
TypeReference[] params,
CompiledMethod cm,
OptOptions opts,
InlineOracle ip)
Use this constructor to create an outermost (non-inlined)
GenerationContext.
|
Modifier and Type | Method and Description |
---|---|
private void |
appendInstruction(BasicBlock b,
Instruction s,
int bcIndex) |
void |
close()
Kill ncGuards, so we do not use outdated mappings unintendedly later on
|
private void |
completeEpilogue(boolean isOutermost)
Fill in the rest of the method epilogue.
|
private void |
completeExceptionHandlers(boolean isOutermost)
If the method is synchronized then we wrap it in a
synthetic exception handler that unlocks & rethrows
PRECONDITION: cfg, arguments & temps have been setup/initialized.
|
private void |
completePrologue(boolean isOutermost)
Fills in the rest of the method prologue.
|
GenerationContext |
createChildContext(ExceptionHandlerBasicBlockBag ebag,
NormalMethod callee,
Instruction callSite)
Creates a child generation context from this context
and callerBB to generate IR for callsite.
|
static GenerationContext |
createSynthetic(GenerationContext parent,
ExceptionHandlerBasicBlockBag ebag)
Only for internal use by Inliner (when inlining multiple targets)
This is probably not the prettiest way to handle this, but it requires
no changes to BC2IR's & Inliner's high level control logic.
|
void |
discardOSRBarrierInformation() |
void |
forceFrameAllocation()
Forces allocation of a stack frame for this method.
|
boolean |
generatedExceptionHandlers() |
(package private) Operand[] |
getArguments() |
(package private) BranchProfiles |
getBranchProfiles() |
ControlFlowGraph |
getCfg() |
(package private) BranchProfileOperand |
getConditionalBranchProfileOperand(int bcIndex,
boolean backwards) |
(package private) ExceptionHandlerBasicBlockBag |
getEnclosingHandlers() |
BasicBlock |
getEpilogue() |
BasicBlock |
getExit() |
(package private) InlineOracle |
getInlinePlan() |
InlineSequence |
getInlineSequence() |
(package private) int |
getLocalNumberFor(Register reg,
TypeReference type)
Gets the local number for a given register
|
private Operand |
getLockObject()
Get the object for locking for synchronized methods.
|
NormalMethod |
getMethod() |
OptOptions |
getOptions() |
(package private) CompiledMethod |
getOriginalCompiledMethod() |
(package private) NormalMethod |
getOriginalMethod() |
Instruction |
getOSRBarrierFromInst(Instruction inst) |
private GenerationContext |
getOutermostContext() |
private Register[] |
getPool(TypeReference type) |
BasicBlock |
getPrologue() |
Operand |
getResult() |
(package private) Register |
getResultReg() |
(package private) SwitchBranchProfile |
getSwitchProfile(int bcIndex) |
GenericRegisterPool |
getTemps() |
(package private) BasicBlock |
getUnlockAndRethrow() |
private void |
initLocalPool() |
(package private) boolean |
isLocal(Operand op,
int i,
TypeReference type)
Is the operand a particular bytecode local?
|
(package private) Register |
localReg(int i,
TypeReference type)
Returns the Register used to for local i of TypeReference type.
|
(package private) RegisterOperand |
makeLocal(int i,
RegisterOperand props)
Makes a register operand that refers to the given local variable number,
and inherits its properties (type, flags) from props
|
(package private) RegisterOperand |
makeLocal(int i,
TypeReference type)
Makes a register operand that refers to the given local variable number
and has the given type.
|
(package private) RegisterOperand |
makeNullCheckGuard(Register ref)
Makes a register operand to use as a null check guard for the
given register.
|
void |
markExceptionHandlersAsGenerated() |
(package private) boolean |
methodIsSelectedForDebuggingWithMethodToPrint()
Is this method selected for debugging with method to print?
|
(package private) boolean |
noBoundsChecks() |
(package private) boolean |
noCheckStoreChecks() |
(package private) boolean |
noNullChecks() |
boolean |
requiresStackFrame() |
private boolean |
requiresUnintMarker() |
private void |
resync_ncGuards()
This method makes sure that _ncGuard only maps to registers that
are actually in the IRs register pool.
|
void |
resync()
Make sure, the generation context is still in sync with the IR, even if we applied some
optimizations.
|
void |
saveOSRBarrierForInst(Instruction osrBarrier,
Instruction inst) |
void |
setEpilogue(BasicBlock epilogue) |
void |
setResult(Operand result) |
void |
transferStateToParent()
Transfers the state from this context back to its direct
parent.
|
private GenerationContext parent
createChildContext(ExceptionHandlerBasicBlockBag, NormalMethod, Instruction)
was called upon in order to create this context. This field is null
if this context is the outermost one.private CompiledMethod original_cm
private NormalMethod method
private BranchProfiles branchProfiles
private OptOptions options
private ControlFlowGraph cfg
private GenericRegisterPool temps
private Operand[] arguments
private BasicBlock prologue
private BasicBlock epilogue
private BasicBlock exit
private BasicBlock unlockAndRethrow
private Register resultReg
private ExceptionHandlerBasicBlockBag enclosingHandlers
private InlineSequence inlineSequence
private InlineOracle inlinePlan
private boolean generatedExceptionHandlers
private boolean allocFrame
private Operand result
private Map<Instruction,Instruction> instToOSRBarriers
Child contexts save this information in their outermost parent
context, so this field will be null
for child contexts.
private Register[] addressLocals
private Register[] floatLocals
private Register[] longLocals
private Register[] doubleLocals
private HashMap<Register,RegisterOperand> _ncGuards
GenerationContext(NormalMethod meth, TypeReference[] params, CompiledMethod cm, OptOptions opts, InlineOracle ip)
meth
- The NormalMethod whose IR will be generatedparams
- The known types of the parameters to the method. For method specialization.cm
- The compiled method id to be used for this compilationopts
- The Options to be used for the generationip
- The InlineOracle to be used for the generationprivate GenerationContext()
public GenerationContext createChildContext(ExceptionHandlerBasicBlockBag ebag, NormalMethod callee, Instruction callSite)
ebag
- the enclosing exception handlers (null if none)callee
- the callee method to be inlined
(may _not_ be equal to Call.getMethod(callSite).method)callSite
- the Call instruction to be inlined.public static GenerationContext createSynthetic(GenerationContext parent, ExceptionHandlerBasicBlockBag ebag)
parent
- the parent GCebag
- the enclosing exception handlers (null if none)public void transferStateToParent()
IllegalStateException
- when this context does not have a parentprivate void initLocalPool()
private Register[] getPool(TypeReference type)
Register localReg(int i, TypeReference type)
i
- local numbertype
- local's typeboolean noNullChecks()
true
if and only if null checks should be generatedboolean noBoundsChecks()
true
if and only if bounds checks should be generatedboolean noCheckStoreChecks()
true
if and only if checkstore checks should be generatedRegisterOperand makeLocal(int i, TypeReference type)
i
- local variable numbertype
- desired data typeRegisterOperand makeLocal(int i, RegisterOperand props)
i
- local variable numberprops
- RegisterOperand to inherit flags fromint getLocalNumberFor(Register reg, TypeReference type)
reg
- the register whose local number should be found outtype
- the register's typeboolean isLocal(Operand op, int i, TypeReference type)
op
- the operand to checki
- the local's indextype
- the local's typetrue
if and only if the given operand is a
an operand for the given bytecode localRegisterOperand makeNullCheckGuard(Register ref)
ref
- the register to check for nullBranchProfileOperand getConditionalBranchProfileOperand(int bcIndex, boolean backwards)
SwitchBranchProfile getSwitchProfile(int bcIndex)
private void completePrologue(boolean isOutermost)
isOutermost
- is this the outermost context (i.e. not an inlined context)private void completeEpilogue(boolean isOutermost)
isOutermost
- is this the outermost context (i.e. not an inlined context)private void completeExceptionHandlers(boolean isOutermost)
isOutermost
- is this the outermost context (i.e. not an inlined context)private Operand getLockObject()
private void appendInstruction(BasicBlock b, Instruction s, int bcIndex)
private boolean requiresUnintMarker()
public void resync()
private void resync_ncGuards()
public void close()
boolean methodIsSelectedForDebuggingWithMethodToPrint()
A method is selected if the name of the original method is contained in the set of methods to print. This ensures that debug output is not omitted during generation of IR for methods that are inlined into a method that is supposed to be printed.
true
if and only if this method is selected for
debugging as described aboveBC2IR.DBG_SELECTIVE
public void forceFrameAllocation()
public boolean requiresStackFrame()
public boolean generatedExceptionHandlers()
public void markExceptionHandlersAsGenerated()
public void saveOSRBarrierForInst(Instruction osrBarrier, Instruction inst)
public Instruction getOSRBarrierFromInst(Instruction inst)
public void discardOSRBarrierInformation()
public NormalMethod getMethod()
public OptOptions getOptions()
public ControlFlowGraph getCfg()
public GenericRegisterPool getTemps()
public BasicBlock getPrologue()
public BasicBlock getEpilogue()
public void setEpilogue(BasicBlock epilogue)
public BasicBlock getExit()
public InlineSequence getInlineSequence()
NormalMethod getOriginalMethod()
CompiledMethod getOriginalCompiledMethod()
BranchProfiles getBranchProfiles()
Operand[] getArguments()
BasicBlock getUnlockAndRethrow()
Register getResultReg()
ExceptionHandlerBasicBlockBag getEnclosingHandlers()
InlineOracle getInlinePlan()
private GenerationContext getOutermostContext()