|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jikesrvm.compilers.opt.driver.CompilerPhase org.jikesrvm.adaptive.recompilation.instrumentation.InstrumentationSamplingFramework
public final class InstrumentationSamplingFramework
Transforms the method so that instrumentation is sampled, rather than executed exhaustively. Includes both the full-duplication and no-duplication variations. See Arnold-Ryder PLDI 2001, and the section 4.1 of Arnold's PhD thesis.
NOTE: This implementation uses yieldpoints to denote where checks should be placed (to transfer control into instrumented code). It is currently assumed that these are on method entries and backedges. When optimized yieldpoint placement exists either a) it should be turned off when using this phase, or b) this phase should detect its own check locations.
To avoid the complexity of duplicating exception handler maps, exception handler blocks are split and a check at the top of the handler. Thus exceptions from both the checking and duplicated code are handled by the same catch block, however the check at the top of the catch block ensures that the hander code has the opportunity to be sampled.
Field Summary | |
---|---|
private RegisterOperand |
cbsReg
Temporary variables |
private static Constructor<CompilerPhase> |
constructor
Constructor for this compiler phase |
private static boolean |
DEBUG
These are local copies of optimizing compiler debug options that can be set via the command line arguments. |
private static boolean |
DEBUG2
|
Fields inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase |
---|
container |
Constructor Summary | |
---|---|
InstrumentationSamplingFramework()
|
Method Summary | |
---|---|
private static void |
adjustPointersInDuplicatedCode(IR ir,
HashMap<BasicBlock,BasicBlock> origToDupMap)
Go through all blocks in duplicated code and adjust the edges as follows: All edges (in duplicated code) that go into a block with a yieldpoint must jump to back to the original code. |
private void |
appendLoad(BasicBlock bb,
IR ir)
Append a load of the global counter to the given basic block. |
private void |
cleanUp(IR ir)
Initialization to perform after the transformation is applied |
private static void |
clearScratchObjects(BasicBlock bb,
IR ir)
Go through all statements in the basic block and clear the scratch objects. |
private void |
conditionalizeInstrumentationOperation(IR ir,
Instruction i,
BasicBlock bb)
Take an instrumentation operation (an instruction) and guard it with a counter-based check. |
private void |
createCheck(BasicBlock checkBB,
BasicBlock noInstBB,
BasicBlock instBB,
boolean fallthroughToInstBB,
IR ir)
Append a check to a basic block, and make it jump to the right places. |
static void |
dumpCFG(IR ir)
Temp debugging code |
private void |
duplicateCode(IR ir,
HashMap<BasicBlock,BasicBlock> origToDupMap,
HashSet<BasicBlock> exceptionHandlerBlocks)
Make a duplicate of all basic blocks down at the bottom of the code order. |
Constructor<CompilerPhase> |
getClassConstructor()
Get a constructor object for this compiler phase |
private static Instruction |
getFirstInstWithOperator(Operator operator,
BasicBlock bb)
Go through all instructions and find the first with the given operator. |
static Instruction |
getFirstInstWithYieldPoint(BasicBlock bb)
Go through all instructions and find one that is a yield point |
String |
getName()
|
private static RegisterOperand |
getOrCreateDupReg(RegisterOperand ro,
IR ir)
The given register a) does not span multiple basic block, and b) is used in a basic block that is being duplicated. |
private void |
insertCBSChecks(IR ir,
HashMap<BasicBlock,BasicBlock> origToDupMap,
HashSet<BasicBlock> exceptionHandlerBlocks)
In the checking code, insert CBS checks at each yieldpoint, to transfer code into the duplicated (instrumented) code. |
private static boolean |
isInstrumentationInstruction(Instruction i)
How to determine whether a given instruction is an "instrumentation instruction". |
static boolean |
isYieldpoint(Instruction i)
Is the given instruction a yieldpoint? |
private static BasicBlock |
myCopyWithoutLinks(BasicBlock bb,
IR ir)
The same as BasicBlock.copyWithoutLinks except that it renames all temp variables that are never used outside the basic block. |
void |
perform(IR ir)
Perform this phase |
private void |
performVariationFullDuplication(IR ir,
CompilerPhase phaseObject)
Perform the full duplication algorithm |
private void |
performVariationNoDuplication(IR ir)
Perform the NoDuplication version of the framework (see Arnold-Ryder PLDI 2001). |
private void |
prependCounterReset(BasicBlock bb,
IR ir)
Prepend the code to reset the global counter to the given basic block. |
private void |
prependDecrement(BasicBlock bb,
IR ir)
Append a decrement of the global counter to the given basic block. |
private void |
prependStore(BasicBlock bb,
IR ir)
Append a store of the global counter to the given basic block. |
private static void |
removeInstrumentationFromOrig(IR ir,
HashMap<BasicBlock,BasicBlock> origToDupMap)
Remove instrumentation from the original version of all duplicated basic blocks. |
boolean |
shouldPerform(OptOptions options)
This method determines if the phase should be run, based on the Options object it is passed. |
private static void |
updateTemps(BasicBlock bb,
IR ir)
Given an basic block, rename all of the temporary registers that are local to the block. |
Methods inherited from class org.jikesrvm.compilers.opt.driver.CompilerPhase |
---|
dumpIR, dumpIR, getCompilerPhaseConstructor, getCompilerPhaseConstructor, newExecution, performPhase, printingEnabled, reportAdditionalStats, setContainer, verify |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static boolean DEBUG
private static boolean DEBUG2
private RegisterOperand cbsReg
private static final Constructor<CompilerPhase> constructor
Constructor Detail |
---|
public InstrumentationSamplingFramework()
Method Detail |
---|
public Constructor<CompilerPhase> getClassConstructor()
getClassConstructor
in class CompilerPhase
public boolean shouldPerform(OptOptions options)
CompilerPhase
shouldPerform
in class CompilerPhase
options
- the compiler options for the compilation
public String getName()
getName
in class CompilerPhase
public void perform(IR ir)
perform
in class CompilerPhase
ir
- the governing IRprivate void cleanUp(IR ir)
private void performVariationFullDuplication(IR ir, CompilerPhase phaseObject)
ir
- the governing IRprivate void duplicateCode(IR ir, HashMap<BasicBlock,BasicBlock> origToDupMap, HashSet<BasicBlock> exceptionHandlerBlocks)
ir
- the governing IRprivate void insertCBSChecks(IR ir, HashMap<BasicBlock,BasicBlock> origToDupMap, HashSet<BasicBlock> exceptionHandlerBlocks)
ir
- the governing IRprivate void createCheck(BasicBlock checkBB, BasicBlock noInstBB, BasicBlock instBB, boolean fallthroughToInstBB, IR ir)
checkBB
- The block to append the CBS check to.noInstBB
- The basic block to jump to if the CBS check failsinstBB
- The basicBlock to jump to if the CBS check succeedsfallthroughToInstBB
- Should checkBB fallthrough to instBB
(otherwise it must fallthrough to noInstBB)private void appendLoad(BasicBlock bb, IR ir)
bb
- The block to append the load toir
- The IRprivate void prependStore(BasicBlock bb, IR ir)
bb
- The block to append the load toir
- The IRprivate void prependDecrement(BasicBlock bb, IR ir)
bb
- The block to append the load toir
- The IRprivate void prependCounterReset(BasicBlock bb, IR ir)
bb
- The block to append the load toir
- The IRprivate static Instruction getFirstInstWithOperator(Operator operator, BasicBlock bb)
operator
- The operator to look forbb
- The basic block in which to look
public static Instruction getFirstInstWithYieldPoint(BasicBlock bb)
bb
- The basic block in which to look
public static boolean isYieldpoint(Instruction i)
private static void adjustPointersInDuplicatedCode(IR ir, HashMap<BasicBlock,BasicBlock> origToDupMap)
ir
- the governing IRprivate static void removeInstrumentationFromOrig(IR ir, HashMap<BasicBlock,BasicBlock> origToDupMap)
The yieldpoints can also be removed from either the original or the duplicated code. If you remove them from the original, it will make it run faster (since it is executed more than the duplicated) however that means that you can't turn off the instrumentation or you could infinitely loop without executing yieldpoints!
ir
- the governing IRprivate static BasicBlock myCopyWithoutLinks(BasicBlock bb, IR ir)
PRECONDITION: the spansBasicBlock bit must be correct by calling DefUse.recomputeSpansBasicBlock(IR);
private static void updateTemps(BasicBlock bb, IR ir)
private static void clearScratchObjects(BasicBlock bb, IR ir)
private static RegisterOperand getOrCreateDupReg(RegisterOperand ro, IR ir)
private void performVariationNoDuplication(IR ir)
private void conditionalizeInstrumentationOperation(IR ir, Instruction i, BasicBlock bb)
private static boolean isInstrumentationInstruction(Instruction i)
public static void dumpCFG(IR ir)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |