From: ivmai Date: Sat, 9 Apr 2011 11:22:22 +0000 (+0000) Subject: 2011-04-09 Ivan Maidanski X-Git-Tag: gc7_2alpha6~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d0d1d875e73eddbe65d30fccf7bb8cdffd6b83f2;p=gc 2011-04-09 Ivan Maidanski * mallocx.c (GC_malloc_uncollectable): Move to malloc.c (since it is used internally in some places). --- diff --git a/ChangeLog b/ChangeLog index 46cdbc55..a8cd985d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-04-09 Ivan Maidanski + + * mallocx.c (GC_malloc_uncollectable): Move to malloc.c (since + it is used internally in some places). + 2011-04-09 Ivan Maidanski * dbg_mlc.c (GC_register_finalizer_no_order): Remove redundant diff --git a/malloc.c b/malloc.c index 781d65ab..fceb9dc6 100644 --- a/malloc.c +++ b/malloc.c @@ -264,6 +264,57 @@ GC_API void * GC_CALL GC_generic_malloc(size_t lb, int k) } } +/* Allocate lb bytes of pointerful, traced, but not collectable data */ +GC_API void * GC_CALL GC_malloc_uncollectable(size_t lb) +{ + void *op; + void **opp; + size_t lg; + DCL_LOCK_STATE; + + if( SMALL_OBJ(lb) ) { + if (EXTRA_BYTES != 0 && lb != 0) lb--; + /* We don't need the extra byte, since this won't be */ + /* collected anyway. */ + lg = GC_size_map[lb]; + opp = &(GC_uobjfreelist[lg]); + LOCK(); + if( (op = *opp) != 0 ) { + *opp = obj_link(op); + obj_link(op) = 0; + GC_bytes_allocd += GRANULES_TO_BYTES(lg); + /* Mark bit ws already set on free list. It will be */ + /* cleared only temporarily during a collection, as a */ + /* result of the normal free list mark bit clearing. */ + GC_non_gc_bytes += GRANULES_TO_BYTES(lg); + UNLOCK(); + } else { + UNLOCK(); + op = (ptr_t)GC_generic_malloc((word)lb, UNCOLLECTABLE); + /* For small objects, the free lists are completely marked. */ + } + GC_ASSERT(0 == op || GC_is_marked(op)); + return((void *) op); + } else { + hdr * hhdr; + + op = (ptr_t)GC_generic_malloc((word)lb, UNCOLLECTABLE); + if (0 == op) return(0); + + GC_ASSERT(((word)op & (HBLKSIZE - 1)) == 0); /* large block */ + hhdr = HDR(op); + /* We don't need the lock here, since we have an undisguised */ + /* pointer. We do need to hold the lock while we adjust */ + /* mark bits. */ + LOCK(); + set_mark_bit_from_hdr(hhdr, 0); /* Only object. */ + GC_ASSERT(hhdr -> hb_n_marks == 0); + hhdr -> hb_n_marks = 1; + UNLOCK(); + return((void *) op); + } +} + #ifdef REDIRECT_MALLOC # ifndef MSWINCE diff --git a/mallocx.c b/mallocx.c index 82088c5b..d92014c9 100644 --- a/mallocx.c +++ b/mallocx.c @@ -438,57 +438,6 @@ GC_API void * GC_CALL GC_malloc_many(size_t lb) return result; } -/* Allocate lb bytes of pointerful, traced, but not collectable data */ -GC_API void * GC_CALL GC_malloc_uncollectable(size_t lb) -{ - void *op; - void **opp; - size_t lg; - DCL_LOCK_STATE; - - if( SMALL_OBJ(lb) ) { - if (EXTRA_BYTES != 0 && lb != 0) lb--; - /* We don't need the extra byte, since this won't be */ - /* collected anyway. */ - lg = GC_size_map[lb]; - opp = &(GC_uobjfreelist[lg]); - LOCK(); - if( (op = *opp) != 0 ) { - *opp = obj_link(op); - obj_link(op) = 0; - GC_bytes_allocd += GRANULES_TO_BYTES(lg); - /* Mark bit ws already set on free list. It will be */ - /* cleared only temporarily during a collection, as a */ - /* result of the normal free list mark bit clearing. */ - GC_non_gc_bytes += GRANULES_TO_BYTES(lg); - UNLOCK(); - } else { - UNLOCK(); - op = (ptr_t)GC_generic_malloc((word)lb, UNCOLLECTABLE); - /* For small objects, the free lists are completely marked. */ - } - GC_ASSERT(0 == op || GC_is_marked(op)); - return((void *) op); - } else { - hdr * hhdr; - - op = (ptr_t)GC_generic_malloc((word)lb, UNCOLLECTABLE); - if (0 == op) return(0); - - GC_ASSERT(((word)op & (HBLKSIZE - 1)) == 0); /* large block */ - hhdr = HDR(op); - /* We don't need the lock here, since we have an undisguised */ - /* pointer. We do need to hold the lock while we adjust */ - /* mark bits. */ - LOCK(); - set_mark_bit_from_hdr(hhdr, 0); /* Only object. */ - GC_ASSERT(hhdr -> hb_n_marks == 0); - hhdr -> hb_n_marks = 1; - UNLOCK(); - return((void *) op); - } -} - /* Not well tested nor integrated. */ /* Debug version is tricky and currently missing. */ #include