示例#1
0
MarkedBlock* MarkedBlock::create(Heap* heap, size_t cellSize)
{
    PageAllocationAligned allocation = PageAllocationAligned::allocate(blockSize, blockSize, OSAllocator::JSGCHeapPages);
    if (!static_cast<bool>(allocation))
        CRASH();
    return new (NotNull, allocation.base()) MarkedBlock(allocation, heap, cellSize);
}
void PageAllocationAligned::deallocate()
{
    // Clear base & size before calling release; if this is *inside* allocation
    // then we won't be able to clear then after deallocating the memory.
    PageAllocationAligned tmp;
    std::swap(tmp, *this);

    ASSERT(tmp);
    ASSERT(!*this);

#if OS(DARWIN)
    vm_deallocate(current_task(), reinterpret_cast<vm_address_t>(tmp.base()), tmp.size());
#else
    ASSERT(tmp.m_reservation.contains(tmp.base(), tmp.size()));
    OSAllocator::decommitAndRelease(tmp.m_reservation.base(), tmp.m_reservation.size());
#endif
}
示例#3
0
CheckedBoolean CopiedSpace::tryAllocateOversize(size_t bytes, void** outPtr)
{
    ASSERT(isOversize(bytes));

    size_t blockSize = WTF::roundUpToMultipleOf(WTF::pageSize(), sizeof(CopiedBlock) + bytes);

    PageAllocationAligned allocation = PageAllocationAligned::allocate(blockSize, WTF::pageSize(), OSAllocator::JSGCHeapPages);
    if (!static_cast<bool>(allocation)) {
        *outPtr = 0;
        return false;
    }

    CopiedBlock* block = new (NotNull, allocation.base()) CopiedBlock(allocation);
    m_oversizeBlocks.push(block);
    m_oversizeFilter.add(reinterpret_cast<Bits>(block));

    *outPtr = allocateFromBlock(block, bytes);

    m_heap->didAllocate(blockSize);

    return true;
}