Modified: trunk/Source/WTF/wtf/OSAllocatorPosix.cpp (137993 => 137994)
--- trunk/Source/WTF/wtf/OSAllocatorPosix.cpp 2012-12-18 08:25:58 UTC (rev 137993)
+++ trunk/Source/WTF/wtf/OSAllocatorPosix.cpp 2012-12-18 08:37:24 UTC (rev 137994)
@@ -41,12 +41,14 @@
void* result = mmap(0, bytes, PROT_NONE, MAP_LAZY | 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)
+#elif OS(LINUX)
+ void* result = mmap(0, bytes, PROT_NONE, MAP_NORESERVE | MAP_PRIVATE | MAP_ANON, -1, 0);
+ if (result == MAP_FAILED)
+ CRASH();
madvise(result, bytes, MADV_DONTNEED);
-#elif HAVE(MADV_FREE_REUSE)
+#else
+ void* result = reserveAndCommit(bytes, usage, writable, executable, includesGuardPages);
+#if 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
@@ -71,18 +73,6 @@
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
@@ -142,8 +132,13 @@
if (MAP_FAILED == mmap(address, bytes, protection, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0))
CRASH();
#elif OS(LINUX)
- UNUSED_PARAM(writable);
- UNUSED_PARAM(executable);
+ int protection = PROT_READ;
+ if (writable)
+ protection |= PROT_WRITE;
+ if (executable)
+ protection |= PROT_EXEC;
+ if (mprotect(address, bytes, protection))
+ CRASH();
madvise(address, bytes, MADV_WILLNEED);
#elif HAVE(MADV_FREE_REUSE)
UNUSED_PARAM(writable);
@@ -165,6 +160,8 @@
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)