Don't align the contents of a pool when a pool section is empty (bug 793390, r=jbramley)
authorMarty Rosenberg <mrosenberg@mozilla.com>
Thu, 04 Oct 2012 00:50:12 -0400
changeset 109316 df3ca5ba3a422ec4e880e673fe74d3c3ed3cae60
parent 109315 bd97a43a46038f520944b36726e35303534bda44
child 109317 9fd65b219801594ba2328c7f8c336f3f9bff3abb
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersjbramley
bugs793390
milestone18.0a1
Don't align the contents of a pool when a pool section is empty (bug 793390, r=jbramley)
js/src/ion/shared/IonAssemblerBufferWithConstantPools.h
--- a/js/src/ion/shared/IonAssemblerBufferWithConstantPools.h
+++ b/js/src/ion/shared/IonAssemblerBufferWithConstantPools.h
@@ -848,18 +848,16 @@ struct AssemblerBufferWithConstantPool :
         // and possibly re-arrange the pool to accomodate its new location.
         int poolOffset = perforation.getOffset();
         int magicAlign =  getInfo(numDumps-1).finalPos - getInfo(numDumps-1).offset;
         poolOffset += magicAlign;
         poolOffset += headerSize;
         for (int poolIdx = 0; poolIdx < numPoolKinds; poolIdx++) {
             bool beforePool = true;
             Pool *p = &pools[poolIdx];
-            // align the pool offset to the alignment of this pool
-            poolOffset = p->align(poolOffset);
             // Any entries that happened to be after the place we put our pool will need to be
             // switched from the forward-referenced pool to the backward-refrenced pool.
             int idx = 0;
             for (BufferOffset *iter = p->loadOffsets.begin();
                  iter != p->loadOffsets.end(); ++iter, ++idx)
             {
                 if (iter->getOffset() >= perforation.getOffset()) {
                     IonSpew(IonSpew_Pools, "[%d] Pushing entry %d in pool %d into the backwards section.", id, idx, poolIdx);
@@ -870,16 +868,20 @@ struct AssemblerBufferWithConstantPool :
                     p->other->updateLimiter(*iter);
 
                     // Update the current pool to report fewer entries.  They are now in the
                     // backwards section.
                     p->numEntries--;
                     beforePool = false;
                 } else {
                     JS_ASSERT(beforePool);
+                    // align the pool offset to the alignment of this pool
+                    // it already only aligns when the pool has data in it, but we want to not
+                    // align when all entries will end up in the backwards half of the pool
+                    poolOffset = p->align(poolOffset);
                     IonSpew(IonSpew_Pools, "[%d] Entry %d in pool %d is before the pool.", id, idx, poolIdx);
                     // Everything here is known, we can safely do the necessary substitutions
                     Inst * inst = this->getInst(*iter);
                     // We need to manually compute the offset, including a possible bias.
                     int codeOffset = poolOffset - iter->getOffset();
                     // That is, patchConstantPoolLoad wants to be handed the address of the
                     // pool entry that is being loaded.  We need to do a non-trivial amount
                     // of math here, since the pool that we've made does not actually reside there