Blame SOURCES/mozbug746112-no-decommit-on-large-pages.patch

c67d24
# See https://bugzilla.redhat.com/show_bug.cgi?id=971519
c67d24
# HG changeset patch
c67d24
# User Terrence Cole <terrence@mozilla.com>
c67d24
# Date 1346874025 25200
c67d24
# Node ID 0558ede9693e57663e4836c7e678b55465ddc2ab
c67d24
# Parent  d28e07f4bec6c16b32ae4743eaeeae2a9e2f6381
c67d24
Bug 746112 - Don't decommit if page size is too large; r=billm
c67d24
c67d24
The powerpc architecture has 64KiB pages, which is too large to represent in the
c67d24
free list.  This patch splits the page size from the arena size and disabled
c67d24
decommit logic in that case.
c67d24
c67d24
diff -up xulrunner-17.0/mozilla-beta/js/src/gc/Heap.h.746112 xulrunner-17.0/mozilla-beta/js/src/gc/Heap.h
c67d24
--- a/js/src/gc/Heap.h.746112	2012-10-17 16:32:43.000000000 +0200
c67d24
+++ b/js/src/gc/Heap.h	2012-10-24 14:48:12.186640489 +0200
c67d24
@@ -103,26 +103,31 @@ struct Cell
c67d24
 };
c67d24
 
c67d24
 /*
c67d24
- * Page size is 4096 by default, except for SPARC, where it is 8192.
c67d24
+ * Page size must be static to support our arena pointer optimizations, so we
c67d24
+ * are forced to support each platform with non-4096 pages as a special case.
c67d24
+ * Note: The freelist supports a maximum arena shift of 15.
c67d24
  * Note: Do not use JS_CPU_SPARC here, this header is used outside JS.
c67d24
  * Bug 692267: Move page size definition to gc/Memory.h and include it
c67d24
  *             directly once jsgc.h is no longer an installed header.
c67d24
  */
c67d24
 #if defined(SOLARIS) && (defined(__sparc) || defined(__sparcv9))
c67d24
 const size_t PageShift = 13;
c67d24
+const size_t ArenaShift = PageShift;
c67d24
+#elif defined(__powerpc__)
c67d24
+const size_t PageShift = 16;
c67d24
+const size_t ArenaShift = 12;
c67d24
 #else
c67d24
 const size_t PageShift = 12;
c67d24
+const size_t ArenaShift = PageShift;
c67d24
 #endif
c67d24
 const size_t PageSize = size_t(1) << PageShift;
c67d24
+const size_t ArenaSize = size_t(1) << ArenaShift;
c67d24
+const size_t ArenaMask = ArenaSize - 1;
c67d24
 
c67d24
 const size_t ChunkShift = 20;
c67d24
 const size_t ChunkSize = size_t(1) << ChunkShift;
c67d24
 const size_t ChunkMask = ChunkSize - 1;
c67d24
 
c67d24
-const size_t ArenaShift = PageShift;
c67d24
-const size_t ArenaSize = PageSize;
c67d24
-const size_t ArenaMask = ArenaSize - 1;
c67d24
-
c67d24
 /*
c67d24
  * This is the maximum number of arenas we allow in the FreeCommitted state
c67d24
  * before we trigger a GC_SHRINK to release free arenas to the OS.
c67d24
diff -up xulrunner-17.0/mozilla-beta/js/src/jsgc.cpp.746112 xulrunner-17.0/mozilla-beta/js/src/jsgc.cpp
c67d24
--- a/js/src/jsgc.cpp.746112	2012-10-17 16:32:44.000000000 +0200
c67d24
+++ b/js/src/jsgc.cpp	2012-10-24 14:46:28.253638095 +0200
c67d24
@@ -251,6 +251,13 @@ static const int BackgroundPhaseLength[]
c67d24
     sizeof(BackgroundPhaseStrings) / sizeof(AllocKind)
c67d24
 };
c67d24
 
c67d24
+/* Unused memory decommiting requires the arena size match the page size. */
c67d24
+static bool
c67d24
+DecommitEnabled()
c67d24
+{
c67d24
+    return PageSize == ArenaSize;
c67d24
+}
c67d24
+
c67d24
 #ifdef DEBUG
c67d24
 void
c67d24
 ArenaHeader::checkSynchronizedWithFreeList() const
c67d24
@@ -742,7 +749,8 @@ Chunk::fetchNextDecommittedArena()
c67d24
     decommittedArenas.unset(offset);
c67d24
 
c67d24
     Arena *arena = &arenas[offset];
c67d24
-    MarkPagesInUse(arena, ArenaSize);
c67d24
+    if (DecommitEnabled())
c67d24
+        MarkPagesInUse(arena, ArenaSize);
c67d24
     arena->aheader.setAsNotAllocated();
c67d24
 
c67d24
     return &arena->aheader;
c67d24
@@ -2731,7 +2739,7 @@ DecommitArenasFromAvailableList(JSRuntim
c67d24
                 chunk->removeFromAvailableList();
c67d24
 
c67d24
             size_t arenaIndex = Chunk::arenaIndex(aheader->arenaAddress());
c67d24
-            bool ok;
c67d24
+            bool ok = true;
c67d24
             {
c67d24
                 /*
c67d24
                  * If the main thread waits for the decommit to finish, skip
c67d24
@@ -2741,7 +2749,8 @@ DecommitArenasFromAvailableList(JSRuntim
c67d24
                 Maybe<AutoUnlockGC> maybeUnlock;
c67d24
                 if (!rt->isHeapBusy())
c67d24
                     maybeUnlock.construct(rt);
c67d24
-                ok = MarkPagesUnused(aheader->getArena(), ArenaSize);
c67d24
+                if (DecommitEnabled())
c67d24
+                    ok = MarkPagesUnused(aheader->getArena(), ArenaSize);
c67d24
             }
c67d24
 
c67d24
             if (ok) {