Bug 979913: Conditionally define PAGE_SIZE, r=khuey
authorThomas Zimmermann <tdz@users.sourceforge.net>
Fri, 14 Mar 2014 11:23:51 +0100
changeset 191871 6659e34090c966de7352c07c877ce605b7760357
parent 191870 0a5e13d2c0039ab24b9573e24816ddeed1927f4e
child 191872 e673315c346f9800b7f4c52b1fe2665e0d142e9c
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs979913
milestone30.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 979913: Conditionally define PAGE_SIZE, r=khuey With this patch the PAGE_SIZE value from the system is used if possible. If page size is not defined by the system, it is set to 4096 bytes and a warning is emitted. PAGE_ALIGN_MASK is now derived from PAGE_SIZE. With these changes, the code should be more robust on systems with non-4KiB page size.
mozglue/build/Nuwa.cpp
--- a/mozglue/build/Nuwa.cpp
+++ b/mozglue/build/Nuwa.cpp
@@ -137,18 +137,21 @@ typedef std::vector<std::pair<pthread_ke
 TLSInfoList;
 
 /**
  * The stack size is chosen carefully so the frozen threads doesn't consume too
  * much memory in the Nuwa process. The threads shouldn't run deep recursive
  * methods or do large allocations on the stack to avoid stack overflow.
  */
 #ifndef NUWA_STACK_SIZE
-#define PAGE_SIZE 4096
-#define PAGE_ALIGN_MASK 0xfffff000
+#ifndef PAGE_SIZE
+#warning "Hard-coding page size to 4096 byte
+#define PAGE_SIZE 4096ul
+#endif
+#define PAGE_ALIGN_MASK (~(PAGE_SIZE-1))
 #define NUWA_STACK_SIZE (1024 * 128)
 #endif
 
 #define NATIVE_THREAD_NAME_LENGTH 16
 
 struct thread_info : public mozilla::LinkedListElement<thread_info> {
   pthread_t origThreadID;
   pthread_t recreatedThreadID;