From c2dddb53a10205f986ae782e5b1e7105f0ea80c5 Mon Sep 17 00:00:00 2001 From: ivmai Date: Sun, 20 Mar 2011 09:08:55 +0000 Subject: 2011-03-20 Ivan Maidanski * alloc.c (GC_finish_collection): Remove redundant brackets; adjust code indentation. * blacklst.c (GC_add_to_black_list_normal): Simplify expression (to improve code readability). * blacklst.c (GC_is_black_listed): Join nested "if" (into a single conditional expression); initialize "nblocks" just before the loop beginning. * misc.c (GC_init): Don't compute initial_heap_sz if GC is already initialized. * include/private/gc_priv.h (GC_initialize_offsets): Move the function declaration to misc.c file. * obj_map.c (GC_initialize_offsets): Remove offsets_initialized static variable since the function is called only once. * tests/middle.c: Include "gc.h" instead of ; expand all tabs to spaces; adjust code indentation; replace the K&R-style function definition with the ANSI C one. * tests/smash_test.c: Ditto. * tests/middle.c (main): Use setter for GC_all_interior_pointers; adjust printf format specifier (and cast the value passed to). --- blacklst.c | 71 ++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 34 insertions(+), 37 deletions(-) (limited to 'blacklst.c') diff --git a/blacklst.c b/blacklst.c index 25ebea8e..1fb9d00c 100644 --- a/blacklst.c +++ b/blacklst.c @@ -172,24 +172,22 @@ GC_INNER void GC_unpromote_black_lists(void) GC_INNER void GC_add_to_black_list_normal(word p) #endif { - if (!(GC_modws_valid_offsets[p & (sizeof(word)-1)])) return; - { - word index = PHT_HASH((word)p); + if (GC_modws_valid_offsets[p & (sizeof(word)-1)]) { + word index = PHT_HASH((word)p); - if (HDR(p) == 0 || get_pht_entry_from_index(GC_old_normal_bl, index)) { -# ifdef PRINT_BLACK_LIST - if (!get_pht_entry_from_index(GC_incomplete_normal_bl, index)) { - GC_err_printf( - "Black listing (normal) %p referenced from %p ", - (ptr_t) p, source); - GC_print_source_ptr(source); - GC_err_puts("\n"); - } -# endif - set_pht_entry_from_index(GC_incomplete_normal_bl, index); - } /* else this is probably just an interior pointer to an allocated */ - /* object, and isn't worth black listing. */ - } + if (HDR(p) == 0 || get_pht_entry_from_index(GC_old_normal_bl, index)) { +# ifdef PRINT_BLACK_LIST + if (!get_pht_entry_from_index(GC_incomplete_normal_bl, index)) { + GC_err_printf("Black listing (normal) %p referenced from %p ", + (ptr_t)p, source); + GC_print_source_ptr(source); + GC_err_puts("\n"); + } +# endif + set_pht_entry_from_index(GC_incomplete_normal_bl, index); + } /* else this is probably just an interior pointer to an allocated */ + /* object, and isn't worth black listing. */ + } } /* And the same for false pointers from the stack. */ @@ -199,20 +197,19 @@ GC_INNER void GC_unpromote_black_lists(void) GC_INNER void GC_add_to_black_list_stack(word p) #endif { - word index = PHT_HASH((word)p); + word index = PHT_HASH((word)p); - if (HDR(p) == 0 || get_pht_entry_from_index(GC_old_stack_bl, index)) { -# ifdef PRINT_BLACK_LIST - if (!get_pht_entry_from_index(GC_incomplete_stack_bl, index)) { - GC_err_printf( - "Black listing (stack) %p referenced from %p ", - (ptr_t)p, source); - GC_print_source_ptr(source); - GC_err_puts("\n"); - } -# endif - set_pht_entry_from_index(GC_incomplete_stack_bl, index); - } + if (HDR(p) == 0 || get_pht_entry_from_index(GC_old_stack_bl, index)) { +# ifdef PRINT_BLACK_LIST + if (!get_pht_entry_from_index(GC_incomplete_stack_bl, index)) { + GC_err_printf("Black listing (stack) %p referenced from %p ", + (ptr_t)p, source); + GC_print_source_ptr(source); + GC_err_puts("\n"); + } +# endif + set_pht_entry_from_index(GC_incomplete_stack_bl, index); + } } /* @@ -227,20 +224,20 @@ GC_INNER struct hblk * GC_is_black_listed(struct hblk *h, word len) { word index = PHT_HASH((word)h); word i; - word nblocks = divHBLKSZ(len); + word nblocks; - if (!GC_all_interior_pointers) { - if (get_pht_entry_from_index(GC_old_normal_bl, index) - || get_pht_entry_from_index(GC_incomplete_normal_bl, index)) { - return(h+1); - } + if (!GC_all_interior_pointers + && (get_pht_entry_from_index(GC_old_normal_bl, index) + || get_pht_entry_from_index(GC_incomplete_normal_bl, index))) { + return (h+1); } + nblocks = divHBLKSZ(len); for (i = 0;;) { if (GC_old_stack_bl[divWORDSZ(index)] == 0 && GC_incomplete_stack_bl[divWORDSZ(index)] == 0) { /* An easy case */ - i += WORDSZ - modWORDSZ(index); + i += WORDSZ - modWORDSZ(index); } else { if (get_pht_entry_from_index(GC_old_stack_bl, index) || get_pht_entry_from_index(GC_incomplete_stack_bl, index)) { -- cgit v1.2.1