void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) { #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(); #elif OS(LINUX) UNUSED_PARAM(usage); UNUSED_PARAM(writable); UNUSED_PARAM(executable); UNUSED_PARAM(includesGuardPages); 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); #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 #endif // OS(QNX) return result; }
void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable) { 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 return result; }
void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) { EA::WebKit::Allocator* pAllocator = EA::WebKit::GetAllocator(); if(pAllocator->SupportsOSMemoryManagement()) { return pAllocator->ReserveUncommitted(bytes,writable,executable); } else { // We don't make a distinction. return reserveAndCommit(bytes, usage, writable, executable, includesGuardPages); } }