Bug 746112 - Don't decommit if page size is too large; r=billm

The powerpc architecture has 64KiB pages, which is too large to represent in the
free list.  This patch splits the page size from the arena size and disabled
decommit logic in that case.
This commit is contained in:
Terrence Cole 2012-09-05 12:40:25 -07:00
parent 4faceed9c4
commit 3aa723ba1f
2 changed files with 25 additions and 5 deletions

View File

@ -104,7 +104,9 @@ struct Cell
};
/*
* Page size is 4096 by default, except for SPARC, where it is 8192.
* Page size must be static to support our arena pointer optimizations, so we
* are forced to support each platform with non-4096 pages as a special case.
* Note: The freelist supports a maximum arena shift of 15.
* Note: Do not use JS_CPU_SPARC here, this header is used outside JS.
* Bug 692267: Move page size definition to gc/Memory.h and include it
* directly once jsgc.h is no longer an installed header.
@ -112,19 +114,22 @@ struct Cell
#if (defined(SOLARIS) || defined(__FreeBSD__)) && \
(defined(__sparc) || defined(__sparcv9) || defined(__ia64))
const size_t PageShift = 13;
const size_t ArenaShift = PageShift;
#elif defined(__powerpc__)
const size_t PageShift = 16;
const size_t ArenaShift = 12;
#else
const size_t PageShift = 12;
const size_t ArenaShift = PageShift;
#endif
const size_t PageSize = size_t(1) << PageShift;
const size_t ArenaSize = size_t(1) << ArenaShift;
const size_t ArenaMask = ArenaSize - 1;
const size_t ChunkShift = 20;
const size_t ChunkSize = size_t(1) << ChunkShift;
const size_t ChunkMask = ChunkSize - 1;
const size_t ArenaShift = PageShift;
const size_t ArenaSize = PageSize;
const size_t ArenaMask = ArenaSize - 1;
/*
* This is the maximum number of arenas we allow in the FreeCommitted state
* before we trigger a GC_SHRINK to release free arenas to the OS.

View File

@ -15,6 +15,15 @@
namespace js {
namespace gc {
/* Unused memory decommiting requires the arena size match the page size. */
extern const size_t PageSize;
extern const size_t ArenaSize;
static bool
DecommitEnabled()
{
return PageSize == ArenaSize;
}
#if defined(XP_WIN)
#include "jswin.h"
#include <psapi.h>
@ -83,6 +92,9 @@ UnmapPages(void *p, size_t size)
bool
MarkPagesUnused(void *p, size_t size)
{
if (!DecommitEnabled())
return false;
JS_ASSERT(uintptr_t(p) % PageSize == 0);
LPVOID p2 = VirtualAlloc(p, size, MEM_RESET, PAGE_READWRITE);
return p2 == p;
@ -352,6 +364,9 @@ UnmapPages(void *p, size_t size)
bool
MarkPagesUnused(void *p, size_t size)
{
if (!DecommitEnabled())
return false;
JS_ASSERT(uintptr_t(p) % PageSize == 0);
int result = madvise(p, size, MADV_DONTNEED);
return result != -1;