Bug 1087207 - Use a smaller initial size for the srcnotes vector. r=jorendorff.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 27 Oct 2014 15:37:47 -0700
changeset 212586 98d0bbc3081747a830296780a30439dd47f855ee
parent 212585 c5b93a000dfba4239004f5928c22896514b62cdf
child 212587 ba4beabcb40bfeee0af98de08552a78c570524a8
push id27721
push usercbook@mozilla.com
push dateTue, 28 Oct 2014 14:55:05 +0000
treeherdermozilla-central@c0ddb1b098ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1087207
milestone36.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 1087207 - Use a smaller initial size for the srcnotes vector. r=jorendorff.
js/src/frontend/BytecodeEmitter.cpp
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -155,16 +155,17 @@ BytecodeEmitter::init()
 }
 
 static ptrdiff_t
 EmitCheck(ExclusiveContext *cx, BytecodeEmitter *bce, ptrdiff_t delta)
 {
     ptrdiff_t offset = bce->code().length();
 
     // Start it off moderately large to avoid repeated resizings early on.
+    // ~98% of cases fit within 1024 bytes.
     if (bce->code().capacity() == 0 && !bce->code().reserve(1024))
         return -1;
 
     jsbytecode dummy = 0;
     if (!bce->code().appendN(dummy, delta)) {
         js_ReportOutOfMemory(cx);
         return -1;
     }
@@ -7077,17 +7078,18 @@ frontend::EmitTree(ExclusiveContext *cx,
 
     return ok;
 }
 
 static int
 AllocSrcNote(ExclusiveContext *cx, SrcNotesVector &notes)
 {
     // Start it off moderately large to avoid repeated resizings early on.
-    if (notes.capacity() == 0 && !notes.reserve(1024))
+    // ~99% of cases fit within 256 bytes.
+    if (notes.capacity() == 0 && !notes.reserve(256))
         return -1;
 
     jssrcnote dummy = 0;
     if (!notes.append(dummy)) {
         js_ReportOutOfMemory(cx);
         return -1;
     }
     return notes.length() - 1;