From 62c20c49fbad796c5d4b076000144e21a1261c65 Mon Sep 17 00:00:00 2001 From: ivmai Date: Sat, 7 May 2011 19:04:25 +0000 Subject: [PATCH] 2011-05-07 Ivan Maidanski * alloc.c (GC_clear_a_few_frames): Use BZERO(). * mark_rts.c (GC_clear_roots, GC_rebuild_root_index): Ditto. * reclaim.c (GC_start_reclaim): Ditto. * blacklst.c (total_stack_black_listed): Remove "len" local variable. * dbg_mlc.c (GC_generate_random_valid_address): Replace "for" statement with "do-while" one. * dyn_load.c (GC_register_dynamic_libraries, GC_register_dynlib_callback): Remove redundant parentheses. --- ChangeLog | 12 ++++++++++++ alloc.c | 4 +--- blacklst.c | 3 +-- dbg_mlc.c | 12 +++++------- dyn_load.c | 20 +++++++------------- mark_rts.c | 8 ++------ reclaim.c | 7 +------ 7 files changed, 29 insertions(+), 37 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6131fa4d..d3a23113 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2011-05-07 Ivan Maidanski + + * alloc.c (GC_clear_a_few_frames): Use BZERO(). + * mark_rts.c (GC_clear_roots, GC_rebuild_root_index): Ditto. + * reclaim.c (GC_start_reclaim): Ditto. + * blacklst.c (total_stack_black_listed): Remove "len" local + variable. + * dbg_mlc.c (GC_generate_random_valid_address): Replace "for" + statement with "do-while" one. + * dyn_load.c (GC_register_dynamic_libraries, + GC_register_dynlib_callback): Remove redundant parentheses. + 2011-05-06 Ivan Maidanski * cord/cordxtra.c (CORD_from_file_lazy_inner): Suppress diff --git a/alloc.c b/alloc.c index df77781f..59253521 100644 --- a/alloc.c +++ b/alloc.c @@ -285,9 +285,7 @@ STATIC void GC_clear_a_few_frames(void) # define CLEAR_NWORDS 64 # endif volatile word frames[CLEAR_NWORDS]; - int i; - - for (i = 0; i < CLEAR_NWORDS; i++) frames[i] = 0; + BZERO((word *)frames, CLEAR_NWORDS * sizeof(word)); } /* Heap size at which we need a collection to avoid expanding past */ diff --git a/blacklst.c b/blacklst.c index a6df6933..9fd00167 100644 --- a/blacklst.c +++ b/blacklst.c @@ -281,8 +281,7 @@ static word total_stack_black_listed(void) 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; + struct hblk * endp1 = start + GC_heap_sects[i].hs_bytes/HBLKSIZE; total += GC_number_stack_black_listed(start, endp1); } diff --git a/dbg_mlc.c b/dbg_mlc.c index c3d9e77f..c2820602 100644 --- a/dbg_mlc.c +++ b/dbg_mlc.c @@ -171,13 +171,11 @@ GC_INNER void GC_default_print_heap_obj_proc(ptr_t p); { ptr_t result; ptr_t base; - for (;;) { - result = GC_generate_random_heap_address(); - base = GC_base(result); - if (0 == base) continue; - if (!GC_is_marked(base)) continue; - return result; - } + do { + result = GC_generate_random_heap_address(); + base = GC_base(result); + } while (base == 0 || !GC_is_marked(base)); + return result; } /* Print back trace for p */ diff --git a/dyn_load.c b/dyn_load.c index 9cc854db..a00e0102 100644 --- a/dyn_load.c +++ b/dyn_load.c @@ -189,9 +189,7 @@ GC_INNER void GC_register_dynamic_libraries(void) struct link_map *lm = GC_FirstDLOpenedLinkMap(); - for (lm = GC_FirstDLOpenedLinkMap(); - lm != (struct link_map *) 0; lm = lm->l_next) - { + for (lm = GC_FirstDLOpenedLinkMap(); lm != 0; lm = lm->l_next) { ElfW(Ehdr) * e; ElfW(Phdr) * p; unsigned long offset; @@ -205,7 +203,7 @@ GC_INNER void GC_register_dynamic_libraries(void) # endif p = ((ElfW(Phdr) *)(((char *)(e)) + e->e_phoff)); offset = ((unsigned long)(lm->l_addr)); - for( i = 0; i < (int)(e->e_phnum); ((i++),(p++)) ) { + for( i = 0; i < (int)e->e_phnum; i++, p++ ) { switch( p->p_type ) { case PT_LOAD: { @@ -454,7 +452,7 @@ STATIC int GC_register_dynlib_callback(struct dl_phdr_info * info, return -1; p = info->dlpi_phdr; - for( i = 0; i < (int)(info->dlpi_phnum); ((i++),(p++)) ) { + for( i = 0; i < (int)info->dlpi_phnum; i++, p++ ) { switch( p->p_type ) { # ifdef PT_GNU_RELRO case PT_GNU_RELRO: @@ -681,8 +679,7 @@ GC_INNER void GC_register_dynamic_libraries(void) } # endif lm = GC_FirstDLOpenedLinkMap(); - for (lm = GC_FirstDLOpenedLinkMap(); - lm != (struct link_map *) 0; lm = lm->l_next) + for (lm = GC_FirstDLOpenedLinkMap(); lm != 0; lm = lm->l_next) { ElfW(Ehdr) * e; ElfW(Phdr) * p; @@ -697,7 +694,7 @@ GC_INNER void GC_register_dynamic_libraries(void) # endif p = ((ElfW(Phdr) *)(((char *)(e)) + e->e_phoff)); offset = ((unsigned long)(lm->l_addr)); - for( i = 0; i < (int)(e->e_phnum); ((i++),(p++)) ) { + for( i = 0; i < (int)e->e_phnum; i++, p++ ) { switch( p->p_type ) { case PT_LOAD: { @@ -1066,7 +1063,6 @@ GC_INNER void GC_register_dynamic_libraries(void) /* For each region in this module */ for (region = 0; region < moduleinfo.lmi_nregion; region++) { - /* Get the region information */ status = ldr_inq_region(mypid, moduleid, region, ®ioninfo, regioninfosize, ®ionreturnsize); @@ -1471,10 +1467,8 @@ GC_INNER GC_bool GC_register_main_static_data(void) for (q = p -> lf_ls; q != NIL; q = q -> ls_next) { if ((q -> ls_flags & PCR_IL_SegFlags_Traced_MASK) == PCR_IL_SegFlags_Traced_on) { - GC_add_roots_inner - ((char *)(q -> ls_addr), - (char *)(q -> ls_addr) + q -> ls_bytes, - TRUE); + GC_add_roots_inner((char *)(q -> ls_addr), + (char *)(q -> ls_addr) + q -> ls_bytes, TRUE); } } } diff --git a/mark_rts.c b/mark_rts.c index 3ae8e614..02acf3bd 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -251,10 +251,7 @@ GC_API void GC_CALL GC_clear_roots(void) n_root_sets = 0; GC_root_size = 0; # if !defined(MSWIN32) && !defined(MSWINCE) && !defined(CYGWIN32) - { - int i; - for (i = 0; i < RT_SIZE; i++) GC_root_index[i] = 0; - } + BZERO(GC_root_index, RT_SIZE * sizeof(void *)); # endif UNLOCK(); } @@ -273,8 +270,7 @@ STATIC void GC_remove_root_at_pos(int i) STATIC void GC_rebuild_root_index(void) { int i; - - for (i = 0; i < RT_SIZE; i++) GC_root_index[i] = 0; + BZERO(GC_root_index, RT_SIZE * sizeof(void *)); for (i = 0; i < n_root_sets; i++) add_roots_to_index(GC_static_roots + i); } diff --git a/reclaim.c b/reclaim.c index c9e8e530..68dd1b98 100644 --- a/reclaim.c +++ b/reclaim.c @@ -511,8 +511,6 @@ GC_INNER void GC_start_reclaim(GC_bool report_if_found) for (kind = 0; kind < GC_n_kinds; kind++) { void **fop; void **lim; - struct hblk ** rlp; - struct hblk ** rlim; struct hblk ** rlist = GC_obj_kinds[kind].ok_reclaim_list; GC_bool should_clobber = (GC_obj_kinds[kind].ok_descriptor != 0); @@ -530,10 +528,7 @@ GC_INNER void GC_start_reclaim(GC_bool report_if_found) } } /* otherwise free list objects are marked, */ /* and its safe to leave them */ - rlim = rlist + MAXOBJGRANULES+1; - for( rlp = rlist; rlp < rlim; rlp++ ) { - *rlp = 0; - } + BZERO(rlist, (MAXOBJGRANULES + 1) * sizeof(void *)); } -- 2.40.0