shrink union header size
This commit is contained in:
parent
470eaa485d
commit
fae4e28396
|
@ -8,7 +8,6 @@ union header {
|
||||||
struct {
|
struct {
|
||||||
union header *ptr;
|
union header *ptr;
|
||||||
size_t size;
|
size_t size;
|
||||||
char mark;
|
|
||||||
} s;
|
} s;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -262,21 +261,13 @@ static void gc_mark_object(pic_state *, union object *);
|
||||||
static bool
|
static bool
|
||||||
gc_obj_is_marked(struct pic_object *obj)
|
gc_obj_is_marked(struct pic_object *obj)
|
||||||
{
|
{
|
||||||
union header *p;
|
return obj->gc_mark == PIC_GC_MARK;
|
||||||
|
|
||||||
p = ((union header *)obj) - 1;
|
|
||||||
|
|
||||||
return p->s.mark == PIC_GC_MARK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gc_unmark_object(struct pic_object *obj)
|
gc_unmark_object(struct pic_object *obj)
|
||||||
{
|
{
|
||||||
union header *p;
|
obj->gc_mark = PIC_GC_UNMARK;
|
||||||
|
|
||||||
p = ((union header *)obj) - 1;
|
|
||||||
|
|
||||||
p->s.mark = PIC_GC_UNMARK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -291,15 +282,11 @@ gc_mark(pic_state *pic, pic_value v)
|
||||||
static void
|
static void
|
||||||
gc_mark_object(pic_state *pic, union object *obj)
|
gc_mark_object(pic_state *pic, union object *obj)
|
||||||
{
|
{
|
||||||
union header *p;
|
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
|
|
||||||
p = ((union header *)obj) - 1;
|
if (obj->obj.gc_mark == PIC_GC_MARK)
|
||||||
|
|
||||||
if (p->s.mark == PIC_GC_MARK)
|
|
||||||
return;
|
return;
|
||||||
p->s.mark = PIC_GC_MARK;
|
obj->obj.gc_mark = PIC_GC_MARK;
|
||||||
|
|
||||||
#define LOOP(o) obj = (union object *)(o); goto loop
|
#define LOOP(o) obj = (union object *)(o); goto loop
|
||||||
|
|
||||||
|
@ -638,6 +625,7 @@ static size_t
|
||||||
gc_sweep_page(pic_state *pic, struct heap_page *page)
|
gc_sweep_page(pic_state *pic, struct heap_page *page)
|
||||||
{
|
{
|
||||||
union header *bp, *p, *head = NULL, *tail = NULL;
|
union header *bp, *p, *head = NULL, *tail = NULL;
|
||||||
|
union object *obj;
|
||||||
size_t alive = 0;
|
size_t alive = 0;
|
||||||
|
|
||||||
for (bp = page->basep; ; bp = bp->s.ptr) {
|
for (bp = page->basep; ; bp = bp->s.ptr) {
|
||||||
|
@ -646,8 +634,9 @@ gc_sweep_page(pic_state *pic, struct heap_page *page)
|
||||||
if (p < page->basep || page->endp <= p) {
|
if (p < page->basep || page->endp <= p) {
|
||||||
goto escape;
|
goto escape;
|
||||||
}
|
}
|
||||||
if (p->s.mark == PIC_GC_MARK) {
|
obj = (union object *)(p + 1);
|
||||||
p->s.mark = PIC_GC_UNMARK;
|
if (obj->obj.gc_mark == PIC_GC_MARK) {
|
||||||
|
obj->obj.gc_mark = PIC_GC_UNMARK;
|
||||||
alive += p->s.size;
|
alive += p->s.size;
|
||||||
} else {
|
} else {
|
||||||
if (head == NULL) {
|
if (head == NULL) {
|
||||||
|
|
|
@ -162,7 +162,8 @@ enum pic_tt {
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PIC_OBJECT_HEADER \
|
#define PIC_OBJECT_HEADER \
|
||||||
enum pic_tt tt;
|
enum pic_tt tt; \
|
||||||
|
char gc_mark;
|
||||||
|
|
||||||
struct pic_object {
|
struct pic_object {
|
||||||
PIC_OBJECT_HEADER
|
PIC_OBJECT_HEADER
|
||||||
|
|
Loading…
Reference in New Issue