move regs field from pic_state to pic_heap
This commit is contained in:
parent
eec7d1754b
commit
1a71f3f578
|
@ -41,6 +41,7 @@ union object {
|
||||||
struct pic_heap {
|
struct pic_heap {
|
||||||
union header base, *freep;
|
union header base, *freep;
|
||||||
struct heap_page *pages;
|
struct heap_page *pages;
|
||||||
|
struct pic_reg *regs; /* weak map chain */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pic_heap *
|
struct pic_heap *
|
||||||
|
@ -56,6 +57,8 @@ pic_heap_open(pic_state *pic)
|
||||||
heap->freep = &heap->base;
|
heap->freep = &heap->base;
|
||||||
heap->pages = NULL;
|
heap->pages = NULL;
|
||||||
|
|
||||||
|
heap->regs = NULL;
|
||||||
|
|
||||||
return heap;
|
return heap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,8 +403,8 @@ gc_mark_object(pic_state *pic, union object *obj)
|
||||||
case PIC_TT_REG: {
|
case PIC_TT_REG: {
|
||||||
struct pic_reg *reg = (struct pic_reg *)obj;
|
struct pic_reg *reg = (struct pic_reg *)obj;
|
||||||
|
|
||||||
reg->prev = pic->regs;
|
reg->prev = pic->heap->regs;
|
||||||
pic->regs = reg;
|
pic->heap->regs = reg;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PIC_TT_CP: {
|
case PIC_TT_CP: {
|
||||||
|
@ -439,7 +442,7 @@ gc_mark_phase(pic_state *pic)
|
||||||
struct pic_proc **xhandler;
|
struct pic_proc **xhandler;
|
||||||
size_t j;
|
size_t j;
|
||||||
|
|
||||||
assert(pic->regs == NULL);
|
assert(pic->heap->regs == NULL);
|
||||||
|
|
||||||
/* checkpoint */
|
/* checkpoint */
|
||||||
if (pic->cp) {
|
if (pic->cp) {
|
||||||
|
@ -519,7 +522,7 @@ gc_mark_phase(pic_state *pic)
|
||||||
struct pic_reg *reg;
|
struct pic_reg *reg;
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
reg = pic->regs;
|
reg = pic->heap->regs;
|
||||||
|
|
||||||
while (reg != NULL) {
|
while (reg != NULL) {
|
||||||
h = ®->hash;
|
h = ®->hash;
|
||||||
|
@ -664,8 +667,8 @@ gc_sweep_phase(pic_state *pic)
|
||||||
size_t total = 0, inuse = 0;
|
size_t total = 0, inuse = 0;
|
||||||
|
|
||||||
/* registries */
|
/* registries */
|
||||||
while (pic->regs != NULL) {
|
while (pic->heap->regs != NULL) {
|
||||||
h = &pic->regs->hash;
|
h = &pic->heap->regs->hash;
|
||||||
for (it = kh_begin(h); it != kh_end(h); ++it) {
|
for (it = kh_begin(h); it != kh_end(h); ++it) {
|
||||||
if (! kh_exist(h, it))
|
if (! kh_exist(h, it))
|
||||||
continue;
|
continue;
|
||||||
|
@ -674,7 +677,7 @@ gc_sweep_phase(pic_state *pic)
|
||||||
kh_del(reg, h, it);
|
kh_del(reg, h, it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pic->regs = pic->regs->prev;
|
pic->heap->regs = pic->heap->regs->prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* symbol table */
|
/* symbol table */
|
||||||
|
|
|
@ -131,7 +131,6 @@ struct pic_state {
|
||||||
struct pic_heap *heap;
|
struct pic_heap *heap;
|
||||||
struct pic_object **arena;
|
struct pic_object **arena;
|
||||||
size_t arena_size, arena_idx;
|
size_t arena_size, arena_idx;
|
||||||
struct pic_reg *regs;
|
|
||||||
|
|
||||||
pic_value err;
|
pic_value err;
|
||||||
|
|
||||||
|
|
|
@ -300,9 +300,6 @@ pic_open(pic_allocf allocf, void *userdata)
|
||||||
/* memory heap */
|
/* memory heap */
|
||||||
pic->heap = pic_heap_open(pic);
|
pic->heap = pic_heap_open(pic);
|
||||||
|
|
||||||
/* registries */
|
|
||||||
pic->regs = NULL;
|
|
||||||
|
|
||||||
/* symbol table */
|
/* symbol table */
|
||||||
kh_init(s, &pic->syms);
|
kh_init(s, &pic->syms);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue