From 5272b24f05ba9dc781582b284d3e4735bd1c5ed1 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm <mast@lysator.liu.se> Date: Wed, 22 Sep 2004 15:40:27 +0200 Subject: [PATCH] Removed the ARRAY_WEAK_SHRINK stuff which only was used by the old multiset implementation. Rev: src/array.c:1.170 Rev: src/array.h:1.62 Rev: src/gc.c:1.257 Rev: src/main.c:1.208 Rev: src/signal_handler.c:1.305 --- src/array.c | 43 +++++++------------------------------------ src/array.h | 5 ++--- src/gc.c | 4 ++-- src/main.c | 4 ++-- src/signal_handler.c | 19 +++++++++++-------- 5 files changed, 24 insertions(+), 51 deletions(-) diff --git a/src/array.c b/src/array.c index 8761b1f81b..206c6ff9c9 100644 --- a/src/array.c +++ b/src/array.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: array.c,v 1.169 2004/09/18 20:50:48 nilsson Exp $ +|| $Id: array.c,v 1.170 2004/09/22 13:40:27 mast Exp $ */ #include "global.h" @@ -44,21 +44,12 @@ PMOD_EXPORT struct array empty_array= PMOD_EXPORT struct array weak_empty_array= { PIKE_CONSTANT_MEMOBJ_INIT(1), - &weak_shrink_empty_array, &empty_array, 0, 0, 0, ARRAY_WEAK_FLAG, + 0, &empty_array, 0, 0, 0, ARRAY_WEAK_FLAG, weak_empty_array.real_item, #ifdef HAVE_UNION_INIT {{0, 0, {0}}}, /* Only to avoid warnings. */ #endif }; -PMOD_EXPORT struct array weak_shrink_empty_array= -{ - PIKE_CONSTANT_MEMOBJ_INIT(1), - 0, &weak_empty_array, 0, 0, 0, ARRAY_WEAK_FLAG|ARRAY_WEAK_SHRINK, - weak_shrink_empty_array.real_item, -#ifdef HAVE_UNION_INIT - {{0, 0, {0}}}, /* Only to avoid warnings. */ -#endif -}; struct array *first_array = &empty_array; struct array *gc_internal_array = 0; @@ -145,7 +136,7 @@ static void array_free_no_free(struct array *v) PMOD_EXPORT void really_free_array(struct array *v) { #ifdef PIKE_DEBUG - if(v == & empty_array || v == &weak_empty_array || v == &weak_shrink_empty_array) + if(v == & empty_array || v == &weak_empty_array) Pike_fatal("Tried to free some *_empty_array.\n"); if (v->refs) { #ifdef DEBUG_MALLOC @@ -183,8 +174,6 @@ PMOD_EXPORT struct array *array_set_flags(struct array *a, int flags) add_ref(a = &empty_array); break; case ARRAY_WEAK_FLAG: add_ref(a = &weak_empty_array); break; - case ARRAY_WEAK_FLAG|ARRAY_WEAK_SHRINK: - add_ref(a = &weak_shrink_empty_array); break; default: Pike_fatal("Invalid flags %x\n", flags); } @@ -2170,6 +2159,7 @@ PMOD_EXPORT void apply_array(struct array *a, INT32 args) for (e=0;e<a->size;e++) { assign_svalues_no_free(Pike_sp, argp, args, BIT_MIXED); Pike_sp+=args; + /* FIXME: Don't throw apply errors from apply_svalue here. */ apply_svalue(ITEM(a)+e,args); new_types |= 1 << Pike_sp[-1].type; DO_AGGREGATE_ARRAY(120); @@ -2316,27 +2306,9 @@ void gc_mark_array_as_referenced(struct array *a) if (a->type_field & BIT_COMPLEX) { if (a->flags & ARRAY_WEAK_FLAG) { - int e; TYPE_FIELD t; - - if(a->flags & ARRAY_WEAK_SHRINK) { - int d=0; -#ifdef PIKE_DEBUG - if (a->refs != 1) - Pike_fatal("Got %d refs to weak shrink array " - "which we'd like to change the size on.\n", a->refs); -#endif - t = 0; - for(e=0;e<a->size;e++) - if (!gc_mark_weak_svalues(a->item+e, 1)) { - a->item[d++]=a->item[e]; - t |= 1 << a->item[e].type; - } - a->size=d; - } - else - if (!(t = gc_mark_weak_svalues(a->item, a->size))) - t = a->type_field; + if (!(t = gc_mark_weak_svalues(a->item, a->size))) + t = a->type_field; /* Ugly, but we are not allowed to change type_field * at the same time as the array is being built... @@ -2368,7 +2340,7 @@ void real_gc_cycle_check_array(struct array *a, int weak) GC_CYCLE_ENTER(a, T_ARRAY, weak) { #ifdef PIKE_DEBUG if (!gc_destruct_everything && - (a == &empty_array || a == &weak_empty_array || a == &weak_shrink_empty_array)) + (a == &empty_array || a == &weak_empty_array)) Pike_fatal("Trying to gc cycle check some *_empty_array.\n"); #endif @@ -2511,7 +2483,6 @@ void debug_dump_array(struct array *a) a->malloced_size, a == &empty_array ? " (the empty_array)" : a == &weak_empty_array ? " (the weak_empty_array)" : - a == &weak_shrink_empty_array ? " (the weak_shrink_empty_array)" : ""); fprintf(stderr,"Type field ="); debug_dump_type_field(a->type_field); diff --git a/src/array.h b/src/array.h index e75bd270f8..9e275e05b9 100644 --- a/src/array.h +++ b/src/array.h @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: array.h,v 1.61 2004/05/28 16:08:24 grubba Exp $ +|| $Id: array.h,v 1.62 2004/09/22 13:40:27 mast Exp $ */ #ifndef ARRAY_H @@ -36,9 +36,8 @@ struct array #define ARRAY_WEAK_FLAG 1 #define ARRAY_CYCLIC 2 #define ARRAY_LVALUE 4 -#define ARRAY_WEAK_SHRINK 8 -PMOD_EXPORT extern struct array empty_array, weak_empty_array, weak_shrink_empty_array; +PMOD_EXPORT extern struct array empty_array, weak_empty_array; extern struct array *first_array; extern struct array *gc_internal_array; diff --git a/src/gc.c b/src/gc.c index a7109a3cd5..84303c463a 100644 --- a/src/gc.c +++ b/src/gc.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: gc.c,v 1.256 2004/09/18 20:50:50 nilsson Exp $ +|| $Id: gc.c,v 1.257 2004/09/22 13:40:27 mast Exp $ */ #include "global.h" @@ -99,7 +99,7 @@ double gc_average_slowness = 0.9; #define GC_VERBOSE_DO(X) #endif -int num_objects = 3; /* Account for *_empty_array. */ +int num_objects = 2; /* Account for *_empty_array. */ ALLOC_COUNT_TYPE num_allocs =0; ALLOC_COUNT_TYPE alloc_threshold = GC_MIN_ALLOC_THRESHOLD; PMOD_EXPORT int Pike_in_gc = 0; diff --git a/src/main.c b/src/main.c index c470f6f156..922c348679 100644 --- a/src/main.c +++ b/src/main.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: main.c,v 1.207 2004/09/18 20:50:52 nilsson Exp $ +|| $Id: main.c,v 1.208 2004/09/22 13:40:27 mast Exp $ */ #include "global.h" @@ -1023,7 +1023,7 @@ void low_exit_main(void) gc_keep_markers = 1; do_gc (NULL, 1); -#define STATIC_ARRAYS {&empty_array, &weak_empty_array, &weak_shrink_empty_array} +#define STATIC_ARRAYS {&empty_array, &weak_empty_array} #define REPORT_LINKED_LIST_LEAKS(TYPE, START, STATICS, T_TYPE, NAME) do { \ size_t num = 0; \ diff --git a/src/signal_handler.c b/src/signal_handler.c index 2947c2635b..c98ece14b6 100644 --- a/src/signal_handler.c +++ b/src/signal_handler.c @@ -2,7 +2,7 @@ || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information. -|| $Id: signal_handler.c,v 1.304 2004/09/18 20:50:55 nilsson Exp $ +|| $Id: signal_handler.c,v 1.305 2004/09/22 13:40:27 mast Exp $ */ #include "global.h" @@ -1740,7 +1740,7 @@ static void f_trace_process_cont(INT32 args) int err = errno; THIS->state = PROCESS_STOPPED; /* FIXME: Better diagnostics. */ - Pike_error("Failed to release process. errno:%d\n", err); + Pike_error("Failed to release process: %s (errno %d)\n", strerror (err), err); } #ifdef __FreeBSD__ @@ -4525,11 +4525,14 @@ static void run_atexit_functions(struct callback *cb, void *arg,void *arg2) { if(atexit_functions) { - push_array(atexit_functions); - atexit_functions=0; - f_reverse(1); - f_call_function(1); - pop_stack(); + int i; + for (i = atexit_functions->size - 1; i; i--) { + struct svalue *s = ITEM (atexit_functions) + i; + if (!IS_DESTRUCTED (s)) { + safe_apply_svalue (s, 0, 1); + pop_stack(); + } + } } } @@ -4575,7 +4578,7 @@ void f_atexit(INT32 args) } atexit_functions=append_array(atexit_functions,Pike_sp-args); - atexit_functions->flags |= ARRAY_WEAK_FLAG | ARRAY_WEAK_SHRINK; + atexit_functions->flags |= ARRAY_WEAK_FLAG; pop_n_elems(args); } -- GitLab