diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WTF/wtf/OSAllocatorPosix.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WTF/wtf/OSAllocatorPosix.cpp')
-rw-r--r-- | Source/WTF/wtf/OSAllocatorPosix.cpp | 18 |
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); |