Bug 1331354 - IonMonkey: Use CopyWithNewTargets for more cases during CFG creation, r=nbp

This commit is contained in:
Hannes Verschore 2017-01-18 10:36:47 +01:00
Родитель 306b562439
Коммит a9848ce225
2 изменённых файлов: 35 добавлений и 8 удалений

Просмотреть файл

@ -101,19 +101,18 @@ ControlFlowGraph::init(TempAllocator& alloc, const CFGBlockVector& blocks)
switch (ins->type()) {
case CFGControlInstruction::Type_Goto: {
CFGBlock* successor = &blocks_[ins->getSuccessor(0)->id()];
copy = CFGGoto::New(alloc, successor, ins->toGoto()->popAmount());
copy = CFGGoto::CopyWithNewTargets(alloc, ins->toGoto(), successor);
break;
}
case CFGControlInstruction::Type_BackEdge: {
CFGBlock* successor = &blocks_[ins->getSuccessor(0)->id()];
copy = CFGBackEdge::New(alloc, successor);
copy = CFGBackEdge::CopyWithNewTargets(alloc, ins->toBackEdge(), successor);
break;
}
case CFGControlInstruction::Type_LoopEntry: {
CFGLoopEntry* old = ins->toLoopEntry();
CFGBlock* successor = &blocks_[ins->getSuccessor(0)->id()];
copy = CFGLoopEntry::New(alloc, successor, old->canOsr(), old->stackPhiCount(),
old->loopStopPc());
copy = CFGLoopEntry::CopyWithNewTargets(alloc, old, successor);
break;
}
case CFGControlInstruction::Type_Throw: {
@ -124,7 +123,7 @@ ControlFlowGraph::init(TempAllocator& alloc, const CFGBlockVector& blocks)
CFGTest* old = ins->toTest();
CFGBlock* trueBranch = &blocks_[old->trueBranch()->id()];
CFGBlock* falseBranch = &blocks_[old->falseBranch()->id()];
copy = CFGTest::New(alloc, trueBranch, falseBranch, old->mustKeepCondition());
copy = CFGTest::CopyWithNewTargets(alloc, old, trueBranch, falseBranch);
break;
}
case CFGControlInstruction::Type_Compare: {
@ -148,7 +147,7 @@ ControlFlowGraph::init(TempAllocator& alloc, const CFGBlockVector& blocks)
CFGBlock* merge = nullptr;
if (old->numSuccessors() == 2)
merge = &blocks_[old->afterTryCatchBlock()->id()];
copy = CFGTry::New(alloc, tryBlock, old->catchStartPc(), merge);
copy = CFGTry::CopyWithNewTargets(alloc, old, tryBlock, merge);
break;
}
case CFGControlInstruction::Type_TableSwitch: {

Просмотреть файл

@ -219,6 +219,12 @@ class CFGTry : public CFGControlInstruction
CFG_CONTROL_HEADER(Try)
TRIVIAL_CFG_NEW_WRAPPERS
static CFGTry* CopyWithNewTargets(TempAllocator& alloc, CFGTry* old,
CFGBlock* tryBlock, CFGBlock* merge)
{
return new(alloc) CFGTry(tryBlock, old->catchStartPc(), merge);
}
size_t numSuccessors() const final override {
return mergePoint_ ? 2 : 1;
}
@ -360,7 +366,6 @@ class CFGCompare : public CFGAryControlInstruction<2>
return new(alloc) CFGCompare(succ1, old->truePopAmount(), succ2, old->falsePopAmount());
}
CFGBlock* trueBranch() const {
return getSuccessor(0);
}
@ -406,6 +411,12 @@ class CFGTest : public CFGAryControlInstruction<2>
CFG_CONTROL_HEADER(Test);
TRIVIAL_CFG_NEW_WRAPPERS
static CFGTest* CopyWithNewTargets(TempAllocator& alloc, CFGTest* old,
CFGBlock* succ1, CFGBlock* succ2)
{
return new(alloc) CFGTest(succ1, succ2, old->mustKeepCondition());
}
CFGBlock* trueBranch() const {
return getSuccessor(0);
}
@ -483,7 +494,7 @@ class CFGUnaryControlInstruction : public CFGAryControlInstruction<1>
*/
class CFGGoto : public CFGUnaryControlInstruction
{
size_t popAmount_;
const size_t popAmount_;
explicit CFGGoto(CFGBlock* block)
: CFGUnaryControlInstruction(block),
@ -499,6 +510,11 @@ class CFGGoto : public CFGUnaryControlInstruction
CFG_CONTROL_HEADER(Goto);
TRIVIAL_CFG_NEW_WRAPPERS
static CFGGoto* CopyWithNewTargets(TempAllocator& alloc, CFGGoto* old, CFGBlock* block)
{
return new(alloc) CFGGoto(block, old->popAmount());
}
size_t popAmount() const {
return popAmount_;
}
@ -521,6 +537,11 @@ class CFGBackEdge : public CFGUnaryControlInstruction
public:
CFG_CONTROL_HEADER(BackEdge);
TRIVIAL_CFG_NEW_WRAPPERS
static CFGBackEdge* CopyWithNewTargets(TempAllocator& alloc, CFGBackEdge* old, CFGBlock* block)
{
return new(alloc) CFGBackEdge(block);
}
};
/**
@ -556,6 +577,13 @@ class CFGLoopEntry : public CFGUnaryControlInstruction
CFG_CONTROL_HEADER(LoopEntry);
TRIVIAL_CFG_NEW_WRAPPERS
static CFGLoopEntry* CopyWithNewTargets(TempAllocator& alloc, CFGLoopEntry* old,
CFGBlock* loopEntry)
{
return new(alloc) CFGLoopEntry(loopEntry, old->canOsr(), old->stackPhiCount(),
old->loopStopPc());
}
void setCanOsr() {
canOsr_ = true;
}