Bug 684180 - Avoid wasted space caused by AssemblerBuffer's growth strategy. r=dvander.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 04 Sep 2011 16:09:56 -0700
changeset 76540 f3174373103972bd7f0a51e517dc991909d428d7
parent 76539 710f3b41a5d7c2218ff7514ca775c80a72907111
child 76541 6f99ff6c4c8655362961d4115428e5e581702bdc
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersdvander
bugs684180
milestone9.0a1
Bug 684180 - Avoid wasted space caused by AssemblerBuffer's growth strategy. r=dvander.
js/src/assembler/assembler/AssemblerBuffer.h
--- a/js/src/assembler/assembler/AssemblerBuffer.h
+++ b/js/src/assembler/assembler/AssemblerBuffer.h
@@ -186,17 +186,21 @@ namespace JSC {
          * can continue assembling into the buffer, deferring OOM checking
          * until the user wants to read code out of the buffer.
          *
          * See also the |executableAllocAndCopy| and |buffer| methods.
          */
 
         void grow(int extraCapacity = 0)
         {
-            int newCapacity = m_capacity + m_capacity / 2 + extraCapacity;
+            /*
+             * If |extraCapacity| is zero (as it almost always is) this is an
+             * allocator-friendly doubling growth strategy.
+             */
+            int newCapacity = m_capacity + m_capacity + extraCapacity;
             char* newBuffer;
 
             if (m_buffer == m_inlineBuffer) {
                 newBuffer = static_cast<char*>(malloc(newCapacity));
                 if (!newBuffer) {
                     m_size = 0;
                     m_oom = true;
                     return;