Declare and define ExecutableAllocator::reprotectRegion only #ifdef NON_WRITABLE_JIT_CODE, to eliminate MOZ_ASSERT of a constant condition that makes some compilers warn. No bug, r=efaust over IRC
authorJeff Walden <jwalden@mit.edu>
Wed, 13 Apr 2016 19:19:03 -0700
changeset 331030 bb3412f7937d17ed0d9176aa81ffbfb4bc204b62
parent 331029 bca6a0b5816fc86522c0cd0c2e81d168847a094e
child 331031 91115264629dfaacf2d60d52a3eff89c18c5af0d
child 331079 b24b880f2e237d4a3d6254a414ad7a32822db3e9
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersefaust
milestone48.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
Declare and define ExecutableAllocator::reprotectRegion only #ifdef NON_WRITABLE_JIT_CODE, to eliminate MOZ_ASSERT of a constant condition that makes some compilers warn. No bug, r=efaust over IRC
js/src/jit/ExecutableAllocator.h
js/src/jit/ExecutableAllocatorPosix.cpp
js/src/jit/ExecutableAllocatorWin.cpp
--- a/js/src/jit/ExecutableAllocator.h
+++ b/js/src/jit/ExecutableAllocator.h
@@ -302,18 +302,21 @@ class ExecutableAllocator
         sync_instruction_memory((caddr_t)code, size);
     }
 #endif
 
   private:
     ExecutableAllocator(const ExecutableAllocator&) = delete;
     void operator=(const ExecutableAllocator&) = delete;
 
+#ifdef NON_WRITABLE_JIT_CODE
     MOZ_WARN_UNUSED_RESULT
     static bool reprotectRegion(void*, size_t, ProtectionSetting);
+#endif
+
     void reprotectAll(ProtectionSetting);
 
     // These are strong references;  they keep pools alive.
     static const size_t maxSmallPools = 4;
     typedef js::Vector<ExecutablePool*, maxSmallPools, js::SystemAllocPolicy> SmallExecPoolVector;
     SmallExecPoolVector m_smallPools;
 
     // All live pools are recorded here, just for stats purposes.  These are
--- a/js/src/jit/ExecutableAllocatorPosix.cpp
+++ b/js/src/jit/ExecutableAllocatorPosix.cpp
@@ -73,36 +73,39 @@ void
 ExecutableAllocator::systemRelease(const ExecutablePool::Allocation& alloc)
 {
     DeallocateExecutableMemory(alloc.pages, alloc.size, pageSize);
 }
 
 static const unsigned FLAGS_RW = PROT_READ | PROT_WRITE;
 static const unsigned FLAGS_RX = PROT_READ | PROT_EXEC;
 
+#if defined(NON_WRITABLE_JIT_CODE)
+
 bool
 ExecutableAllocator::reprotectRegion(void* start, size_t size, ProtectionSetting setting)
 {
-    MOZ_ASSERT(NON_WRITABLE_JIT_CODE);
     MOZ_ASSERT(pageSize);
 
     // Calculate the start of the page containing this region,
     // and account for this extra memory within size.
     intptr_t startPtr = reinterpret_cast<intptr_t>(start);
     intptr_t pageStartPtr = startPtr & ~(pageSize - 1);
     void* pageStart = reinterpret_cast<void*>(pageStartPtr);
     size += (startPtr - pageStartPtr);
 
     // Round size up
     size += (pageSize - 1);
     size &= ~(pageSize - 1);
 
     return !mprotect(pageStart, size, (setting == Writable) ? FLAGS_RW : FLAGS_RX);
 }
 
+#endif // defined(NON_WRITABLE_JIT_CODE)
+
 /* static */ unsigned
 ExecutableAllocator::initialProtectionFlags(ProtectionSetting protection)
 {
 #ifdef NON_WRITABLE_JIT_CODE
     return (protection == Writable) ? FLAGS_RW : FLAGS_RX;
 #else
     return FLAGS_RW | FLAGS_RX;
 #endif
--- a/js/src/jit/ExecutableAllocatorWin.cpp
+++ b/js/src/jit/ExecutableAllocatorWin.cpp
@@ -234,20 +234,21 @@ ExecutableAllocator::systemAlloc(size_t 
 }
 
 void
 ExecutableAllocator::systemRelease(const ExecutablePool::Allocation& alloc)
 {
     DeallocateExecutableMemory(alloc.pages, alloc.size, pageSize);
 }
 
+#if defined(NON_WRITABLE_JIT_CODE)
+
 bool
 ExecutableAllocator::reprotectRegion(void* start, size_t size, ProtectionSetting setting)
 {
-    MOZ_ASSERT(NON_WRITABLE_JIT_CODE);
     MOZ_ASSERT(pageSize);
 
     // Calculate the start of the page containing this region,
     // and account for this extra memory within size.
     intptr_t startPtr = reinterpret_cast<intptr_t>(start);
     intptr_t pageStartPtr = startPtr & ~(pageSize - 1);
     void* pageStart = reinterpret_cast<void*>(pageStartPtr);
     size += (startPtr - pageStartPtr);
@@ -256,16 +257,18 @@ ExecutableAllocator::reprotectRegion(voi
     size += (pageSize - 1);
     size &= ~(pageSize - 1);
 
     DWORD oldProtect;
     int flags = (setting == Writable) ? PAGE_READWRITE : PAGE_EXECUTE_READ;
     return VirtualProtect(pageStart, size, flags, &oldProtect);
 }
 
+#endif // defined(NON_WRITABLE_JIT_CODE)
+
 /* static */ unsigned
 ExecutableAllocator::initialProtectionFlags(ProtectionSetting protection)
 {
 #ifdef NON_WRITABLE_JIT_CODE
     return (protection == Writable) ? PAGE_READWRITE : PAGE_EXECUTE_READ;
 #else
     return PAGE_EXECUTE_READWRITE;
 #endif