/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Implementation of the branch hinting proposal // Some control instructions (if and br_if) can have a hint of the form // likely or unlikely. That means a specific branch will be likely/unlikely // to be executed at runtime.
// This pass will propagate the branch hints to successor blocks in the CFG. // Currently, we use the branch hinting information for the following: // - Unlikely blocks are moved out of line, this is done at the LIR level. // - TODO: use branch hinting to optimize likely blocks. bool jit::BranchHinting(const MIRGenerator* mir, MIRGraph& graph) {
JitSpew(JitSpew_BranchHint, "Beginning BranchHinting pass");
/* This pass propagates branch hints across the control flow graph usingdominatorinformation.Branchhintsarereadatcompile-timefor specificbasicblocks.Thispasspropagatesthispropertytosuccessor blocksinaconservativeway.Thealgorithmworksasfollows: -TheCFGistraversedinreverse-post-order(RPO).Dominatorparentsare visitedbeforetheblockstheydominate.
Becauseweonlypropagatealongdominator-treeedges(parent->child), eachblockreceivesinformationfromexactlyonesource.Thisavoids conflictsthatwouldotherwiseariseatCFGjoinpoints.
*/ for (ReversePostorderIterator block(graph.rpoBegin());
block != graph.rpoEnd(); block++) { if (block->isUnknownFrequency()) { continue;
}
for (MBasicBlock** it = block->immediatelyDominatedBlocksBegin();
it != block->immediatelyDominatedBlocksEnd(); it++) { // Don't propagate the information if this successor block has already // some branch hints. if ((*it)->isUnknownFrequency()) {
(*it)->setFrequency(block->getFrequency());
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.