From: Zoltan Varga Date: Mon, 22 Feb 2010 01:19:53 +0000 (-0000) Subject: 2010-02-22 Zoltan Varga X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=81d967fb86345847a14624d2fd06fb00ab3587eb;p=mono.git 2010-02-22 Zoltan Varga * obj_map.c (GC_add_map_entry): Speed this up for the common case where GC_register_displacement () was never called. svn path=/trunk/mono/; revision=152155 --- diff --git a/libgc/ChangeLog b/libgc/ChangeLog index f5d69bb3e47..0dcfc7e5a79 100644 --- a/libgc/ChangeLog +++ b/libgc/ChangeLog @@ -1,3 +1,8 @@ +2010-02-22 Zoltan Varga + + * obj_map.c (GC_add_map_entry): Speed this up for the common case where + GC_register_displacement () was never called. + 2010-01-29 Geoff Norton * include/private/gcconfig.h: Don't define NO_PTHREAD_TRYLOCK on darwin-x86 diff --git a/libgc/include/private/gc_priv.h b/libgc/include/private/gc_priv.h index 8fa89b6580b..2efb4732f79 100644 --- a/libgc/include/private/gc_priv.h +++ b/libgc/include/private/gc_priv.h @@ -940,6 +940,7 @@ struct _GC_arrays { # define MAP_SIZE MAP_ENTRIES # define CPP_MAX_OFFSET (OFFSET_TOO_BIG - 1) # define MAX_OFFSET ((word)CPP_MAX_OFFSET) +# define INIT_MAP(map) memset((map), OBJ_INVALID, MAP_SIZE) /* The following are used only if GC_all_interior_ptrs != 0 */ # define VALID_OFFSET_SZ \ (CPP_MAX_OFFSET > WORDS_TO_BYTES(CPP_MAXOBJSZ)? \ diff --git a/libgc/obj_map.c b/libgc/obj_map.c index d002d65b4dd..39993451cc7 100644 --- a/libgc/obj_map.c +++ b/libgc/obj_map.c @@ -22,6 +22,7 @@ # include "private/gc_priv.h" map_entry_type * GC_invalid_map = 0; +static max_valid_offset = 0; /* Invalidate the object map associated with a block. Free blocks */ /* are identified by invalid maps. */ @@ -76,6 +77,8 @@ word offset; if (!GC_valid_offsets[offset]) { GC_valid_offsets[offset] = TRUE; GC_modws_valid_offsets[offset % sizeof(word)] = TRUE; + if (offset > max_valid_offset) + max_valid_offset = offset; if (!GC_all_interior_pointers) { for (i = 0; i <= MAXOBJSZ; i++) { if (GC_obj_map[i] != 0) { @@ -117,11 +120,9 @@ word sz; # ifdef PRINTSTATS GC_printf1("Adding block map for size %lu\n", (unsigned long)sz); # endif - for (displ = 0; displ < HBLKSIZE; displ++) { - MAP_ENTRY(new_map,displ) = OBJ_INVALID; - } + INIT_MAP(new_map); if (sz == 0) { - for(displ = 0; displ <= HBLKSIZE; displ++) { + for(displ = 0; displ <= max_valid_offset; displ++) { if (OFFSET_VALID(displ)) { map_entry = BYTES_TO_WORDS(displ); if (map_entry > MAX_OFFSET) map_entry = OFFSET_TOO_BIG; @@ -132,7 +133,7 @@ word sz; for (obj_start = 0; obj_start + WORDS_TO_BYTES(sz) <= HBLKSIZE; obj_start += WORDS_TO_BYTES(sz)) { - for (displ = 0; displ < WORDS_TO_BYTES(sz); displ++) { + for (displ = 0; displ <= max_valid_offset; displ++) { if (OFFSET_VALID(displ)) { map_entry = BYTES_TO_WORDS(displ); if (map_entry > MAX_OFFSET) map_entry = OFFSET_TOO_BIG;