Bug 1058095 - IonMonkey: Simplify getInputMoveGroup and getMoveGroupAfter r=bhackett
authorDan Gohman <sunfish@mozilla.com>
Fri, 10 Oct 2014 21:21:36 -0700
changeset 233175 204dc904b8c01bf29ce336abbc4b18e554cc023d
parent 233174 80c1cb537478c1bacc45a6a33356465efc2f06ab
child 233176 cdbdea7d3705993ae5fee3b29b9663be07036d76
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs1058095
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1058095 - IonMonkey: Simplify getInputMoveGroup and getMoveGroupAfter r=bhackett
js/src/jit/BacktrackingAllocator.cpp
js/src/jit/LinearScan.cpp
js/src/jit/LinearScan.h
js/src/jit/LiveRangeAllocator.h
js/src/jit/RegisterAllocator.cpp
js/src/jit/RegisterAllocator.h
js/src/jit/StupidAllocator.cpp
--- a/js/src/jit/BacktrackingAllocator.cpp
+++ b/js/src/jit/BacktrackingAllocator.cpp
@@ -959,20 +959,20 @@ BacktrackingAllocator::resolveControlFlo
 
             CodePosition start = interval->start();
             LNode *ins = insData[start];
             if (interval->start() > entryOf(ins->block())) {
                 MOZ_ASSERT(start == inputOf(ins) || start == outputOf(ins));
 
                 LiveInterval *prevInterval = reg->intervalFor(start.previous());
                 if (start.subpos() == CodePosition::INPUT) {
-                    if (!moveInput(inputOf(ins), prevInterval, interval, reg->type()))
+                    if (!moveInput(ins->toInstruction(), prevInterval, interval, reg->type()))
                         return false;
                 } else {
-                    if (!moveAfter(outputOf(ins), prevInterval, interval, reg->type()))
+                    if (!moveAfter(ins->toInstruction(), prevInterval, interval, reg->type()))
                         return false;
                 }
             }
         }
     }
 
     JitSpew(JitSpew_RegAlloc, "Resolving control flow (block loop)");
 
@@ -1122,17 +1122,17 @@ BacktrackingAllocator::reifyAllocations(
                 LNode *ins = insData[iter->pos];
                 if (LDefinition *def = FindReusingDefinition(ins, alloc)) {
                     LiveInterval *outputInterval =
                         vregs[def->virtualRegister()].intervalFor(outputOf(ins));
                     LAllocation *res = outputInterval->getAllocation();
                     LAllocation *sourceAlloc = interval->getAllocation();
 
                     if (*res != *alloc) {
-                        LMoveGroup *group = getInputMoveGroup(inputOf(ins));
+                        LMoveGroup *group = getInputMoveGroup(ins->toInstruction());
                         if (!group->addAfter(sourceAlloc, res, reg->type()))
                             return false;
                         *alloc = *res;
                     }
                 }
             }
 
             addLiveRegistersForInterval(reg, interval);
--- a/js/src/jit/LinearScan.cpp
+++ b/js/src/jit/LinearScan.cpp
@@ -290,22 +290,22 @@ LinearScanAllocator::resolveControlFlow(
             }
         }
     }
 
     return true;
 }
 
 bool
