Bug 639743 - JM: clean up Executable{Pool,Allocator} some more, 3/6. r=dvander.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 09 Mar 2011 19:11:59 -0800
changeset 64266 03151dfd666386d4bc9761d8e9b1401fc8d6bb9f
parent 64265 504939f68ed2ad15a8cd308ff1510c5412b5fc71
child 64267 5a256e0cd7b6dd23a79c16fe880a963e39f9e402
push id19328
push usercleary@mozilla.com
push dateTue, 29 Mar 2011 21:56:11 +0000
treeherdermozilla-central@3d0784802ce6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs639743
milestone2.0b13pre
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 639743 - JM: clean up Executable{Pool,Allocator} some more, 3/6. r=dvander.
js/src/assembler/jit/ExecutableAllocator.h
--- a/js/src/assembler/jit/ExecutableAllocator.h
+++ b/js/src/assembler/jit/ExecutableAllocator.h
@@ -67,40 +67,16 @@ extern "C" __declspec(dllimport) void Ca
 #if ENABLE_ASSEMBLER_WX_EXCLUSIVE
 #define PROTECTION_FLAGS_RW (PROT_READ | PROT_WRITE)
 #define PROTECTION_FLAGS_RX (PROT_READ | PROT_EXEC)
 #define INITIAL_PROTECTION_FLAGS PROTECTION_FLAGS_RX
 #else
 #define INITIAL_PROTECTION_FLAGS (PROT_READ | PROT_WRITE | PROT_EXEC)
 #endif
 
-namespace JSC {
-
-// Something included via windows.h defines a macro with this name,
-// which causes the function below to fail to compile.
-#ifdef _MSC_VER
-# undef max
-#endif
-
-const size_t OVERSIZE_ALLOCATION = size_t(-1);
-
-inline size_t roundUpAllocationSize(size_t request, size_t granularity)
-{
-    if ((std::numeric_limits<size_t>::max() - granularity) <= request)
-        return OVERSIZE_ALLOCATION;
-    
-    // Round up to next page boundary
-    size_t size = request + (granularity - 1);
-    size = size & ~(granularity - 1);
-    JS_ASSERT(size >= request);
-    return size;
-}
-
-}
-
 #if ENABLE_ASSEMBLER
 
 //#define DEBUG_STRESS_JSC_ALLOCATOR
 
 namespace JSC {
 
   // These are reference-counted. A new one starts with a count of 1. 
   class ExecutablePool {
@@ -155,17 +131,16 @@ private:
     ~ExecutablePool()
     {
         if (m_allocation.pages)
             ExecutablePool::systemRelease(m_allocation);
     }
 
     void* alloc(size_t n)
     {
-        JS_ASSERT(n != OVERSIZE_ALLOCATION);
         JS_ASSERT(n <= available());
         void *result = m_freePtr;
         m_freePtr += n;
         return result;
     }
     
     void destroy()
     {
@@ -224,16 +199,36 @@ public:
         // This alloc is infallible because poolForSize() just obtained
         // (found, or created if necessary) a pool that had enough space.
         void *result = (*poolp)->alloc(n);
         JS_ASSERT(result);
         return result;
     }
 
 private:
+    static const size_t OVERSIZE_ALLOCATION = size_t(-1);
+
+    static size_t roundUpAllocationSize(size_t request, size_t granularity)
+    {
+        // Something included via windows.h defines a macro with this name,
+        // which causes the function below to fail to compile.
+        #ifdef _MSC_VER
+        # undef max
+        #endif
+
+        if ((std::numeric_limits<size_t>::max() - granularity) <= request)
+            return OVERSIZE_ALLOCATION;
+        
+        // Round up to next page boundary
+        size_t size = request + (granularity - 1);
+        size = size & ~(granularity - 1);
+        JS_ASSERT(size >= request);
+        return size;
+    }
+
     ExecutablePool* createPool(size_t n)
     {
         size_t allocSize = roundUpAllocationSize(n, JIT_ALLOCATOR_PAGE_SIZE);
         if (allocSize == OVERSIZE_ALLOCATION)
             return NULL;
 #ifdef DEBUG_STRESS_JSC_ALLOCATOR
         ExecutablePool::Allocation a = ExecutablePool::systemAlloc(size_t(4294967291));
 #else