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 76504 f3174373103972bd7f0a51e517dc991909d428d7
parent 76503 710f3b41a5d7c2218ff7514ca775c80a72907111
child 76540 6f99ff6c4c8655362961d4115428e5e581702bdc
push id1698
push usernnethercote@mozilla.com
push dateSun, 04 Sep 2011 23:10:15 +0000
treeherdermozilla-inbound@f31743731039 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs684180
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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;