本文整理汇总了C++中MInstruction::setDependency方法的典型用法代码示例。如果您正苦于以下问题:C++ MInstruction::setDependency方法的具体用法?C++ MInstruction::setDependency怎么用?C++ MInstruction::setDependency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MInstruction
的用法示例。
在下文中一共展示了MInstruction::setDependency方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: boxAt
bool
FilterTypeSetPolicy::adjustInputs(TempAllocator &alloc, MInstruction *ins)
{
MOZ_ASSERT(ins->numOperands() == 1);
MIRType inputType = ins->getOperand(0)->type();
MIRType outputType = ins->type();
// Input and output type are already in accordance.
if (inputType == outputType)
return true;
// Output is a value, box the input.
if (outputType == MIRType_Value) {
MOZ_ASSERT(inputType != MIRType_Value);
ins->replaceOperand(0, boxAt(alloc, ins, ins->getOperand(0)));
return true;
}
// The outputType should be a subset of the inputType else we are in code
// that has never executed yet. Bail to see the new type (if that hasn't
// happened yet).
if (inputType != MIRType_Value) {
MBail *bail = MBail::New(alloc);
ins->block()->insertBefore(ins, bail);
bail->setDependency(ins->dependency());
ins->setDependency(bail);
ins->replaceOperand(0, boxAt(alloc, ins, ins->getOperand(0)));
}
// We can't unbox a value to null/undefined/lazyargs. So keep output
// also a value.
// Note: Using setResultType shouldn't be done in TypePolicies,
// Here it is fine, since the type barrier has no uses.
if (IsNullOrUndefined(outputType) || outputType == MIRType_MagicOptimizedArguments) {
MOZ_ASSERT(!ins->hasDefUses());
ins->setResultType(MIRType_Value);
return true;
}
// Unbox / propagate the right type.
MUnbox::Mode mode = MUnbox::Infallible;
MInstruction *replace = MUnbox::New(alloc, ins->getOperand(0), ins->type(), mode);
ins->block()->insertBefore(ins, replace);
ins->replaceOperand(0, replace);
if (!replace->typePolicy()->adjustInputs(alloc, replace))
return false;
// Carry over the dependency the MFilterTypeSet had.
replace->setDependency(ins->dependency());
return true;
}
示例2: defs
// This pass annotates every load instruction with the last store instruction
// on which it depends. The algorithm is optimistic in that it ignores explicit
// dependencies and only considers loads and stores.
//
// Loads inside loops only have an implicit dependency on a store before the
// loop header if no instruction inside the loop body aliases it. To calculate
// this efficiently, we maintain a list of maybe-invariant loads and the combined
// alias set for all stores inside the loop. When we see the loop's backedge, this
// information is used to mark every load we wrongly assumed to be loop invariant as
// having an implicit dependency on the last instruction of the loop header, so that
// it's never moved before the loop header.
//
// The algorithm depends on the invariant that both control instructions and effectful
// instructions (stores) are never hoisted.
bool
AliasAnalysis::analyze()
{
Vector<MInstructionVector, AliasSet::NumCategories, JitAllocPolicy> stores(alloc());
// Initialize to the first instruction.
MInstruction* firstIns = *graph_.entryBlock()->begin();
for (unsigned i = 0; i < AliasSet::NumCategories; i++) {
MInstructionVector defs(alloc());
if (!defs.append(firstIns))
return false;
if (!stores.append(Move(defs)))
return false;
}
// Type analysis may have inserted new instructions. Since this pass depends
// on the instruction number ordering, all instructions are renumbered.
uint32_t newId = 0;
for (ReversePostorderIterator block(graph_.rpoBegin()); block != graph_.rpoEnd(); block++) {
if (mir->shouldCancel("Alias Analysis (main loop)"))
return false;
if (block->isLoopHeader()) {
JitSpew(JitSpew_Alias, "Processing loop header %d", block->id());
loop_ = new(alloc()) LoopAliasInfo(alloc(), loop_, *block);
}
for (MPhiIterator def(block->phisBegin()), end(block->phisEnd()); def != end; ++def)
def->setId(newId++);
for (MInstructionIterator def(block->begin()), end(block->begin(block->lastIns()));
def != end;
++def)
{
def->setId(newId++);
AliasSet set = def->getAliasSet();
if (set.isNone())
continue;
// For the purposes of alias analysis, all recoverable operations
// are treated as effect free as the memory represented by these
// operations cannot be aliased by others.
if (def->canRecoverOnBailout())
continue;
if (set.isStore()) {
for (AliasSetIterator iter(set); iter; iter++) {
if (!stores[*iter].append(*def))
return false;
}
if (JitSpewEnabled(JitSpew_Alias)) {
Fprinter& out = JitSpewPrinter();
out.printf("Processing store ");
def->printName(out);
out.printf(" (flags %x)\n", set.flags());
}
} else {
// Find the most recent store on which this instruction depends.
MInstruction* lastStore = firstIns;
for (AliasSetIterator iter(set); iter; iter++) {
MInstructionVector& aliasedStores = stores[*iter];
for (int i = aliasedStores.length() - 1; i >= 0; i--) {
MInstruction* store = aliasedStores[i];
if (genericMightAlias(*def, store) != MDefinition::AliasType::NoAlias &&
def->mightAlias(store) != MDefinition::AliasType::NoAlias &&
BlockMightReach(store->block(), *block))
{
if (lastStore->id() < store->id())
lastStore = store;
break;
}
}
}
def->setDependency(lastStore);
IonSpewDependency(*def, lastStore, "depends", "");
// If the last store was before the current loop, we assume this load
// is loop invariant. If a later instruction writes to the same location,
// we will fix this at the end of the loop.
if (loop_ && lastStore->id() < loop_->firstInstruction()->id()) {
if (!loop_->addInvariantLoad(*def))
//.........这里部分代码省略.........
示例3: BoxAt
bool
FilterTypeSetPolicy::adjustInputs(TempAllocator& alloc, MInstruction* ins)
{
MOZ_ASSERT(ins->numOperands() == 1);
MIRType inputType = ins->getOperand(0)->type();
MIRType outputType = ins->type();
// Special case when output is a Float32, but input isn't.
if (outputType == MIRType_Float32 && inputType != MIRType_Float32) {
// Create a MToFloat32 to add between the MFilterTypeSet and
// its uses.
MInstruction* replace = MToFloat32::New(alloc, ins);
ins->justReplaceAllUsesWithExcept(replace);
ins->block()->insertAfter(ins, replace);
// Reset the type to not MIRType_Float32
// Note: setResultType shouldn't happen in TypePolicies,
// Here it is fine, since there is just one use we just
// added ourself. And the resulting type after MToFloat32
// equals the original type.
ins->setResultType(ins->resultTypeSet()->getKnownMIRType());
outputType = ins->type();
// Do the type analysis
if (!replace->typePolicy()->adjustInputs(alloc, replace))
return false;
// Fall through to let the MFilterTypeSet adjust its input based
// on its new type.
}
// Input and output type are already in accordance.
if (inputType == outputType)
return true;
// Output is a value, box the input.
if (outputType == MIRType_Value) {
MOZ_ASSERT(inputType != MIRType_Value);
ins->replaceOperand(0, BoxAt(alloc, ins, ins->getOperand(0)));
return true;
}
// The outputType should be a subset of the inputType else we are in code
// that has never executed yet. Bail to see the new type (if that hasn't
// happened yet).
if (inputType != MIRType_Value) {
MBail* bail = MBail::New(alloc);
ins->block()->insertBefore(ins, bail);
bail->setDependency(ins->dependency());
ins->setDependency(bail);
ins->replaceOperand(0, BoxAt(alloc, ins, ins->getOperand(0)));
}
// We can't unbox a value to null/undefined/lazyargs. So keep output
// also a value.
// Note: Using setResultType shouldn't be done in TypePolicies,
// Here it is fine, since the type barrier has no uses.
if (IsNullOrUndefined(outputType) || outputType == MIRType_MagicOptimizedArguments) {
MOZ_ASSERT(!ins->hasDefUses());
ins->setResultType(MIRType_Value);
return true;
}
// Unbox / propagate the right type.
MUnbox::Mode mode = MUnbox::Infallible;
MInstruction* replace = MUnbox::New(alloc, ins->getOperand(0), ins->type(), mode);
ins->block()->insertBefore(ins, replace);
ins->replaceOperand(0, replace);
if (!replace->typePolicy()->adjustInputs(alloc, replace))
return false;
// Carry over the dependency the MFilterTypeSet had.
replace->setDependency(ins->dependency());
return true;
}