Mercurial > hg > xemacs-beta
changeset 2666:7bf1f40e6acb
[xemacs-hg @ 2005-03-15 11:56:32 by crestani]
* alloc.c: Dynamically allocate KKCC backtrace stack and some
minor typo-fixes for KKCC functions.
* alloc.c (lispdesc_indirect_count_1): Condition kkcc_backtrace on
DEBUG_XEMACS.
* alloc.c (kkcc_bt_init): New.
* alloc.c (kkcc_bt_stack_realloc): New.
* alloc.c (kkcc_bt_free): New.
* alloc.c (kkcc_bt_push): If stack size is exhausted, realloc the
stack.
* alloc.c (kkcc_marking): Init and free backtrace stack.
author | crestani |
---|---|
date | Tue, 15 Mar 2005 11:56:35 +0000 |
parents | bac3173b2665 |
children | 4f72b178ae35 |
files | src/ChangeLog src/alloc.c |
diffstat | 2 files changed, 89 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Tue Mar 15 06:15:41 2005 +0000 +++ b/src/ChangeLog Tue Mar 15 11:56:35 2005 +0000 @@ -1,3 +1,16 @@ +2005-03-15 Marcus Crestani <crestani@informatik.uni-tuebingen.de> + + * alloc.c: Dynamically allocate KKCC backtrace stack and some + minor typo-fixes for KKCC functions. + * alloc.c (lispdesc_indirect_count_1): Condition kkcc_backtrace on + DEBUG_XEMACS. + * alloc.c (kkcc_bt_init): New. + * alloc.c (kkcc_bt_stack_realloc): New. + * alloc.c (kkcc_bt_free): New. + * alloc.c (kkcc_bt_push): If stack size is exhausted, realloc the + stack. + * alloc.c (kkcc_marking): Init and free backtrace stack. + 2005-03-13 Marcus Crestani <crestani@informatik.uni-tuebingen.de> * alloc.c (KKCC_BT_STACK_SIZE): Temporary fix for KKCC
--- a/src/alloc.c Tue Mar 15 06:15:41 2005 +0000 +++ b/src/alloc.c Tue Mar 15 11:56:35 2005 +0000 @@ -3091,7 +3091,7 @@ default: stderr_out ("Unsupported count type : %d (line = %d, code = %ld)\n", idesc[line].type, line, (long) code); -#ifdef USE_KKCC +#if defined(USE_KKCC) && defined(DEBUG_XEMACS) if (gc_in_progress) kkcc_backtrace (); #endif @@ -3300,41 +3300,35 @@ They mark objects according to their descriptions. They are modeled on the corresponding pdumper procedures. */ -/* Object memory descriptions are in the lrecord_implementation structure. - But copying them to a parallel array is much more cache-friendly. */ -const struct memory_description *lrecord_memory_descriptions[countof (lrecord_implementations_table)]; - -/* the initial stack size in kkcc_gc_stack_entries */ -#define KKCC_INIT_GC_STACK_SIZE 16384 +#ifdef DEBUG_XEMACS +/* The backtrace for the KKCC mark functions. */ +#define KKCC_INIT_BT_STACK_SIZE 4096 typedef struct { - void *data; - const struct memory_description *desc; -#ifdef DEBUG_XEMACS - int level; - int pos; -#endif -} kkcc_gc_stack_entry; - -static kkcc_gc_stack_entry *kkcc_gc_stack_ptr; -static kkcc_gc_stack_entry *kkcc_gc_stack_top; -static kkcc_gc_stack_entry *kkcc_gc_stack_last_entry; -static int kkcc_gc_stack_size; - -#ifdef DEBUG_XEMACS -#define KKCC_BT_STACK_SIZE 524288 - -static struct -{ void *obj; const struct memory_description *desc; int pos; -} kkcc_bt[KKCC_BT_STACK_SIZE]; - +} kkcc_bt_stack_entry; + +static kkcc_bt_stack_entry *kkcc_bt; +static int kkcc_bt_stack_size; static int kkcc_bt_depth = 0; -#define KKCC_BT_INIT() kkcc_bt_depth = 0; +static void +kkcc_bt_init (void) +{ + kkcc_bt_depth = 0; + kkcc_bt_stack_size = KKCC_INIT_BT_STACK_SIZE; + kkcc_bt = (kkcc_bt_stack_entry *) + malloc (kkcc_bt_stack_size * sizeof (kkcc_bt_stack_entry)); + if (!kkcc_bt) + { + stderr_out ("KKCC backtrace stack init failed for size %d\n", + kkcc_bt_stack_size); + ABORT (); + } +} void kkcc_backtrace (void) @@ -3367,6 +3361,28 @@ } static void +kkcc_bt_stack_realloc (void) +{ + kkcc_bt_stack_size *= 2; + kkcc_bt = (kkcc_bt_stack_entry *) + realloc (kkcc_bt, kkcc_bt_stack_size * sizeof (kkcc_bt_stack_entry)); + if (!kkcc_bt) + { + stderr_out ("KKCC backtrace stack realloc failed for size %d\n", + kkcc_bt_stack_size); + ABORT (); + } +} + +static void +kkcc_bt_free (void) +{ + free (kkcc_bt); + kkcc_bt = 0; + kkcc_bt_stack_size = 0; +} + +static void kkcc_bt_push (void *obj, const struct memory_description *desc, int level, int pos) { @@ -3375,19 +3391,37 @@ kkcc_bt[kkcc_bt_depth].desc = desc; kkcc_bt[kkcc_bt_depth].pos = pos; kkcc_bt_depth++; - if (kkcc_bt_depth > KKCC_BT_STACK_SIZE) - { - stderr_out ("KKCC backtrace overflow, adjust KKCC_BT_STACK_SIZE.\n"); - stderr_out ("Maybe it is a loop?\n"); - ABORT (); - } + if (kkcc_bt_depth >= kkcc_bt_stack_size) + kkcc_bt_stack_realloc (); } #else /* not DEBUG_XEMACS */ -#define KKCC_BT_INIT() +#define kkcc_bt_init() #define kkcc_bt_push(obj, desc, level, pos) #endif /* not DEBUG_XEMACS */ +/* Object memory descriptions are in the lrecord_implementation structure. + But copying them to a parallel array is much more cache-friendly. */ +const struct memory_description *lrecord_memory_descriptions[countof (lrecord_implementations_table)]; + +/* the initial stack size in kkcc_gc_stack_entries */ +#define KKCC_INIT_GC_STACK_SIZE 16384 + +typedef struct +{ + void *data; + const struct memory_description *desc; +#ifdef DEBUG_XEMACS + int level; + int pos; +#endif +} kkcc_gc_stack_entry; + +static kkcc_gc_stack_entry *kkcc_gc_stack_ptr; +static kkcc_gc_stack_entry *kkcc_gc_stack_top; +static kkcc_gc_stack_entry *kkcc_gc_stack_last_entry; +static int kkcc_gc_stack_size; + static void kkcc_gc_stack_init (void) { @@ -3397,7 +3431,7 @@ if (!kkcc_gc_stack_ptr) { stderr_out ("stack init failed for size %d\n", kkcc_gc_stack_size); - exit(23); + ABORT (); } kkcc_gc_stack_top = kkcc_gc_stack_ptr - 1; kkcc_gc_stack_last_entry = kkcc_gc_stack_ptr + kkcc_gc_stack_size - 1; @@ -3423,7 +3457,7 @@ if (!kkcc_gc_stack_ptr) { stderr_out ("stack realloc failed for size %d\n", kkcc_gc_stack_size); - exit(23); + ABORT (); } kkcc_gc_stack_top = kkcc_gc_stack_ptr + current_offset; kkcc_gc_stack_last_entry = kkcc_gc_stack_ptr + kkcc_gc_stack_size - 1; @@ -3484,7 +3518,7 @@ if (! MARKED_RECORD_HEADER_P (lheader)) { MARK_RECORD_HEADER (lheader); - kkcc_gc_stack_push((void*) lheader, desc, level, pos); + kkcc_gc_stack_push ((void*) lheader, desc, level, pos); } } } @@ -3583,7 +3617,7 @@ int pos; #ifdef DEBUG_XEMACS int level = 0; - KKCC_BT_INIT (); + kkcc_bt_init (); #endif while ((stack_entry = kkcc_gc_stack_pop ()) != 0) @@ -3691,6 +3725,9 @@ } } } +#ifdef DEBUG_XEMACS + kkcc_bt_free (); +#endif } #endif /* USE_KKCC */