changed moo_makeheap() a bit
added the PERM bit to the object header
This commit is contained in:
parent
29b19e10b3
commit
647edf3268
@ -712,6 +712,8 @@ moo_oop_t moo_moveoop (moo_t* moo, moo_oop_t oop)
|
||||
|
||||
if (!MOO_OOP_IS_POINTER(oop)) return oop;
|
||||
|
||||
if (MOO_OBJ_GET_FLAGS_PERM(oop)) return oop;
|
||||
|
||||
if (MOO_OBJ_GET_FLAGS_MOVED(oop))
|
||||
{
|
||||
/* this object has migrated to the new heap.
|
||||
|
@ -32,12 +32,11 @@
|
||||
moo_heap_t* moo_makeheap (moo_t* moo, moo_oow_t size)
|
||||
{
|
||||
moo_heap_t* heap;
|
||||
moo_oow_t half_size;
|
||||
moo_oow_t space_size;
|
||||
|
||||
if (size < MIN_HEAP_SIZE) size = MIN_HEAP_SIZE;
|
||||
half_size = size / 2;
|
||||
|
||||
heap = (moo_heap_t*)moo->vmprim.alloc_heap(moo, MOO_SIZEOF(*heap) + PERM_SPACE_SIZE + size);
|
||||
heap = (moo_heap_t*)moo->vmprim.alloc_heap(moo, MOO_SIZEOF(*heap) + size);
|
||||
if (!heap)
|
||||
{
|
||||
const moo_ooch_t* oldmsg = moo_backuperrmsg(moo);
|
||||
@ -49,20 +48,22 @@ moo_heap_t* moo_makeheap (moo_t* moo, moo_oow_t size)
|
||||
heap->base = (moo_uint8_t*)(heap + 1);
|
||||
heap->size = size;
|
||||
|
||||
/* TODO: consider placing permspace in a separate memory allocated block in case we have to grow
|
||||
space_size = (size - PERM_SPACE_SIZE) / 2;
|
||||
|
||||
/* TODO: consider placing permspace in a separate memory chunk in case we have to grow
|
||||
* other spaces. we may be able to realloc() the entire heap region without affecting the separately
|
||||
* allocated block. */
|
||||
* allocated chunk. */
|
||||
heap->permspace.base = (moo_uint8_t*)(heap + 1);
|
||||
heap->permspace.ptr = (moo_uint8_t*)MOO_ALIGN(((moo_uintptr_t)heap->permspace.base), MOO_SIZEOF(moo_oop_t));
|
||||
heap->permspace.limit = heap->permspace.base + PERM_SPACE_SIZE;
|
||||
|
||||
heap->curspace.base = heap->permspace.limit;
|
||||
heap->curspace.ptr = (moo_uint8_t*)MOO_ALIGN(((moo_uintptr_t)heap->curspace.base), MOO_SIZEOF(moo_oop_t));
|
||||
heap->curspace.limit = heap->curspace.base + half_size;
|
||||
heap->curspace.limit = heap->curspace.base + space_size;
|
||||
|
||||
heap->newspace.base = heap->curspace.limit; /*(moo_uint8_t*)(heap + 1) + half_size;*/
|
||||
heap->newspace.base = heap->curspace.limit;
|
||||
heap->newspace.ptr = (moo_uint8_t*)MOO_ALIGN(((moo_uintptr_t)heap->newspace.base), MOO_SIZEOF(moo_oop_t));
|
||||
heap->newspace.limit = heap->newspace.base + half_size;
|
||||
heap->newspace.limit = heap->newspace.base + space_size;
|
||||
|
||||
/* if size is too small, space.ptr may go past space.limit even at
|
||||
* this moment depending on the alignment of space.base. subsequent
|
||||
|
@ -380,6 +380,7 @@ typedef enum moo_gcfin_t moo_gcfin_t;
|
||||
#define MOO_OBJ_FLAGS_UNIT_BITS 5
|
||||
#define MOO_OBJ_FLAGS_EXTRA_BITS 1
|
||||
#define MOO_OBJ_FLAGS_KERNEL_BITS 2
|
||||
#define MOO_OBJ_FLAGS_PERM_BITS 1
|
||||
#define MOO_OBJ_FLAGS_MOVED_BITS 1
|
||||
#define MOO_OBJ_FLAGS_NGC_BITS 1
|
||||
#define MOO_OBJ_FLAGS_RDONLY_BITS 1
|
||||
@ -389,7 +390,8 @@ typedef enum moo_gcfin_t moo_gcfin_t;
|
||||
#define MOO_OBJ_FLAGS_TYPE_SHIFT (MOO_OBJ_FLAGS_UNIT_BITS + MOO_OBJ_FLAGS_UNIT_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_UNIT_SHIFT (MOO_OBJ_FLAGS_EXTRA_BITS + MOO_OBJ_FLAGS_EXTRA_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_EXTRA_SHIFT (MOO_OBJ_FLAGS_KERNEL_BITS + MOO_OBJ_FLAGS_KERNEL_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_KERNEL_SHIFT (MOO_OBJ_FLAGS_MOVED_BITS + MOO_OBJ_FLAGS_MOVED_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_KERNEL_SHIFT (MOO_OBJ_FLAGS_PERM_BITS + MOO_OBJ_FLAGS_PERM_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_PERM_SHIFT (MOO_OBJ_FLAGS_MOVED_BITS + MOO_OBJ_FLAGS_MOVED_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_MOVED_SHIFT (MOO_OBJ_FLAGS_NGC_BITS + MOO_OBJ_FLAGS_NGC_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_NGC_SHIFT (MOO_OBJ_FLAGS_RDONLY_BITS + MOO_OBJ_FLAGS_RDONLY_SHIFT)
|
||||
#define MOO_OBJ_FLAGS_RDONLY_SHIFT (MOO_OBJ_FLAGS_GCFIN_BITS + MOO_OBJ_FLAGS_GCFIN_SHIFT)
|
||||
@ -400,6 +402,7 @@ typedef enum moo_gcfin_t moo_gcfin_t;
|
||||
#define MOO_OBJ_GET_FLAGS_UNIT(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_UNIT_SHIFT, MOO_OBJ_FLAGS_UNIT_BITS)
|
||||
#define MOO_OBJ_GET_FLAGS_EXTRA(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_EXTRA_SHIFT, MOO_OBJ_FLAGS_EXTRA_BITS)
|
||||
#define MOO_OBJ_GET_FLAGS_KERNEL(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_KERNEL_SHIFT, MOO_OBJ_FLAGS_KERNEL_BITS)
|
||||
#define MOO_OBJ_GET_FLAGS_PERM(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_PERM_SHIFT, MOO_OBJ_FLAGS_PERM_BITS)
|
||||
#define MOO_OBJ_GET_FLAGS_MOVED(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_MOVED_SHIFT, MOO_OBJ_FLAGS_MOVED_BITS)
|
||||
#define MOO_OBJ_GET_FLAGS_NGC(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_NGC_SHIFT, MOO_OBJ_FLAGS_NGC_BITS)
|
||||
#define MOO_OBJ_GET_FLAGS_RDONLY(oop) MOO_GETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_RDONLY_SHIFT, MOO_OBJ_FLAGS_RDONLY_BITS)
|
||||
@ -410,6 +413,7 @@ typedef enum moo_gcfin_t moo_gcfin_t;
|
||||
#define MOO_OBJ_SET_FLAGS_UNIT(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_UNIT_SHIFT, MOO_OBJ_FLAGS_UNIT_BITS, v)
|
||||
#define MOO_OBJ_SET_FLAGS_EXTRA(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_EXTRA_SHIFT, MOO_OBJ_FLAGS_EXTRA_BITS, v)
|
||||
#define MOO_OBJ_SET_FLAGS_KERNEL(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_KERNEL_SHIFT, MOO_OBJ_FLAGS_KERNEL_BITS, v)
|
||||
#define MOO_OBJ_SET_FLAGS_PERM(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_PERM_SHIFT, MOO_OBJ_FLAGS_PERM_BITS, v)
|
||||
#define MOO_OBJ_SET_FLAGS_MOVED(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_MOVED_SHIFT, MOO_OBJ_FLAGS_MOVED_BITS, v)
|
||||
#define MOO_OBJ_SET_FLAGS_NGC(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_NGC_SHIFT, MOO_OBJ_FLAGS_NGC_BITS, v)
|
||||
#define MOO_OBJ_SET_FLAGS_RDONLY(oop,v) MOO_SETBITS(moo_oow_t, (oop)->_flags, MOO_OBJ_FLAGS_RDONLY_SHIFT, MOO_OBJ_FLAGS_RDONLY_BITS, v)
|
||||
|
Loading…
Reference in New Issue
Block a user