Modified: trunk/Source/WTF/wtf/OSAllocatorPosix.cpp (128817 => 128818)
--- trunk/Source/WTF/wtf/OSAllocatorPosix.cpp 2012-09-17 22:51:04 UTC (rev 128817)
+++ trunk/Source/WTF/wtf/OSAllocatorPosix.cpp 2012-09-17 23:00:32 UTC (rev 128818)
@@ -41,14 +41,12 @@
void* result = mmap(0, bytes, PROT_NONE, MAP_LAZY | MAP_PRIVATE | MAP_ANON, -1, 0);
if (result == MAP_FAILED)
CRASH();
-#elif OS(LINUX)
- void* result = mmap(0, bytes, PROT_NONE, MAP_NORESERVE | MAP_PRIVATE | MAP_ANON, -1, 0);
- if (result == MAP_FAILED)
- CRASH();
+#else // OS(QNX)
+
+ void* result = reserveAndCommit(bytes, usage, writable, executable, includesGuardPages);
+#if OS(LINUX)
madvise(result, bytes, MADV_DONTNEED);
-#else
- void* result = reserveAndCommit(bytes, usage, writable, executable, includesGuardPages);
-#if HAVE(MADV_FREE_REUSE)
+#elif HAVE(MADV_FREE_REUSE)
// To support the "reserve then commit" model, we have to initially decommit.
while (madvise(result, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
#endif
@@ -73,6 +71,18 @@
flags |= MAP_JIT;
#endif
+#if (OS(LINUX) && CPU(X86_64))
+ // Linux distros usually do not allow overcommit by default, so
+ // JSC's strategy of mmaping a large amount of memory upfront
+ // won't work very well on some systems. Fortunately there's a
+ // flag we can pass to mmap to disable the overcommit check for
+ // this particular call, so we can get away with it as long as the
+ // overcommit flag value in /proc/sys/vm/overcommit_memory is 0
+ // ('heuristic') and not 2 (always check). 0 is the usual default
+ // value, so this should work well in general.
+ flags |= MAP_NORESERVE;
+#endif
+
#if OS(DARWIN)
int fd = usage;
#else
@@ -131,13 +141,8 @@
if (MAP_FAILED == mmap(address, bytes, protection, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0))
CRASH();
#elif OS(LINUX)
- int protection = PROT_READ;
- if (writable)
- protection |= PROT_WRITE;
- if (executable)
- protection |= PROT_EXEC;
- if (!mprotect(address, bytes, protection))
- CRASH();
+ UNUSED_PARAM(writable);
+ UNUSED_PARAM(executable);
madvise(address, bytes, MADV_WILLNEED);
#elif HAVE(MADV_FREE_REUSE)
UNUSED_PARAM(writable);
@@ -159,8 +164,6 @@
mmap(address, bytes, PROT_NONE, MAP_FIXED | MAP_LAZY | MAP_PRIVATE | MAP_ANON, -1, 0);
#elif OS(LINUX)
madvise(address, bytes, MADV_DONTNEED);
- if (!mprotect(address, bytes, PROT_NONE))
- CRASH();
#elif HAVE(MADV_FREE_REUSE)
while (madvise(address, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
#elif HAVE(MADV_FREE)