summaryrefslogtreecommitdiff
path: root/headers.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2020-06-21 14:36:01 +0300
committerIvan Maidanski <ivmai@mail.ru>2020-06-21 14:36:01 +0300
commit45a7c3594f10ddb2cbf851a65d96379a511678ad (patch)
treed1e7d7e58e7f602a98e8511ea0a2bd12e656ffc8 /headers.c
parente7819c6dee3e15447dce87104a6301266b4c9ad1 (diff)
downloadbdwgc-45a7c3594f10ddb2cbf851a65d96379a511678ad.tar.gz
Add GC_ prefix to scan_ptr and some other static variables
(code refactoring) The following variables are prefixed: scratch_free_ptr, hdr_free_list, scan_ptr, main_local_mark_stack, roots_were_cleared. * doc/gcdescr.md (Mark phase): Add GC_ prefix to scan_ptr. * headers.c (scratch_free_ptr, hdr_free_list): Add GC_ prefix to name; change static to STATIC. * mark.c (scan_ptr): Likewise. * mark.c [PARALLEL_MARK] (main_local_mark_stack): Likewise. * mark_rts.c (roots_were_cleared): Likewise. * headers.c (GC_scratch_alloc): Add GC_ prefix to scratch_free_ptr. * headers.c (alloc_hdr, free_hdr): Add GC_ prefix to hdr_free_list. * headers.c (GC_init_headers): Add assertion that GC_all_nils is null on entry. * include/private/gc_pmark.h (MS_PUSH_RESCUERS, MS_PUSH_UNCOLLECTABLE, MS_PARTIALLY_INVALID): Add GC_ prefix to scan_ptr. * mark.c (GC_clear_marks, GC_initiate_gc, alloc_mark_stack): Likewise. * mark.c [WRAP_MARK_SOME] (GC_mark_some): Likewise. * mark.c [PARALLEL_MARK] (GC_wait_for_markers_init, GC_do_parallel_mark): Add GC_ prefix to main_local_mark_stack. * mark_rts.c (GC_clear_roots, GC_push_roots): Add GC_ prefix to roots_were_cleared. * mark_rts.c (GC_next_exclusion): Add assertion that GC_excl_table_entries is positive.
Diffstat (limited to 'headers.c')
-rw-r--r--headers.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/headers.c b/headers.c
index 1b3b3ebb..6a353686 100644
--- a/headers.c
+++ b/headers.c
@@ -110,20 +110,20 @@ GC_INNER hdr *
/* Routines to dynamically allocate collector data structures that will */
/* never be freed. */
-static ptr_t scratch_free_ptr = 0;
+STATIC ptr_t GC_scratch_free_ptr = 0;
/* GC_scratch_last_end_ptr is end point of last obtained scratch area. */
/* GC_scratch_end_ptr is end point of current scratch area. */
GC_INNER ptr_t GC_scratch_alloc(size_t bytes)
{
- ptr_t result = scratch_free_ptr;
+ ptr_t result = GC_scratch_free_ptr;
size_t bytes_to_get;
bytes = ROUNDUP_GRANULE_SIZE(bytes);
for (;;) {
- scratch_free_ptr += bytes;
- if ((word)scratch_free_ptr <= (word)GC_scratch_end_ptr) {
+ GC_scratch_free_ptr += bytes;
+ if ((word)GC_scratch_free_ptr <= (word)GC_scratch_end_ptr) {
/* Unallocated space of scratch buffer has enough size. */
return result;
}
@@ -133,7 +133,7 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes)
result = (ptr_t)GET_MEM(bytes_to_get);
GC_add_to_our_memory(result, bytes_to_get);
/* Undo scratch free area pointer update; get memory directly. */
- scratch_free_ptr -= bytes;
+ GC_scratch_free_ptr -= bytes;
if (result != NULL) {
/* Update end point of last obtained area (needed only */
/* by GC_register_dynamic_libraries for some targets). */
@@ -149,39 +149,39 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes)
if (NULL == result) {
WARN("Out of memory - trying to allocate requested amount"
" (%" WARN_PRIdPTR " bytes)...\n", (word)bytes);
- scratch_free_ptr -= bytes; /* Undo free area pointer update */
+ GC_scratch_free_ptr -= bytes; /* Undo free area pointer update */
bytes_to_get = ROUNDUP_PAGESIZE_IF_MMAP(bytes);
result = (ptr_t)GET_MEM(bytes_to_get);
GC_add_to_our_memory(result, bytes_to_get);
return result;
}
/* Update scratch area pointers and retry. */
- scratch_free_ptr = result;
- GC_scratch_end_ptr = scratch_free_ptr + bytes_to_get;
+ GC_scratch_free_ptr = result;
+ GC_scratch_end_ptr = GC_scratch_free_ptr + bytes_to_get;
GC_scratch_last_end_ptr = GC_scratch_end_ptr;
}
}
-static hdr * hdr_free_list = 0;
+STATIC hdr * GC_hdr_free_list = 0;
/* Return an uninitialized header */
static hdr * alloc_hdr(void)
{
hdr * result;
- if (NULL == hdr_free_list) {
+ if (NULL == GC_hdr_free_list) {
result = (hdr *)GC_scratch_alloc(sizeof(hdr));
} else {
- result = hdr_free_list;
- hdr_free_list = (hdr *) (result -> hb_next);
+ result = GC_hdr_free_list;
+ GC_hdr_free_list = (hdr *) result -> hb_next;
}
return(result);
}
GC_INLINE void free_hdr(hdr * hhdr)
{
- hhdr -> hb_next = (struct hblk *) hdr_free_list;
- hdr_free_list = hhdr;
+ hhdr -> hb_next = (struct hblk *) GC_hdr_free_list;
+ GC_hdr_free_list = hhdr;
}
#ifdef COUNT_HDR_CACHE_HITS
@@ -194,6 +194,7 @@ GC_INNER void GC_init_headers(void)
{
unsigned i;
+ GC_ASSERT(NULL == GC_all_nils);
GC_all_nils = (bottom_index *)GC_scratch_alloc(sizeof(bottom_index));
if (GC_all_nils == NULL) {
GC_err_printf("Insufficient memory for GC_all_nils\n");