Moved weak.c statics to NewGC struct

A little cleanup to help my static analysis tool

svn: r12288
This commit is contained in:
Kevin Tew 2008-11-05 21:08:24 +00:00
parent b6add696af
commit 4d0cdd5b9d
4 changed files with 25 additions and 25 deletions

View File

@ -14,18 +14,24 @@
*/ */
/* interface to GC */ /* interface to GC */
/*
static void *malloc_pages(size_t len, size_t alignment); static void *malloc_pages(size_t len, size_t alignment);
static void *malloc_dirty_pages(size_t len, size_t alignment); static void *malloc_dirty_pages(size_t len, size_t alignment);
static void free_pages(void *p, size_t len); static void free_pages(void *p, size_t len);
static void flush_freed_pages(void); static void flush_freed_pages(void);
static void protect_pages(void *p, size_t len, int writable); static void protect_pages(void *p, size_t len, int writable);
*/
/* interface to OS */ /* interface to OS */
/*
static void os_vm_free_pages(void *p, size_t len); static void os_vm_free_pages(void *p, size_t len);
static void *os_vm_alloc_pages(size_t len); static void *os_vm_alloc_pages(size_t len);
*/
/* private utility functions */ /* private utility functions */
/*
static void *do_malloc_pages(size_t len, size_t alignment, int dirty_ok); static void *do_malloc_pages(size_t len, size_t alignment, int dirty_ok);
*/
static void *malloc_pages(size_t len, size_t alignment) static void *malloc_pages(size_t len, size_t alignment)

View File

