# New Ticket Created by Leopold Toetsch # Please include the string: [perl #19332] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=19332 >
I'll send this first to the list for review. This patch changes mark_used(PMC *) so that the PMC field next_for_GC isn't used anymore (it could be removed now, making a PMC one ptr size smaller). This would allow finally to use one common mark function: void pobject_lives(PObj* obj) which is the same as buffer_lives() now looks like (modulo the interpreter used for GC_DEBUG). A short test (5E6 new P0, .PerlUndef) in a loop shows ~1% speed increase due to one less instruction in headers.c:get_free_pmc(). Comments welcome, leo -- attachment 1 ------------------------------------------------------ url: http://rt.perl.org/rt2/attach/46018/36002/ea1b6f/mark.patch
--- parrot/dod.c Thu Dec 12 09:07:25 2002 +++ parrot-leo/dod.c Sat Dec 21 16:28:57 2002 @@ -23,6 +23,7 @@ extern void flush_register_windows(void); static size_t find_common_mask(size_t val1, size_t val2); +#ifdef MARK_USE_NEXT_FOR_GC PMC * mark_used(PMC *used_pmc, PMC *current_end_of_list) { @@ -49,6 +50,24 @@ return used_pmc; } +#else + +static PMC ** mark_list, ** mark_ptr; + +PMC * +mark_used(PMC *used_pmc, PMC *current_end_of_list) +{ + if (PObj_is_live_or_free_TESTALL(used_pmc)) { + return current_end_of_list; + } + PObj_live_SET(used_pmc); + *mark_ptr++ = used_pmc; + *mark_ptr = NULL; + return *mark_ptr; +} + +#endif + #if DISABLE_GC_DEBUG void buffer_lives(struct Parrot_Interp *interpreter, Buffer *buffer) @@ -120,6 +139,12 @@ /* We have to start somewhere, and the global stash is a good place */ last = current = interpreter->perl_stash->stash_hash; +#ifndef MARK_USE_NEXT_FOR_GC + mark_list = realloc(mark_list, + (interpreter->arena_base->pmc_pool->total_objects + 1) * + sizeof(PMC *)); + mark_ptr = mark_list; +#endif /* mark it as used and get an updated end of list */ last = mark_used(current, last); /* Parrot_base_classname_hash */ @@ -218,7 +243,11 @@ /* Okay, we've marked the whole root set, and should have a good-sized * list 'o things to look at. Run through it */ prev = NULL; +#ifdef MARK_USE_NEXT_FOR_GC for (; current != prev; current = current->next_for_GC) { +#else + for (j = 0, current = mark_list[0]; current; current = mark_list[++j]) { +#endif UINTVAL bits = PObj_get_FLAGS(current) & mask; /* mark properties */ --- parrot/headers.c Sat Dec 21 11:08:06 2002 +++ parrot-leo/headers.c Sat Dec 21 16:29:50 2002 @@ -60,8 +60,10 @@ pool->free_list = *(void **)pmc; PObj_flags_SETTO(pmc, 0); +#ifdef MARK_USE_NEXT_FOR_GC /* Make sure it doesn't seem to be on the GC list */ pmc->next_for_GC = NULL; +#endif return pmc; }