* must trace the complex_descriptor.
*
* Note that descriptors inside objects may appear cleared, if we encounter a
- * false refrence to an object on a free list. In the GC_descr case, this
+ * false reference to an object on a free list. In the GC_descr case, this
* is OK, since a 0 descriptor corresponds to examining no fields.
* In the complex_descriptor case, we explicitly check for that case.
*
* since they are not accessible through the current interface.
*/
-#include "config.h"
-
#include "private/gc_pmark.h"
#include "gc_typed.h"
# define TYPD_EXTRA_BYTES (sizeof(word) - EXTRA_BYTES)
-GC_bool GC_explicit_typing_initialized = FALSE;
+STATIC GC_bool GC_explicit_typing_initialized = FALSE;
-int GC_explicit_kind; /* Object kind for objects with indirect */
+STATIC int GC_explicit_kind;
+ /* Object kind for objects with indirect */
/* (possibly extended) descriptors. */
-int GC_array_kind; /* Object kind for objects with complex */
+STATIC int GC_array_kind;
+ /* Object kind for objects with complex */
/* descriptors and GC_array_mark_proc. */
/* Extended descriptors. GC_typed_mark_proc understands these. */
} complex_descriptor;
#define TAG ld.ld_tag
-ext_descr * GC_ext_descriptors; /* Points to array of extended */
- /* descriptors. */
+STATIC ext_descr * GC_ext_descriptors; /* Points to array of extended */
+ /* descriptors. */
-size_t GC_ed_size = 0; /* Current size of above arrays. */
+STATIC size_t GC_ed_size = 0; /* Current size of above arrays. */
# define ED_INITIAL_SIZE 100;
-size_t GC_avail_descr = 0; /* Next available slot. */
+STATIC size_t GC_avail_descr = 0; /* Next available slot. */
-int GC_typed_mark_proc_index; /* Indices of my mark */
-int GC_array_mark_proc_index; /* procedures. */
+STATIC int GC_typed_mark_proc_index; /* Indices of my mark */
+STATIC int GC_array_mark_proc_index; /* procedures. */
static void GC_push_typed_structures_proc (void)
{
/* starting index. */
/* Returns -1 on failure. */
/* Caller does not hold allocation lock. */
-signed_word GC_add_ext_descriptor(GC_bitmap bm, word nbits)
+STATIC signed_word GC_add_ext_descriptor(GC_bitmap bm, word nbits)
{
size_t nwords = divWORDSZ(nbits + WORDSZ-1);
signed_word result;
/* The result is known to be short enough to fit into a bitmap */
/* descriptor. */
/* Descriptor is a GC_DS_LENGTH or GC_DS_BITMAP descriptor. */
-GC_descr GC_double_descr(GC_descr descriptor, word nwords)
+STATIC GC_descr GC_double_descr(GC_descr descriptor, word nwords)
{
if ((descriptor & GC_DS_TAGS) == GC_DS_LENGTH) {
descriptor = GC_bm_table[BYTES_TO_WORDS((word)descriptor)];
return(descriptor);
}
-complex_descriptor * GC_make_sequence_descriptor();
+STATIC complex_descriptor *
+GC_make_sequence_descriptor(complex_descriptor *first,
+ complex_descriptor *second);
/* Build a descriptor for an array with nelements elements, */
/* each of which can be described by a simple descriptor. */
# define LEAF 1
# define SIMPLE 0
# define NO_MEM (-1)
-int GC_make_array_descriptor(size_t nelements, size_t size, GC_descr descriptor,
- GC_descr *simple_d,
- complex_descriptor **complex_d,
- struct LeafDescriptor * leaf)
+STATIC int GC_make_array_descriptor(size_t nelements, size_t size,
+ GC_descr descriptor, GC_descr *simple_d,
+ complex_descriptor **complex_d,
+ struct LeafDescriptor * leaf)
{
# define OPT_THRESHOLD 50
/* For larger arrays, we try to combine descriptors of adjacent */
}
}
-complex_descriptor * GC_make_sequence_descriptor(complex_descriptor *first,
- complex_descriptor *second)
+STATIC complex_descriptor *
+GC_make_sequence_descriptor(complex_descriptor *first,
+ complex_descriptor *second)
{
struct SequenceDescriptor * result =
(struct SequenceDescriptor *)
}
#endif
-ptr_t * GC_eobjfreelist;
+STATIC ptr_t * GC_eobjfreelist;
-ptr_t * GC_arobjfreelist;
+STATIC ptr_t * GC_arobjfreelist;
-mse * GC_typed_mark_proc(word * addr, mse * mark_stack_ptr,
- mse * mark_stack_limit, word env);
+STATIC mse * GC_typed_mark_proc(word * addr, mse * mark_stack_ptr,
+ mse * mark_stack_limit, word env);
-mse * GC_array_mark_proc(word * addr, mse * mark_stack_ptr,
- mse * mark_stack_limit, word env);
+STATIC mse * GC_array_mark_proc(word * addr, mse * mark_stack_ptr,
+ mse * mark_stack_limit, word env);
/* Caller does not hold allocation lock. */
-void GC_init_explicit_typing(void)
+STATIC void GC_init_explicit_typing(void)
{
register int i;
DCL_LOCK_STATE;
-
- /* Ignore gcc "no effect" warning. */
GC_STATIC_ASSERT(sizeof(struct LeafDescriptor) % sizeof(word) == 0);
LOCK();
if (GC_explicit_typing_initialized) {
UNLOCK();
}
-mse * GC_typed_mark_proc(word * addr, mse * mark_stack_ptr,
- mse * mark_stack_limit, word env)
+STATIC mse * GC_typed_mark_proc(word * addr, mse * mark_stack_ptr,
+ mse * mark_stack_limit, word env)
{
word bm = GC_ext_descriptors[env].ed_bitmap;
word * current_p = addr;
FIXUP_POINTER(current);
if ((ptr_t)current >= least_ha && (ptr_t)current <= greatest_ha) {
PUSH_CONTENTS((ptr_t)current, mark_stack_ptr,
- mark_stack_limit, current_p, exit1);
+ mark_stack_limit, (ptr_t)current_p, exit1);
}
}
}
/* Return the size of the object described by d. It would be faster to */
/* store this directly, or to compute it as part of */
/* GC_push_complex_descriptor, but hopefully it doesn't matter. */
-word GC_descr_obj_size(complex_descriptor *d)
+STATIC word GC_descr_obj_size(complex_descriptor *d)
{
switch(d -> TAG) {
case LEAF_TAG:
/* Push descriptors for the object at addr with complex descriptor d */
/* onto the mark stack. Return 0 if the mark stack overflowed. */
-mse * GC_push_complex_descriptor(word *addr, complex_descriptor *d,
- mse *msp, mse *msl)
+STATIC mse * GC_push_complex_descriptor(word *addr, complex_descriptor *d,
+ mse *msp, mse *msl)
{
register ptr_t current = (ptr_t) addr;
register word nelements;
}
/*ARGSUSED*/
-mse * GC_array_mark_proc(word * addr, mse * mark_stack_ptr,
- mse * mark_stack_limit, word env)
+STATIC mse * GC_array_mark_proc(word * addr, mse * mark_stack_ptr,
+ mse * mark_stack_limit, word env)
{
hdr * hhdr = HDR(addr);
size_t sz = hhdr -> hb_sz;
return new_mark_stack_ptr;
}
-GC_descr GC_make_descriptor(GC_bitmap bm, size_t len)
+GC_API GC_descr GC_CALL GC_make_descriptor(GC_bitmap bm, size_t len)
{
signed_word last_set_bit = len - 1;
GC_descr result;
}
}
-ptr_t GC_clear_stack();
+void * GC_clear_stack(void *);
#define GENERAL_MALLOC(lb,k) \
(void *)GC_clear_stack(GC_generic_malloc((word)lb, k))
#define GENERAL_MALLOC_IOP(lb,k) \
(void *)GC_clear_stack(GC_generic_malloc_ignore_off_page(lb, k))
-void * GC_malloc_explicitly_typed(size_t lb, GC_descr d)
+GC_API void * GC_CALL GC_malloc_explicitly_typed(size_t lb, GC_descr d)
{
ptr_t op;
ptr_t * opp;
GC_bytes_allocd += GRANULES_TO_BYTES(lg);
UNLOCK();
}
+ ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
} else {
op = (ptr_t)GENERAL_MALLOC((word)lb, GC_explicit_kind);
- if (op != NULL)
+ if (op != NULL) {
lg = BYTES_TO_GRANULES(GC_size(op));
+ ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
+ }
}
- if (op != NULL)
- ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
return((void *) op);
}
-void * GC_malloc_explicitly_typed_ignore_off_page(size_t lb, GC_descr d)
+GC_API void * GC_CALL GC_malloc_explicitly_typed_ignore_off_page(size_t lb,
+ GC_descr d)
{
ptr_t op;
ptr_t * opp;
if( (op = *opp) == 0 ) {
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_bytes_allocd += GRANULES_TO_BYTES(lg);
UNLOCK();
}
+ ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
} else {
op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_explicit_kind);
- if (op != NULL)
+ if (op != NULL) {
lg = BYTES_TO_WORDS(GC_size(op));
+ ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
+ }
}
- if (op != NULL)
- ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
return((void *) op);
}
-void * GC_calloc_explicitly_typed(size_t n, size_t lb, GC_descr d)
+GC_API void * GC_CALL GC_calloc_explicitly_typed(size_t n, size_t lb,
+ GC_descr d)
{
ptr_t op;
ptr_t * opp;
lp -> ld_descriptor = leaf.ld_descriptor;
((volatile word *)op)[GRANULES_TO_WORDS(lg) - 1] = (word)lp;
} else {
- extern unsigned GC_finalization_failures;
- unsigned ff = GC_finalization_failures;
size_t lw = GRANULES_TO_WORDS(lg);
((word *)op)[lw - 1] = (word)complex_descr;
/* Make sure the descriptor is cleared once there is any danger */
/* it may have been collected. */
- (void)
- GC_general_register_disappearing_link((void * *)
- ((word *)op+lw-1),
- (void *) op);
- if (ff != GC_finalization_failures) {
+ if (GC_general_register_disappearing_link((void * *)((word *)op+lw-1),
+ op) == 2) {
/* Couldn't register it due to lack of memory. Punt. */
/* This will probably fail too, but gives the recovery code */
/* a chance. */