Fix the backwards code so it matches the well thought out comment (bug 792589, r=jbramley)
authorMarty Rosenberg <mrosenberg@mozilla.com>
Mon, 08 Oct 2012 06:32:39 -0400
changeset 113263 5c59fd005fb897b33cceaad689eb6fa28765ff77
parent 113262 c28cc500c23935d0bb587a7ba2d5c4cc9f26e278
child 113264 41b5180cf6af91e751669e144e7dfa58ae3a0789
push id2248
push userakeybl@mozilla.com
push dateMon, 08 Oct 2012 19:23:44 +0000
treeherdermozilla-aurora@118a3b748323 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjbramley
bugs792589
milestone18.0a1
Fix the backwards code so it matches the well thought out comment (bug 792589, r=jbramley)
js/src/ion/shared/IonAssemblerBufferWithConstantPools.h
--- a/js/src/ion/shared/IonAssemblerBufferWithConstantPools.h
+++ b/js/src/ion/shared/IonAssemblerBufferWithConstantPools.h
@@ -476,17 +476,17 @@ struct AssemblerBufferWithConstantPool :
         // TODO: calculating offsets for the alignment requirements is *hard*
         // Instead, assume that we always add the maximum.
         int poolOffset = footerSize;
         Pool *cur, *tmp;
         // NOTE: we want to process the pools from last to first.
         // Since the last pool is pools[0].other, and the first pool
         // is pools[numPoolKinds-1], we actually want to process this
         // forwards.
-        for (cur = &pools[numPoolKinds-1]; cur >= pools; cur--) {
+        for (cur = pools; cur < &pools[numPoolKinds]; cur++) {
             // fetch the pool for the backwards half.
             tmp = cur->other;
             if (p == cur)
                 tmp->updateLimiter(this->nextOffset());
 
             if (tmp->checkFullBackref(poolOffset, perforation.getOffset())) {
                 // uh-oh, the backwards pool is full.  Time to finalize it, and
                 // switch to a new forward pool.
@@ -499,17 +499,16 @@ struct AssemblerBufferWithConstantPool :
                 return this->insertEntryForwards(instSize, inst, p, data);
             }
             // when moving back to front, calculating the alignment is hard, just be
             // conservative with it.
             poolOffset += tmp->immSize * tmp->numEntries + tmp->getAlignment();
             if (p == tmp) {
                 poolOffset += tmp->immSize;
             }
-            poolOffset += tmp->immSize * tmp->numEntries + tmp->getAlignment();
         }
         return p->numEntries + p->other->insertEntry(data, this->nextOffset());
     }
 
     // Simultaneously insert an instSized instruction into the stream,
     // and an entry into the pool.  There are many things that can happen.
     // 1) the insertion goes as planned
     // 2) inserting an instruction pushes a previous pool-reference out of range, forcing a dump