Bug 1003230 - Don't re-query page size information when memory mapping files r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 15 Jul 2014 09:42:47 +0100
changeset 216065 5340b5943f31fd1c24ea5c7d81493978400705f5
parent 216064 e7e6db764418d757a19e3843ab08f09d7e74cf2a
child 216066 21f83c1eba9220038bd04dbbe299290d55265a88
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1003230
milestone33.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 1003230 - Don't re-query page size information when memory mapping files r=sfink
js/src/gc/Memory.cpp
--- a/js/src/gc/Memory.cpp
+++ b/js/src/gc/Memory.cpp
@@ -677,37 +677,36 @@ GetPageFaultCount()
 
 void *
 AllocateMappedContent(int fd, size_t offset, size_t length, size_t alignment)
 {
 #define NEED_PAGE_ALIGNED 0
     size_t pa_start; // Page aligned starting
     size_t pa_end; // Page aligned ending
     size_t pa_size; // Total page aligned size
-    size_t page_size = sysconf(_SC_PAGESIZE); // Page size
     struct stat st;
     uint8_t *buf;
 
     // Make sure file exists and do sanity check for offset and size.
     if (fstat(fd, &st) < 0 || offset >= (size_t) st.st_size ||
         length == 0 || length > (size_t) st.st_size - offset)
         return nullptr;
 
     // Check for minimal alignment requirement.
 #if NEED_PAGE_ALIGNED
-    alignment = std::max(alignment, page_size);
+    alignment = std::max(alignment, pageSize);
 #endif
     if (offset & (alignment - 1))
         return nullptr;
 
     // Page aligned starting of the offset.
-    pa_start = offset & ~(page_size - 1);
+    pa_start = offset & ~(pageSize - 1);
     // Calculate page aligned ending by adding one page to the page aligned
     // starting of data end position(offset + length - 1).
-    pa_end = ((offset + length - 1) & ~(page_size - 1)) + page_size;
+    pa_end = ((offset + length - 1) & ~(pageSize - 1)) + pageSize;
     pa_size = pa_end - pa_start;
 
     // Ask for a continuous memory location.
     buf = (uint8_t *) MapMemory(pa_size);
     if (!buf)
         return nullptr;
 
     buf = (uint8_t *) MapMemoryAt(buf, pa_size, PROT_READ | PROT_WRITE,
@@ -723,21 +722,20 @@ AllocateMappedContent(int fd, size_t off
 
     return buf + (offset - pa_start);
 }
 
 void
 DeallocateMappedContent(void *p, size_t length)
 {
     void *pa_start; // Page aligned starting
-    size_t page_size = sysconf(_SC_PAGESIZE); // Page size
     size_t total_size; // Total allocated size
 
-    pa_start = (void *)(uintptr_t(p) & ~(page_size - 1));
-    total_size = ((uintptr_t(p) + length) & ~(page_size - 1)) + page_size - uintptr_t(pa_start);
+    pa_start = (void *)(uintptr_t(p) & ~(pageSize - 1));
+    total_size = ((uintptr_t(p) + length) & ~(pageSize - 1)) + pageSize - uintptr_t(pa_start);
     if (munmap(pa_start, total_size))
         MOZ_ASSERT(errno == ENOMEM);
 }
 
 #else
 #error "Memory mapping functions are not defined for your OS."
 #endif