Source/wtf/PageAllocator.cpp
// This simple internal function wraps the OS-specific page allocation call so
// that it behaves consistently: the address is a hint and if it cannot be used,
// the allocation will be placed elsewhere.
This simple internal function wraps the OS-specific page allocation call so
that it behaves consistently: the address is a hint and if it cannot be used,
the allocation will be placed elsewhere.
This simple internal function wraps the OS - specific page allocation call so that it behaves consistently : the address is a hint and if it cannot be used the allocation will be placed elsewhere .
static void* systemAllocPages(void* addr, size_t len)
{
    ASSERT(!(len & kPageAllocationGranularityOffsetMask));
    ASSERT(!(reinterpret_cast<uintptr_t>(addr) & kPageAllocationGranularityOffsetMask));
    void* ret;
#if OS(WIN)
    ret = VirtualAlloc(addr, len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
    if (!ret)
        ret = VirtualAlloc(0, len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
#else
    ret = mmap(addr, len, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
    if (ret == MAP_FAILED)
        ret = 0;
#endif
    return ret;
}
static void * systemAllocPages ( void * addr , size_t len ) { ASSERT ( ! ( len & kPageAllocationGranularityOffsetMask ) ) ; ASSERT ( ! ( reinterpret_cast < uintptr_t > ( addr ) & kPageAllocationGranularityOffsetMask ) ) ; void * ret ; #if OS ( WIN ) ret = VirtualAlloc ( addr , len , MEM_RESERVE | MEM_COMMIT , PAGE_READWRITE ) ; if ( ! ret ) ret = VirtualAlloc ( 0 , len , MEM_RESERVE | MEM_COMMIT , PAGE_READWRITE ) ; #else ret = mmap ( addr , len , PROT_READ | PROT_WRITE , MAP_ANONYMOUS | MAP_PRIVATE , -1 , 0 ) ; if ( ret == MAP_FAILED ) ret = 0 ; #endif return ret ; }
This simple internal function wraps the OS-specific page allocation call so
that it behaves consistently: the address is a hint and if it cannot be used,
the allocation will be placed elsewhere.
This simple internal function wraps the OS - specific page allocation call so that it behaves consistently : the address is a hint and if it cannot be used the allocation will be placed elsewhere .