From 9effe671fd4baacd924b58a25dac89587d38eb27 Mon Sep 17 00:00:00 2001 From: Paul Khuong Date: Sat, 2 Jul 2011 21:52:50 -0400 Subject: [PATCH] Lazier zero_dirty_pages in gencgc Upon allocation, only zero out pages that haven't already been cleared. --- src/runtime/gencgc-internal.h | 2 +- src/runtime/gencgc.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/runtime/gencgc-internal.h b/src/runtime/gencgc-internal.h index cdaa456..84178ad 100644 --- a/src/runtime/gencgc-internal.h +++ b/src/runtime/gencgc-internal.h @@ -82,7 +82,7 @@ struct page { * set. No other objects should be allocated to these pages. * This is only valid when the page is allocated. */ large_object :1, - /* True if the page is known to contain only zeroes. */ + /* Cleared if the page is known to contain only zeroes. */ need_to_zero :1; /* the generation that this page belongs to. This should be valid diff --git a/src/runtime/gencgc.c b/src/runtime/gencgc.c index 1ea30b4..be5cc4b 100644 --- a/src/runtime/gencgc.c +++ b/src/runtime/gencgc.c @@ -627,13 +627,13 @@ zero_pages(page_index_t start, page_index_t end) { */ static void zero_dirty_pages(page_index_t start, page_index_t end) { - page_index_t i; + page_index_t i, j; for (i = start; i <= end; i++) { - if (page_table[i].need_to_zero == 1) { - zero_pages(start, end); - break; - } + if (!page_table[i].need_to_zero) continue; + for (j = i+1; (j <= end) && (page_table[j].need_to_zero); j++); + zero_pages(i, j-1); + i = j; } for (i = start; i <= end; i++) { -- 1.7.10.4