本文整理汇总了C++中BasicBlock::at方法的典型用法代码示例。如果您正苦于以下问题:C++ BasicBlock::at方法的具体用法?C++ BasicBlock::at怎么用?C++ BasicBlock::at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BasicBlock
的用法示例。
在下文中一共展示了BasicBlock::at方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dump
void Graph::dump()
{
NodeIndex lastNodeIndex = NoNode;
for (size_t b = 0; b < m_blocks.size(); ++b) {
BasicBlock* block = m_blocks[b].get();
if (!block)
continue;
dumpBlockHeader("", b, DumpAllPhis);
dataLog(" vars before: ");
if (block->cfaHasVisited)
dumpOperands(block->valuesAtHead, WTF::dataFile());
else
dataLog("<empty>");
dataLog("\n");
dataLog(" var links: ");
dumpOperands(block->variablesAtHead, WTF::dataFile());
dataLog("\n");
for (size_t i = 0; i < block->size(); ++i) {
dumpCodeOrigin("", lastNodeIndex, block->at(i));
dump("", block->at(i));
lastNodeIndex = block->at(i);
}
dataLog(" vars after: ");
if (block->cfaHasVisited)
dumpOperands(block->valuesAtTail, WTF::dataFile());
else
dataLog("<empty>");
dataLog("\n");
dataLog(" var links: ");
dumpOperands(block->variablesAtTail, WTF::dataFile());
dataLog("\n");
}
}
示例2: run
bool run()
{
ASSERT(m_graph.m_form != SSA);
BlockSet blocksThatNeedInvalidationPoints;
for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
BasicBlock* block = m_graph.block(blockIndex);
if (!block)
continue;
for (unsigned nodeIndex = 0; nodeIndex < block->size(); ++nodeIndex)
handle(nodeIndex, block->at(nodeIndex));
// Note: this assumes that control flow occurs at bytecode instruction boundaries.
if (m_originThatHadFire.isSet()) {
for (unsigned i = block->numSuccessors(); i--;)
blocksThatNeedInvalidationPoints.add(block->successor(i));
}
m_insertionSet.execute(block);
}
for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
BasicBlock* block = m_graph.block(blockIndex);
if (!blocksThatNeedInvalidationPoints.contains(block))
continue;
insertInvalidationCheck(0, block->at(0));
m_insertionSet.execute(block);
}
return true;
}
示例3: run
bool run()
{
ScoreBoard scoreBoard(m_graph.m_nextMachineLocal);
scoreBoard.assertClear();
for (size_t blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex) {
BasicBlock* block = m_graph.block(blockIndex);
if (!block)
continue;
if (!block->isReachable)
continue;
for (size_t indexInBlock = 0; indexInBlock < block->size(); ++indexInBlock) {
Node* node = block->at(indexInBlock);
if (!node->shouldGenerate())
continue;
switch (node->op()) {
case Phi:
case Flush:
case PhantomLocal:
continue;
case GetLocal:
ASSERT(!node->child1()->hasResult());
break;
default:
break;
}
// First, call use on all of the current node's children, then
// allocate a VirtualRegister for this node. We do so in this
// order so that if a child is on its last use, and a
// VirtualRegister is freed, then it may be reused for node.
if (node->flags() & NodeHasVarArgs) {
for (unsigned childIdx = node->firstChild(); childIdx < node->firstChild() + node->numChildren(); childIdx++)
scoreBoard.useIfHasResult(m_graph.m_varArgChildren[childIdx]);
} else {
scoreBoard.useIfHasResult(node->child1());
scoreBoard.useIfHasResult(node->child2());
scoreBoard.useIfHasResult(node->child3());
}
if (!node->hasResult())
continue;
VirtualRegister virtualRegister = scoreBoard.allocate();
node->setVirtualRegister(virtualRegister);
// 'mustGenerate' nodes have their useCount artificially elevated,
// call use now to account for this.
if (node->mustGenerate())
scoreBoard.use(node);
}
scoreBoard.assertClear();
}
// Record the number of virtual registers we're using. This is used by calls
// to figure out where to put the parameters.
m_graph.m_nextMachineLocal = scoreBoard.highWatermark();
return true;
}
示例4: process
void process(BlockIndex blockIndex)
{
BasicBlock* block = m_graph.block(blockIndex);
if (!block)
return;
// FIXME: It's likely that this can be improved, for static analyses that use
// HashSets. https://bugs.webkit.org/show_bug.cgi?id=118455
m_live = block->ssa->liveAtTail;
for (unsigned nodeIndex = block->size(); nodeIndex--;) {
Node* node = block->at(nodeIndex);
// Given an Upsilon:
//
// n: Upsilon(@x, ^p)
//
// We say that it def's @p and @n and uses @x.
//
// Given a Phi:
//
// p: Phi()
//
// We say nothing. It's neither a use nor a def.
//
// Given a node:
//
// n: Thingy(@a, @b, @c)
//
// We say that it def's @n and uses @a, @b, @c.
switch (node->op()) {
case Upsilon: {
Node* phi = node->phi();
m_live.remove(phi);
m_live.remove(node);
m_live.add(node->child1().node());
break;
}
case Phi: {
break;
}
default:
m_live.remove(node);
DFG_NODE_DO_TO_CHILDREN(m_graph, node, addChildUse);
break;
}
}
if (m_live == block->ssa->liveAtHead)
return;
m_changed = true;
block->ssa->liveAtHead = m_live;
for (unsigned i = block->predecessors.size(); i--;)
block->predecessors[i]->ssa->liveAtTail.add(m_live.begin(), m_live.end());
}
示例5: run
bool run()
{
ASSERT(m_graph.m_form == SSA);
for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
BasicBlock* block = m_graph.block(blockIndex);
if (!block)
continue;
block->ssa->availabilityAtHead.clear();
block->ssa->availabilityAtTail.clear();
}
BasicBlock* root = m_graph.block(0);
root->ssa->availabilityAtHead.m_locals.fill(Availability::unavailable());
for (unsigned argument = m_graph.m_argumentFormats.size(); argument--;) {
FlushedAt flushedAt = FlushedAt(
m_graph.m_argumentFormats[argument],
virtualRegisterForArgument(argument));
root->ssa->availabilityAtHead.m_locals.argument(argument) = Availability(flushedAt);
}
// This could be made more efficient by processing blocks in reverse postorder.
LocalOSRAvailabilityCalculator calculator;
bool changed;
do {
changed = false;
for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex) {
BasicBlock* block = m_graph.block(blockIndex);
if (!block)
continue;
calculator.beginBlock(block);
for (unsigned nodeIndex = 0; nodeIndex < block->size(); ++nodeIndex)
calculator.executeNode(block->at(nodeIndex));
if (calculator.m_availability == block->ssa->availabilityAtTail)
continue;
block->ssa->availabilityAtTail = calculator.m_availability;
changed = true;
for (unsigned successorIndex = block->numSuccessors(); successorIndex--;) {
BasicBlock* successor = block->successor(successorIndex);
successor->ssa->availabilityAtHead.merge(calculator.m_availability);
successor->ssa->availabilityAtHead.pruneByLiveness(
m_graph, successor->firstOrigin().forExit);
}
}
} while (changed);
return true;
}
示例6: collectGarbage
void Graph::collectGarbage()
{
// First reset the counts to 0 for all nodes.
for (unsigned i = size(); i--;)
at(i).setRefCount(0);
// Now find the roots: the nodes that are must-generate. Set their ref counts to
// 1 and put them on the worklist.
Vector<NodeIndex, 128> worklist;
for (BlockIndex blockIndex = 0; blockIndex < m_blocks.size(); ++blockIndex) {
BasicBlock* block = m_blocks[blockIndex].get();
if (!block)
continue;
for (unsigned indexInBlock = block->size(); indexInBlock--;) {
NodeIndex nodeIndex = block->at(indexInBlock);
Node& node = at(nodeIndex);
if (!(node.flags() & NodeMustGenerate))
continue;
node.setRefCount(1);
worklist.append(nodeIndex);
}
}
while (!worklist.isEmpty()) {
NodeIndex nodeIndex = worklist.last();
worklist.removeLast();
Node& node = at(nodeIndex);
ASSERT(node.shouldGenerate()); // It should not be on the worklist unless it's ref'ed.
if (node.flags() & NodeHasVarArgs) {
for (unsigned childIdx = node.firstChild();
childIdx < node.firstChild() + node.numChildren();
++childIdx) {
if (!m_varArgChildren[childIdx])
continue;
NodeIndex childNodeIndex = m_varArgChildren[childIdx].index();
if (!at(childNodeIndex).ref())
continue;
worklist.append(childNodeIndex);
}
} else if (node.child1()) {
if (at(node.child1()).ref())
worklist.append(node.child1().index());
if (node.child2()) {
if (at(node.child2()).ref())
worklist.append(node.child2().index());
if (node.child3()) {
if (at(node.child3()).ref())
worklist.append(node.child3().index());
}
}
}
}
}
示例7: killUnreachable
void killUnreachable(BlockIndex blockIndex)
{
BasicBlock* block = m_graph.m_blocks[blockIndex].get();
ASSERT(block);
ASSERT(!block->isReachable);
for (unsigned phiIndex = block->phis.size(); phiIndex--;)
m_graph.m_allocator.free(block->phis[phiIndex]);
for (unsigned nodeIndex = block->size(); nodeIndex--;)
m_graph.m_allocator.free(block->at(nodeIndex));
m_graph.m_blocks[blockIndex].clear();
}
示例8: run
bool run()
{
for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
BasicBlock* block = m_graph.block(blockIndex);
if (!block)
continue;
for (unsigned nodeIndex = block->size(); nodeIndex--;) {
m_node = block->at(nodeIndex);
handle();
}
}
return true;
}
示例9: dump
void Disassembler::dump(LinkBuffer& linkBuffer)
{
m_graph.m_dominators.computeIfNecessary(m_graph);
dataLogF("Generated JIT code for DFG CodeBlock %p, instruction count = %u:\n", m_graph.m_codeBlock, m_graph.m_codeBlock->instructionCount());
dataLogF(" Code at [%p, %p):\n", linkBuffer.debugAddress(), static_cast<char*>(linkBuffer.debugAddress()) + linkBuffer.debugSize());
const char* prefix = " ";
const char* disassemblyPrefix = " ";
NodeIndex lastNodeIndex = NoNode;
MacroAssembler::Label previousLabel = m_startOfCode;
for (size_t blockIndex = 0; blockIndex < m_graph.m_blocks.size(); ++blockIndex) {
BasicBlock* block = m_graph.m_blocks[blockIndex].get();
if (!block)
continue;
dumpDisassembly(disassemblyPrefix, linkBuffer, previousLabel, m_labelForBlockIndex[blockIndex], lastNodeIndex);
m_graph.dumpBlockHeader(prefix, blockIndex, Graph::DumpLivePhisOnly);
NodeIndex lastNodeIndexForDisassembly = block->at(0);
for (size_t i = 0; i < block->size(); ++i) {
if (!m_graph[block->at(i)].willHaveCodeGenOrOSR() && !Options::showAllDFGNodes())
continue;
MacroAssembler::Label currentLabel;
if (m_labelForNodeIndex[block->at(i)].isSet())
currentLabel = m_labelForNodeIndex[block->at(i)];
else {
// Dump the last instruction by using the first label of the next block
// as the end point. This case is hit either during peephole compare
// optimizations (the Branch won't have its own label) or if we have a
// forced OSR exit.
if (blockIndex + 1 < m_graph.m_blocks.size())
currentLabel = m_labelForBlockIndex[blockIndex + 1];
else
currentLabel = m_endOfMainPath;
}
dumpDisassembly(disassemblyPrefix, linkBuffer, previousLabel, currentLabel, lastNodeIndexForDisassembly);
m_graph.dumpCodeOrigin(prefix, lastNodeIndex, block->at(i));
m_graph.dump(prefix, block->at(i));
lastNodeIndex = block->at(i);
lastNodeIndexForDisassembly = block->at(i);
}
}
dumpDisassembly(disassemblyPrefix, linkBuffer, previousLabel, m_endOfMainPath, lastNodeIndex);
dataLogF("%s(End Of Main Path)\n", prefix);
dumpDisassembly(disassemblyPrefix, linkBuffer, previousLabel, m_endOfCode, NoNode);
}
示例10: run
bool run()
{
for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex) {
BasicBlock* block = m_graph.block(blockIndex);
if (!block)
continue;
// Prevent a tower of overflowing additions from creating a value that is out of the
// safe 2^48 range.
m_allowNestedOverflowingAdditions = block->size() < (1 << 16);
for (unsigned indexInBlock = block->size(); indexInBlock--;)
propagate(block->at(indexInBlock));
}
return true;
}
示例11: checkOperand
void checkOperand(
BlockIndex blockIndex, Operands<size_t>& getLocalPositions,
Operands<size_t>& setLocalPositions, int operand)
{
if (getLocalPositions.operand(operand) == notSet)
return;
if (setLocalPositions.operand(operand) == notSet)
return;
BasicBlock* block = m_graph.m_blocks[blockIndex].get();
VALIDATE(
(block->at(getLocalPositions.operand(operand)),
block->at(setLocalPositions.operand(operand)),
blockIndex),
getLocalPositions.operand(operand) < setLocalPositions.operand(operand));
}
示例12: performBlockCFA
void performBlockCFA(BlockIndex blockIndex)
{
BasicBlock* block = m_graph.m_blocks[blockIndex].get();
if (!block)
return;
if (!block->cfaShouldRevisit)
return;
#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
dataLogF(" Block #%u (bc#%u):\n", blockIndex, block->bytecodeBegin);
#endif
m_state.beginBasicBlock(block);
#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
dataLogF(" head vars: ");
dumpOperands(block->valuesAtHead, WTF::dataFile());
dataLogF("\n");
#endif
for (unsigned i = 0; i < block->size(); ++i) {
#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
Node* node = block->at(i);
dataLogF(" %s @%u: ", Graph::opName(node->op()), node->index());
m_state.dump(WTF::dataFile());
dataLogF("\n");
#endif
if (!m_state.execute(i)) {
#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
dataLogF(" Expect OSR exit.\n");
#endif
break;
}
}
#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
dataLogF(" tail regs: ");
m_state.dump(WTF::dataFile());
dataLogF("\n");
#endif
m_changed |= m_state.endBasicBlock(AbstractState::MergeToSuccessors);
#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
dataLogF(" tail vars: ");
dumpOperands(block->valuesAtTail, WTF::dataFile());
dataLogF("\n");
#endif
}
示例13: paintUnreachableCode
// This is necessary because the CFA may reach conclusions about constants based on its
// assumption that certain code must exit, but then those constants may lead future
// reexecutions of the CFA to believe that the same code will now no longer exit. Thus
// to ensure soundness, we must paint unreachable code as such, by inserting an
// unconditional ForceOSRExit wherever we find that a node would have always exited.
// This will only happen in cases where we are making static speculations, or we're
// making totally wrong speculations due to imprecision on the prediction propagator.
bool paintUnreachableCode(BlockIndex blockIndex)
{
bool changed = false;
#if DFG_ENABLE(DEBUG_PROPAGATION_VERBOSE)
dataLog("Painting unreachable code in Block #%u.\n", blockIndex);
#endif
BasicBlock* block = m_graph.m_blocks[blockIndex].get();
m_state.beginBasicBlock(block);
for (unsigned indexInBlock = 0; indexInBlock < block->size(); ++indexInBlock) {
m_state.execute(indexInBlock);
if (m_state.isValid())
continue;
NodeIndex nodeIndex = block->at(indexInBlock);
Node& node = m_graph[nodeIndex];
switch (node.op()) {
case Return:
case Throw:
case ThrowReferenceError:
case ForceOSRExit:
// Do nothing. These nodes will already do the right thing.
break;
default:
Node forceOSRExit(ForceOSRExit, node.codeOrigin);
forceOSRExit.ref();
NodeIndex forceOSRExitIndex = m_graph.size();
m_graph.append(forceOSRExit);
m_insertionSet.append(indexInBlock, forceOSRExitIndex);
changed = true;
break;
}
break;
}
m_state.reset();
m_insertionSet.execute(*block);
return changed;
}
示例14: run
bool run()
{
InsertionSet insertionSet(m_graph);
for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
BasicBlock* block = m_graph.block(blockIndex);
if (!block)
continue;
for (unsigned nodeIndex = 0; nodeIndex < block->size(); ++nodeIndex) {
Node* node = block->at(nodeIndex);
if (!node->hasResult())
continue;
insertionSet.insertNode(
nodeIndex + 1, SpecNone, Phantom, node->origin, Edge(node));
}
insertionSet.execute(block);
}
return true;
}
示例15: run
bool run()
{
ASSERT(m_graph.m_form == ThreadedCPS || m_graph.m_form == SSA);
// First reset the counts to 0 for all nodes.
for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex) {
BasicBlock* block = m_graph.block(blockIndex);
if (!block)
continue;
for (unsigned indexInBlock = block->size(); indexInBlock--;)
block->at(indexInBlock)->setRefCount(0);
for (unsigned phiIndex = block->phis.size(); phiIndex--;)
block->phis[phiIndex]->setRefCount(0);
}
// Now find the roots:
// - Nodes that are must-generate.
// - Nodes that are reachable from type checks.
// Set their ref counts to 1 and put them on the worklist.
for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex) {
BasicBlock* block = m_graph.block(blockIndex);
if (!block)
continue;
for (unsigned indexInBlock = block->size(); indexInBlock--;) {
Node* node = block->at(indexInBlock);
DFG_NODE_DO_TO_CHILDREN(m_graph, node, findTypeCheckRoot);
if (!(node->flags() & NodeMustGenerate))
continue;
if (!node->postfixRef())
m_worklist.append(node);
}
}
while (!m_worklist.isEmpty()) {
while (!m_worklist.isEmpty()) {
Node* node = m_worklist.last();
m_worklist.removeLast();
ASSERT(node->shouldGenerate()); // It should not be on the worklist unless it's ref'ed.
DFG_NODE_DO_TO_CHILDREN(m_graph, node, countEdge);
}
if (m_graph.m_form == SSA) {
// Find Phi->Upsilon edges, which are represented as meta-data in the
// Upsilon.
for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
BasicBlock* block = m_graph.block(blockIndex);
if (!block)
continue;
for (unsigned nodeIndex = block->size(); nodeIndex--;) {
Node* node = block->at(nodeIndex);
if (node->op() != Upsilon)
continue;
if (node->shouldGenerate())
continue;
if (node->phi()->shouldGenerate())
countNode(node);
}
}
}
}
if (m_graph.m_form == SSA) {
// Need to process the graph in reverse DFS order, so that we get to the uses
// of a node before we get to the node itself.
Vector<BasicBlock*> depthFirst;
m_graph.getBlocksInDepthFirstOrder(depthFirst);
for (unsigned i = depthFirst.size(); i--;)
fixupBlock(depthFirst[i]);
} else {
RELEASE_ASSERT(m_graph.m_form == ThreadedCPS);
for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex)
fixupBlock(m_graph.block(blockIndex));
cleanVariables(m_graph.m_arguments);
}
m_graph.m_refCountState = ExactRefCount;
return true;
}