summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/webkit/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/webkit/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp')
-rw-r--r--src/3rdparty/webkit/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/3rdparty/webkit/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp b/src/3rdparty/webkit/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp
index 8c3b8090b0..5ba5410251 100644
--- a/src/3rdparty/webkit/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp
+++ b/src/3rdparty/webkit/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp
@@ -35,11 +35,21 @@ namespace WTF {
void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable)
{
+#if OS(QNX)
+ // Reserve memory with PROT_NONE and MAP_LAZY so it isn't committed now.
+ 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);
#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
+
+#endif // OS(QNX)
+
return result;
}
@@ -98,20 +108,35 @@ void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bo
return result;
}
-void OSAllocator::commit(void* address, size_t bytes, bool, bool)
+void OSAllocator::commit(void* address, size_t bytes, bool writable, bool executable)
{
-#if HAVE(MADV_FREE_REUSE)
+#if OS(QNX)
+ int protection = PROT_READ;
+ if (writable)
+ protection |= PROT_WRITE;
+ if (executable)
+ protection |= PROT_EXEC;
+ if (MAP_FAILED == mmap(address, bytes, protection, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0))
+ CRASH();
+#elif HAVE(MADV_FREE_REUSE)
+ UNUSED_PARAM(writable);
+ UNUSED_PARAM(executable);
while (madvise(address, bytes, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { }
#else
// Non-MADV_FREE_REUSE reservations automatically commit on demand.
UNUSED_PARAM(address);
UNUSED_PARAM(bytes);
+ UNUSED_PARAM(writable);
+ UNUSED_PARAM(executable);
#endif
}
void OSAllocator::decommit(void* address, size_t bytes)
{
-#if HAVE(MADV_FREE_REUSE)
+#if OS(QNX)
+ // Use PROT_NONE and MAP_LAZY to decommit the pages.
+ mmap(address, bytes, PROT_NONE, MAP_FIXED | MAP_LAZY | MAP_PRIVATE | MAP_ANON, -1, 0);
+#elif HAVE(MADV_FREE_REUSE)
while (madvise(address, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
#elif HAVE(MADV_FREE)
while (madvise(address, bytes, MADV_FREE) == -1 && errno == EAGAIN) { }