I'll paste a diff -ub below to show the changes without the reindentation noise.
I am about to commit a patch that: - Fixes a bit test bug, changing to bits == (bitA | bitB) from bits == (bitA & bitB)) - Count of elements in an array of PMCs was wrong. It was looping over PMC*'s 0..Buffer->buflen-1, but buflen is a byte size, not an element count. - Also reformatted some else { if (...) { to be else if (...) { because it confused me and caused needless line wrapping. But mostly I just like it better this way, dammit! I suspect we need better ways of testing DOD than just doing lots of collections. There are two types of errors: (1) not collecting dead objects, and (2) collecting live objects. For (1), maybe we should add an opcode: get_number_of_live_objects? Then you could write a test case that records the number of live objects, does stuff, forces a sweep and collect, and checks that the saved number + #expected live objects is equal to the currently live number? For (2), a compile option that scribbles 010101010101... all over collected objects? It's not perfect, but it would make it quite a bit less likely for mistakes to slip by. diff -u -b -r1.47 resources.c --- resources.c 25 Apr 2002 21:35:14 -0000 1.47 +++ resources.c 27 Apr 2002 19:11:48 -0000 @@ -360,7 +360,7 @@ } } -static PMC * +PMC * mark_used(PMC *used_pmc, PMC *current_end_of_list) { @@ -452,21 +452,19 @@ if (bits == PMC_is_PMC_ptr_FLAG) { last = mark_used(current->data, last); } - else { - if (bits == PMC_is_buffer_ptr_FLAG) { + else if (bits == PMC_is_buffer_ptr_FLAG) { if (current->data) { buffer_lives(current->data); } } - else { - if (bits == (PMC_is_buffer_ptr_FLAG & - PMC_is_PMC_ptr_FLAG)) { + else if (bits == (PMC_is_buffer_ptr_FLAG | PMC_is_PMC_ptr_FLAG)) + { /* buffer of PMCs */ Buffer *trace_buf = current->data; PMC **cur_pmc = trace_buf->bufstart; /* Mark the damn buffer as used! */ trace_buf->flags |= BUFFER_live_FLAG; - for (i = 0; i < trace_buf->buflen; i++) { + for (i = 0; i < trace_buf->buflen / sizeof(*cur_pmc); i++) { if (cur_pmc[i]) { last = mark_used(cur_pmc[i], last); } @@ -474,12 +472,10 @@ } else { /* All that's left is the custom */ - last = current->vtable->mark(interpreter, - current, last); - } - } + last = current->vtable->mark(interpreter, current, last); } } + prev = current; } }