diff --git a/src/array.c b/src/array.c index 1403f16e7346546b2bb268a4a088a98a4bef318d..5057bda103c0645dc7184a667141e7b0990325ba 100644 --- a/src/array.c +++ b/src/array.c @@ -1447,7 +1447,6 @@ void check_all_arrays(void) } #endif /* DEBUG */ -#ifdef GC2 void gc_mark_array_as_referenced(struct array *a) { @@ -1524,8 +1523,6 @@ void gc_free_all_unreferenced_arrays(void) } -#endif /* GC2 */ - #ifdef DEBUG void debug_dump_type_field(TYPE_FIELD t) diff --git a/src/builtin_functions.c b/src/builtin_functions.c index bde56ec17407773dda3d765c547b7633a7b56680..624c3bc4785c8fbcc62308bb9174c06c30017311 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: builtin_functions.c,v 1.55 1997/11/07 05:36:02 grubba Exp $"); +RCSID("$Id: builtin_functions.c,v 1.56 1997/11/08 01:34:36 hubbe Exp $"); #include "interpret.h" #include "svalue.h" #include "pike_macros.h" @@ -1216,7 +1216,6 @@ void f_sleep(INT32 args) } } -#ifdef GC2 void f_gc(INT32 args) { INT32 tmp; @@ -1225,7 +1224,6 @@ void f_gc(INT32 args) do_gc(); push_int(tmp - num_objects); } -#endif #ifdef TYPEP #undef TYPEP @@ -1891,9 +1889,7 @@ void init_builtin_efuns(void) #endif add_efun("_memory_usage",f__memory_usage,"function(:mapping(string:int))",OPT_EXTERNAL_DEPEND); -#ifdef GC2 add_efun("gc",f_gc,"function(:int)",OPT_SIDE_EFFECT); -#endif add_efun("version", f_version, "function(:string)", OPT_TRY_OPTIMIZE); add_efun("encode_value", f_encode_value, "function(mixed:string)", OPT_TRY_OPTIMIZE); diff --git a/src/gc.c b/src/gc.c index fe144f34c50dd5560f5c59b0fed14a72091ea9ee..647b25ee4d2319d355b1caf60d11bdfd66f898e9 100644 --- a/src/gc.c +++ b/src/gc.c @@ -6,8 +6,6 @@ #include "global.h" -#ifdef GC2 - struct callback *gc_evaluator_callback=0; #include "array.h" @@ -163,11 +161,12 @@ TYPE_T attempt_to_identify(void *something) static void *check_for =0; static char *found_where=""; static void *found_in=0; -static TYPE_T found_in_type=0; +static int found_in_type=0; void *gc_svalue_location=0; void describe_location(void *memblock, TYPE_T type, void *location) { + if(!location) return; fprintf(stderr,"**Location of (short) svalue: %p\n",location); if(type==T_OBJECT) { @@ -206,11 +205,20 @@ void describe_location(void *memblock, TYPE_T type, void *location) static void gdb_gc_stop_here(void *a) { - fprintf(stderr,"**One ref found%s.\n",found_where); + fprintf(stderr,"***One ref found%s.\n",found_where); describe_something(found_in, found_in_type); describe_location(found_in, found_in_type, gc_svalue_location); } +void debug_gc_xmark_svalues(struct svalue *s, int num, char *fromwhere) +{ + found_in=(void *)fromwhere; + found_in_type=-1; + gc_xmark_svalues(s,num); + found_in_type=T_UNKNOWN; + found_in=0; +} + TYPE_FIELD debug_gc_check_svalues(struct svalue *s, int num, TYPE_T t, void *data) { TYPE_FIELD ret; @@ -218,6 +226,7 @@ TYPE_FIELD debug_gc_check_svalues(struct svalue *s, int num, TYPE_T t, void *dat found_in_type=t; ret=gc_check_svalues(s,num); found_in_type=T_UNKNOWN; + found_in=0; return ret; } @@ -227,12 +236,19 @@ void debug_gc_check_short_svalue(union anything *u, TYPE_T type, TYPE_T t, void found_in_type=t; gc_check_short_svalue(u,type); found_in_type=T_UNKNOWN; + found_in=0; } -void describe_something(void *a, TYPE_T t) +void describe_something(void *a, int t) { struct program *p=(struct program *)a; if(!a) return; + if(t==-1) + { + fprintf(stderr,"**Location description: %s\n",(char *)a); + return; + } + fprintf(stderr,"**Location: %p Type: %s Refs: %d\n",a, get_name_of_type(t), *(INT32 *)a); @@ -544,5 +560,4 @@ void do_gc(void) in_gc=0; } -#endif diff --git a/src/gc.h b/src/gc.h index e6b72e8e4c1ca7c3503744ced21c2a4028aa430d..c0c41548ca676bc56fc4af76a8b8c4155eec3f22 100644 --- a/src/gc.h +++ b/src/gc.h @@ -1,8 +1,6 @@ #ifndef GC_H #define GC_H -#ifdef GC2 - #include "global.h" #include "callback.h" @@ -24,24 +22,19 @@ extern void *gc_svalue_location; #define GC_ALLOC() do{ num_objects++; num_allocs++; if(num_allocs == alloc_threshold && !gc_evaluator_callback) ADD_GC_CALLBACK(); } while(0) #endif -#ifdef DEBUG -#define GC_FREE() do { num_objects-- ; if(num_objects < 0) fatal("Panic!! less than zero objects!\n"); }while(0) -#else -#define debug_gc_check_svalues(S,N,T,V) gc_check_svalues(S,N) -#define debug_gc_check_short_svalue(S,N,T,V) gc_check_short_svalues(S,N) -#define GC_FREE() do { num_objects-- ; }while(0) -#endif - /* Prototypes begin here */ struct callback *add_gc_callback(callback_func call, void *arg, callback_func free_func); struct marker; struct marker_chunk; +void dump_gc_info(void); TYPE_T attempt_to_identify(void *something); +void describe_location(void *memblock, TYPE_T type, void *location); +void debug_gc_xmark_svalues(struct svalue *s, int num, char *fromwhere); TYPE_FIELD debug_gc_check_svalues(struct svalue *s, int num, TYPE_T t, void *data); void debug_gc_check_short_svalue(union anything *u, TYPE_T type, TYPE_T t, void *data); -void describe_something(void *a, TYPE_T t); +void describe_something(void *a, int t); INT32 gc_check(void *a); int gc_is_referenced(void *a); int gc_external_mark(void *a); @@ -50,11 +43,14 @@ int gc_do_free(void *a); void do_gc(void); /* Prototypes end here */ +#ifdef DEBUG +#define GC_FREE() do { num_objects-- ; if(num_objects < 0) fatal("Panic!! less than zero objects!\n"); }while(0) #else +#define debug_gc_check_svalues(S,N,T,V) gc_check_svalues(S,N) +#define debug_gc_check_short_svalue(S,N,T,V) gc_check_short_svalues(S,N) +#define debug_gc_xmark_svalue(S,N,X) gc_xmark_svalue(S,N) +#define GC_FREE() do { num_objects-- ; }while(0) +#endif -#define GC_ALLOC() -#define GC_FREE() -#define do_gc() #endif -#endif diff --git a/src/interpret.c b/src/interpret.c index 09bbffb1cc932052c97eecf0e24837ae00e60fe9..e773afe4bae6932d41bca2b5f3d067bb6304af61 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: interpret.c,v 1.54 1997/11/01 21:57:49 grubba Exp $"); +RCSID("$Id: interpret.c,v 1.55 1997/11/08 01:34:38 hubbe Exp $"); #include "interpret.h" #include "object.h" #include "program.h" @@ -87,7 +87,7 @@ struct frame *fp; /* frame pointer */ #ifdef DEBUG static void gc_check_stack_callback(struct callback *foo, void *bar, void *gazonk) { - gc_xmark_svalues(evaluator_stack,sp-evaluator_stack-1); + debug_gc_xmark_svalues(evaluator_stack,sp-evaluator_stack-1,"interpreter stack"); } #endif @@ -1140,7 +1140,7 @@ static void eval_instruction(unsigned char *pc) } do_return: -#if defined(DEBUG) && defined(GC2) +#ifdef DEBUG if(d_flag > 2) do_gc(); #endif diff --git a/src/lex.c b/src/lex.c index f189edcf6570928029401684476bd6454450e4cc..0cb7b442866ae0209331074fe75ce89109ed592b 100644 --- a/src/lex.c +++ b/src/lex.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: lex.c,v 1.29 1997/10/27 09:59:22 hubbe Exp $"); +RCSID("$Id: lex.c,v 1.30 1997/11/08 01:34:40 hubbe Exp $"); #include "language.h" #include "array.h" #include "lex.h" @@ -1088,7 +1088,7 @@ static int char_const(void) break; case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - c=GETC()-'a'+10; + c=GETC()-'A'+10; break; } switch(LOOK()) diff --git a/src/main.c b/src/main.c index 125772fdce39eaa28e877def39d699a7fbef98c1..637eec9d645c88177972bd7793455ed40ab71e7e 100644 --- a/src/main.c +++ b/src/main.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: main.c,v 1.26 1997/11/02 17:19:50 grubba Exp $"); +RCSID("$Id: main.c,v 1.27 1997/11/08 01:34:40 hubbe Exp $"); #include "backend.h" #include "module.h" #include "object.h" @@ -297,9 +297,7 @@ void low_exit_main(void) cleanup_pike_types(); cleanup_program(); -#ifdef GC2 do_gc(); -#endif cleanup_callbacks(); zap_all_arrays(); diff --git a/src/mapping.c b/src/mapping.c index a3f6cc7dcc08626a1a1a8e9695846a1d455e128a..b0663a51a7fe546e9417e8c304e3ee4babaf57ed 100644 --- a/src/mapping.c +++ b/src/mapping.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: mapping.c,v 1.23 1997/10/16 06:34:26 hubbe Exp $"); +RCSID("$Id: mapping.c,v 1.24 1997/11/08 01:34:41 hubbe Exp $"); #include "main.h" #include "object.h" #include "mapping.h" @@ -948,8 +948,6 @@ void check_all_mappings(void) #endif -#ifdef GC2 - void gc_mark_mapping_as_referenced(struct mapping *m) { INT32 e; @@ -1057,8 +1055,6 @@ void gc_free_all_unreferenced_mappings(void) } } -#endif /* GC2 */ - void zap_all_mappings(void) { INT32 e; diff --git a/src/modules/files/file.c b/src/modules/files/file.c index e1bd38b4fa51946f45ac4ad697d57a1059fa2a5a..c2f2a37faafee755d08058e6a66de97ba135036b 100644 --- a/src/modules/files/file.c +++ b/src/modules/files/file.c @@ -6,7 +6,7 @@ #define READ_BUFFER 8192 #include "global.h" -RCSID("$Id: file.c,v 1.60 1997/11/07 19:42:21 grubba Exp $"); +RCSID("$Id: file.c,v 1.61 1997/11/08 01:35:41 hubbe Exp $"); #include "interpret.h" #include "svalue.h" #include "stralloc.h" @@ -1536,8 +1536,8 @@ void mark_ids(struct callback *foo, void *bar, void *gazonk) gc_check_svalues( & files[e].close_callback, 1); }else{ #ifdef DEBUG - gc_xmark_svalues( & files[e].read_callback, 1); - gc_xmark_svalues( & files[e].close_callback, 1); + debug_gc_xmark_svalues( & files[e].read_callback, 1, "File->read_callback"); + debug_gc_xmark_svalues( & files[e].close_callback, 1, "File->close_callback"); #endif tmp=0; } @@ -1547,7 +1547,7 @@ void mark_ids(struct callback *foo, void *bar, void *gazonk) gc_check_svalues( & files[e].write_callback, 1); }else{ #ifdef DEBUG - gc_xmark_svalues( & files[e].write_callback, 1); + debug_gc_xmark_svalues( & files[e].write_callback, 1, "File->write_callback"); #endif tmp=0; } @@ -1559,7 +1559,7 @@ void mark_ids(struct callback *foo, void *bar, void *gazonk) #ifdef DEBUG else { - gc_xmark_svalues( & files[e].id, 1); + debug_gc_xmark_svalues( & files[e].id, 1, "File->id"); } #endif } diff --git a/src/multiset.c b/src/multiset.c index 7e595ca723b32f033bb6ab98a92381cbabb416c2..2ff4603447ccc707a48e991833f76c8ba1b7c1e2 100644 --- a/src/multiset.c +++ b/src/multiset.c @@ -263,8 +263,6 @@ struct multiset *copy_multiset_recursively(struct multiset *l, } -#ifdef GC2 - void gc_mark_multiset_as_referenced(struct multiset *l) { if(gc_mark(l)) @@ -306,8 +304,6 @@ void gc_free_all_unreferenced_multisets(void) } } -#endif /* GC2 */ - void count_memory_in_multisets(INT32 *num_, INT32 *size_) { struct multiset *m; diff --git a/src/object.c b/src/object.c index b194772b14b4c0c820cfadb419fd5e35c25e7a40..ee5160f98c1ff1689d595c9913c2743fe68fbdc4 100644 --- a/src/object.c +++ b/src/object.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: object.c,v 1.28 1997/10/29 11:23:25 hubbe Exp $"); +RCSID("$Id: object.c,v 1.29 1997/11/08 01:34:42 hubbe Exp $"); #include "object.h" #include "dynamic_buffer.h" #include "interpret.h" @@ -779,8 +779,6 @@ struct array *object_values(struct object *o) return a; } -#ifdef GC2 - void gc_mark_object_as_referenced(struct object *o) { @@ -898,8 +896,6 @@ void gc_free_all_unreferenced_objects(void) } } -#endif /* GC2 */ - void count_memory_in_objects(INT32 *num_, INT32 *size_) { INT32 num=0, size=0; diff --git a/src/program.c b/src/program.c index 2ccd50f67a45a3bf24adb846a08052fd36a73194..791f3ddfe33786f189b8771648fcb476f89d4f17 100644 --- a/src/program.c +++ b/src/program.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: program.c,v 1.45 1997/10/17 02:31:41 hubbe Exp $"); +RCSID("$Id: program.c,v 1.46 1997/11/08 01:34:43 hubbe Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -1770,8 +1770,6 @@ void cleanup_program(void) #endif } -#ifdef GC2 - void gc_mark_program_as_referenced(struct program *p) { if(gc_mark(p)) @@ -1828,8 +1826,6 @@ void gc_free_all_unreferenced_programs(void) } } -#endif /* GC2 */ - void count_memory_in_programs(INT32 *num_, INT32 *size_) { diff --git a/src/stralloc.c b/src/stralloc.c index c126a6005b1f9ca921718a6124a299ad1c73975b..431288ae96a043190d2e85980c93dd6fc4e236ad 100644 --- a/src/stralloc.c +++ b/src/stralloc.c @@ -621,8 +621,6 @@ void count_memory_in_strings(INT32 *num, INT32 *size) size[0]=size_; } -#ifdef GC2 - void gc_mark_all_strings(void) { unsigned INT32 e; @@ -633,4 +631,3 @@ void gc_mark_all_strings(void) for(p=base_table[e];p;p=p->next) gc_is_referenced(p); } } -#endif diff --git a/src/svalue.c b/src/svalue.c index 66de470211f98a9020ba6f49080bb00fe30f54f9..940d406be5628d33e7e415b28987d1ae8b968efd 100644 --- a/src/svalue.c +++ b/src/svalue.c @@ -844,7 +844,6 @@ void check_svalue(struct svalue *s) #endif -#ifdef GC2 TYPE_FIELD gc_check_svalues(struct svalue *s, int num) { INT32 e; @@ -900,6 +899,10 @@ TYPE_FIELD gc_check_svalues(struct svalue *s, int num) f|= 1 << s->type; } +#ifdef DEBUG + gc_svalue_location=0; +#endif + return f; } @@ -916,10 +919,17 @@ void gc_xmark_svalues(struct svalue *s, int num) { check_type(s->type); check_refs(s); + +#ifdef DEBUG + gc_svalue_location=(void *)s; +#endif if(s->type <= MAX_REF_TYPE) gc_external_mark(s->u.refs); } +#ifdef DEBUG + gc_svalue_location=0; +#endif } #endif @@ -953,6 +963,9 @@ void gc_check_short_svalue(union anything *u, TYPE_T type) gc_check(u->refs); break; } +#ifdef DEBUG + gc_svalue_location=0; +#endif } void gc_mark_svalues(struct svalue *s, int num) @@ -1005,7 +1018,6 @@ void gc_mark_short_svalue(union anything *u, TYPE_T type) break; } } -#endif /* GC2 */ INT32 pike_sizeof(struct svalue *s) { diff --git a/src/threads.c b/src/threads.c index 4b197a33575b6571fd5b69c53bb34fa11d737829..b52bb23f3c3bafafea2fe2fb2c3914f243388bcf 100644 --- a/src/threads.c +++ b/src/threads.c @@ -1,5 +1,5 @@ #include "global.h" -RCSID("$Id: threads.c,v 1.45 1997/10/16 06:34:28 hubbe Exp $"); +RCSID("$Id: threads.c,v 1.46 1997/11/08 01:34:45 hubbe Exp $"); int num_threads = 1; int threads_disabled = 0; @@ -405,7 +405,7 @@ static void thread_was_marked(struct object *o) struct thread_state *tmp=(struct thread_state *)(o->storage); if(tmp->swapped) { - gc_xmark_svalues(tmp->evaluator_stack,tmp->sp-tmp->evaluator_stack-1); + debug_gc_xmark_svalues(tmp->evaluator_stack,tmp->sp-tmp->evaluator_stack-1,"idle thread stack"); } } #endif