本文整理汇总了C++中MIRGraph类的典型用法代码示例。如果您正苦于以下问题:C++ MIRGraph类的具体用法?C++ MIRGraph怎么用?C++ MIRGraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MIRGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EagerSimdUnbox
bool
EagerSimdUnbox(MIRGenerator* mir, MIRGraph& graph)
{
const JitCompartment* jitCompartment = GetJitContext()->compartment->jitCompartment();
for (PostorderIterator block = graph.poBegin(); block != graph.poEnd(); block++) {
if (mir->shouldCancel("Eager Simd Unbox"))
return false;
for (MInstructionReverseIterator ins = block->rbegin(); ins != block->rend(); ins++) {
if (!ins->isSimdUnbox())
continue;
MSimdUnbox* unbox = ins->toSimdUnbox();
if (!unbox->input()->isPhi())
continue;
MPhi* phi = unbox->input()->toPhi();
if (!CanUnboxSimdPhi(jitCompartment, phi, unbox->simdType()))
continue;
UnboxSimdPhi(jitCompartment, graph, phi, unbox->simdType());
}
}
return true;
}
示例2: JitSpew
bool
jit::LICM(MIRGenerator *mir, MIRGraph &graph)
{
JitSpew(JitSpew_LICM, "Beginning LICM pass");
// Iterate in RPO to visit outer loops before inner loops. We'd hoist the
// same things either way, but outer first means we do a little less work.
for (auto i(graph.rpoBegin()), e(graph.rpoEnd()); i != e; ++i) {
MBasicBlock *header = *i;
if (!header->isLoopHeader())
continue;
bool canOsr;
MarkLoopBlocks(graph, header, &canOsr);
// Hoisting out of a loop that has an entry from the OSR block in
// addition to its normal entry is tricky. In theory we could clone
// the instruction and insert phis.
if (!canOsr)
VisitLoop(graph, header);
else
JitSpew(JitSpew_LICM, " Skipping loop with header block%u due to OSR", header->id());
UnmarkLoopBlocks(graph, header);
if (mir->shouldCancel("LICM (main loop)"))
return false;
}
return true;
}
示例3: AssertReversePostOrder
void
ion::AssertGraphCoherency(MIRGraph &graph)
{
#ifdef DEBUG
// Assert successor and predecessor list coherency.
uint32_t count = 0;
for (MBasicBlockIterator block(graph.begin()); block != graph.end(); block++) {
count++;
for (size_t i = 0; i < block->numSuccessors(); i++)
JS_ASSERT(CheckSuccessorImpliesPredecessor(*block, block->getSuccessor(i)));
for (size_t i = 0; i < block->numPredecessors(); i++)
JS_ASSERT(CheckPredecessorImpliesSuccessor(*block, block->getPredecessor(i)));
for (MInstructionIterator ins = block->begin(); ins != block->end(); ins++) {
for (uint32_t i = 0; i < ins->numOperands(); i++)
JS_ASSERT(CheckMarkedAsUse(*ins, ins->getOperand(i)));
}
}
JS_ASSERT(graph.numBlocks() == count);
AssertReversePostOrder(graph);
#endif
}
示例4: defined
MBasicBlock::MBasicBlock(MIRGraph &graph, CompileInfo &info, const BytecodeSite &site, Kind kind)
: unreachable_(false),
graph_(graph),
info_(info),
predecessors_(graph.alloc()),
stackPosition_(info_.firstStackSlot()),
lastIns_(nullptr),
pc_(site.pc()),
lir_(nullptr),
start_(nullptr),
entryResumePoint_(nullptr),
successorWithPhis_(nullptr),
positionInPhiSuccessor_(0),
kind_(kind),
loopDepth_(0),
mark_(false),
immediatelyDominated_(graph.alloc()),
immediateDominator_(nullptr),
numDominated_(0),
trackedSite_(site)
#if defined (JS_ION_PERF)
, lineno_(0u),
columnIndex_(0u)
#endif
{
}
示例5: VisitLoop
static void
VisitLoop(MIRGraph &graph, MBasicBlock *header)
{
MInstruction *hoistPoint = header->loopPredecessor()->lastIns();
JitSpew(JitSpew_LICM, " Visiting loop with header block%u, hoisting to %s%u",
header->id(), hoistPoint->opName(), hoistPoint->id());
MBasicBlock *backedge = header->backedge();
// This indicates whether the loop contains calls or other things which
// clobber most or all floating-point registers. In such loops,
// floating-point constants should not be hoisted unless it enables further
// hoisting.
bool hasCalls = LoopContainsPossibleCall(graph, header, backedge);
for (auto i(graph.rpoBegin(header)); ; ++i) {
MOZ_ASSERT(i != graph.rpoEnd(), "Reached end of graph searching for blocks in loop");
MBasicBlock *block = *i;
if (!block->isMarked())
continue;
VisitLoopBlock(block, header, hoistPoint, hasCalls);
if (block == backedge)
break;
}
}
示例6:
bool
ion::RenumberBlocks(MIRGraph &graph)
{
size_t id = 0;
for (ReversePostorderIterator block(graph.rpoBegin()); block != graph.rpoEnd(); block++)
block->setId(id++);
return true;
}
示例7: AnalyzeAsmHeapAddress
static void
AnalyzeAsmHeapAddress(MDefinition* ptr, MIRGraph& graph)
{
// Fold (a+i)&m to (a&m)+i, provided that this doesn't change the result,
// since the users of the BitAnd include heap accesses. This will expose
// the redundancy for GVN when expressions like this:
// a&m
// (a+1)&m,
// (a+2)&m,
// are transformed into this:
// a&m
// (a&m)+1
// (a&m)+2
// and it will allow the constants to be folded by the
// EffectiveAddressAnalysis pass.
//
// Putting the add on the outside might seem like it exposes other users of
// the expression to the possibility of i32 overflow, if we aren't in wasm
// and they aren't naturally truncating. However, since we use MAdd::New
// with MIRType::Int32, we make sure that the value is truncated, just as it
// would be by the MBitAnd.
MOZ_ASSERT(IsCompilingWasm());
if (!ptr->isBitAnd())
return;
MDefinition* lhs = ptr->toBitAnd()->getOperand(0);
MDefinition* rhs = ptr->toBitAnd()->getOperand(1);
if (lhs->isConstant())
mozilla::Swap(lhs, rhs);
if (!lhs->isAdd() || !rhs->isConstant())
return;
MDefinition* op0 = lhs->toAdd()->getOperand(0);
MDefinition* op1 = lhs->toAdd()->getOperand(1);
if (op0->isConstant())
mozilla::Swap(op0, op1);
if (!op1->isConstant())
return;
uint32_t i = op1->toConstant()->toInt32();
uint32_t m = rhs->toConstant()->toInt32();
if (!IsAlignmentMask(m) || (i & m) != i)
return;
// The pattern was matched! Produce the replacement expression.
MInstruction* and_ = MBitAnd::New(graph.alloc(), op0, rhs, MIRType::Int32);
ptr->block()->insertBefore(ptr->toBitAnd(), and_);
MInstruction* add = MAdd::New(graph.alloc(), and_, op1, MIRType::Int32);
ptr->block()->insertBefore(ptr->toBitAnd(), add);
ptr->replaceAllUsesWith(add);
ptr->block()->discard(ptr->toBitAnd());
}
示例8:
ValueNumberer::ValueNumberer(MIRGenerator* mir, MIRGraph& graph)
: mir_(mir), graph_(graph),
values_(graph.alloc()),
deadDefs_(graph.alloc()),
remainingBlocks_(graph.alloc()),
nextDef_(nullptr),
totalNumVisited_(0),
rerun_(false),
blocksRemoved_(false),
updateAliasAnalysis_(false),
dependenciesBroken_(false)
{}
示例9: AssertGraphCoherency
void
ion::AssertExtendedGraphCoherency(MIRGraph &graph)
{
// Checks the basic GraphCoherency but also other conditions that
// do not hold immediately (such as the fact that critical edges
// are split)
#ifdef DEBUG
AssertGraphCoherency(graph);
uint32_t idx = 0;
for (MBasicBlockIterator block(graph.begin()); block != graph.end(); block++) {
JS_ASSERT(block->id() == idx++);
// No critical edges:
if (block->numSuccessors() > 1)
for (size_t i = 0; i < block->numSuccessors(); i++)
JS_ASSERT(block->getSuccessor(i)->numPredecessors() == 1);
if (block->isLoopHeader()) {
JS_ASSERT(block->numPredecessors() == 2);
MBasicBlock *backedge = block->getPredecessor(1);
JS_ASSERT(backedge->id() >= block->id());
JS_ASSERT(backedge->numSuccessors() == 1);
JS_ASSERT(backedge->getSuccessor(0) == *block);
}
if (!block->phisEmpty()) {
for (size_t i = 0; i < block->numPredecessors(); i++) {
MBasicBlock *pred = block->getPredecessor(i);
JS_ASSERT(pred->successorWithPhis() == *block);
JS_ASSERT(pred->positionInPhiSuccessor() == i);
}
}
uint32_t successorWithPhis = 0;
for (size_t i = 0; i < block->numSuccessors(); i++)
if (!block->getSuccessor(i)->phisEmpty())
successorWithPhis++;
JS_ASSERT(successorWithPhis <= 1);
JS_ASSERT_IF(successorWithPhis, block->successorWithPhis() != NULL);
// I'd like to assert this, but it's not necc. true. Sometimes we set this
// flag to non-NULL just because a successor has multiple preds, even if it
// does not actually have any phis.
//
// JS_ASSERT_IF(!successorWithPhis, block->successorWithPhis() == NULL);
}
#endif
}
示例10: mir
ValueNumberer::ValueNumberer(MIRGenerator *mir, MIRGraph &graph, bool optimistic)
: mir(mir),
graph_(graph),
values(graph.alloc()),
pessimisticPass_(!optimistic),
count_(0)
{ }
示例11: AssertReversePostOrder
static void
AssertReversePostOrder(MIRGraph &graph)
{
// Check that every block is visited after all its predecessors (except backedges).
for (ReversePostorderIterator block(graph.rpoBegin()); block != graph.rpoEnd(); block++) {
JS_ASSERT(!block->isMarked());
for (size_t i = 0; i < block->numPredecessors(); i++) {
MBasicBlock *pred = block->getPredecessor(i);
JS_ASSERT_IF(!pred->isLoopBackedge(), pred->isMarked());
}
block->mark();
}
graph.unmarkBlocks();
}
示例12: FoldLinearArithConstants
bool
FoldLinearArithConstants(MIRGenerator* mir, MIRGraph& graph)
{
for (PostorderIterator block(graph.poBegin()); block != graph.poEnd(); block++) {
if (mir->shouldCancel("Fold Linear Arithmetic Constants (main loop)"))
return false;
for (MInstructionIterator i = block->begin(); i != block->end(); i++) {
if (!graph.alloc().ensureBallast())
return false;
if (mir->shouldCancel("Fold Linear Arithmetic Constants (inner loop)"))
return false;
if (i->isAdd())
AnalyzeAdd(graph.alloc(), i->toAdd());
}
}
return true;
}
示例13: LoopContainsPossibleCall
// Test whether any instruction in the loop possiblyCalls().
static bool
LoopContainsPossibleCall(MIRGraph &graph, MBasicBlock *header, MBasicBlock *backedge)
{
for (auto i(graph.rpoBegin(header)); ; ++i) {
MOZ_ASSERT(i != graph.rpoEnd(), "Reached end of graph searching for blocks in loop");
MBasicBlock *block = *i;
if (!block->isMarked())
continue;
for (auto insIter(block->begin()), insEnd(block->end()); insIter != insEnd; ++insIter) {
MInstruction *ins = *insIter;
if (ins->possiblyCalls()) {
JitSpew(JitSpew_LICM, " Possile call found at %s%u", ins->opName(), ins->id());
return true;
}
}
if (block == backedge)
break;
}
return false;
}
示例14: UnboxSimdPhi
static void
UnboxSimdPhi(const JitCompartment* jitCompartment, MIRGraph& graph, MPhi* phi, SimdType unboxType)
{
TempAllocator& alloc = graph.alloc();
// Unbox and replace all operands.
for (size_t i = 0, e = phi->numOperands(); i < e; i++) {
MDefinition* op = phi->getOperand(i);
MSimdUnbox* unbox = MSimdUnbox::New(alloc, op, unboxType);
op->block()->insertAtEnd(unbox);
phi->replaceOperand(i, unbox);
}
// Change the MIRType of the Phi.
MIRType mirType = SimdTypeToMIRType(unboxType);
phi->setResultType(mirType);
MBasicBlock* phiBlock = phi->block();
MInstruction* atRecover = phiBlock->safeInsertTop(nullptr, MBasicBlock::IgnoreRecover);
MInstruction* at = phiBlock->safeInsertTop(atRecover);
// Note, we capture the uses-list now, as new instructions are not visited.
MUseIterator i(phi->usesBegin()), e(phi->usesEnd());
// Add a MSimdBox, and replace all the Phi uses with it.
JSObject* templateObject = jitCompartment->maybeGetSimdTemplateObjectFor(unboxType);
InlineTypedObject* inlineTypedObject = &templateObject->as<InlineTypedObject>();
MSimdBox* recoverBox = MSimdBox::New(alloc, nullptr, phi, inlineTypedObject, unboxType, gc::DefaultHeap);
recoverBox->setRecoveredOnBailout();
phiBlock->insertBefore(atRecover, recoverBox);
MSimdBox* box = nullptr;
while (i != e) {
MUse* use = *i++;
MNode* ins = use->consumer();
if ((ins->isDefinition() && ins->toDefinition()->isRecoveredOnBailout()) ||
(ins->isResumePoint() && ins->toResumePoint()->isRecoverableOperand(use)))
{
use->replaceProducer(recoverBox);
continue;
}
if (!box) {
box = MSimdBox::New(alloc, nullptr, phi, inlineTypedObject, unboxType, gc::DefaultHeap);
phiBlock->insertBefore(at, box);
}
use->replaceProducer(box);
}
}
示例15: ComputeImmediateDominators
static void
ComputeImmediateDominators(MIRGraph &graph)
{
// The default start block is a root and therefore only self-dominates.
MBasicBlock *startBlock = *graph.begin();
startBlock->setImmediateDominator(startBlock);
// Any OSR block is a root and therefore only self-dominates.
MBasicBlock *osrBlock = graph.osrBlock();
if (osrBlock)
osrBlock->setImmediateDominator(osrBlock);
bool changed = true;
while (changed) {
changed = false;
ReversePostorderIterator block = graph.rpoBegin();
// For each block in RPO, intersect all dominators.
for (; block != graph.rpoEnd(); block++) {
// If a node has once been found to have no exclusive dominator,
// it will never have an exclusive dominator, so it may be skipped.
if (block->immediateDominator() == *block)
continue;
MBasicBlock *newIdom = block->getPredecessor(0);
// Find the first common dominator.
for (size_t i = 1; i < block->numPredecessors(); i++) {
MBasicBlock *pred = block->getPredecessor(i);
if (pred->immediateDominator() != NULL)
newIdom = IntersectDominators(pred, newIdom);
// If there is no common dominator, the block self-dominates.
if (newIdom == NULL) {
block->setImmediateDominator(*block);
changed = true;
break;
}
}
if (newIdom && block->immediateDominator() != newIdom) {
block->setImmediateDominator(newIdom);
changed = true;
}
}
}
#ifdef DEBUG
// Assert that all blocks have dominator information.
for (MBasicBlockIterator block(graph.begin()); block != graph.end(); block++) {
JS_ASSERT(block->immediateDominator() != NULL);
}
#endif
}