Mercurial > hg > xemacs-beta
comparison src/alloc.c @ 1643:763f577d57b0
[xemacs-hg @ 2003-08-25 20:53:58 by crestani]
2003-08-25 Marcus Crestani <crestani@informatik.uni-tuebingen.de>
* alloc.c (kkcc_gc_stack_init):
(kkcc_gc_stack_free):
(kkcc_gc_stack_realloc):
(kkcc_gc_stack_full):
(kkcc_gc_stack_empty):
(kkcc_gc_stack_push):
(kkcc_gc_stack_pop): Remove kkcc_gc_stack_count.
(mark_object_maybe_checking_free): Push on stack instead of marking.
(garbage_collect_1): Invoke kkcc_marking after finish_marking_*.
author | crestani |
---|---|
date | Mon, 25 Aug 2003 20:53:59 +0000 |
parents | 750821e2c014 |
children | a72f7bf813c9 |
comparison
equal
deleted
inserted
replaced
1642:793259f54fc4 | 1643:763f577d57b0 |
---|---|
2960 const struct memory_description *desc; | 2960 const struct memory_description *desc; |
2961 } kkcc_gc_stack_entry; | 2961 } kkcc_gc_stack_entry; |
2962 | 2962 |
2963 static kkcc_gc_stack_entry *kkcc_gc_stack_ptr; | 2963 static kkcc_gc_stack_entry *kkcc_gc_stack_ptr; |
2964 static kkcc_gc_stack_entry *kkcc_gc_stack_top; | 2964 static kkcc_gc_stack_entry *kkcc_gc_stack_top; |
2965 static kkcc_gc_stack_entry *kkcc_gc_stack_last_entry; | |
2965 static int kkcc_gc_stack_size; | 2966 static int kkcc_gc_stack_size; |
2966 static int kkcc_gc_stack_count; | |
2967 | 2967 |
2968 static void | 2968 static void |
2969 kkcc_gc_stack_init (void) | 2969 kkcc_gc_stack_init (void) |
2970 { | 2970 { |
2971 kkcc_gc_stack_size = KKCC_INIT_GC_STACK_SIZE; | 2971 kkcc_gc_stack_size = KKCC_INIT_GC_STACK_SIZE; |
2975 { | 2975 { |
2976 stderr_out ("stack init failed for size %d\n", kkcc_gc_stack_size); | 2976 stderr_out ("stack init failed for size %d\n", kkcc_gc_stack_size); |
2977 exit(23); | 2977 exit(23); |
2978 } | 2978 } |
2979 kkcc_gc_stack_top = kkcc_gc_stack_ptr - 1; | 2979 kkcc_gc_stack_top = kkcc_gc_stack_ptr - 1; |
2980 kkcc_gc_stack_count = 0; | 2980 kkcc_gc_stack_last_entry = kkcc_gc_stack_ptr + kkcc_gc_stack_size - 1; |
2981 } | 2981 } |
2982 | 2982 |
2983 static void | 2983 static void |
2984 kkcc_gc_stack_free (void) | 2984 kkcc_gc_stack_free (void) |
2985 { | 2985 { |
2990 } | 2990 } |
2991 | 2991 |
2992 static void | 2992 static void |
2993 kkcc_gc_stack_realloc (void) | 2993 kkcc_gc_stack_realloc (void) |
2994 { | 2994 { |
2995 int current_offset = (int)(kkcc_gc_stack_top - kkcc_gc_stack_ptr); | |
2995 kkcc_gc_stack_size *= 2; | 2996 kkcc_gc_stack_size *= 2; |
2996 kkcc_gc_stack_ptr = (kkcc_gc_stack_entry *) | 2997 kkcc_gc_stack_ptr = (kkcc_gc_stack_entry *) |
2997 realloc (kkcc_gc_stack_ptr, | 2998 realloc (kkcc_gc_stack_ptr, |
2998 kkcc_gc_stack_size * sizeof (kkcc_gc_stack_entry)); | 2999 kkcc_gc_stack_size * sizeof (kkcc_gc_stack_entry)); |
2999 if (!kkcc_gc_stack_ptr) | 3000 if (!kkcc_gc_stack_ptr) |
3000 { | 3001 { |
3001 stderr_out ("stack realloc failed for size %d\n", kkcc_gc_stack_size); | 3002 stderr_out ("stack realloc failed for size %d\n", kkcc_gc_stack_size); |
3002 exit(23); | 3003 exit(23); |
3003 } | 3004 } |
3004 kkcc_gc_stack_top = kkcc_gc_stack_ptr + kkcc_gc_stack_count - 1; | 3005 kkcc_gc_stack_top = kkcc_gc_stack_ptr + current_offset; |
3006 kkcc_gc_stack_last_entry = kkcc_gc_stack_ptr + kkcc_gc_stack_size - 1; | |
3005 } | 3007 } |
3006 | 3008 |
3007 static int | 3009 static int |
3008 kkcc_gc_stack_full (void) | 3010 kkcc_gc_stack_full (void) |
3009 { | 3011 { |
3010 if (kkcc_gc_stack_count > (kkcc_gc_stack_size - 1)) | 3012 if (kkcc_gc_stack_top >= kkcc_gc_stack_last_entry) |
3011 return 1; | 3013 return 1; |
3012 return 0; | 3014 return 0; |
3013 } | 3015 } |
3014 | 3016 |
3015 static int | 3017 static int |
3016 kkcc_gc_stack_empty (void) | 3018 kkcc_gc_stack_empty (void) |
3017 { | 3019 { |
3018 if (kkcc_gc_stack_count == 0) | 3020 if (kkcc_gc_stack_top < kkcc_gc_stack_ptr) |
3019 return 1; | 3021 return 1; |
3020 return 0; | 3022 return 0; |
3021 } | 3023 } |
3022 | 3024 |
3023 static void | 3025 static void |
3024 kkcc_gc_stack_push (void *data, const struct memory_description *desc) | 3026 kkcc_gc_stack_push (void *data, const struct memory_description *desc) |
3025 { | 3027 { |
3026 if (kkcc_gc_stack_full ()) | 3028 if (kkcc_gc_stack_full ()) |
3027 kkcc_gc_stack_realloc(); | 3029 kkcc_gc_stack_realloc(); |
3028 | |
3029 kkcc_gc_stack_top++; | 3030 kkcc_gc_stack_top++; |
3030 kkcc_gc_stack_count++; | |
3031 kkcc_gc_stack_top->data = data; | 3031 kkcc_gc_stack_top->data = data; |
3032 kkcc_gc_stack_top->desc = desc; | 3032 kkcc_gc_stack_top->desc = desc; |
3033 } | 3033 } |
3034 | 3034 |
3035 static kkcc_gc_stack_entry * | 3035 static kkcc_gc_stack_entry * |
3036 kkcc_gc_stack_pop (void) //void *data, const struct memory_description *desc) | 3036 kkcc_gc_stack_pop (void) //void *data, const struct memory_description *desc) |
3037 { | 3037 { |
3038 if (kkcc_gc_stack_empty ()) | 3038 if (kkcc_gc_stack_empty ()) |
3039 return 0; | 3039 return 0; |
3040 | |
3041 kkcc_gc_stack_top--; | 3040 kkcc_gc_stack_top--; |
3042 kkcc_gc_stack_count--; | |
3043 | |
3044 return kkcc_gc_stack_top + 1; | 3041 return kkcc_gc_stack_top + 1; |
3045 } | 3042 } |
3046 | 3043 |
3047 void | 3044 void |
3048 kkcc_gc_stack_push_lisp_object (Lisp_Object obj) | 3045 kkcc_gc_stack_push_lisp_object (Lisp_Object obj) |
3327 #else /* NOT USE_KKCC */ | 3324 #else /* NOT USE_KKCC */ |
3328 mark_object (obj); | 3325 mark_object (obj); |
3329 #endif /* NOT USE_KKCC */ | 3326 #endif /* NOT USE_KKCC */ |
3330 } | 3327 } |
3331 #else | 3328 #else |
3332 #define mark_object_maybe_checking_free(obj, allow_free) mark_object (obj) | 3329 #define mark_object_maybe_checking_free(obj, allow_free) \ |
3330 kkcc_gc_stack_push_lisp_object (obj) | |
3333 #endif /* ERROR_CHECK_GC */ | 3331 #endif /* ERROR_CHECK_GC */ |
3334 | 3332 |
3335 | 3333 |
3336 /* This function loops all elements of a struct pointer and calls | 3334 /* This function loops all elements of a struct pointer and calls |
3337 mark_with_description with each element. */ | 3335 mark_with_description with each element. */ |
4704 continue_marking_ephemerons () > 0) | 4702 continue_marking_ephemerons () > 0) |
4705 ; | 4703 ; |
4706 | 4704 |
4707 #ifdef USE_KKCC | 4705 #ifdef USE_KKCC |
4708 kkcc_marking (); | 4706 kkcc_marking (); |
4709 kkcc_gc_stack_free (); | |
4710 #endif /* USE_KKCC */ | 4707 #endif /* USE_KKCC */ |
4711 | 4708 |
4712 /* At this point, we know which objects need to be finalized: we | 4709 /* At this point, we know which objects need to be finalized: we |
4713 still need to resurrect them */ | 4710 still need to resurrect them */ |
4714 | 4711 |
4715 while (finish_marking_ephemerons () > 0 || | 4712 while (finish_marking_ephemerons () > 0 || |
4716 finish_marking_weak_lists () > 0 || | 4713 finish_marking_weak_lists () > 0 || |
4717 finish_marking_weak_hash_tables () > 0) | 4714 finish_marking_weak_hash_tables () > 0) |
4718 ; | 4715 ; |
4716 | |
4717 #ifdef USE_KKCC | |
4718 kkcc_marking (); | |
4719 kkcc_gc_stack_free (); | |
4720 #endif /* USE_KKCC */ | |
4719 | 4721 |
4720 /* And prune (this needs to be called after everything else has been | 4722 /* And prune (this needs to be called after everything else has been |
4721 marked and before we do any sweeping). */ | 4723 marked and before we do any sweeping). */ |
4722 /* #### this is somewhat ad-hoc and should probably be an object | 4724 /* #### this is somewhat ad-hoc and should probably be an object |
4723 method */ | 4725 method */ |