diff options
author | ivmai <ivmai> | 2009-09-16 14:43:37 +0000 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2011-07-26 21:06:46 +0400 |
commit | db2565100a193fa71336be2951b342ef7596f828 (patch) | |
tree | 4214eb726e4912fa34628655dc41ae247213caf8 /blacklst.c | |
parent | d70b0280af3c3d53e2a794b26aa7a3127943b8c3 (diff) | |
download | bdwgc-db2565100a193fa71336be2951b342ef7596f828.tar.gz |
2009-09-16 Ivan Maidanski <ivmai@mail.ru>
* ChangeLog: Remove trailing spaces at EOLn; insert blank lines
where missed.
* doc/README: Expand all tabs to spaces; remove trailing spaces at
EOLn; remove multiple trailing blank lines.
* doc/README.autoconf: Ditto.
* doc/README.DGUX386: Ditto.
* doc/README.environment: Ditto.
* doc/README.macros: Ditto.
* doc/README.win32: Ditto.
* tests/test.c: Ditto.
* tests/test_cpp.cc: Ditto.
* backgraph.c: Ditto.
* blacklst.c: Ditto.
* checksums.c: Ditto.
* darwin_stop_world.c: Ditto.
* dbg_mlc.c: Ditto.
* dyn_load.c: Ditto.
* finalize.c: Ditto.
* gc_dlopen.c: Ditto.
* gcj_mlc.c: Ditto.
* headers.c: Ditto.
* mach_dep.c: Ditto.
* malloc.c: Ditto.
* mallocx.c: Ditto.
* new_hblk.c: Ditto.
* obj_map.c: Ditto.
* ptr_chck.c: Ditto.
* real_malloc.c: Ditto.
* reclaim.c: Ditto.
* stubborn.c: Ditto.
* thread_local_alloc.c: Ditto.
* typd_mlc.c: Ditto.
* gc_cpp.cc: Ditto.
* include/gc_allocator.h: Ditto.
* include/gc_backptr.h: Ditto.
* include/gc_config_macros.h: Ditto.
* include/gc_cpp.h: Ditto.
* include/gc_gcj.h: Ditto.
* include/gc_inline.h: Ditto.
* include/gc_mark.h: Ditto.
* include/gc_pthread_redirects.h: Ditto.
* include/gc_typed.h: Ditto.
* include/gc_version.h: Ditto.
* include/javaxfc.h: Ditto.
* include/new_gc_alloc.h: Ditto.
* include/private/darwin_semaphore.h: Ditto.
* include/private/dbg_mlc.h: Ditto.
* include/private/gc_hdrs.h: Ditto.
* include/private/gc_locks.h: Ditto.
* include/private/gc_pmark.h: Ditto.
* include/private/gcconfig.h: Ditto.
* include/private/pthread_support.h: Ditto.
* include/private/thread_local_alloc.h: Ditto.
* darwin_stop_world.c: Add copyright header.
* include/gc_backptr.h: Ditto.
* include/gc_config_macros.h: Ditto.
* include/gc_pthread_redirects.h: Ditto.
* include/gc_version.h: Ditto.
* include/javaxfc.h: Ditto.
* include/private/darwin_semaphore.h: Ditto.
* include/private/pthread_support.h: Ditto.
* gc_cpp.cc: Make copyright header uniform across the package.
* include/gc_cpp.h: Ditto.
Diffstat (limited to 'blacklst.c')
-rw-r--r-- | blacklst.c | 143 |
1 files changed, 71 insertions, 72 deletions
@@ -1,4 +1,4 @@ -/* +/* * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. * @@ -23,10 +23,10 @@ * from elsewhere, since the former can pin a large object that spans the * block, eventhough it does not start on the dangerous block. */ - + /* * Externally callable routines are: - + * GC_add_to_black_list_normal * GC_add_to_black_list_stack * GC_promote_black_lists @@ -35,14 +35,14 @@ * All require that the allocator lock is held. */ -/* Pointers to individual tables. We replace one table by another by */ -/* switching these pointers. */ +/* Pointers to individual tables. We replace one table by another by */ +/* switching these pointers. */ STATIC word * GC_old_normal_bl; - /* Nonstack false references seen at last full */ - /* collection. */ + /* Nonstack false references seen at last full */ + /* collection. */ STATIC word * GC_incomplete_normal_bl; - /* Nonstack false references seen since last */ - /* full collection. */ + /* Nonstack false references seen since last */ + /* full collection. */ STATIC word * GC_old_stack_bl; STATIC word * GC_incomplete_stack_bl; @@ -57,7 +57,7 @@ void GC_default_print_heap_obj_proc(ptr_t p) ptr_t base = GC_base(p); GC_err_printf("start: %p, appr. length: %ld", base, - (unsigned long)GC_size(base)); + (unsigned long)GC_size(base)); } void (*GC_print_heap_obj) (ptr_t p) = GC_default_print_heap_obj_proc; @@ -67,17 +67,17 @@ STATIC void GC_print_source_ptr(ptr_t p) { ptr_t base = GC_base(p); if (0 == base) { - if (0 == p) { - GC_err_printf("in register"); - } else { - GC_err_printf("in root set"); - } + if (0 == p) { + GC_err_printf("in register"); + } else { + GC_err_printf("in root set"); + } } else { - GC_err_printf("in object at "); - /* FIXME: We can't call the debug version of GC_print_heap_obj */ - /* (with PRINT_CALL_CHAIN) here because the lock is held and */ - /* the world is stopped. */ - GC_default_print_heap_obj_proc(base); + GC_err_printf("in object at "); + /* FIXME: We can't call the debug version of GC_print_heap_obj */ + /* (with PRINT_CALL_CHAIN) here because the lock is held and */ + /* the world is stopped. */ + GC_default_print_heap_obj_proc(base); } } #endif @@ -86,9 +86,9 @@ void GC_bl_init(void) { if (!GC_all_interior_pointers) { GC_old_normal_bl = (word *) - GC_scratch_alloc((word)(sizeof (page_hash_table))); + GC_scratch_alloc((word)(sizeof (page_hash_table))); GC_incomplete_normal_bl = (word *)GC_scratch_alloc - ((word)(sizeof(page_hash_table))); + ((word)(sizeof(page_hash_table))); if (GC_old_normal_bl == 0 || GC_incomplete_normal_bl == 0) { GC_err_printf("Insufficient memory for black list\n"); EXIT(); @@ -98,7 +98,7 @@ void GC_bl_init(void) } GC_old_stack_bl = (word *)GC_scratch_alloc((word)(sizeof(page_hash_table))); GC_incomplete_stack_bl = (word *)GC_scratch_alloc - ((word)(sizeof(page_hash_table))); + ((word)(sizeof(page_hash_table))); if (GC_old_stack_bl == 0 || GC_incomplete_stack_bl == 0) { GC_err_printf("Insufficient memory for black list\n"); EXIT(); @@ -106,7 +106,7 @@ void GC_bl_init(void) GC_clear_bl(GC_old_stack_bl); GC_clear_bl(GC_incomplete_stack_bl); } - + void GC_clear_bl(word *doomed) { BZERO(doomed, sizeof(page_hash_table)); @@ -119,13 +119,13 @@ void GC_copy_bl(word *old, word *new) static word total_stack_black_listed(void); -/* Signal the completion of a collection. Turn the incomplete black */ -/* lists into new black lists, etc. */ +/* Signal the completion of a collection. Turn the incomplete black */ +/* lists into new black lists, etc. */ void GC_promote_black_lists(void) { word * very_old_normal_bl = GC_old_normal_bl; word * very_old_stack_bl = GC_old_stack_bl; - + GC_old_normal_bl = GC_incomplete_normal_bl; GC_old_stack_bl = GC_incomplete_stack_bl; if (!GC_all_interior_pointers) { @@ -136,21 +136,21 @@ void GC_promote_black_lists(void) GC_incomplete_stack_bl = very_old_stack_bl; GC_total_stack_black_listed = total_stack_black_listed(); if (GC_print_stats == VERBOSE) - GC_log_printf("%ld bytes in heap blacklisted for interior pointers\n", - (unsigned long)GC_total_stack_black_listed); + GC_log_printf("%ld bytes in heap blacklisted for interior pointers\n", + (unsigned long)GC_total_stack_black_listed); if (GC_total_stack_black_listed != 0) { GC_black_list_spacing = - HBLKSIZE*(GC_heapsize/GC_total_stack_black_listed); + HBLKSIZE*(GC_heapsize/GC_total_stack_black_listed); } if (GC_black_list_spacing < 3 * HBLKSIZE) { - GC_black_list_spacing = 3 * HBLKSIZE; + GC_black_list_spacing = 3 * HBLKSIZE; } if (GC_black_list_spacing > MAXHINCR * HBLKSIZE) { - GC_black_list_spacing = MAXHINCR * HBLKSIZE; - /* Makes it easier to allocate really huge blocks, which otherwise */ - /* may have problems with nonuniform blacklist distributions. */ - /* This way we should always succeed immediately after growing the */ - /* heap. */ + GC_black_list_spacing = MAXHINCR * HBLKSIZE; + /* Makes it easier to allocate really huge blocks, which otherwise */ + /* may have problems with nonuniform blacklist distributions. */ + /* This way we should always succeed immediately after growing the */ + /* heap. */ } } @@ -162,9 +162,9 @@ void GC_unpromote_black_lists(void) GC_copy_bl(GC_old_stack_bl, GC_incomplete_stack_bl); } -/* P is not a valid pointer reference, but it falls inside */ -/* the plausible heap bounds. */ -/* Add it to the normal incomplete black list if appropriate. */ +/* P is not a valid pointer reference, but it falls inside */ +/* the plausible heap bounds. */ +/* Add it to the normal incomplete black list if appropriate. */ #ifdef PRINT_BLACK_LIST void GC_add_to_black_list_normal(word p, ptr_t source) #else @@ -174,20 +174,20 @@ void GC_unpromote_black_lists(void) if (!(GC_modws_valid_offsets[p & (sizeof(word)-1)])) return; { 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"); - } +# 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. */ + /* object, and isn't worth black listing. */ } } @@ -199,18 +199,18 @@ void GC_unpromote_black_lists(void) #endif { 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"); - } +# 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); + set_pht_entry_from_index(GC_incomplete_stack_bl, index); } } @@ -234,7 +234,7 @@ struct hblk * GC_is_black_listed(struct hblk *h, word len) return(h+1); } } - + for (i = 0; ; ) { if (GC_old_stack_bl[divWORDSZ(index)] == 0 && GC_incomplete_stack_bl[divWORDSZ(index)] == 0) { @@ -254,17 +254,17 @@ struct hblk * GC_is_black_listed(struct hblk *h, word len) } -/* Return the number of blacklisted blocks in a given range. */ -/* Used only for statistical purposes. */ -/* Looks only at the GC_incomplete_stack_bl. */ +/* Return the number of blacklisted blocks in a given range. */ +/* Used only for statistical purposes. */ +/* Looks only at the GC_incomplete_stack_bl. */ word GC_number_stack_black_listed(struct hblk *start, struct hblk *endp1) { register struct hblk * h; word result = 0; - + for (h = start; h < endp1; h++) { word index = PHT_HASH((word)h); - + if (get_pht_entry_from_index(GC_old_stack_bl, index)) result++; } return(result); @@ -276,14 +276,13 @@ static word total_stack_black_listed(void) { register unsigned i; word total = 0; - + for (i = 0; i < GC_n_heap_sects; i++) { - struct hblk * start = (struct hblk *) GC_heap_sects[i].hs_start; - size_t len = (word) GC_heap_sects[i].hs_bytes; - struct hblk * endp1 = start + len/HBLKSIZE; - - total += GC_number_stack_black_listed(start, endp1); + struct hblk * start = (struct hblk *) GC_heap_sects[i].hs_start; + size_t len = (word) GC_heap_sects[i].hs_bytes; + struct hblk * endp1 = start + len/HBLKSIZE; + + total += GC_number_stack_black_listed(start, endp1); } return(total * HBLKSIZE); } - |