本文整理汇总了C++中tr::Block::split方法的典型用法代码示例。如果您正苦于以下问题:C++ Block::split方法的具体用法?C++ Block::split怎么用?C++ Block::split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tr::Block
的用法示例。
在下文中一共展示了Block::split方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: perform
// This opt tries to reduce merge backs from cold code that are the result of inliner
// gnerated nopable virtual guards
// It looks for one basic pattern
//
// guard1 -> cold1
// BBEND
// BBSTART
// guard2 -> cold2
// if guard1 is the guard for a method which calls the method guard2 protects or cold1 is
// a predecessor of cold2 (a situation commonly greated by virtual guard tail splitter) we
// can transform the guards as follows when guard1 and guard2 a
// guard1 -> cold1
// BBEND
// BBSTART
// guard2 -> cold1
// This is safe because there are no trees between the guards and calling the caller will
// result in the call to the callee if we need to patch guard2. cold2 and its mergebacks
// can then be eliminated
//
// In addition this opt will try to move guard2 up from the end of a block to the
// start of the block. We can do this if guard2 is an HCR guard and there is no GC point
// between BBSTART and guard2 since HCR is a stop-the-world event.
//
// Finally, there is a simple tail splitting step run before the analysis of a guard if we
// detect that the taken side of the guard merges back in the next block - this happens
// for some empty methods and is common for Object.<init> at the top of constructors.
int32_t TR_VirtualGuardHeadMerger::perform() {
static char *disableVGHeadMergerTailSplitting = feGetEnv("TR_DisableVGHeadMergerTailSplitting");
TR::CFG *cfg = comp()->getFlowGraph();
// Cache the loads for the outer guard's cold path
TR_BitVector coldPathLoads(comp()->trMemory()->currentStackRegion());
TR_BitVector privArgSymRefs(comp()->trMemory()->currentStackRegion());
bool evaluatedColdPathLoads = false;
for (TR::Block *block = optimizer()->getMethodSymbol()->getFirstTreeTop()->getNode()->getBlock();
block; block = block->getNextBlock())
{
TR::Node *guard1 = block->getLastRealTreeTop()->getNode();
if (isMergeableGuard(guard1))
{
if (trace())
traceMsg(comp(), "Found mergeable guard in block_%d\n", block->getNumber());
TR::Block *cold1 = guard1->getBranchDestination()->getEnclosingBlock();
// check for an immediate merge back from the cold block and
// tail split one block if we can - we only handle splitting a block
// ending in a fallthrough, a branch or a goto for now for simplicity
if (!disableVGHeadMergerTailSplitting &&
(cold1->getSuccessors().size() == 1) &&
cold1->hasSuccessor(block->getNextBlock()) &&
cold1->getLastRealTreeTop()->getNode()->getOpCode().isGoto())
{
// TODO handle moving code earlier in the block down below the guard
// tail split
if ((block->getNextBlock()->getSuccessors().size() == 1) ||
((block->getNextBlock()->getSuccessors().size() == 2) &&
block->getNextBlock()->getLastRealTreeTop()->getNode()->getOpCode().isBranch()) &&
performTransformation(comp(), "%sCloning block_%d and placing clone after block_%d to reduce HCR guard nops\n", OPT_DETAILS, block->getNextBlock()->getNumber(), cold1->getNumber()))
tailSplitBlock(block, cold1);
}
// guard motion is fairly complex but what we want to achieve around guard1 is a sequence
// of relocated privarg blocks, followed by a sequence of runtime patchable guards going to
// guard1's cold block, followed by a sequence of stop-the-world guards going to guard1's
// cold block
//
// The following code is to setup the various insert points based on the following diagrams
// of basic blocks:
//
// start: setup: end result after moving runtime guard'
// | | +-------+ <-- privargIns
// | | <-- privargIns |
// +-------+ <-- runtimeIns +-------+
// | | | | Guard'|
// | | V +-------+ <-- runtimeIns
// +-------+ +-------+ |
// | Guard | | Guard | V
// +-------+ +-------+ <-- HCRIns +-------+
// | ===> | ===> | Guard |
// V V +-------+ <-- HCRIns
// +-------+ +-------+ |
// | | | | V
// | | | | +-------+
//
// Note we always split the block - this may create an empty block but preserves the incoming
// control flow we leave the rest to block extension to fix later
block = block->split(block->getLastRealTreeTop(), cfg, true, false);
TR::Block *privargIns = block->getPrevBlock();
TR::Block *runtimeIns = block->getPrevBlock();
TR::Block *HCRIns = block;
// New outer guard so cold paths must be evaluated
evaluatedColdPathLoads = false;
// scan for candidate guards to merge with guard1 identified above
for (TR::Block *nextBlock = block->getNextBlock(); nextBlock; nextBlock = nextBlock->getNextBlock())
{
//.........这里部分代码省略.........