-LinearScanAllocator::moveInputAlloc(CodePosition pos, LAllocation *from, LAllocation *to,
+LinearScanAllocator::moveInputAlloc(LInstruction *ins, LAllocation *from, LAllocation *to,
                                     LDefinition::Type type)
 {
     if (*from == *to)
         return true;
-    LMoveGroup *moves = getInputMoveGroup(pos);
+    LMoveGroup *moves = getInputMoveGroup(ins);
     return moves->add(from, to, type);
 }
 
 static inline void
 SetOsiPointUses(LiveInterval *interval, CodePosition defEnd, const LAllocation &allocation)
 {
     // Moves are inserted after OsiPoint instructions. This function sets
     // any OsiPoint uses of this interval to the allocation of the value
@@ -344,17 +344,17 @@ LinearScanAllocator::reifyAllocations()
             continue;
 
         UsePositionIterator usePos(interval->usesBegin());
         for (; usePos != interval->usesEnd(); usePos++) {
             if (usePos->use->isFixedRegister()) {
                 LiveInterval *to = fixedIntervals[GetFixedRegister(reg->def(), usePos->use).code()];
 
                 *static_cast<LAllocation *>(usePos->use) = *to->getAllocation();
-                if (!moveInput(usePos->pos, interval, to, reg->type()))
+                if (!moveInput(insData[usePos->pos]->toInstruction(), interval, to, reg->type()))
                     return false;
             } else {
                 MOZ_ASSERT(UseCompatibleWith(usePos->use, *interval->getAllocation()));
                 *static_cast<LAllocation *>(usePos->use) = *interval->getAllocation();
             }
         }
 
         // Erase the def of this interval if it's the first one
@@ -370,28 +370,28 @@ LinearScanAllocator::reifyAllocations()
             if (def->policy() == LDefinition::FIXED && def->output()->isRegister()) {
                 AnyRegister fixedReg = def->output()->toRegister();
                 LiveInterval *from = fixedIntervals[fixedReg.code()];
 
                 // If we insert the move after an OsiPoint that uses this vreg,
                 // it should use the fixed register instead.
                 SetOsiPointUses(interval, defEnd, LAllocation(fixedReg));
 
-                if (!moveAfter(defEnd, from, interval, def->type()))
+                if (!moveAfter(insData[defEnd]->toInstruction(), from, interval, def->type()))
                     return false;
                 spillFrom = from->getAllocation();
             } else {
                 if (def->policy() == LDefinition::MUST_REUSE_INPUT) {
                     LAllocation *inputAlloc = reg->ins()->getOperand(def->getReusedInput());
                     LAllocation *origAlloc = LAllocation::New(alloc(), *inputAlloc);
 
                     MOZ_ASSERT(!inputAlloc->isUse());
 
                     *inputAlloc = *interval->getAllocation();
-                    if (!moveInputAlloc(inputOf(reg->ins()), origAlloc, inputAlloc, def->type()))
+                    if (!moveInputAlloc(reg->ins()->toInstruction(), origAlloc, inputAlloc, def->type()))
                         return false;
                 }
 
                 MOZ_ASSERT(DefinitionCompatibleWith(reg->ins(), def, *interval->getAllocation()));
                 def->setOutput(*interval->getAllocation());
 
                 spillFrom = interval->getAllocation();
             }
@@ -410,17 +410,17 @@ LinearScanAllocator::reifyAllocations()
             {
                 // If we move the spill after an OsiPoint, the OsiPoint should
                 // use the original location instead.
                 SetOsiPointUses(interval, defEnd, *spillFrom);
 
                 // Insert a spill after this instruction (or after any OsiPoint
                 // or Nop instructions). Note that we explicitly ignore phis,
                 // which should have been handled in resolveControlFlow().
-                LMoveGroup *moves = getMoveGroupAfter(defEnd);
+                LMoveGroup *moves = getMoveGroupAfter(insData[defEnd]->toInstruction());
                 if (!moves->add(spillFrom, reg->canonicalSpill(), def->type()))
                     return false;
             }
         }
         else if (interval->start() > entryOf(insData[interval->start()]->block()) &&
                  (!reg->canonicalSpill() ||
                   (reg->canonicalSpill() == interval->getAllocation() &&
                    !reg->mustSpillAtDefinition()) ||
@@ -432,25 +432,25 @@ LinearScanAllocator::reifyAllocations()
             // Don't do this if the interval starts at the first instruction of the
             // block; this case should have been handled by resolveControlFlow().
             //
             // If the interval starts at the output half of an instruction, we have to
             // emit the move *after* this instruction, to prevent clobbering an input
             // register.
             LiveInterval *prevInterval = reg->getInterval(interval->index() - 1);
             CodePosition start = interval->start();
-            LNode *ins = insData[start];
+            LInstruction *ins = insData[start]->toInstruction();
 
             MOZ_ASSERT(start == inputOf(ins) || start == outputOf(ins));
 
             if (start.subpos() == CodePosition::INPUT) {
-                if (!moveInput(inputOf(ins), prevInterval, interval, reg->type()))
+                if (!moveInput(ins, prevInterval, interval, reg->type()))
                     return false;
             } else {
-                if (!moveAfter(outputOf(ins), prevInterval, interval, reg->type()))
+                if (!moveAfter(ins, prevInterval, interval, reg->type()))
                     return false;
             }
 
             // Mark this interval's spill position, if needed.
             if (reg->canonicalSpill() == interval->getAllocation() &&
                 !reg->mustSpillAtDefinition())
             {
                 reg->setSpillPosition(interval->start());
--- a/js/src/jit/LinearScan.h
+++ b/js/src/jit/LinearScan.h
@@ -106,17 +106,17 @@ class LinearScanAllocator
     bool splitBlockingIntervals(AnyRegister allocatedReg);
     bool assign(LAllocation allocation);
     bool spill();
     void freeAllocation(LiveInterval *interval, LAllocation *alloc);
     void finishInterval(LiveInterval *interval);
     AnyRegister::Code findBestFreeRegister(CodePosition *freeUntil);
     AnyRegister::Code findBestBlockedRegister(CodePosition *nextUsed);
     bool canCoexist(LiveInterval *a, LiveInterval *b);
-    bool moveInputAlloc(CodePosition pos, LAllocation *from, LAllocation *to, LDefinition::Type type);
+    bool moveInputAlloc(LInstruction *ins, LAllocation *from, LAllocation *to, LDefinition::Type type);
     void setIntervalRequirement(LiveInterval *interval);
     bool isSpilledAt(LiveInterval *interval, CodePosition pos);
 
 #ifdef DEBUG
     void validateIntervals();
     void validateAllocations();
 #else
     inline void validateIntervals() { }
--- a/js/src/jit/LiveRangeAllocator.h
+++ b/js/src/jit/LiveRangeAllocator.h
@@ -668,27 +668,27 @@ class LiveRangeAllocator : protected Reg
     }
 #endif
 
     bool addMove(LMoveGroup *moves, LiveInterval *from, LiveInterval *to, LDefinition::Type type) {
         MOZ_ASSERT(*from->getAllocation() != *to->getAllocation());
         return moves->add(from->getAllocation(), to->getAllocation(), type);
     }
 
-    bool moveInput(CodePosition pos, LiveInterval *from, LiveInterval *to, LDefinition::Type type) {
+    bool moveInput(LInstruction *ins, LiveInterval *from, LiveInterval *to, LDefinition::Type type) {
         if (*from->getAllocation() == *to->getAllocation())
             return true;
-        LMoveGroup *moves = getInputMoveGroup(pos);
+        LMoveGroup *moves = getInputMoveGroup(ins);
         return addMove(moves, from, to, type);
     }
 
-    bool moveAfter(CodePosition pos, LiveInterval *from, LiveInterval *to, LDefinition::Type type) {
+    bool moveAfter(LInstruction *ins, LiveInterval *from, LiveInterval *to, LDefinition::Type type) {
         if (*from->getAllocation() == *to->getAllocation())
             return true;
-        LMoveGroup *moves = getMoveGroupAfter(pos);
+        LMoveGroup *moves = getMoveGroupAfter(ins);
         return addMove(moves, from, to, type);
     }
 
     bool moveAtExit(LBlock *block, LiveInterval *from, LiveInterval *to, LDefinition::Type type) {
         if (*from->getAllocation() == *to->getAllocation())
             return true;
         LMoveGroup *moves = block->getExitMoveGroup(alloc());
         return addMove(moves, from, to, type);
--- a/js/src/jit/RegisterAllocator.cpp
+++ b/js/src/jit/RegisterAllocator.cpp
@@ -480,36 +480,33 @@ RegisterAllocator::init()
             insData[phi->id()] = phi;
         }
     }
 
     return true;
 }
 
 LMoveGroup *
-RegisterAllocator::getInputMoveGroup(uint32_t id)
+RegisterAllocator::getInputMoveGroup(LInstruction *ins)
 {
-    LInstruction *ins = insData[id]->toInstruction();
     MOZ_ASSERT(!ins->isLabel());
 
     if (ins->inputMoves())
         return ins->inputMoves();
 
     LMoveGroup *moves = LMoveGroup::New(alloc());
     ins->setInputMoves(moves);
     ins->block()->insertBefore(ins, moves);
 
     return moves;
 }
 
 LMoveGroup *
-RegisterAllocator::getMoveGroupAfter(uint32_t id)
+RegisterAllocator::getMoveGroupAfter(LInstruction *ins)
 {
-    LInstruction *ins = insData[id]->toInstruction();
-
     if (ins->movesAfter())
         return ins->movesAfter();
 
     LMoveGroup *moves = LMoveGroup::New(alloc());
     ins->setMovesAfter(moves);
 
     if (ins->isLabel())
         ins->block()->insertAfter(ins->block()->getEntryMoveGroup(alloc()), moves);
--- a/js/src/jit/RegisterAllocator.h
+++ b/js/src/jit/RegisterAllocator.h
@@ -324,25 +324,18 @@ class RegisterAllocator
         return block->numPhis() != 0
                ? CodePosition(block->getPhi(0)->id(), CodePosition::INPUT)
                : inputOf(block->firstInstructionWithId());
     }
     CodePosition exitOf(const LBlock *block) {
         return outputOf(block->lastInstructionWithId());
     }
 
-    LMoveGroup *getInputMoveGroup(uint32_t id);
-    LMoveGroup *getMoveGroupAfter(uint32_t id);
-
-    LMoveGroup *getInputMoveGroup(CodePosition pos) {
-        return getInputMoveGroup(pos.ins());
-    }
-    LMoveGroup *getMoveGroupAfter(CodePosition pos) {
-        return getMoveGroupAfter(pos.ins());
-    }
+    LMoveGroup *getInputMoveGroup(LInstruction *ins);
+    LMoveGroup *getMoveGroupAfter(LInstruction *ins);
 
     CodePosition minimalDefEnd(LNode *ins) {
         // Compute the shortest interval that captures vregs defined by ins.
         // Watch for instructions that are followed by an OSI point and/or Nop.
         // If moves are introduced between the instruction and the OSI point then
         // safepoint information for the instruction may be incorrect.
         while (true) {
             LNode *next = insData[ins->id() + 1];
--- a/js/src/jit/StupidAllocator.cpp
+++ b/js/src/jit/StupidAllocator.cpp
@@ -177,17 +177,17 @@ StupidAllocator::allocateRegister(LInstr
     evictAliasedRegister(ins, best);
     return best;
 }
 
 void
 StupidAllocator::syncRegister(LInstruction *ins, RegisterIndex index)
 {
     if (registers[index].dirty) {
-        LMoveGroup *input = getInputMoveGroup(ins->id());
+        LMoveGroup *input = getInputMoveGroup(ins);
         LAllocation *source = new(alloc()) LAllocation(registers[index].reg);
 
         uint32_t existing = registers[index].vreg;
         LAllocation *dest = stackLocation(existing);
         input->addAfter(source, dest, registers[index].type);
 
         registers[index].dirty = false;
     }
@@ -209,17 +209,17 @@ StupidAllocator::evictAliasedRegister(LI
         registers[aindex].set(MISSING_ALLOCATION);
     }
 }
 
 void
 StupidAllocator::loadRegister(LInstruction *ins, uint32_t vreg, RegisterIndex index, LDefinition::Type type)
 {
     // Load a vreg from its stack location to a register.
-    LMoveGroup *input = getInputMoveGroup(ins->id());
+    LMoveGroup *input = getInputMoveGroup(ins);
     LAllocation *source = stackLocation(vreg);
     LAllocation *dest = new(alloc()) LAllocation(registers[index].reg);
     input->addAfter(source, dest, type);
     registers[index].set(vreg, ins);
     registers[index].type = type;
 }
 
 StupidAllocator::RegisterIndex
@@ -304,17 +304,17 @@ StupidAllocator::syncForBlockEnd(LBlock 
                 continue;
 
             LAllocation *source = stackLocation(sourcevreg);
             LAllocation *dest = stackLocation(destvreg);
 
             if (!group) {
                 // The moves we insert here need to happen simultaneously with
                 // each other, yet after any existing moves before the instruction.
-                LMoveGroup *input = getInputMoveGroup(ins->id());
+                LMoveGroup *input = getInputMoveGroup(ins);
                 if (input->numMoves() == 0) {
                     group = input;
                 } else {
                     group = LMoveGroup::New(alloc());
                     block->insertAfter(input, group);
                 }
             }