# New Ticket Created by Matt Fowles # Please include the string: [perl #24841] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=24841 >
All~ This patch just changes a long if-else-if chain into a switch statement for easier reading. Also running `run-indent.pl src/dod.c` cause the diff of dod.c to be very large. I trimmed it down by hand to just the appropriate part, but this should probably be updated. Matt
Index: src/dod.c =================================================================== RCS file: /cvs/public/parrot/src/dod.c,v retrieving revision 1.78 diff -u -r1.78 dod.c --- src/dod.c 2 Jan 2004 14:09:38 -0000 1.78 +++ src/dod.c 7 Jan 2004 23:36:27 -0000 @@ -194,71 +194,71 @@ /* Find important stuff on the system stack */ #if TRACE_SYSTEM_AREAS if (trace_stack) - trace_system_areas(interpreter); + trace_system_areas(interpreter); #endif /* Okay, we've marked the whole root set, and should have a good-sized * list 'o things to look at. Run through it */ trace_children(interpreter, current); } -static void + static void trace_children(struct Parrot_Interp *interpreter, PMC *current) { PMC *prev = NULL; unsigned i = 0; UINTVAL mask = PObj_is_PMC_ptr_FLAG | PObj_is_buffer_ptr_FLAG - | PObj_custom_mark_FLAG; + | PObj_custom_mark_FLAG; for (; current != prev; current = current->next_for_GC) { - UINTVAL bits = PObj_get_FLAGS(current) & mask; - - /* mark properties */ - if (current->metadata) { - pobject_lives(interpreter, (PObj *)current->metadata); - } - /* Start by checking if there's anything at all. This assumes that the - * largest percentage of PMCs won't have anything in their data - * pointer that we need to trace */ - if (bits) { - if (bits == PObj_is_PMC_ptr_FLAG) { - if (PMC_data(current)) { - pobject_lives(interpreter, PMC_data(current)); - } - } - else if (bits == PObj_is_buffer_ptr_FLAG) { - if (PMC_data(current)) { - pobject_lives(interpreter, PMC_data(current)); - } - } - else if (bits == PObj_is_buffer_of_PMCs_ptr_FLAG) { - /* buffer of PMCs */ - Buffer *trace_buf = PMC_data(current); - - if (trace_buf) { - PMC **cur_pmc = trace_buf->bufstart; - - /* Mark the damn buffer as used! */ - pobject_lives(interpreter, trace_buf); - for (i = 0; i < trace_buf->buflen / sizeof(*cur_pmc); i++) { - if (cur_pmc[i]) { - pobject_lives(interpreter, (PObj *)cur_pmc[i]); - } - } - } - } - else { - /* All that's left is the custom */ - VTABLE_mark(interpreter, current); - } - } + /* mark properties */ + if (current->metadata) { + pobject_lives(interpreter, (PObj *)current->metadata); + } + + /* check if we need to trace from the data pointer */ + switch(PObj_get_FLAGS(current) & mask) + { + case(0): + /* nothing in the data pointer to trace */ + break; + case(PObj_is_PMC_ptr_FLAG): + case(PObj_is_buffer_ptr_FLAG): + if (PMC_data(current)) { + pobject_lives(interpreter, PMC_data(current)); + } + break; + + case(PObj_is_buffer_of_PMCs_ptr_FLAG): + { + /* buffer of PMCs */ + Buffer *trace_buf = PMC_data(current); + + if (trace_buf) { + PMC **cur_pmc = trace_buf->bufstart; + + /* Mark the damn buffer as used! */ + pobject_lives(interpreter, trace_buf); + for (i = 0; i < trace_buf->buflen / sizeof(*cur_pmc); i++) { + if (cur_pmc[i]) { + pobject_lives(interpreter, (PObj *)cur_pmc[i]); + } + } + } + } + break; + default: + /* All that's left is the custom */ + VTABLE_mark(interpreter, current); + break; + } - prev = current; + prev = current; } } /* Scan any buffers in S registers and other non-PMC places and mark * them as active */ -static void + static void trace_active_buffers(struct Parrot_Interp *interpreter) { UINTVAL i, j;