Optimize FrameState merging algorithm (bug 591836 part 6, r=dmandelin).
☠☠ backed out by a44d33974ac7 ☠ ☠
authorDavid Anderson <danderson@mozilla.com>
Wed, 01 Sep 2010 02:30:44 -0700
changeset 74513 b364b2ffc970bd4f77e0f8f5f11f4202217bd294
parent 74512 6e24d99e29c0f83a8575b78a102d90eabcde829d
child 74514 e8dc1103c1b76aec702e06c92358b7274bc237f0
child 74555 a44d33974ac742efc9004dac355dcac140d74506
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersdmandelin
bugs591836
milestone2.0b5pre
Optimize FrameState merging algorithm (bug 591836 part 6, r=dmandelin).
js/src/methodjit/FrameState.cpp
js/src/methodjit/MachineRegs.h
--- a/js/src/methodjit/FrameState.cpp
+++ b/js/src/methodjit/FrameState.cpp
@@ -469,40 +469,41 @@ FrameState::syncAndKill(Registers kill, 
             fe->type.setMemory();
         }
     }
 }
 
 void
 FrameState::merge(Assembler &masm, Changes changes) const
 {
-    Registers temp(Registers::TempRegs);
-
-    for (uint32 i = 0; i < tracker.nentries; i++) {
-        FrameEntry *fe = tracker[i];
-        if (fe >= sp)
-            continue;
+    Registers search(Registers::AvailRegs & ~freeRegs.freeMask);
 
-        /* Copies do not have registers. */
-        if (fe->isCopy()) {
-            JS_ASSERT(!fe->data.inRegister());
-            JS_ASSERT(!fe->type.inRegister());
+    while (!search.empty()) {
+        RegisterID reg = search.peekReg();
+
+        FrameEntry *fe = regstate[reg].usedBy();
+        if (!fe)
             continue;
-        }
 
 #if defined JS_PUNBOX64
         if (fe->data.inRegister() && fe->type.inRegister()) {
             masm.loadValueAsComponents(addressOf(fe), fe->type.reg(), fe->data.reg());
+            search.takeReg(fe->data.reg());
+            search.takeReg(fe->type.reg());
         } else
 #endif
         {
-            if (fe->data.inRegister())
+            if (fe->data.inRegister()) {
                 masm.loadPayload(addressOf(fe), fe->data.reg());
-            if (fe->type.inRegister())
+                search.takeReg(fe->data.reg());
+            }
+            if (fe->type.inRegister()) {
                 masm.loadTypeTag(addressOf(fe), fe->type.reg());
+                search.takeReg(fe->type.reg());
+            }
         }
     }
 }
 
 JSC::MacroAssembler::RegisterID
 FrameState::copyDataIntoReg(FrameEntry *fe)
 {
     return copyDataIntoReg(this->masm, fe);
--- a/js/src/methodjit/MachineRegs.h
+++ b/js/src/methodjit/MachineRegs.h
@@ -180,21 +180,26 @@ struct Registers {
     bool empty() const {
         return !freeMask;
     }
 
     bool empty(uint32 mask) const {
         return !(freeMask & mask);
     }
 
-    RegisterID takeAnyReg() {
+    RegisterID peekReg() {
         JS_ASSERT(!empty());
         int ireg;
         JS_FLOOR_LOG2(ireg, freeMask);
         RegisterID reg = (RegisterID)ireg;
+        return reg;
+    }
+
+    RegisterID takeAnyReg() {
+        RegisterID reg = peekReg();
         takeReg(reg);
         return reg;
     }
 
     bool hasRegInMask(uint32 mask) const {
         Registers temp(freeMask & mask);
         return !temp.empty();
     }