Mercurial > hg > xemacs-beta
comparison src/gc.h @ 3092:141c2920ea48
[xemacs-hg @ 2005-11-25 01:41:31 by crestani]
Incremental Garbage Collector
author | crestani |
---|---|
date | Fri, 25 Nov 2005 01:42:08 +0000 |
parents | |
children | d674024a8674 |
comparison
equal
deleted
inserted
replaced
3091:c22d8984148c | 3092:141c2920ea48 |
---|---|
1 /* New incremental garbage collector for XEmacs. | |
2 Copyright (C) 2005 Marcus Crestani. | |
3 | |
4 This file is part of XEmacs. | |
5 | |
6 XEmacs is free software; you can redistribute it and/or modify it | |
7 under the terms of the GNU General Public License as published by the | |
8 Free Software Foundation; either version 2, or (at your option) any | |
9 later version. | |
10 | |
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with XEmacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 Boston, MA 02111-1307, USA. */ | |
20 | |
21 /* Synched up with: Not in FSF. */ | |
22 | |
23 #ifndef INCLUDED_gc_h_ | |
24 #define INCLUDED_gc_h_ | |
25 | |
26 BEGIN_C_DECLS | |
27 | |
28 | |
29 #ifdef NEW_GC | |
30 /************************************************************************/ | |
31 /* Incremental Statistics */ | |
32 /************************************************************************/ | |
33 #ifdef ERROR_CHECK_GC | |
34 void gc_stat_print_stats (void); | |
35 void gc_stat_finalized (void); | |
36 void gc_stat_freed (void); | |
37 void gc_stat_explicitly_freed (void); | |
38 void gc_stat_explicitly_tried_freed (void); | |
39 # define GC_STAT_FINALIZED gc_stat_finalized () | |
40 # define GC_STAT_FREED gc_stat_freed () | |
41 # define GC_STAT_EXPLICITLY_FREED gc_stat_explicitly_freed () | |
42 # define GC_STAT_EXPLICITLY_TRIED_FREED gc_stat_explicitly_tried_freed () | |
43 #else /* not ERROR_CHECK_GC */ | |
44 # define GC_STAT_FINALIZED | |
45 # define GC_STAT_FREED | |
46 # define GC_STAT_EXPLICITLY_FREED | |
47 # define GC_STAT_EXPLICITLY_TRIED_FREED | |
48 #endif /* not ERROR_CHECK_GC */ | |
49 #endif /* not NEW_GC */ | |
50 | |
51 | |
52 /************************************************************************/ | |
53 /* Global Variables */ | |
54 /************************************************************************/ | |
55 /* Number of bytes of consing done since the last GC. */ | |
56 extern EMACS_INT consing_since_gc; | |
57 | |
58 /* Number of bytes of consing done since startup. */ | |
59 extern EMACS_UINT total_consing; | |
60 | |
61 /* Number of bytes of current allocated heap objects. */ | |
62 extern EMACS_INT total_gc_usage; | |
63 | |
64 /* If the above is set. */ | |
65 extern int total_gc_usage_set; | |
66 | |
67 /* Number of bytes of consing since gc before another gc should be done. */ | |
68 extern EMACS_INT gc_cons_threshold; | |
69 | |
70 /* Percentage of consing of total data size before another GC. */ | |
71 extern EMACS_INT gc_cons_percentage; | |
72 | |
73 #ifdef NEW_GC | |
74 /* Number of bytes of consing since gc before another cycle of the gc | |
75 should be done in incremental mode. */ | |
76 extern EMACS_INT gc_cons_incremental_threshold; | |
77 | |
78 /* Nonzero during gc */ | |
79 extern int gc_in_progress; | |
80 | |
81 /* Nonzero during write barrier */ | |
82 extern int write_barrier_enabled; | |
83 | |
84 /* Enable/disable incremental garbage collection during runtime. */ | |
85 extern int allow_incremental_gc; | |
86 #endif /* NEW_GC */ | |
87 | |
88 | |
89 /************************************************************************/ | |
90 /* Prototypes */ | |
91 /************************************************************************/ | |
92 | |
93 #ifndef MALLOC_OVERHEAD | |
94 #ifdef GNU_MALLOC | |
95 #define MALLOC_OVERHEAD 0 | |
96 #elif defined (rcheck) | |
97 #define MALLOC_OVERHEAD 20 | |
98 #else | |
99 #define MALLOC_OVERHEAD 8 | |
100 #endif | |
101 #endif /* MALLOC_OVERHEAD */ | |
102 | |
103 #ifdef ERROR_CHECK_GC | |
104 #define GC_CHECK_LHEADER_INVARIANTS(lheader) do { \ | |
105 struct lrecord_header * GCLI_lh = (lheader); \ | |
106 assert (GCLI_lh != 0); \ | |
107 assert (GCLI_lh->type < (unsigned int) lrecord_type_count); \ | |
108 } while (0) | |
109 #else | |
110 #define GC_CHECK_LHEADER_INVARIANTS(lheader) | |
111 #endif | |
112 | |
113 void recompute_need_to_garbage_collect (void); | |
114 | |
115 | |
116 /* KKCC mark algorithm. */ | |
117 #ifdef DEBUG_XEMACS | |
118 void kkcc_gc_stack_push_lisp_object_1 (Lisp_Object obj, int level, int pos); | |
119 #define kkcc_gc_stack_push_lisp_object(obj, level, pos) \ | |
120 kkcc_gc_stack_push_lisp_object_1 (obj, level, pos) | |
121 void kkcc_gc_stack_repush_dirty_object_1 (Lisp_Object obj, int level, int pos); | |
122 #define kkcc_gc_stack_repush_dirty_object(obj) \ | |
123 kkcc_gc_stack_repush_dirty_object_1 (obj, 0, -2) | |
124 void kkcc_backtrace (void); | |
125 #else | |
126 void kkcc_gc_stack_push_lisp_object_1 (Lisp_Object obj); | |
127 #define kkcc_gc_stack_push_lisp_object(obj, level, pos) \ | |
128 kkcc_gc_stack_push_lisp_object_1 (obj) | |
129 void kkcc_gc_stack_repush_dirty_object_1 (Lisp_Object obj); | |
130 #define kkcc_gc_stack_repush_dirty_object(obj) \ | |
131 kkcc_gc_stack_repush_dirty_object_1 (obj) | |
132 #define kkcc_backtrace() | |
133 #endif | |
134 | |
135 #ifdef NEW_GC | |
136 | |
137 /* Repush objects that are caught by the write barrier. */ | |
138 #define gc_write_barrier(obj) kkcc_gc_stack_repush_dirty_object (obj); | |
139 | |
140 | |
141 /* GC functions: */ | |
142 | |
143 /* Perform a full garbage collection without interruption. If an | |
144 incremental garbage collection is already running it is completed | |
145 without further interruption. This function calls gc() with a | |
146 negative or zero argument. */ | |
147 void gc_full (void); | |
148 | |
149 /* This function starts an incremental garbage collection. If an | |
150 incremental garbage collection is already running, the next cycle | |
151 of traversal work is done, or the garbage collection is completed | |
152 when no more traversal work has to be done. This function calls gc | |
153 with a positive argument, indicating how many objects can be | |
154 traversed in this cycle. */ | |
155 void gc_incremental (void); | |
156 #endif /* NEW_GC */ | |
157 | |
158 /* Initializers */ | |
159 void init_gc_early (void); | |
160 void reinit_gc_early (void); | |
161 void init_gc_once_early (void); | |
162 | |
163 void syms_of_gc (void); | |
164 void vars_of_gc (void); | |
165 void complex_vars_of_gc (void); | |
166 | |
167 #ifndef NEW_GC | |
168 /* Needed prototypes due to the garbage collector code move from | |
169 alloc.c to gc.c. */ | |
170 void gc_sweep_1 (void); | |
171 | |
172 #ifndef MC_ALLOC | |
173 extern void *breathing_space; | |
174 #endif /* not MC_ALLOC */ | |
175 #endif /* not NEW_GC */ | |
176 | |
177 END_C_DECLS | |
178 | |
179 #endif /* INCLUDED_gc_h_ */ |