static void push_in_progress(ptr_t p) { if (n_in_progress >= in_progress_size) { if (in_progress_size == 0) { in_progress_size = INITIAL_IN_PROGRESS; in_progress_space = (ptr_t *)GET_MEM(in_progress_size * sizeof(ptr_t)); GC_add_to_our_memory((ptr_t)in_progress_space, in_progress_size * sizeof(ptr_t)); } else { ptr_t * new_in_progress_space; in_progress_size *= 2; new_in_progress_space = (ptr_t *) GET_MEM(in_progress_size * sizeof(ptr_t)); GC_add_to_our_memory((ptr_t)new_in_progress_space, in_progress_size * sizeof(ptr_t)); BCOPY(in_progress_space, new_in_progress_space, n_in_progress * sizeof(ptr_t)); in_progress_space = new_in_progress_space; /* FIXME: This just drops the old space. */ } } if (in_progress_space == 0) ABORT("MAKE_BACK_GRAPH: Out of in-progress space: " "Huge linear data structure?"); in_progress_space[n_in_progress++] = p; }
static void push_in_progress(ptr_t p) { if (n_in_progress >= in_progress_size) { ptr_t * new_in_progress_space; if (NULL == in_progress_space) { in_progress_size = ROUNDUP_PAGESIZE_IF_MMAP(INITIAL_IN_PROGRESS * sizeof(ptr_t)) / sizeof(ptr_t); new_in_progress_space = (ptr_t *)GET_MEM(in_progress_size * sizeof(ptr_t)); } else { in_progress_size *= 2; new_in_progress_space = (ptr_t *) GET_MEM(in_progress_size * sizeof(ptr_t)); if (new_in_progress_space != NULL) BCOPY(in_progress_space, new_in_progress_space, n_in_progress * sizeof(ptr_t)); } GC_add_to_our_memory((ptr_t)new_in_progress_space, in_progress_size * sizeof(ptr_t)); # ifndef GWW_VDB GC_scratch_recycle_no_gww(in_progress_space, n_in_progress * sizeof(ptr_t)); # elif defined(LINT2) /* TODO: implement GWW-aware recycling as in alloc_mark_stack */ GC_noop1((word)in_progress_space); # endif in_progress_space = new_in_progress_space; } if (in_progress_space == 0) ABORT("MAKE_BACK_GRAPH: Out of in-progress space: " "Huge linear data structure?"); in_progress_space[n_in_progress++] = p; }
GC_INNER ptr_t GC_scratch_alloc(size_t bytes) { register ptr_t result = scratch_free_ptr; bytes += GRANULE_BYTES-1; bytes &= ~(GRANULE_BYTES-1); scratch_free_ptr += bytes; if (scratch_free_ptr <= GC_scratch_end_ptr) { return(result); } { word bytes_to_get = MINHINCR * HBLKSIZE; if (bytes_to_get <= bytes) { /* Undo the damage, and get memory directly */ bytes_to_get = bytes; # ifdef USE_MMAP bytes_to_get += GC_page_size - 1; bytes_to_get &= ~(GC_page_size - 1); # endif result = (ptr_t)GET_MEM(bytes_to_get); GC_add_to_our_memory(result, bytes_to_get); scratch_free_ptr -= bytes; GC_scratch_last_end_ptr = result + bytes; return(result); } result = (ptr_t)GET_MEM(bytes_to_get); GC_add_to_our_memory(result, bytes_to_get); if (result == 0) { if (GC_print_stats) GC_printf("Out of memory - trying to allocate less\n"); scratch_free_ptr -= bytes; bytes_to_get = bytes; # ifdef USE_MMAP bytes_to_get += GC_page_size - 1; bytes_to_get &= ~(GC_page_size - 1); # endif result = (ptr_t)GET_MEM(bytes_to_get); GC_add_to_our_memory(result, bytes_to_get); return result; } scratch_free_ptr = result; GC_scratch_end_ptr = scratch_free_ptr + bytes_to_get; GC_scratch_last_end_ptr = GC_scratch_end_ptr; return(GC_scratch_alloc(bytes)); } }
static back_edges * new_back_edges(void) { if (0 == back_edge_space) { back_edge_space = (back_edges *) GET_MEM(MAX_BACK_EDGE_STRUCTS*sizeof(back_edges)); GC_add_to_our_memory((ptr_t)back_edge_space, MAX_BACK_EDGE_STRUCTS*sizeof(back_edges)); } if (0 != avail_back_edges) { back_edges * result = avail_back_edges; avail_back_edges = result -> cont; result -> cont = 0; return result; } if (GC_n_back_edge_structs >= MAX_BACK_EDGE_STRUCTS - 1) { ABORT("needed too much space for back edges: adjust " "MAX_BACK_EDGE_STRUCTS"); } return back_edge_space + (GC_n_back_edge_structs++); }
static back_edges * new_back_edges(void) { if (0 == back_edge_space) { size_t bytes_to_get = ROUNDUP_PAGESIZE_IF_MMAP(MAX_BACK_EDGE_STRUCTS * sizeof(back_edges)); back_edge_space = (back_edges *)GET_MEM(bytes_to_get); if (NULL == back_edge_space) ABORT("Insufficient memory for back edges"); GC_add_to_our_memory((ptr_t)back_edge_space, bytes_to_get); } if (0 != avail_back_edges) { back_edges * result = avail_back_edges; avail_back_edges = result -> cont; result -> cont = 0; return result; } if (GC_n_back_edge_structs >= MAX_BACK_EDGE_STRUCTS - 1) { ABORT("Needed too much space for back edges: adjust " "MAX_BACK_EDGE_STRUCTS"); } return back_edge_space + (GC_n_back_edge_structs++); }