mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-11 06:20:23 +02:00
* gc.h: remove DOUBLECELL card flags.
* gc-malloc.c (scm_calloc): try to use calloc() before calling scm_realloc(). * gc-segment.c (scm_i_initialize_heap_segment_data): remove card init loop; handle this from scm_init_card_freelist() * gc-card.c (scm_init_card_freelist): init bit vector here.
This commit is contained in:
parent
8fa5786d7c
commit
1383773ba1
6 changed files with 53 additions and 38 deletions
|
@ -1,5 +1,15 @@
|
|||
2002-08-29 Han-Wen Nienhuys <hanwen@cs.uu.nl>
|
||||
|
||||
* gc.h: remove DOUBLECELL card flags.
|
||||
|
||||
* gc-malloc.c (scm_calloc): try to use calloc() before calling
|
||||
scm_realloc().
|
||||
|
||||
* gc-segment.c (scm_i_initialize_heap_segment_data): remove card
|
||||
init loop; handle this from scm_init_card_freelist()
|
||||
|
||||
* gc-card.c (scm_init_card_freelist): init bit vector here.
|
||||
|
||||
* numbers.c (scm_make_real): prevent reordering of statements
|
||||
num2float.i.c (FLOAT2NUM): idem
|
||||
|
||||
|
|
|
@ -80,11 +80,12 @@ long int scm_i_deprecated_memory_return;
|
|||
*/
|
||||
|
||||
int
|
||||
scm_i_sweep_card (scm_t_cell * p, SCM *free_list, int span)
|
||||
scm_i_sweep_card (scm_t_cell * p, SCM *free_list, scm_t_heap_segment*seg)
|
||||
#define FUNC_NAME "sweep_card"
|
||||
{
|
||||
scm_t_c_bvec_long *bitvec = SCM_GC_CARD_BVEC(p);
|
||||
scm_t_cell * end = p + SCM_GC_CARD_N_CELLS;
|
||||
int span = seg->span;
|
||||
int offset =SCM_MAX (SCM_GC_CARD_N_HEADER_CELLS, span);
|
||||
int free_count = 0;
|
||||
|
||||
|
@ -294,11 +295,19 @@ scm_i_sweep_card (scm_t_cell * p, SCM *free_list, int span)
|
|||
Like sweep, but no complicated logic to do the sweeping.
|
||||
*/
|
||||
int
|
||||
scm_init_card_freelist (scm_t_cell * card, SCM *free_list, int span)
|
||||
scm_i_init_card_freelist (scm_t_cell * card, SCM *free_list,
|
||||
scm_t_heap_segment*seg)
|
||||
{
|
||||
int span = seg->span;
|
||||
scm_t_cell *end = card + SCM_GC_CARD_N_CELLS;
|
||||
scm_t_cell *p = end - span;
|
||||
|
||||
scm_t_c_bvec_long * bvec_ptr = (scm_t_c_bvec_long* ) seg->bounds[1];
|
||||
int idx = (card - seg->bounds[0]) / SCM_GC_CARD_N_CELLS;
|
||||
|
||||
bvec_ptr += idx *SCM_GC_CARD_BVEC_SIZE_IN_LONGS;
|
||||
SCM_GC_CELL_BVEC (card) = bvec_ptr;
|
||||
|
||||
/*
|
||||
ASSUMPTION: n_header_cells <= 2.
|
||||
*/
|
||||
|
@ -318,7 +327,7 @@ scm_init_card_freelist (scm_t_cell * card, SCM *free_list, int span)
|
|||
/*
|
||||
These functions are meant to be called from GDB as a debug aid.
|
||||
|
||||
I've left them as a convenience for future generations.
|
||||
I've left them as a convenience for future generations. --hwn.
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
@ -150,7 +150,17 @@ scm_malloc (size_t sz)
|
|||
void *
|
||||
scm_calloc (size_t sz)
|
||||
{
|
||||
void * ptr = scm_realloc (NULL, sz);
|
||||
void * ptr;
|
||||
|
||||
/*
|
||||
By default, try to use calloc, as it is likely more efficient than
|
||||
calling memset by hand.
|
||||
*/
|
||||
SCM_SYSCALL(ptr= calloc (sz, 1));
|
||||
if (ptr)
|
||||
return ptr;
|
||||
|
||||
ptr = scm_realloc (NULL, sz);
|
||||
memset (ptr, 0x0, sz);
|
||||
return ptr;
|
||||
}
|
||||
|
|
|
@ -50,10 +50,6 @@
|
|||
|
||||
|
||||
|
||||
#define SCM_GC_CARD_BVEC_SIZE_IN_LONGS \
|
||||
((SCM_GC_CARD_N_CELLS + SCM_C_BVEC_LONG_BITS - 1) / SCM_C_BVEC_LONG_BITS)
|
||||
#define SCM_GC_IN_CARD_HEADERP(x) \
|
||||
(scm_t_cell *) (x) < SCM_GC_CELL_CARD (x) + SCM_GC_CARD_N_HEADER_CELLS
|
||||
|
||||
|
||||
size_t scm_max_segment_size;
|
||||
|
@ -120,25 +116,11 @@ scm_i_initialize_heap_segment_data (scm_t_heap_segment * segment, size_t request
|
|||
|
||||
bvec_ptr = (scm_t_c_bvec_long*) segment->bounds[1];
|
||||
|
||||
|
||||
{
|
||||
scm_t_cell * ptr = segment->bounds [0];
|
||||
|
||||
for (;
|
||||
ptr < segment->bounds[1]; ptr += SCM_GC_CARD_N_CELLS)
|
||||
{
|
||||
SCM_GC_CELL_BVEC (ptr) = bvec_ptr;
|
||||
if (segment->span == 2)
|
||||
SCM_GC_SET_CARD_DOUBLECELL (ptr);
|
||||
|
||||
bvec_ptr += SCM_GC_CARD_BVEC_SIZE_IN_LONGS;
|
||||
|
||||
/*
|
||||
Don't init the mem. This is handled by lazy sweeping.
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Don't init the mem or the bitvector. This is handled by lazy
|
||||
sweeping.
|
||||
*/
|
||||
|
||||
segment->next_free_card = segment->bounds[0];
|
||||
segment->first_time = 1;
|
||||
return 1;
|
||||
|
@ -180,15 +162,15 @@ scm_i_sweep_some_cards (scm_t_heap_segment *seg)
|
|||
SCM cells = SCM_EOL;
|
||||
int threshold = 512;
|
||||
int collected = 0;
|
||||
int (*sweeper) (scm_t_cell *, SCM *, int )
|
||||
= (seg->first_time) ? &scm_init_card_freelist : &scm_i_sweep_card;
|
||||
int (*sweeper) (scm_t_cell *, SCM *, scm_t_heap_segment* )
|
||||
= (seg->first_time) ? &scm_i_init_card_freelist : &scm_i_sweep_card;
|
||||
|
||||
scm_t_cell * next_free = seg->next_free_card;
|
||||
int cards_swept = 0;
|
||||
|
||||
while (collected < threshold && next_free < seg->bounds[1])
|
||||
{
|
||||
collected += (*sweeper) (next_free, &cells, seg->span);
|
||||
collected += (*sweeper) (next_free, &cells, seg);
|
||||
next_free += SCM_GC_CARD_N_CELLS;
|
||||
cards_swept ++;
|
||||
}
|
||||
|
@ -438,7 +420,7 @@ scm_i_find_heap_segment_containing_object (SCM obj)
|
|||
}
|
||||
}
|
||||
|
||||
if (!DOUBLECELL_ALIGNED_P (obj) && scm_i_heap_segment_table[i]->span == 2)
|
||||
if (!SCM_DOUBLECELL_ALIGNED_P (obj) && scm_i_heap_segment_table[i]->span == 2)
|
||||
return -1;
|
||||
else if (SCM_GC_IN_CARD_HEADERP (ptr))
|
||||
return -1;
|
||||
|
|
|
@ -107,10 +107,10 @@ typedef struct scm_t_cell
|
|||
#define SCM_GC_CLEAR_CARD_FLAG(card, shift) \
|
||||
(SCM_GC_SET_CARD_FLAGS (card, SCM_GC_GET_CARD_FLAGS(card) & ~(1L << (shift))))
|
||||
|
||||
#define SCM_GC_CARDF_DOUBLECELL 0
|
||||
|
||||
#define SCM_GC_CARD_DOUBLECELLP(card) SCM_GC_GET_CARD_FLAG (card, SCM_GC_CARDF_DOUBLECELL)
|
||||
#define SCM_GC_SET_CARD_DOUBLECELL(card) SCM_GC_SET_CARD_FLAG (card, SCM_GC_CARDF_DOUBLECELL)
|
||||
/*
|
||||
Remove card flags. They hamper lazy initialization, and aren't used
|
||||
anyways.
|
||||
*/
|
||||
|
||||
/* card addressing. for efficiency, cards are *always* aligned to
|
||||
SCM_GC_CARD_SIZE. */
|
||||
|
|
|
@ -63,9 +63,13 @@
|
|||
#define SCM_HEAP_SEG_SIZE (16384L * sizeof (scm_t_cell))
|
||||
|
||||
|
||||
#define DOUBLECELL_ALIGNED_P(x) (((2 * sizeof (scm_t_cell) - 1) & SCM_UNPACK (x)) == 0)
|
||||
#define SCM_DOUBLECELL_ALIGNED_P(x) (((2 * sizeof (scm_t_cell) - 1) & SCM_UNPACK (x)) == 0)
|
||||
|
||||
|
||||
#define SCM_GC_CARD_BVEC_SIZE_IN_LONGS \
|
||||
((SCM_GC_CARD_N_CELLS + SCM_C_BVEC_LONG_BITS - 1) / SCM_C_BVEC_LONG_BITS)
|
||||
#define SCM_GC_IN_CARD_HEADERP(x) \
|
||||
(scm_t_cell *) (x) < SCM_GC_CELL_CARD (x) + SCM_GC_CARD_N_HEADER_CELLS
|
||||
|
||||
|
||||
int scm_getenv_int (const char *var, int def);
|
||||
|
@ -204,8 +208,8 @@ extern scm_t_heap_segment ** scm_i_heap_segment_table;
|
|||
extern size_t scm_i_heap_segment_table_size;
|
||||
|
||||
|
||||
int scm_init_card_freelist (scm_t_cell * card, SCM *free_list,int);
|
||||
int scm_i_sweep_card (scm_t_cell * card, SCM *free_list,int);
|
||||
int scm_i_init_card_freelist (scm_t_cell * card, SCM *free_list,scm_t_heap_segment*);
|
||||
int scm_i_sweep_card (scm_t_cell * card, SCM *free_list, scm_t_heap_segment*);
|
||||
int scm_i_initialize_heap_segment_data (scm_t_heap_segment * segment, size_t requested);
|
||||
int scm_i_segment_card_count (scm_t_heap_segment * seg);
|
||||
int scm_i_segment_cell_count (scm_t_heap_segment * seg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue