* kind k objects of size i points to a non-empty
* free list. It returns a pointer to the first entry on the free list.
* In a single-threaded world, GC_allocobj may be called to allocate
- * an object of (small) size i as follows:
+ * an object of (small) size lb as follows:
*
- * opp = &(GC_objfreelist[i]);
- * if (*opp == 0) GC_allocobj(i, NORMAL);
- * ptr = *opp;
- * *opp = obj_link(ptr);
+ * lg = GC_size_map[lb];
+ * op = GC_objfreelist[lg];
+ * if (NULL == op) {
+ * op = GENERAL_MALLOC(lb, NORMAL);
+ * } else {
+ * GC_objfreelist[lg] = obj_link(op);
+ * }
*
* Note that this is very fast if the free list is non-empty; it should
* only involve the execution of 4 or 5 simple instructions.
#endif
{
ptr_t op;
- ptr_t *opp;
word lg;
DCL_LOCK_STATE;
if (SMALL_OBJ(lb)) {
GC_DBG_COLLECT_AT_MALLOC(lb);
lg = GC_size_map[lb];
- opp = &GC_finalized_objfreelist[lg];
LOCK();
- op = *opp;
+ op = GC_finalized_objfreelist[lg];
if (EXPECT(0 == op, FALSE)) {
UNLOCK();
op = GC_generic_malloc((word)lb, GC_finalized_kind);
/* GC_generic_malloc has extended the size map for us. */
lg = GC_size_map[lb];
} else {
- *opp = obj_link(op);
+ GC_finalized_objfreelist[lg] = obj_link(op);
obj_link(op) = 0;
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
UNLOCK();
#endif
{
ptr_t op;
- ptr_t * opp;
word lg;
DCL_LOCK_STATE;
GC_DBG_COLLECT_AT_MALLOC(lb);
if(SMALL_OBJ(lb)) {
lg = GC_size_map[lb];
- opp = &(GC_gcjobjfreelist[lg]);
LOCK();
- op = *opp;
- if(EXPECT(op == 0, FALSE)) {
+ op = GC_gcjobjfreelist[lg];
+ if(EXPECT(0 == op, FALSE)) {
maybe_finalize();
op = (ptr_t)GENERAL_MALLOC_INNER((word)lb, GC_gcj_kind);
if (0 == op) {
return((*oom_fn)(lb));
}
} else {
- *opp = obj_link(op);
+ GC_gcjobjfreelist[lg] = obj_link(op);
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
}
*(void **)op = ptr_to_struct_containing_descr;
void * ptr_to_struct_containing_descr)
{
ptr_t op;
- ptr_t * opp;
word lg;
DCL_LOCK_STATE;
GC_DBG_COLLECT_AT_MALLOC(lb);
if(SMALL_OBJ(lb)) {
lg = GC_size_map[lb];
- opp = &(GC_gcjobjfreelist[lg]);
LOCK();
- op = *opp;
+ op = GC_gcjobjfreelist[lg];
if (EXPECT(0 == op, FALSE)) {
maybe_finalize();
op = (ptr_t)GENERAL_MALLOC_INNER_IOP(lb, GC_gcj_kind);
return((*oom_fn)(lb));
}
} else {
- *opp = obj_link(op);
+ GC_gcjobjfreelist[lg] = obj_link(op);
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
}
} else {
#endif
{
void *op;
- void ** opp;
size_t lg;
DCL_LOCK_STATE;
if(SMALL_OBJ(lb)) {
GC_DBG_COLLECT_AT_MALLOC(lb);
lg = GC_size_map[lb];
- opp = &(GC_aobjfreelist[lg]);
LOCK();
- if (EXPECT((op = *opp) == 0, FALSE)) {
+ op = GC_aobjfreelist[lg];
+ if (EXPECT(0 == op, FALSE)) {
UNLOCK();
return(GENERAL_MALLOC((word)lb, PTRFREE));
}
- *opp = obj_link(op);
+ GC_aobjfreelist[lg] = obj_link(op);
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
UNLOCK();
return((void *) op);
} else {
- return(GENERAL_MALLOC((word)lb, PTRFREE));
+ return(GENERAL_MALLOC((word)lb, PTRFREE));
}
}
#endif
{
void *op;
- void **opp;
size_t lg;
DCL_LOCK_STATE;
if(SMALL_OBJ(lb)) {
GC_DBG_COLLECT_AT_MALLOC(lb);
lg = GC_size_map[lb];
- opp = (void **)&(GC_objfreelist[lg]);
LOCK();
- if (EXPECT((op = *opp) == 0, FALSE)) {
+ op = GC_objfreelist[lg];
+ if (EXPECT(0 == op, FALSE)) {
UNLOCK();
return (GENERAL_MALLOC((word)lb, NORMAL));
}
<= (word)GC_greatest_plausible_heap_addr
&& (word)obj_link(op)
>= (word)GC_least_plausible_heap_addr));
- *opp = obj_link(op);
+ GC_objfreelist[lg] = obj_link(op);
obj_link(op) = 0;
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
UNLOCK();
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 (SMALL_OBJ(lb)) {
GC_DBG_COLLECT_AT_MALLOC(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();
- op = *opp;
- if (EXPECT(0 != op, TRUE)) {
- *opp = obj_link(op);
+ op = GC_uobjfreelist[lg];
+ if (EXPECT(op != 0, TRUE)) {
+ GC_uobjfreelist[lg] = 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 */
GC_API void * GC_CALL GC_malloc_atomic_uncollectable(size_t lb)
{
void *op;
- void **opp;
size_t lg;
DCL_LOCK_STATE;
- if( SMALL_OBJ(lb) ) {
+ if (SMALL_OBJ(lb)) {
GC_DBG_COLLECT_AT_MALLOC(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_auobjfreelist[lg]);
LOCK();
- op = *opp;
- if (EXPECT(0 != op, TRUE)) {
- *opp = obj_link(op);
+ op = GC_auobjfreelist[lg];
+ if (EXPECT(op != 0, TRUE)) {
+ GC_auobjfreelist[lg] = obj_link(op);
obj_link(op) = 0;
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
/* Mark bit was already set while object was on free list. */
GC_API void * GC_CALL GC_malloc_explicitly_typed(size_t lb, GC_descr d)
{
ptr_t op;
- ptr_t * opp;
size_t lg;
DCL_LOCK_STATE;
if(SMALL_OBJ(lb)) {
GC_DBG_COLLECT_AT_MALLOC(lb);
lg = GC_size_map[lb];
- opp = &(GC_eobjfreelist[lg]);
LOCK();
- op = *opp;
+ op = GC_eobjfreelist[lg];
if (EXPECT(0 == op, FALSE)) {
UNLOCK();
op = (ptr_t)GENERAL_MALLOC((word)lb, GC_explicit_kind);
if (0 == op) return 0;
lg = GC_size_map[lb]; /* May have been uninitialized. */
} else {
- *opp = obj_link(op);
+ GC_eobjfreelist[lg] = obj_link(op);
obj_link(op) = 0;
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
UNLOCK();
GC_descr d)
{
ptr_t op;
- ptr_t * opp;
size_t lg;
DCL_LOCK_STATE;
lb += TYPD_EXTRA_BYTES;
- if( SMALL_OBJ(lb) ) {
+ if (SMALL_OBJ(lb)) {
GC_DBG_COLLECT_AT_MALLOC(lb);
lg = GC_size_map[lb];
- opp = &(GC_eobjfreelist[lg]);
LOCK();
- op = *opp;
+ op = GC_eobjfreelist[lg];
if (EXPECT(0 == op, FALSE)) {
UNLOCK();
op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_explicit_kind);
if (0 == op) return 0;
lg = GC_size_map[lb]; /* May have been uninitialized. */
} else {
- *opp = obj_link(op);
+ GC_eobjfreelist[lg] = obj_link(op);
obj_link(op) = 0;
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
UNLOCK();
GC_descr d)
{
ptr_t op;
- ptr_t * opp;
size_t lg;
GC_descr simple_descr;
complex_descriptor *complex_descr;
}
if( SMALL_OBJ(lb) ) {
lg = GC_size_map[lb];
- opp = &(GC_arobjfreelist[lg]);
LOCK();
- op = *opp;
+ op = GC_arobjfreelist[lg];
if (EXPECT(0 == op, FALSE)) {
UNLOCK();
op = (ptr_t)GENERAL_MALLOC((word)lb, GC_array_kind);
if (0 == op) return(0);
lg = GC_size_map[lb]; /* May have been uninitialized. */
} else {
- *opp = obj_link(op);
+ GC_arobjfreelist[lg] = obj_link(op);
obj_link(op) = 0;
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
UNLOCK();