=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/gc/typd_mlc.c,v retrieving revision 1.1.1.1 retrieving revision 1.6 diff -u -p -r1.1.1.1 -r1.6 --- OpenXM_contrib2/asir2000/gc/typd_mlc.c 1999/12/03 07:39:10 1.1.1.1 +++ OpenXM_contrib2/asir2000/gc/typd_mlc.c 2003/06/24 05:11:34 1.6 @@ -1,5 +1,6 @@ /* * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * opyright (c) 1999-2000 by Hewlett-Packard Company. All rights reserved. * * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. @@ -11,7 +12,6 @@ * modified is included with the above copyright notice. * */ -/* Boehm, July 31, 1995 5:02 pm PDT */ /* @@ -36,15 +36,10 @@ * since they are not accessible through the current interface. */ -#include "gc_priv.h" -#include "gc_mark.h" +#include "private/gc_pmark.h" #include "gc_typed.h" -# ifdef ADD_BYTE_AT_END -# define EXTRA_BYTES (sizeof(word) - 1) -# else -# define EXTRA_BYTES (sizeof(word)) -# endif +# define TYPD_EXTRA_BYTES (sizeof(word) - EXTRA_BYTES) GC_bool GC_explicit_typing_initialized = FALSE; @@ -170,15 +165,15 @@ GC_descr GC_bm_table[WORDSZ/2]; /* each of which is described by descriptor. */ /* The result is known to be short enough to fit into a bitmap */ /* descriptor. */ -/* Descriptor is a DS_LENGTH or DS_BITMAP descriptor. */ +/* Descriptor is a GC_DS_LENGTH or GC_DS_BITMAP descriptor. */ GC_descr GC_double_descr(descriptor, nwords) register GC_descr descriptor; register word nwords; { - if (descriptor && DS_TAGS == DS_LENGTH) { + if ((descriptor & GC_DS_TAGS) == GC_DS_LENGTH) { descriptor = GC_bm_table[BYTES_TO_WORDS((word)descriptor)]; }; - descriptor |= (descriptor & ~DS_TAGS) >> nwords; + descriptor |= (descriptor & ~GC_DS_TAGS) >> nwords; return(descriptor); } @@ -196,7 +191,7 @@ complex_descriptor * GC_make_sequence_descriptor(); /* is returned in *simple_d. */ /* If the result is NO_MEM, then */ /* we failed to allocate the descriptor. */ -/* The implementation knows that DS_LENGTH is 0. */ +/* The implementation knows that GC_DS_LENGTH is 0. */ /* *leaf, *complex_d, and *simple_d may be used as temporaries */ /* during the construction. */ # define COMPLEX 2 @@ -216,7 +211,7 @@ struct LeafDescriptor * leaf; /* For larger arrays, we try to combine descriptors of adjacent */ /* descriptors to speed up marking, and to reduce the amount */ /* of space needed on the mark stack. */ - if ((descriptor & DS_TAGS) == DS_LENGTH) { + if ((descriptor & GC_DS_TAGS) == GC_DS_LENGTH) { if ((word)descriptor == size) { *simple_d = nelements * descriptor; return(SIMPLE); @@ -236,7 +231,7 @@ struct LeafDescriptor * leaf; } } } else if (size <= BITMAP_BITS/2 - && (descriptor & DS_TAGS) != DS_PROC + && (descriptor & GC_DS_TAGS) != GC_DS_PROC && (size & (sizeof(word)-1)) == 0) { int result = GC_make_array_descriptor(nelements/2, 2*size, @@ -343,9 +338,15 @@ ptr_t * GC_eobjfreelist; ptr_t * GC_arobjfreelist; -mse * GC_typed_mark_proc(); +mse * GC_typed_mark_proc GC_PROTO((register word * addr, + register mse * mark_stack_ptr, + mse * mark_stack_limit, + word env)); -mse * GC_array_mark_proc(); +mse * GC_array_mark_proc GC_PROTO((register word * addr, + register mse * mark_stack_ptr, + mse * mark_stack_limit, + word env)); GC_descr GC_generic_array_descr; @@ -370,14 +371,14 @@ void GC_init_explicit_typing() GC_explicit_typing_initialized = TRUE; /* Set up object kind with simple indirect descriptor. */ GC_eobjfreelist = (ptr_t *) - GC_generic_malloc_inner((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE); + GC_INTERNAL_MALLOC((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE); if (GC_eobjfreelist == 0) ABORT("Couldn't allocate GC_eobjfreelist"); BZERO(GC_eobjfreelist, (MAXOBJSZ+1)*sizeof(ptr_t)); GC_explicit_kind = GC_n_kinds++; GC_obj_kinds[GC_explicit_kind].ok_freelist = GC_eobjfreelist; GC_obj_kinds[GC_explicit_kind].ok_reclaim_list = 0; GC_obj_kinds[GC_explicit_kind].ok_descriptor = - (((word)WORDS_TO_BYTES(-1)) | DS_PER_OBJECT); + (((word)WORDS_TO_BYTES(-1)) | GC_DS_PER_OBJECT); GC_obj_kinds[GC_explicit_kind].ok_relocate_descr = TRUE; GC_obj_kinds[GC_explicit_kind].ok_init = TRUE; /* Descriptors are in the last word of the object. */ @@ -387,7 +388,7 @@ void GC_init_explicit_typing() /* Moving this up breaks DEC AXP compiler. */ /* Set up object kind with array descriptor. */ GC_arobjfreelist = (ptr_t *) - GC_generic_malloc_inner((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE); + GC_INTERNAL_MALLOC((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE); if (GC_arobjfreelist == 0) ABORT("Couldn't allocate GC_arobjfreelist"); BZERO(GC_arobjfreelist, (MAXOBJSZ+1)*sizeof(ptr_t)); if (GC_n_mark_procs >= MAX_MARK_PROCS) @@ -399,26 +400,33 @@ void GC_init_explicit_typing() GC_obj_kinds[GC_array_kind].ok_freelist = GC_arobjfreelist; GC_obj_kinds[GC_array_kind].ok_reclaim_list = 0; GC_obj_kinds[GC_array_kind].ok_descriptor = - MAKE_PROC(GC_array_mark_proc_index, 0);; + GC_MAKE_PROC(GC_array_mark_proc_index, 0);; GC_obj_kinds[GC_array_kind].ok_relocate_descr = FALSE; GC_obj_kinds[GC_array_kind].ok_init = TRUE; /* Descriptors are in the last word of the object. */ GC_mark_procs[GC_array_mark_proc_index] = GC_array_mark_proc; for (i = 0; i < WORDSZ/2; i++) { GC_descr d = (((word)(-1)) >> (WORDSZ - i)) << (WORDSZ - i); - d |= DS_BITMAP; + d |= GC_DS_BITMAP; GC_bm_table[i] = d; } - GC_generic_array_descr = MAKE_PROC(GC_array_mark_proc_index, 0); + GC_generic_array_descr = GC_MAKE_PROC(GC_array_mark_proc_index, 0); UNLOCK(); ENABLE_SIGNALS(); } -mse * GC_typed_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env) -register word * addr; -register mse * mark_stack_ptr; -mse * mark_stack_limit; -word env; +# if defined(__STDC__) || defined(__cplusplus) + mse * GC_typed_mark_proc(register word * addr, + register mse * mark_stack_ptr, + mse * mark_stack_limit, + word env) +# else + mse * GC_typed_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env) + register word * addr; + register mse * mark_stack_ptr; + mse * mark_stack_limit; + word env; +# endif { register word bm = GC_ext_descriptors[env].ed_bitmap; register word * current_p = addr; @@ -429,8 +437,9 @@ word env; for (; bm != 0; bm >>= 1, current_p++) { if (bm & 1) { current = *current_p; + FIXUP_POINTER(current); if ((ptr_t)current >= least_ha && (ptr_t)current <= greatest_ha) { - PUSH_CONTENTS(current, mark_stack_ptr, + PUSH_CONTENTS((ptr_t)current, mark_stack_ptr, mark_stack_limit, current_p, exit1); } } @@ -446,7 +455,7 @@ word env; } mark_stack_ptr -> mse_start = addr + WORDSZ; mark_stack_ptr -> mse_descr = - MAKE_PROC(GC_typed_mark_proc_index, env+1); + GC_MAKE_PROC(GC_typed_mark_proc_index, env+1); } return(mark_stack_ptr); } @@ -533,11 +542,18 @@ mse * msl; } /*ARGSUSED*/ -mse * GC_array_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env) -register word * addr; -register mse * mark_stack_ptr; -mse * mark_stack_limit; -word env; +# if defined(__STDC__) || defined(__cplusplus) + mse * GC_array_mark_proc(register word * addr, + register mse * mark_stack_ptr, + mse * mark_stack_limit, + word env) +# else + mse * GC_array_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env) + register word * addr; + register mse * mark_stack_ptr; + mse * mark_stack_limit; + word env; +# endif { register hdr * hhdr = HDR(addr); register word sz = hhdr -> hb_sz; @@ -563,12 +579,12 @@ word env; GC_mark_stack_too_small = TRUE; new_mark_stack_ptr = orig_mark_stack_ptr + 1; new_mark_stack_ptr -> mse_start = addr; - new_mark_stack_ptr -> mse_descr = WORDS_TO_BYTES(sz) | DS_LENGTH; + new_mark_stack_ptr -> mse_descr = WORDS_TO_BYTES(sz) | GC_DS_LENGTH; } else { /* Push descriptor itself */ new_mark_stack_ptr++; new_mark_stack_ptr -> mse_start = addr + sz - 1; - new_mark_stack_ptr -> mse_descr = sizeof(word) | DS_LENGTH; + new_mark_stack_ptr -> mse_descr = sizeof(word) | GC_DS_LENGTH; } return(new_mark_stack_ptr); } @@ -600,7 +616,7 @@ word env; } if (all_bits_set) { /* An initial section contains all pointers. Use length descriptor. */ - return(WORDS_TO_BYTES(last_set_bit+1) | DS_LENGTH); + return(WORDS_TO_BYTES(last_set_bit+1) | GC_DS_LENGTH); } } # endif @@ -612,16 +628,16 @@ word env; result >>= 1; if (GC_get_bit(bm, i)) result |= HIGH_BIT; } - result |= DS_BITMAP; + result |= GC_DS_BITMAP; return(result); } else { signed_word index; index = GC_add_ext_descriptor(bm, (word)last_set_bit+1); - if (index == -1) return(WORDS_TO_BYTES(last_set_bit+1) | DS_LENGTH); + if (index == -1) return(WORDS_TO_BYTES(last_set_bit+1) | GC_DS_LENGTH); /* Out of memory: use conservative */ /* approximation. */ - result = MAKE_PROC(GC_typed_mark_proc_index, (word)index); + result = GC_MAKE_PROC(GC_typed_mark_proc_index, (word)index); return(result); } } @@ -647,7 +663,7 @@ register ptr_t * opp; register word lw; DCL_LOCK_STATE; - lb += EXTRA_BYTES; + lb += TYPD_EXTRA_BYTES; if( SMALL_OBJ(lb) ) { # ifdef MERGE_SIZES lw = GC_size_map[lb]; @@ -659,12 +675,13 @@ DCL_LOCK_STATE; if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) { FASTUNLOCK(); op = (ptr_t)GENERAL_MALLOC((word)lb, GC_explicit_kind); - if (0 == op) return(0); + if (0 == op) return 0; # ifdef MERGE_SIZES - lw = GC_size_map[lb]; /* May have been uninitialized. */ + lw = GC_size_map[lb]; /* May have been uninitialized. */ # endif } else { *opp = obj_link(op); + obj_link(op) = 0; GC_words_allocd += lw; FASTUNLOCK(); } @@ -691,7 +708,7 @@ register ptr_t * opp; register word lw; DCL_LOCK_STATE; - lb += EXTRA_BYTES; + lb += TYPD_EXTRA_BYTES; if( SMALL_OBJ(lb) ) { # ifdef MERGE_SIZES lw = GC_size_map[lb]; @@ -704,10 +721,11 @@ DCL_LOCK_STATE; FASTUNLOCK(); op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_explicit_kind); # ifdef MERGE_SIZES - lw = GC_size_map[lb]; /* May have been uninitialized. */ + lw = GC_size_map[lb]; /* May have been uninitialized. */ # endif } else { *opp = obj_link(op); + obj_link(op) = 0; GC_words_allocd += lw; FASTUNLOCK(); } @@ -717,7 +735,7 @@ DCL_LOCK_STATE; lw = BYTES_TO_WORDS(GC_size(op)); } if (op != NULL) - ((word *)op)[lw - 1] = d; + ((word *)op)[lw - 1] = d; return((GC_PTR) op); } @@ -748,11 +766,11 @@ DCL_LOCK_STATE; case SIMPLE: return(GC_malloc_explicitly_typed(n*lb, simple_descr)); case LEAF: lb *= n; - lb += sizeof(struct LeafDescriptor) + EXTRA_BYTES; + lb += sizeof(struct LeafDescriptor) + TYPD_EXTRA_BYTES; break; case COMPLEX: lb *= n; - lb += EXTRA_BYTES; + lb += TYPD_EXTRA_BYTES; break; } if( SMALL_OBJ(lb) ) { @@ -772,6 +790,7 @@ DCL_LOCK_STATE; # endif } else { *opp = obj_link(op); + obj_link(op) = 0; GC_words_allocd += lw; FASTUNLOCK(); }