From 88cf4f7e66cf426f8aaf0a105226d5de911eae2b Mon Sep 17 00:00:00 2001 From: Martin Stjernholm <mast@lysator.liu.se> Date: Sat, 11 Jan 2003 01:01:21 +0100 Subject: [PATCH] Provide data for more accurate calculation of freed things in the gc. Rev: src/array.c:1.134 Rev: src/array.h:1.45 Rev: src/mapping.c:1.160 Rev: src/mapping.h:1.48 Rev: src/multiset.c:1.66 Rev: src/multiset.h:1.31 Rev: src/object.c:1.216 Rev: src/object.h:1.76 Rev: src/program.c:1.472 Rev: src/program.h:1.172 --- src/array.c | 12 ++++++++---- src/array.h | 4 ++-- src/mapping.c | 10 +++++++--- src/mapping.h | 4 ++-- src/multiset.c | 18 +++++++++++++----- src/multiset.h | 6 +++--- src/object.c | 10 +++++++--- src/object.h | 4 ++-- src/program.c | 12 ++++++++---- src/program.h | 4 ++-- 10 files changed, 54 insertions(+), 30 deletions(-) diff --git a/src/array.c b/src/array.c index 83790c34f4..2c815a7256 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.133 2002/12/01 00:16:54 mast Exp $ +|| $Id: array.c,v 1.134 2003/01/11 00:01:20 mast Exp $ */ #include "global.h" @@ -25,7 +25,7 @@ #include "bignum.h" #include "cyclic.h" -RCSID("$Id: array.c,v 1.133 2002/12/01 00:16:54 mast Exp $"); +RCSID("$Id: array.c,v 1.134 2003/01/11 00:01:20 mast Exp $"); PMOD_EXPORT struct array empty_array= { @@ -86,7 +86,7 @@ PMOD_EXPORT struct array *low_allocate_array(ptrdiff_t size, ptrdiff_t extra_spa Pike_error("Couldn't allocate array, out of memory.\n"); GC_ALLOC(v); - + /* for now, we don't know what will go in here */ v->type_field=BIT_MIXED | BIT_UNFINISHED; @@ -2244,9 +2244,10 @@ void gc_zap_ext_weak_refs_in_arrays(void) discard_queue(&gc_mark_queue); } -void gc_free_all_unreferenced_arrays(void) +size_t gc_free_all_unreferenced_arrays(void) { struct array *a,*next; + size_t freed = 0; for (a = gc_internal_array; a != &weak_empty_array; a = next) { @@ -2262,12 +2263,15 @@ void gc_free_all_unreferenced_arrays(void) gc_free_extra_ref(a); SET_NEXT_AND_FREE(a, free_array); + freed++; } else { next=a->next; } } + + return freed; } diff --git a/src/array.h b/src/array.h index d99788dfd8..b18bcf7e08 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.44 2002/10/11 01:39:28 nilsson Exp $ +|| $Id: array.h,v 1.45 2003/01/11 00:01:20 mast Exp $ */ #ifndef ARRAY_H @@ -171,7 +171,7 @@ void gc_check_all_arrays(void); void gc_mark_all_arrays(void); void gc_cycle_check_all_arrays(void); void gc_zap_ext_weak_refs_in_arrays(void); -void gc_free_all_unreferenced_arrays(void); +size_t gc_free_all_unreferenced_arrays(void); void debug_dump_type_field(TYPE_FIELD t); void debug_dump_array(struct array *a); void zap_all_arrays(void); diff --git a/src/mapping.c b/src/mapping.c index 4fd5d5039f..5d69878588 100644 --- a/src/mapping.c +++ b/src/mapping.c @@ -2,11 +2,11 @@ || 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: mapping.c,v 1.159 2003/01/10 12:49:03 grubba Exp $ +|| $Id: mapping.c,v 1.160 2003/01/11 00:01:20 mast Exp $ */ #include "global.h" -RCSID("$Id: mapping.c,v 1.159 2003/01/10 12:49:03 grubba Exp $"); +RCSID("$Id: mapping.c,v 1.160 2003/01/11 00:01:20 mast Exp $"); #include "main.h" #include "object.h" #include "mapping.h" @@ -2392,10 +2392,11 @@ void gc_zap_ext_weak_refs_in_mappings(void) discard_queue(&gc_mark_queue); } -void gc_free_all_unreferenced_mappings(void) +size_t gc_free_all_unreferenced_mappings(void) { struct mapping *m,*next; struct mapping_data *md; + size_t freed = 0; for(m=gc_internal_mapping;m;m=next) { @@ -2420,12 +2421,15 @@ void gc_free_all_unreferenced_mappings(void) #endif gc_free_extra_ref(m); SET_NEXT_AND_FREE(m, free_mapping); + freed++; } else { next=m->next; } } + + return freed; } #ifdef PIKE_DEBUG diff --git a/src/mapping.h b/src/mapping.h index e6172b469e..72599b24cd 100644 --- a/src/mapping.h +++ b/src/mapping.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: mapping.h,v 1.47 2003/01/10 12:49:03 grubba Exp $ +|| $Id: mapping.h,v 1.48 2003/01/11 00:01:20 mast Exp $ */ #ifndef MAPPING_H @@ -173,7 +173,7 @@ void gc_check_all_mappings(void); void gc_mark_all_mappings(void); void gc_cycle_check_all_mappings(void); void gc_zap_ext_weak_refs_in_mappings(void); -void gc_free_all_unreferenced_mappings(void); +size_t gc_free_all_unreferenced_mappings(void); void simple_describe_mapping(struct mapping *m); void debug_dump_mapping(struct mapping *m); void zap_all_mappings(void); diff --git a/src/multiset.c b/src/multiset.c index 60a204bcd5..a953a3eba7 100644 --- a/src/multiset.c +++ b/src/multiset.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: multiset.c,v 1.65 2003/01/09 15:21:27 grubba Exp $ +|| $Id: multiset.c,v 1.66 2003/01/11 00:01:20 mast Exp $ */ #include "global.h" @@ -14,7 +14,7 @@ * Created by Martin Stjernholm 2001-05-07 */ -RCSID("$Id: multiset.c,v 1.65 2003/01/09 15:21:27 grubba Exp $"); +RCSID("$Id: multiset.c,v 1.66 2003/01/11 00:01:20 mast Exp $"); #include "builtin_functions.h" #include "gc.h" @@ -4122,9 +4122,10 @@ void gc_zap_ext_weak_refs_in_multisets (void) discard_queue (&gc_mark_queue); } -void gc_free_all_unreferenced_multisets (void) +size_t gc_free_all_unreferenced_multisets (void) { struct multiset *l, *next; + size_t freed = 0; for (l = gc_internal_multiset; l; l = next) { if (gc_do_free (l)) { @@ -4137,9 +4138,12 @@ void gc_free_all_unreferenced_multisets (void) } gc_free_extra_ref (l); SET_NEXT_AND_FREE (l, free_multiset); + freed++; } else next = l->next; } + + return freed; } void init_multiset() @@ -5277,7 +5281,7 @@ void test_multiset (void) #include "gc.h" #include "security.h" -RCSID("$Id: multiset.c,v 1.65 2003/01/09 15:21:27 grubba Exp $"); +RCSID("$Id: multiset.c,v 1.66 2003/01/11 00:01:20 mast Exp $"); struct multiset *first_multiset; @@ -5669,9 +5673,10 @@ void gc_cycle_check_all_multisets(void) } } -void gc_free_all_unreferenced_multisets(void) +size_t gc_free_all_unreferenced_multisets(void) { struct multiset *l,*next; + size_t freed = 0; for(l=gc_internal_multiset;l;l=next) { @@ -5683,10 +5688,13 @@ void gc_free_all_unreferenced_multisets(void) gc_free_extra_ref(l); SET_NEXT_AND_FREE(l, free_multiset); + freed++; }else{ next=l->next; } } + + return freed; } void count_memory_in_multisets(INT32 *num_, INT32 *size_) diff --git a/src/multiset.h b/src/multiset.h index ac7d510884..84b0fa5706 100644 --- a/src/multiset.h +++ b/src/multiset.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: multiset.h,v 1.30 2002/12/22 17:18:55 mast Exp $ +|| $Id: multiset.h,v 1.31 2003/01/11 00:01:20 mast Exp $ */ #ifndef MULTISET_H @@ -420,7 +420,7 @@ void gc_mark_all_multisets (void); void gc_zap_ext_weak_refs_in_multisets (void); void real_gc_cycle_check_multiset (struct multiset *l, int weak); void gc_cycle_check_all_multisets (void); -void gc_free_all_unreferenced_multisets (void); +size_t gc_free_all_unreferenced_multisets (void); #define gc_cycle_check_multiset(X, WEAK) \ gc_cycle_enqueue ((gc_cycle_check_cb *) real_gc_cycle_check_multiset, (X), (WEAK)) @@ -488,7 +488,7 @@ unsigned gc_touch_all_multisets(void); void gc_check_all_multisets(void); void gc_mark_all_multisets(void); void gc_cycle_check_all_multisets(void); -void gc_free_all_unreferenced_multisets(void); +size_t gc_free_all_unreferenced_multisets(void); void count_memory_in_multisets(INT32 *num_, INT32 *size_); int multiset_is_constant(struct multiset *m, struct processing *p); diff --git a/src/object.c b/src/object.c index 7968eb250b..ce35e72332 100644 --- a/src/object.c +++ b/src/object.c @@ -2,11 +2,11 @@ || 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: object.c,v 1.215 2002/12/20 19:07:27 grubba Exp $ +|| $Id: object.c,v 1.216 2003/01/11 00:01:20 mast Exp $ */ #include "global.h" -RCSID("$Id: object.c,v 1.215 2002/12/20 19:07:27 grubba Exp $"); +RCSID("$Id: object.c,v 1.216 2003/01/11 00:01:20 mast Exp $"); #include "object.h" #include "dynamic_buffer.h" #include "interpret.h" @@ -1723,9 +1723,10 @@ void gc_zap_ext_weak_refs_in_objects(void) discard_queue(&gc_mark_queue); } -void gc_free_all_unreferenced_objects(void) +size_t gc_free_all_unreferenced_objects(void) { struct object *o,*next; + size_t freed = 0; for(o=gc_internal_object; o; o=next) { @@ -1742,10 +1743,13 @@ void gc_free_all_unreferenced_objects(void) gc_free_extra_ref(o); SET_NEXT_AND_FREE(o,free_object); + freed++; }else{ next=o->next; } } + + return freed; } struct magic_index_struct diff --git a/src/object.h b/src/object.h index 80c8b4d535..906b355737 100644 --- a/src/object.h +++ b/src/object.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: object.h,v 1.75 2002/11/24 22:47:06 mast Exp $ +|| $Id: object.h,v 1.76 2003/01/11 00:01:20 mast Exp $ */ #ifndef OBJECT_H @@ -109,7 +109,7 @@ void gc_check_all_objects(void); void gc_mark_all_objects(void); void gc_cycle_check_all_objects(void); void gc_zap_ext_weak_refs_in_objects(void); -void gc_free_all_unreferenced_objects(void); +size_t gc_free_all_unreferenced_objects(void); struct magic_index_struct; void push_magic_index(struct program *type, int inherit_no, int parent_level); void init_object(void); diff --git a/src/program.c b/src/program.c index 636da5d2a0..3670bb466e 100644 --- a/src/program.c +++ b/src/program.c @@ -2,11 +2,11 @@ || 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: program.c,v 1.471 2003/01/09 18:59:00 grubba Exp $ +|| $Id: program.c,v 1.472 2003/01/11 00:01:20 mast Exp $ */ #include "global.h" -RCSID("$Id: program.c,v 1.471 2003/01/09 18:59:00 grubba Exp $"); +RCSID("$Id: program.c,v 1.472 2003/01/11 00:01:20 mast Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -6234,7 +6234,7 @@ static void gc_recurse_trampoline(struct object *o) } -/* This placeholder should is used +/* This placeholder should be used * in the first compiler pass to take the place * of unknown things */ @@ -6568,9 +6568,10 @@ void gc_zap_ext_weak_refs_in_programs(void) discard_queue(&gc_mark_queue); } -void gc_free_all_unreferenced_programs(void) +size_t gc_free_all_unreferenced_programs(void) { struct program *p,*next; + size_t freed = 0; #ifdef PIKE_DEBUG int first = 1; #endif @@ -6610,6 +6611,7 @@ void gc_free_all_unreferenced_programs(void) gc_free_extra_ref(p); SET_NEXT_AND_FREE(p, free_program); + freed++; #ifdef PIKE_DEBUG if (first) gc_internal_program = next; #endif @@ -6636,6 +6638,8 @@ void gc_free_all_unreferenced_programs(void) gc_fatal(p, 1 ,"garbage collector failed to free program!!!\n"); } #endif + + return freed; } #endif /* GC2 */ diff --git a/src/program.h b/src/program.h index 6c051149b0..c547580df5 100644 --- a/src/program.h +++ b/src/program.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: program.h,v 1.171 2002/12/16 14:32:21 grubba Exp $ +|| $Id: program.h,v 1.172 2003/01/11 00:01:21 mast Exp $ */ #ifndef PROGRAM_H @@ -630,7 +630,7 @@ void gc_check_all_programs(void); void gc_mark_all_programs(void); void gc_cycle_check_all_programs(void); void gc_zap_ext_weak_refs_in_programs(void); -void gc_free_all_unreferenced_programs(void); +size_t gc_free_all_unreferenced_programs(void); void push_compiler_frame(int lexical_scope); void low_pop_local_variables(int level); void pop_local_variables(int level); -- GitLab