Bug 552614 - nanojit: fix AR::Iter::next(). r=rreitmai.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 18 Mar 2010 09:53:06 +1100
changeset 40296 20ea2635b1c0c08080ae415d9bb15ad863a0f39d
parent 40295 d775e874fb2f9f2ef104caacb9cb328769929695
child 40297 7e0ebb967dfefb3dbefdec275848c6fa0e921f2c
push id12610
push userrsayre@mozilla.com
push dateMon, 05 Apr 2010 17:26:41 +0000
treeherdermozilla-central@1942c0b4e101 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrreitmai
bugs552614
milestone1.9.3a3pre
Bug 552614 - nanojit: fix AR::Iter::next(). r=rreitmai.
js/src/nanojit/Assembler.cpp
js/src/nanojit/Assembler.h
--- a/js/src/nanojit/Assembler.cpp
+++ b/js/src/nanojit/Assembler.cpp
@@ -113,59 +113,59 @@ namespace nanojit
         NanoAssert(_highWaterMark < NJ_MAX_STACK_ENTRY);
         NanoAssert(_entries[0] == NULL);
         for (uint32_t i = 1; i <= _highWaterMark; ++i)
             NanoAssert(_entries[i] != BAD_ENTRY);
         for (uint32_t i = _highWaterMark+1; i < NJ_MAX_STACK_ENTRY; ++i)
             NanoAssert(_entries[i] == BAD_ENTRY);
     }
 
-     void AR::validate()
-     {
+    void AR::validate()
+    {
         static uint32_t validateCounter = 0;
-         if (++validateCounter >= 100)
-         {
-             validateFull();
-             validateCounter = 0;
-         }
-         else
-         {
-             validateQuick();
-         }
-     }
+        if (++validateCounter >= 100)
+        {
+            validateFull();
+            validateCounter = 0;
+        }
+        else
+        {
+            validateQuick();
+        }
+    }
 
 #endif
 
-     inline void AR::clear()
-     {
-         _highWaterMark = 0;
+    inline void AR::clear()
+    {
+        _highWaterMark = 0;
         NanoAssert(_entries[0] == NULL);
     #ifdef _DEBUG
         for (uint32_t i = 1; i < NJ_MAX_STACK_ENTRY; ++i)
             _entries[i] = BAD_ENTRY;
     #endif
-     }
+    }
 
-     bool AR::Iter::next(LIns*& ins, uint32_t& nStackSlots, int32_t& arIndex)
-     {
-         while (++_i <= _ar._highWaterMark)
-         {
-             if ((ins = _ar._entries[_i]) != NULL)
-             {
-                 nStackSlots = nStackSlotsFor(ins);
-                 _i += nStackSlots - 1;
-                 arIndex = _i;
-                 return true;
-             }
-         }
-         ins = NULL;
-         nStackSlots = 0;
-         arIndex = 0;
-         return false;
-     }
+    bool AR::Iter::next(LIns*& ins, uint32_t& nStackSlots, int32_t& arIndex)
+    {
+        while (_i <= _ar._highWaterMark) {
+            ins = _ar._entries[_i];
+            if (ins) {
+                arIndex = _i;
+                nStackSlots = nStackSlotsFor(ins);
+                _i += nStackSlots;
+                return true;
+            }
+            _i++;
+        }
+        ins = NULL;
+        nStackSlots = 0;
+        arIndex = 0;
+        return false;
+    }
 
     void Assembler::arReset()
     {
         _activation.clear();
         _branchStateMap.clear();
         _patches.clear();
         _labels.clear();
     #if NJ_USES_QUAD_CONSTANTS
@@ -2049,17 +2049,17 @@ namespace nanojit
         // no space. oh well.
         return 0;
     }
 
     #ifdef _DEBUG
     void AR::checkForResourceLeaks() const
     {
         for (uint32_t i = 1; i <= _highWaterMark; i++) {
-            NanoAssertMsgf(_entries[i] == NULL, "frame entry %d wasn't freed\n",-4*i);
+            NanoAssertMsgf(_entries[i] == NULL, "frame entry %d wasn't freed\n",4*i);
         }
     }
     #endif
 
     uint32_t Assembler::arReserve(LIns* ins)
     {
         uint32_t i = _activation.reserveEntry(ins);
         if (!i)
--- a/js/src/nanojit/Assembler.h
+++ b/js/src/nanojit/Assembler.h
@@ -131,16 +131,17 @@ namespace nanojit
         void checkForResourceConsistency(const RegAlloc& regs);
         void checkForResourceLeaks() const;
         #endif
 
         class Iter
         {
         private:
             const AR& _ar;
+            // '_i' points to the start of the entries for an LIns, or to the first NULL entry.
             uint32_t _i;
         public:
             inline Iter(const AR& ar) : _ar(ar), _i(1) { }
             bool next(LIns*& ins, uint32_t& nStackSlots, int32_t& offset);             // get the next one (moves iterator forward)
         };
     };
 
     inline AR::AR()