From d7d87bae1aa90cbec5214110c0eb3bcfdd835ca9 Mon Sep 17 00:00:00 2001 From: Douglas Katzman Date: Wed, 12 Apr 2017 12:56:08 -0400 Subject: [PATCH] Accept generalized "stop" flag from callback in walk_generation() --- src/runtime/gencgc-internal.h | 4 ++-- src/runtime/gencgc.c | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/runtime/gencgc-internal.h b/src/runtime/gencgc-internal.h index f266acb15..0cf8e3afd 100644 --- a/src/runtime/gencgc-internal.h +++ b/src/runtime/gencgc-internal.h @@ -267,6 +267,6 @@ extern boolean gencgc_partial_pickup; #endif -extern void -walk_generation(void (*proc)(lispobj*,lispobj*), +extern uword_t +walk_generation(uword_t (*proc)(lispobj*,lispobj*), generation_index_t generation); diff --git a/src/runtime/gencgc.c b/src/runtime/gencgc.c index 5ebe4d84c..797659108 100644 --- a/src/runtime/gencgc.c +++ b/src/runtime/gencgc.c @@ -3204,8 +3204,9 @@ verify_range(lispobj *start, size_t words) start += count; } } -static void verify_space(lispobj *start, lispobj *end) { +static uword_t verify_space(lispobj *start, lispobj *end) { verify_range(start, end-start); + return 0; } static void verify_dynamic_space(); @@ -3243,8 +3244,11 @@ verify_gc(void) verify_dynamic_space(); } -void -walk_generation(void (*proc)(lispobj*,lispobj*), +/* Call 'proc' with pairs of addresses demarcating ranges in the + * specified generation. + * Stop if any invocation returns non-zero, and return that value */ +uword_t +walk_generation(uword_t (*proc)(lispobj*,lispobj*), generation_index_t generation) { page_index_t i; @@ -3270,11 +3274,16 @@ walk_generation(void (*proc)(lispobj*,lispobj*), if (page_ends_contiguous_block_p(last_page, page_table[i].gen)) break; - proc(page_address(i), (lispobj*)((char*)page_address(last_page) + - page_bytes_used(last_page))); + uword_t result = + proc(page_address(i), + (lispobj*)(page_bytes_used(last_page) + + (char*)page_address(last_page))); + if (result) return result; + i = last_page; } } + return 0; } static void verify_generation(generation_index_t generation) { -- 2.11.4.GIT