@ -1841,7 +1841,7 @@ void GC_dump_with_traces(int flags,
GCWARN((GCOUTF,"# of major collections: %li\n", GC->num_major_collects)); GCWARN((GCOUTF,"# of major collections: %li\n", GC->num_major_collects));
GCWARN((GCOUTF,"# of minor collections: %li\n", GC->num_minor_collects)); GCWARN((GCOUTF,"# of minor collections: %li\n", GC->num_minor_collects));
GCWARN((GCOUTF,"# of installed finalizers: %i\n", GC->num_fnls)); GCWARN((GCOUTF,"# of installed finalizers: %i\n", GC->num_fnls));
GCWARN((GCOUTF,"# of traced ephemerons: %i\n", num_last_seen_ephemerons)); GCWARN((GCOUTF,"# of traced ephemerons: %i\n", GC->num_last_seen_ephemerons));
if (flags & GC_DUMP_SHOW_TRACE) { if (flags & GC_DUMP_SHOW_TRACE) {
print_traced_objects(path_length_limit, get_type_name, get_xtagged_name, print_tagged_value); print_traced_objects(path_length_limit, get_type_name, get_xtagged_name, print_tagged_value);

View File

@ -1,7 +1,9 @@
/* Provides: */ /* Provides: */
/*
static void os_vm_free_pages(void *p, size_t len); static void os_vm_free_pages(void *p, size_t len);
static void *os_vm_alloc_pages(size_t len); static void *os_vm_alloc_pages(size_t len);
static void protect_pages(void *p, size_t len, int writeable); static void protect_pages(void *p, size_t len, int writeable);
*/
/* Requires: */ /* Requires: */
/* Optional: /* Optional:
CHECK_USED_AGAINST_MAX(len) CHECK_USED_AGAINST_MAX(len)

View File

@ -25,8 +25,6 @@
/* weak arrays */ /* weak arrays */
/******************************************************************************/ /******************************************************************************/
static GC_Weak_Array *weak_arrays;
static int size_weak_array(void *p) static int size_weak_array(void *p)
{ {
GC_Weak_Array *a = (GC_Weak_Array *)p; GC_Weak_Array *a = (GC_Weak_Array *)p;
@ -41,8 +39,8 @@ static int mark_weak_array(void *p)
gcMARK(a->replace_val); gcMARK(a->replace_val);
a->next = weak_arrays; a->next = GC->weak_arrays;
weak_arrays = a; GC->weak_arrays = a;
#if CHECKS #if CHECKS
/* For now, weak arrays only used for symbols, keywords, and falses: */ /* For now, weak arrays only used for symbols, keywords, and falses: */
@ -105,7 +103,7 @@ void *GC_malloc_weak_array(size_t size_in_bytes, void *replace_val)
} }
void init_weak_arrays() { void init_weak_arrays() {
weak_arrays = NULL; GC->weak_arrays = NULL;
} }
static void zero_weak_arrays() static void zero_weak_arrays()
@ -113,7 +111,7 @@ static void zero_weak_arrays()
GC_Weak_Array *wa; GC_Weak_Array *wa;
int i; int i;
wa = weak_arrays; wa = GC->weak_arrays;
while (wa) { while (wa) {
void **data; void **data;
@ -132,8 +130,6 @@ static void zero_weak_arrays()
/* weak boxes */ /* weak boxes */
/******************************************************************************/ /******************************************************************************/
static GC_Weak_Box *weak_boxes;
static int size_weak_box(void *p) static int size_weak_box(void *p)
{ {
return gcBYTES_TO_WORDS(sizeof(GC_Weak_Box)); return gcBYTES_TO_WORDS(sizeof(GC_Weak_Box));
@ -146,8 +142,8 @@ static int mark_weak_box(void *p)
gcMARK(wb->secondary_erase); gcMARK(wb->secondary_erase);
if (wb->val) { if (wb->val) {
wb->next = weak_boxes; wb->next = GC->weak_boxes;
weak_boxes = wb; GC->weak_boxes = wb;
} }
return gcBYTES_TO_WORDS(sizeof(GC_Weak_Box)); return gcBYTES_TO_WORDS(sizeof(GC_Weak_Box));
@ -187,14 +183,14 @@ void *GC_malloc_weak_box(void *p, void **secondary, int soffset)
} }
void init_weak_boxes() { void init_weak_boxes() {
weak_boxes = NULL; GC->weak_boxes = NULL;
} }
static void zero_weak_boxes() static void zero_weak_boxes()
{ {
GC_Weak_Box *wb; GC_Weak_Box *wb;
wb = weak_boxes; wb = GC->weak_boxes;
while (wb) { while (wb) {
if (!is_marked(wb->val)) { if (!is_marked(wb->val)) {
wb->val = NULL; wb->val = NULL;
@ -213,10 +209,6 @@ static void zero_weak_boxes()
/* ephemeron */ /* ephemeron */
/******************************************************************************/ /******************************************************************************/
static GC_Ephemeron *ephemerons;
static int num_last_seen_ephemerons = 0;
static int size_ephemeron(void *p) static int size_ephemeron(void *p)
{ {
return gcBYTES_TO_WORDS(sizeof(GC_Ephemeron)); return gcBYTES_TO_WORDS(sizeof(GC_Ephemeron));
@ -227,8 +219,8 @@ static int mark_ephemeron(void *p)
GC_Ephemeron *eph = (GC_Ephemeron *)p; GC_Ephemeron *eph = (GC_Ephemeron *)p;
if (eph->val) { if (eph->val) {
eph->next = ephemerons; eph->next = GC->ephemerons;
ephemerons = eph; GC->ephemerons = eph;
} }
return gcBYTES_TO_WORDS(sizeof(GC_Ephemeron)); return gcBYTES_TO_WORDS(sizeof(GC_Ephemeron));
@ -280,25 +272,25 @@ void *GC_malloc_ephemeron(void *k, void *v)
} }
void init_ephemerons() { void init_ephemerons() {
ephemerons = NULL; GC->ephemerons = NULL;
num_last_seen_ephemerons = 0; GC->num_last_seen_ephemerons = 0;
} }
static void mark_ready_ephemerons() static void mark_ready_ephemerons()
{ {
GC_Ephemeron *waiting = NULL, *next, *eph; GC_Ephemeron *waiting = NULL, *next, *eph;
for (eph = ephemerons; eph; eph = next) { for (eph = GC->ephemerons; eph; eph = next) {
next = eph->next; next = eph->next;
if (is_marked(eph->key)) { if (is_marked(eph->key)) {
gcMARK(eph->val); gcMARK(eph->val);
num_last_seen_ephemerons++; GC->num_last_seen_ephemerons++;
} else { } else {
eph->next = waiting; eph->next = waiting;
waiting = eph; waiting = eph;
} }
} }
ephemerons = waiting; GC->ephemerons = waiting;
} }
static void zero_remaining_ephemerons() static void zero_remaining_ephemerons()
@ -307,7 +299,7 @@ static void zero_remaining_ephemerons()
/* After unordered finalization, any remaining ephemerons /* After unordered finalization, any remaining ephemerons
should be zeroed. */ should be zeroed. */
for (eph = ephemerons; eph; eph = eph->next) { for (eph = GC->ephemerons; eph; eph = eph->next) {
eph->key = NULL; eph->key = NULL;
eph->val = NULL; eph->val = NULL;
} }