Bug 1438126 part 3 - Don't release small ExecutablePools when they're still in use elsewhere. r=tcampbell
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 15 Feb 2018 12:37:09 +0100
changeset 403927 515a82d2ec7bb7ab02e72970f0b2e3b2835e0c6d
parent 403926 303215766a6fb28fc64da9317bc690af824cd1a6
child 403928 0a00a0ef8bfcb309fc1f67e94b33d248f82f061b
push id99887
push userjandemooij@gmail.com
push dateThu, 15 Feb 2018 11:37:48 +0000
treeherdermozilla-inbound@515a82d2ec7b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstcampbell
bugs1438126
milestone60.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 1438126 part 3 - Don't release small ExecutablePools when they're still in use elsewhere. r=tcampbell
js/src/jit/ExecutableAllocator.cpp
--- a/js/src/jit/ExecutableAllocator.cpp
+++ b/js/src/jit/ExecutableAllocator.cpp
@@ -255,19 +255,29 @@ ExecutableAllocator::releasePoolPages(Ex
 }
 
 void
 ExecutableAllocator::purge()
 {
     // Don't race with reprotectAll called from the signal handler.
     JitRuntime::AutoPreventBackedgePatching apbp(rt_);
 
-    for (size_t i = 0; i < m_smallPools.length(); i++)
-        m_smallPools[i]->release();
-    m_smallPools.clear();
+    for (size_t i = 0; i < m_smallPools.length(); ) {
+        ExecutablePool* pool = m_smallPools[i];
+        if (pool->m_refCount > 1) {
+            // Releasing this pool is not going to deallocate it, so we might as
+            // well hold on to it and reuse it for future allocations.
+            i++;
+            continue;
+        }
+
+        MOZ_ASSERT(pool->m_refCount == 1);
+        pool->release();
+        m_smallPools.erase(&m_smallPools[i]);
+    }
 }
 
 void
 ExecutableAllocator::addSizeOfCode(JS::CodeSizes* sizes) const
 {
     if (m_pools.initialized()) {
         for (ExecPoolHashSet::Range r = m_pools.all(); !r.empty(); r.popFront()) {
             ExecutablePool* pool = r.front();