summaryrefslogtreecommitdiff
path: root/reclaim.c
diff options
context:
space:
mode:
authorivmai <ivmai>2011-04-18 23:14:54 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:57 +0200
commit1178f485b6757985b906b7821cb458cba826f696 (patch)
tree6d22c5e9bcd1ce98c6f17f5aa352a87579096cfa /reclaim.c
parent5525068dbc6e9707f5bc703825bf1cfb76eeeb5f (diff)
2011-04-18 Ivan Maidanski <ivmai@mail.ru>
* dbg_mlc.c (GC_store_debug_info_inner): Always define; add "const" to its string argument. * dbg_mlc.c (GC_store_debug_info): Call GC_store_debug_info_inner. * dbg_mlc.c (GC_debug_free): Set GC_have_errors in case of smashed or previously deallocated found. * dbg_mlc.c (GC_check_heap_block): Replace while loop with a for one. * reclaim.c (GC_reclaim_check): Ditto. * dbg_mlc.c (GC_check_heap_proc): Remove redundant cast to word. * os_dep.c (GC_get_stack_base): Don't initialize stackbase_main_self/ss_sp on Solaris if thr_main() is zero (thus calling GC_INIT() from a non-primordial thread is possible now). * reclaim.c (GC_add_leaked): Turn into an inline one. * reclaim.c (GC_reclaim_small_nonempty_block): Change report_if_found type from int/word to boolean. * include/private/gc_priv.h (GC_start_reclaim): Ditto. * include/private/gc_priv.h (set_mark_bit_from_hdr, clear_mark_bit_from_hdr): Place closing parenthesis properly; reformat the code.
Diffstat (limited to 'reclaim.c')
-rw-r--r--reclaim.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/reclaim.c b/reclaim.c
index efade9b..6a204f7 100644
--- a/reclaim.c
+++ b/reclaim.c
@@ -41,7 +41,7 @@ STATIC unsigned GC_n_leaked = 0;
GC_INNER GC_bool GC_have_errors = FALSE;
-STATIC void GC_add_leaked(ptr_t leaked)
+GC_INLINE void GC_add_leaked(ptr_t leaked)
{
GC_have_errors = TRUE;
/* FIXME: Prevent adding an object while printing leaked ones. */
@@ -204,24 +204,20 @@ STATIC ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
/* Don't really reclaim objects, just check for unmarked ones: */
STATIC void GC_reclaim_check(struct hblk *hbp, hdr *hhdr, word sz)
{
- word bit_no = 0;
+ word bit_no;
ptr_t p, plim;
-
GC_ASSERT(sz == hhdr -> hb_sz);
- p = hbp->hb_body;
- plim = p + HBLKSIZE - sz;
/* go through all words in block */
- while (p <= plim) {
- if( !mark_bit_from_hdr(hhdr, bit_no) ) {
- GC_add_leaked(p);
- }
- p += sz;
- bit_no += MARK_BIT_OFFSET(sz);
- }
+ p = hbp->hb_body;
+ plim = p + HBLKSIZE - sz;
+ for (bit_no = 0; p <= plim; p += sz, bit_no += MARK_BIT_OFFSET(sz)) {
+ if (!mark_bit_from_hdr(hhdr, bit_no)) {
+ GC_add_leaked(p);
+ }
+ }
}
-
/*
* Generic procedure to rebuild a free list in hbp.
* Also called directly from GC_malloc_many.
@@ -254,7 +250,7 @@ GC_INNER ptr_t GC_reclaim_generic(struct hblk * hbp, hdr *hhdr, size_t sz,
* caller should perform that check.
*/
STATIC void GC_reclaim_small_nonempty_block(struct hblk *hbp,
- int report_if_found)
+ GC_bool report_if_found)
{
hdr *hhdr = HDR(hbp);
size_t sz = hhdr -> hb_sz;
@@ -326,7 +322,7 @@ STATIC void GC_reclaim_block(struct hblk *hbp, word report_if_found)
GC_atomic_in_use += sz * hhdr -> hb_n_marks;
}
if (report_if_found) {
- GC_reclaim_small_nonempty_block(hbp, (int)report_if_found);
+ GC_reclaim_small_nonempty_block(hbp, (GC_bool)report_if_found);
} else if (empty) {
GC_bytes_found += HBLKSIZE;
GC_freehblk(hbp);