summaryrefslogtreecommitdiff
path: root/Source/WTF/wtf/OSAllocatorPosix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WTF/wtf/OSAllocatorPosix.cpp')
-rw-r--r--Source/WTF/wtf/OSAllocatorPosix.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/Source/WTF/wtf/OSAllocatorPosix.cpp b/Source/WTF/wtf/OSAllocatorPosix.cpp
index 61661eecc..f5e6669a9 100644
--- a/Source/WTF/wtf/OSAllocatorPosix.cpp
+++ b/Source/WTF/wtf/OSAllocatorPosix.cpp
@@ -50,8 +50,10 @@ void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable,
#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) { }
+ if (result) {
+ // To support the "reserve then commit" model, we have to initially decommit.
+ while (madvise(result, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
+ }
#endif
#endif
@@ -104,11 +106,9 @@ void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bo
result = mmap(result, bytes, protection, flags, fd, 0);
if (result == MAP_FAILED) {
-#if ENABLE(LLINT)
if (executable)
result = 0;
else
-#endif
CRASH();
}
if (result && includesGuardPages) {
@@ -164,6 +164,16 @@ void OSAllocator::decommit(void* address, size_t bytes)
#endif
}
+void OSAllocator::hintMemoryNotNeededSoon(void* address, size_t bytes)
+{
+#if HAVE(MADV_DONTNEED)
+ while (madvise(address, bytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { }
+#else
+ UNUSED_PARAM(address);
+ UNUSED_PARAM(bytes);
+#endif
+}
+
void OSAllocator::releaseDecommitted(void* address, size_t bytes)
{
int result = munmap(address, bytes);