#include "AutoLarge.h"
#include "AutoSubzone.h"
#include "AutoZone.h"
namespace Auto {
Large::Large(usword_t vm_size, usword_t size, usword_t layout, usword_t refcount, usword_t age, unsigned char* write_barrier_cards)
: _prev(NULL), _next(NULL), _vm_size(vm_size), _size(size), _layout(layout), _refcount(refcount), _age(age),
_is_pending(false), _is_marked(false), _is_freed(false),
_write_barrier(displace(this, side_data_size()), write_barrier_cards, WriteBarrier::bytes_needed(size))
{
}
Large *Large::allocate(Zone *zone, const usword_t size, usword_t layout, bool refcount_is_one) {
usword_t header_size = side_data_size();
usword_t allocation_size = align2(size, allocate_quantum_small_log2);
usword_t wb_size = align2(WriteBarrier::bytes_needed(allocation_size), allocate_quantum_small_log2);
usword_t vm_size = align2(header_size + allocation_size + wb_size, page_size_log2);
void *space = zone->arena_allocate_large(vm_size);
return space != NULL ? new (space) Large(vm_size, allocation_size, layout, refcount_is_one ? 1 : 0, initial_age,
(unsigned char *)displace(space, header_size + allocation_size)) : NULL;
}
void Large::deallocate(Zone *zone) {
zone->arena_deallocate((void *)this, _vm_size);
}
};