summaryrefslogtreecommitdiff
path: root/reclaim.c
diff options
context:
space:
mode:
authorhboehm <hboehm>2008-07-26 02:51:33 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:43 +0200
commit68b9f2740e77bfae2b94392140608d952114b199 (patch)
tree492d095c29a2cfc5cbbc4a49b41fa1f5b06bc6ff /reclaim.c
parent1867d249698c81214418b2cf9752a987abb7b4f2 (diff)
2008-07-25 Hans Boehm <Hans.Boehm@hp.com> (Really mostly Ivan Maidanski)
Ivan's description of the patch follows. Note that a few pieces like the GC_malloc(0) patch, were not applied since an alternate had been previously applied. A few differed stylistically from the rest of the code (mostly casts to void * instead of target type), or were classified as too minor to bother. Note that all of Ivan's static declarations which did not correct outright naming bugs (as a few did), where replaced by STATIC, which is ignored by default. - minor bug fixing (for FreeBSD, for THREAD_LOCAL_ALLOC and for GC_malloc(0)); - addition of missing getter/setter functions for public variables (may be useful if compiled as Win32 DLL); - addition of missing GC_API for some exported functions; - addition of missing "static" declarator for internal functions and variables (where possible); - replacement of all remaining K&R-style definitions with ANSI C ones (__STDC__ macro is not used anymore); - addition of some Win32 macro definitions (that may be missing in the standard headers supplied with a compiler) for GWW_VDB mode; - elimination of most compiler warnings (except for "uninitialized data" warning); - several typos correction; - missing parenthesis addition in macros in some header files of "libatomic_ops" module. My highlights based on reading the patch: * allchblk.c: Remove GC_freehblk_ptr decl. Make free_list_index_of() static. * include/gc.h: Use __int64 on win64, define GC_oom_func, GC_finalizer_notifier_proc, GC_finalizer_notifier_proc, add getter and setters: GC_get_gc_no, GC_get_parallel, GC_set_oom_fn, GC_set_finalize_on_demand, GC_set_java_finalization, GC_set_dont_expand, GC_set_no_dls, GC_set_max_retries, GC_set_dont_precollect, GC_set_finalizer_notifier. Always define GC_win32_free_heap. gc_config_macros.h: Define _REENTRANT after processing GC_THREADS. * include/gc_cpp.h: Improve GC_PLACEMENT_DELETE test, handling of operator new[] for old Windows compilers. * include/gc_inline.h (GC_MALLOC_FAST_GRANS): Add parentheses around arguments. * dbg_mlc.c, malloc.c, misc.c: Add many GC_API specs. * mark.c (GC_mark_and_push_stack): Fix source argument for blacklist printing. * misc.c: Fix log file naming based on environment variable for Windows. Make GC_set_warn_proc and GC_set_free_space_divisor just return current value with 0 argument. Add DONT_USER_USER32_DLL. Add various getters and setters as in gc.h. * os_dep.c: Remove no longer used GC_disable/enable_signals implementations. (GC_get_stack_base): Add pthread_attr_destroy call. No longer set GC_old_bus_handler in DARWIN workaround. * pthread_support.c: GC_register_my_thread must also call GC_init_thread_local.
Diffstat (limited to 'reclaim.c')
-rw-r--r--reclaim.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/reclaim.c b/reclaim.c
index 43fdf70..0b01b1a 100644
--- a/reclaim.c
+++ b/reclaim.c
@@ -34,11 +34,11 @@ signed_word GC_bytes_found = 0;
/* the collector, e.g. without the allocation lock. */
#define MAX_LEAKED 40
ptr_t GC_leaked[MAX_LEAKED];
-unsigned GC_n_leaked = 0;
+STATIC unsigned GC_n_leaked = 0;
GC_bool GC_have_errors = FALSE;
-void GC_add_leaked(ptr_t leaked)
+STATIC void GC_add_leaked(ptr_t leaked)
{
if (GC_n_leaked < MAX_LEAKED) {
GC_have_errors = TRUE;
@@ -51,7 +51,7 @@ void GC_add_leaked(ptr_t leaked)
static GC_bool printing_errors = FALSE;
/* Print all objects on the list after printing any smashed objs. */
/* Clear both lists. */
-void GC_print_all_errors ()
+void GC_print_all_errors (void)
{
unsigned i;
@@ -97,7 +97,7 @@ GC_bool GC_block_empty(hdr *hhdr)
return (hhdr -> hb_n_marks == 0);
}
-GC_bool GC_block_nearly_full(hdr *hhdr)
+STATIC GC_bool GC_block_nearly_full(hdr *hhdr)
{
return (hhdr -> hb_n_marks > 7 * HBLK_OBJS(hhdr -> hb_sz)/8);
}
@@ -110,9 +110,8 @@ GC_bool GC_block_nearly_full(hdr *hhdr)
* free list. Returns the new list.
* Clears unmarked objects. Sz is in bytes.
*/
-/*ARGSUSED*/
-ptr_t GC_reclaim_clear(struct hblk *hbp, hdr *hhdr, size_t sz,
- ptr_t list, signed_word *count)
+STATIC ptr_t GC_reclaim_clear(struct hblk *hbp, hdr *hhdr, size_t sz,
+ ptr_t list, signed_word *count)
{
word bit_no = 0;
word *p, *q, *plim;
@@ -158,9 +157,8 @@ ptr_t GC_reclaim_clear(struct hblk *hbp, hdr *hhdr, size_t sz,
}
/* The same thing, but don't clear objects: */
-/*ARGSUSED*/
-ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
- ptr_t list, signed_word *count)
+STATIC ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
+ ptr_t list, signed_word *count)
{
word bit_no = 0;
word *p, *plim;
@@ -186,8 +184,7 @@ ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
}
/* Don't really reclaim objects, just check for unmarked ones: */
-/*ARGSUSED*/
-void GC_reclaim_check(struct hblk *hbp, hdr *hhdr, word sz)
+STATIC void GC_reclaim_check(struct hblk *hbp, hdr *hhdr, word sz)
{
word bit_no = 0;
ptr_t p, plim;
@@ -215,7 +212,7 @@ void GC_reclaim_check(struct hblk *hbp, hdr *hhdr, word sz)
ptr_t GC_reclaim_generic(struct hblk * hbp, hdr *hhdr, size_t sz,
GC_bool init, ptr_t list, signed_word *count)
{
- ptr_t result = list;
+ ptr_t result;
GC_ASSERT(GC_find_header((ptr_t)hbp) == hhdr);
GC_remove_protection(hbp, 1, (hhdr)->hb_descr == 0 /* Pointer-free? */);
@@ -235,8 +232,8 @@ ptr_t GC_reclaim_generic(struct hblk * hbp, hdr *hhdr, size_t sz,
* If entirely empty blocks are to be completely deallocated, then
* caller should perform that check.
*/
-void GC_reclaim_small_nonempty_block(struct hblk *hbp,
- int report_if_found, signed_word *count)
+STATIC void GC_reclaim_small_nonempty_block(struct hblk *hbp,
+ int report_if_found)
{
hdr *hhdr = HDR(hbp);
size_t sz = hhdr -> hb_sz;
@@ -263,7 +260,7 @@ void GC_reclaim_small_nonempty_block(struct hblk *hbp,
* If report_if_found is TRUE, then process any block immediately, and
* simply report free objects; do not actually reclaim them.
*/
-void GC_reclaim_block(struct hblk *hbp, word report_if_found)
+STATIC void GC_reclaim_block(struct hblk *hbp, word report_if_found)
{
hdr * hhdr = HDR(hbp);
size_t sz = hhdr -> hb_sz; /* size of objects in current block */
@@ -308,8 +305,7 @@ 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_bytes_found);
+ GC_reclaim_small_nonempty_block(hbp, (int)report_if_found);
} else if (empty) {
GC_bytes_found += HBLKSIZE;
GC_freehblk(hbp);
@@ -340,7 +336,7 @@ struct Print_stats
#ifdef USE_MARK_BYTES
/* Return the number of set mark bits in the given header */
-int GC_n_set_marks(hdr *hhdr)
+STATIC int GC_n_set_marks(hdr *hhdr)
{
int result = 0;
int i;
@@ -371,7 +367,7 @@ static int set_bits(word n)
}
/* Return the number of set mark bits in the given header */
-int GC_n_set_marks(hdr *hhdr)
+STATIC int GC_n_set_marks(hdr *hhdr)
{
int result = 0;
int i;
@@ -398,8 +394,8 @@ int GC_n_set_marks(hdr *hhdr)
#endif /* !USE_MARK_BYTES */
-/*ARGSUSED*/
-void GC_print_block_descr(struct hblk *h, word /* struct PrintStats */ raw_ps)
+STATIC void GC_print_block_descr(struct hblk *h,
+ word /* struct PrintStats */ raw_ps)
{
hdr * hhdr = HDR(h);
size_t bytes = hhdr -> hb_sz;
@@ -422,7 +418,7 @@ void GC_print_block_descr(struct hblk *h, word /* struct PrintStats */ raw_ps)
ps->number_of_blocks++;
}
-void GC_print_block_list()
+void GC_print_block_list(void)
{
struct Print_stats pstats;
@@ -463,7 +459,7 @@ void GC_print_free_list(int kind, size_t sz_in_granules)
* since may otherwise end up with dangling "descriptor" pointers.
* It may help for other pointer-containing objects.
*/
-void GC_clear_fl_links(void **flp)
+STATIC void GC_clear_fl_links(void **flp)
{
void *next = *flp;
@@ -551,7 +547,7 @@ void GC_continue_reclaim(size_t sz /* granules */, int kind)
while ((hbp = *rlh) != 0) {
hhdr = HDR(hbp);
*rlh = hhdr -> hb_next;
- GC_reclaim_small_nonempty_block(hbp, FALSE, &GC_bytes_found);
+ GC_reclaim_small_nonempty_block(hbp, FALSE);
if (*flh != 0) break;
}
}
@@ -574,11 +570,13 @@ GC_bool GC_reclaim_all(GC_stop_func stop_func, GC_bool ignore_old)
struct obj_kind * ok;
struct hblk ** rlp;
struct hblk ** rlh;
- CLOCK_TYPE start_time;
- CLOCK_TYPE done_time;
-
- if (GC_print_stats == VERBOSE)
+# ifndef SMALL_CONFIG
+ CLOCK_TYPE start_time;
+ CLOCK_TYPE done_time;
+
+ if (GC_print_stats == VERBOSE)
GET_TIME(start_time);
+# endif
for (kind = 0; kind < GC_n_kinds; kind++) {
ok = &(GC_obj_kinds[kind]);
@@ -596,15 +594,17 @@ GC_bool GC_reclaim_all(GC_stop_func stop_func, GC_bool ignore_old)
/* It's likely we'll need it this time, too */
/* It's been touched recently, so this */
/* shouldn't trigger paging. */
- GC_reclaim_small_nonempty_block(hbp, FALSE, &GC_bytes_found);
+ GC_reclaim_small_nonempty_block(hbp, FALSE);
}
}
}
}
- if (GC_print_stats == VERBOSE) {
+# ifndef SMALL_CONFIG
+ if (GC_print_stats == VERBOSE) {
GET_TIME(done_time);
GC_log_printf("Disposing of reclaim lists took %lu msecs\n",
MS_TIME_DIFF(done_time,start_time));
- }
+ }
+# endif
return(TRUE);
}