Backed out changeset 91389f18d45b
authorDavid Anderson <danderson@mozilla.com>
Mon, 06 Sep 2010 18:16:12 -0700
changeset 74551 ed10917e52e89152a48fef48069f00f41826aa5f
parent 74515 91389f18d45b194728ad8212fe946c94a1b63fb3
child 74552 88ee72b88b7058131d2672bd5cf3ceb46c8895f1
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone2.0b5pre
backs out91389f18d45b194728ad8212fe946c94a1b63fb3
Backed out changeset 91389f18d45b
js/src/methodjit/FrameState.cpp
--- a/js/src/methodjit/FrameState.cpp
+++ b/js/src/methodjit/FrameState.cpp
@@ -412,105 +412,67 @@ FrameState::sync(Assembler &masm, Uses u
                 masm.storePayload(backing->data.reg(), address);
         }
     }
 }
 
 void
 FrameState::syncAndKill(Registers kill, Uses uses)
 {
-    /* Sync all kill-registers up-front. */
-    Registers search(kill.freeMask & ~freeRegs.freeMask);
-    while (!search.empty()) {
-        RegisterID reg = search.takeAnyReg();
-        FrameEntry *fe = regstate[reg].usedBy();
-        if (!fe)
-            continue;
-
-        JS_ASSERT(fe->isTracked());
+    /* Backwards, so we can allocate registers to backing slots better. */
+    FrameEntry *bottom = sp - uses.nuses;
 
-        if (regstate[reg].type() == RematInfo::DATA) {
-            JS_ASSERT(fe->data.reg() == reg);
-            if (!fe->data.synced()) {
-                syncData(fe, addressOf(fe), masm);
-                fe->data.sync();
-            }
-        } else {
-            JS_ASSERT(fe->type.reg() == reg);
-            if (!fe->type.synced()) {
-                syncType(fe, addressOf(fe), masm);
-                fe->type.sync();
-            }
-        }
-    }
+    if (inTryBlock)
+        bottom = NULL;
 
-    uint32 maxvisits = tracker.nentries;
-    FrameEntry *bottom = sp - uses.nuses;
-    if (inTryBlock)
-        bottom = entries;
-
-    for (FrameEntry *fe = sp - 1; fe >= bottom && maxvisits; fe--) {
-        if (!fe->isTracked())
+    for (uint32 i = tracker.nentries - 1; i < tracker.nentries; i--) {
+        FrameEntry *fe = tracker[i];
+        if (fe >= sp)
             continue;
 
-        maxvisits--;
-
         Address address = addressOf(fe);
         FrameEntry *backing = fe;
-        if (fe->isCopy())
+        if (fe->isCopy()) {
+            if (!inTryBlock && fe < bottom)
+                continue;
             backing = fe->copyOf();
+        }
 
-        if (!fe->data.synced()) {
+        JS_ASSERT_IF(i == 0, !fe->isCopy());
+
+        bool killData = fe->data.inRegister() && kill.hasReg(fe->data.reg());
+        if (!fe->data.synced() && (killData || fe >= bottom)) {
             if (backing != fe && backing->data.inMemory())
                 tempRegForData(backing);
             syncData(backing, address, masm);
             fe->data.sync();
-            if (fe->isConstant() && !fe->type.synced()) {
+            if (fe->isConstant() && !fe->type.synced())
                 fe->type.sync();
-            } else if (fe->data.inRegister() && kill.hasReg(fe->data.reg())) {
+        }
+        if (killData) {
+            JS_ASSERT(backing == fe);
+            JS_ASSERT(fe->data.synced());
+            if (regstate[fe->data.reg()].fe())
                 forgetReg(fe->data.reg());
-                fe->data.setMemory();
-            }
+            fe->data.setMemory();
         }
-        if (!fe->type.synced()) {
+        bool killType = fe->type.inRegister() && kill.hasReg(fe->type.reg());
+        if (!fe->type.synced() && (killType || fe >= bottom)) {
             if (backing != fe && backing->type.inMemory())
                 tempRegForType(backing);
             syncType(backing, address, masm);
             fe->type.sync();
-            if (fe->type.inRegister() && kill.hasReg(fe->type.reg())) {
+        }
+        if (killType) {
+            JS_ASSERT(backing == fe);
+            JS_ASSERT(fe->type.synced());
+            if (regstate[fe->type.reg()].fe())
                 forgetReg(fe->type.reg());
-                fe->type.setMemory();
-            }
-        }
-    }
-
-    /*
-     * Anything still alive at this point is guaranteed to be synced. However,
-     * it is necessary to evict temporary registers.
-     */
-    search = Registers(kill.freeMask & ~freeRegs.freeMask);
-    while (!search.empty()) {
-        RegisterID reg = search.takeAnyReg();
-        FrameEntry *fe = regstate[reg].usedBy();
-        if (!fe)
-            continue;
-
-        JS_ASSERT(fe->isTracked());
-
-        if (regstate[reg].type() == RematInfo::DATA) {
-            JS_ASSERT(fe->data.reg() == reg);
-            JS_ASSERT(fe->data.synced());
-            fe->data.setMemory();
-        } else {
-            JS_ASSERT(fe->type.reg() == reg);
-            JS_ASSERT(fe->type.synced());
             fe->type.setMemory();
         }
-
-        forgetReg(reg);
     }
 }
 
 void
 FrameState::merge(Assembler &masm, Changes changes) const
 {
     Registers search(Registers::AvailRegs & ~freeRegs.freeMask);