save a few instructions on mark-stack operations
svn: r12716
This commit is contained in:
parent
bf8816007a
commit
014bd392da
|
@ -1244,35 +1244,37 @@ typedef struct MarkSegment {
|
|||
struct MarkSegment *prev;
|
||||
struct MarkSegment *next;
|
||||
void **top;
|
||||
void **end;
|
||||
void *stop_here; /* this is only used for its address */
|
||||
} MarkSegment;
|
||||
|
||||
#define MARK_STACK_START(ms) ((void **)(void *)&ms[1])
|
||||
#define MARK_STACK_END(ms) ((void **)((char *)ms + STACK_PART_SIZE))
|
||||
|
||||
static THREAD_LOCAL MarkSegment *mark_stack = NULL;
|
||||
|
||||
inline static MarkSegment* mark_stack_create_frame() {
|
||||
MarkSegment *mark_frame = (MarkSegment*)ofm_malloc(STACK_PART_SIZE);
|
||||
mark_frame->next = NULL;
|
||||
mark_frame->top = &(mark_frame->stop_here);
|
||||
mark_frame->end = PPTR(NUM(mark_frame) + STACK_PART_SIZE);
|
||||
mark_frame->top = MARK_STACK_START(mark_frame);
|
||||
return mark_frame;
|
||||
}
|
||||
|
||||
inline static void push_ptr(void *ptr)
|
||||
inline static void init_mark_stack()
|
||||
{
|
||||
/* This happens at the very beginning */
|
||||
if(!mark_stack) {
|
||||
mark_stack = mark_stack_create_frame();
|
||||
mark_stack->prev = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
inline static void push_ptr(void *ptr)
|
||||
{
|
||||
/* This happens during propoagation if we go past the end of this MarkSegment*/
|
||||
if(mark_stack->top == mark_stack->end) {
|
||||
if(mark_stack->top == MARK_STACK_END(mark_stack)) {
|
||||
/* test to see if we already have another stack page ready */
|
||||
if(mark_stack->next) {
|
||||
/* we do, so just use it */
|
||||
mark_stack = mark_stack->next;
|
||||
mark_stack->top = &(mark_stack->stop_here);
|
||||
mark_stack->top = MARK_STACK_START(mark_stack);
|
||||
} else {
|
||||
/* we don't, so we need to allocate one */
|
||||
mark_stack->next = mark_stack_create_frame();
|
||||
|
@ -1287,7 +1289,7 @@ inline static void push_ptr(void *ptr)
|
|||
|
||||
inline static int pop_ptr(void **ptr)
|
||||
{
|
||||
if(mark_stack->top == &mark_stack->stop_here) {
|
||||
if(mark_stack->top == MARK_STACK_START(mark_stack)) {
|
||||
if(mark_stack->prev) {
|
||||
/* if there is a previous page, go to it */
|
||||
mark_stack = mark_stack->prev;
|
||||
|
@ -1323,7 +1325,7 @@ inline static void clear_stack_pages(void)
|
|||
free(mark_stack);
|
||||
}
|
||||
mark_stack = base;
|
||||
mark_stack->top = PPTR(mark_stack) + 4;
|
||||
mark_stack->top = MARK_STACK_START(mark_stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1332,7 +1334,7 @@ inline static void reset_pointer_stack(void)
|
|||
/* go to the head of the list */
|
||||
for(; mark_stack->prev; mark_stack = mark_stack->prev) {}
|
||||
/* reset the stack */
|
||||
mark_stack->top = PPTR(mark_stack) + 4;
|
||||
mark_stack->top = MARK_STACK_START(mark_stack);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1424,6 +1426,8 @@ void NewGC_initialize(NewGC *newgc) {
|
|||
newgc->generations_available = 1;
|
||||
newgc->last_full_mem_use = (20 * 1024 * 1024);
|
||||
newgc->new_btc_mark = 1;
|
||||
|
||||
init_mark_stack();
|
||||
}
|
||||
|
||||
void GC_init_type_tags(int count, int pair, int mutable_pair, int weakbox, int ephemeron, int weakarray, int custbox)
|
||||
|
@ -1655,11 +1659,11 @@ void GC_mark(const void *const_p)
|
|||
work->has_new = 1;
|
||||
|
||||
/* transfer the object */
|
||||
ohead->mark = 1; /* mark is copied to newplace, too */
|
||||
memcpy(newplace, (const void *)ohead, size);
|
||||
/* mark the old location as marked and moved, and the new location
|
||||
as marked */
|
||||
ohead->mark = ohead->moved = 1;
|
||||
((struct objhead *)newplace)->mark = 1;
|
||||
ohead->moved = 1;
|
||||
/* if we're doing memory accounting, then we need the btc_mark
|
||||
to be set properly */
|
||||
#ifdef NEWGC_BTC_ACCOUNT
|
||||
|
|
Loading…
Reference in New Issue
Block a user