00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GCC_GGC_H
00023 #define GCC_GGC_H
00024 #include "statistics.h"
00025
00026
00027
00028
00029
00030 extern const char empty_string[];
00031 extern const char digit_vector[];
00032 #define digit_string(d) (digit_vector + ((d) * 2))
00033
00034
00035
00036
00037
00038 typedef void (*gt_pointer_operator) (void *, void *);
00039
00040 #include "gtype-desc.h"
00041
00042
00043
00044
00045 typedef void (*gt_note_pointers) (void *, void *, gt_pointer_operator,
00046 void *);
00047
00048
00049
00050
00051
00052
00053 typedef void (*gt_handle_reorder) (void *, void *, gt_pointer_operator,
00054 void *);
00055
00056
00057 extern int gt_pch_note_object (void *, void *, gt_note_pointers,
00058 enum gt_types_enum);
00059
00060
00061
00062 extern void gt_pch_note_reorder (void *, void *, gt_handle_reorder);
00063
00064
00065 typedef void (*gt_pointer_walker) (void *);
00066
00067
00068
00069 struct ggc_root_tab {
00070 void *base;
00071 size_t nelt;
00072 size_t stride;
00073 gt_pointer_walker cb;
00074 gt_pointer_walker pchw;
00075 };
00076 #define LAST_GGC_ROOT_TAB { NULL, 0, 0, NULL, NULL }
00077
00078 extern const struct ggc_root_tab * const gt_ggc_rtab[];
00079 extern const struct ggc_root_tab * const gt_ggc_deletable_rtab[];
00080 extern const struct ggc_root_tab * const gt_pch_cache_rtab[];
00081 extern const struct ggc_root_tab * const gt_pch_scalar_rtab[];
00082
00083
00084 struct htab;
00085 struct ggc_cache_tab {
00086 struct htab * *base;
00087 size_t nelt;
00088 size_t stride;
00089 gt_pointer_walker cb;
00090 gt_pointer_walker pchw;
00091 int (*marked_p) (const void *);
00092 };
00093 #define LAST_GGC_CACHE_TAB { NULL, 0, 0, NULL, NULL, NULL }
00094
00095 extern const struct ggc_cache_tab * const gt_ggc_cache_rtab[];
00096
00097
00098
00099 #define ggc_test_and_set_mark(EXPR) \
00100 ((EXPR) != NULL && ((void *) (EXPR)) != (void *) 1 && ! ggc_set_mark (EXPR))
00101
00102 #define ggc_mark(EXPR) \
00103 do { \
00104 const void *const a__ = (EXPR); \
00105 if (a__ != NULL && a__ != (void *) 1) \
00106 ggc_set_mark (a__); \
00107 } while (0)
00108
00109
00110
00111
00112
00113
00114 extern int ggc_set_mark (const void *);
00115
00116
00117
00118
00119 extern int ggc_marked_p (const void *);
00120
00121
00122 extern void ggc_mark_stringpool (void);
00123
00124
00125
00126 extern void ggc_mark_roots (void);
00127
00128
00129
00130 extern void gt_pch_save_stringpool (void);
00131 extern void gt_pch_fixup_stringpool (void);
00132 extern void gt_pch_restore_stringpool (void);
00133
00134
00135
00136 extern void gt_pch_p_S (void *, void *, gt_pointer_operator, void *);
00137 extern void gt_pch_n_S (const void *);
00138 extern void gt_ggc_m_S (void *);
00139
00140
00141 extern void init_stringpool (void);
00142
00143
00144
00145
00146
00147 struct alloc_zone;
00148
00149
00150 extern void init_ggc (void);
00151
00152
00153 extern struct alloc_zone *new_ggc_zone (const char *);
00154
00155
00156 extern void destroy_ggc_zone (struct alloc_zone *);
00157
00158 struct ggc_pch_data;
00159
00160
00161 extern struct ggc_pch_data *init_ggc_pch (void);
00162
00163
00164
00165
00166
00167 extern void ggc_pch_count_object (struct ggc_pch_data *, void *, size_t, bool,
00168 enum gt_types_enum);
00169
00170
00171
00172 extern size_t ggc_pch_total_size (struct ggc_pch_data *);
00173
00174
00175
00176 extern void ggc_pch_this_base (struct ggc_pch_data *, void *);
00177
00178
00179
00180
00181 extern char *ggc_pch_alloc_object (struct ggc_pch_data *, void *, size_t, bool,
00182 enum gt_types_enum);
00183
00184
00185 extern void ggc_pch_prepare_write (struct ggc_pch_data *, FILE *);
00186
00187
00188 extern void ggc_pch_write_object (struct ggc_pch_data *, FILE *, void *,
00189 void *, size_t, bool);
00190
00191
00192 extern void ggc_pch_finish (struct ggc_pch_data *, FILE *);
00193
00194
00195
00196 extern void ggc_pch_read (FILE *, void *);
00197
00198
00199
00200
00201
00202 extern bool ggc_force_collect;
00203
00204
00205 extern void *ggc_alloc_stat (size_t MEM_STAT_DECL);
00206 #define ggc_alloc(s) ggc_alloc_stat (s MEM_STAT_INFO)
00207
00208 extern void *ggc_alloc_typed_stat (enum gt_types_enum, size_t MEM_STAT_DECL);
00209 #define ggc_alloc_typed(s,z) ggc_alloc_typed_stat (s,z MEM_STAT_INFO)
00210
00211 extern void *ggc_alloc_cleared_stat (size_t MEM_STAT_DECL);
00212 #define ggc_alloc_cleared(s) ggc_alloc_cleared_stat (s MEM_STAT_INFO)
00213
00214 extern void *ggc_realloc_stat (void *, size_t MEM_STAT_DECL);
00215 #define ggc_realloc(s,z) ggc_realloc_stat (s,z MEM_STAT_INFO)
00216
00217 extern void *ggc_calloc (size_t, size_t);
00218
00219 extern void ggc_free (void *);
00220
00221 extern void ggc_record_overhead (size_t, size_t, void * MEM_STAT_DECL);
00222 extern void ggc_free_overhead (void *);
00223 extern void ggc_prune_overhead_list (void);
00224
00225 extern void dump_ggc_loc_statistics (void);
00226
00227
00228 #define GGC_NEW(T) ((T *) ggc_alloc (sizeof (T)))
00229 #define GGC_CNEW(T) ((T *) ggc_alloc_cleared (sizeof (T)))
00230 #define GGC_NEWVEC(T, N) ((T *) ggc_alloc ((N) * sizeof(T)))
00231 #define GGC_CNEWVEC(T, N) ((T *) ggc_alloc_cleared ((N) * sizeof(T)))
00232 #define GGC_NEWVAR(T, S) ((T *) ggc_alloc ((S)))
00233 #define GGC_CNEWVAR(T, S) ((T *) ggc_alloc_cleared ((S)))
00234 #define GGC_RESIZEVEC(T, P, N) ((T *) ggc_realloc ((P), (N) * sizeof (T)))
00235
00236 #define ggc_alloc_rtvec(NELT) \
00237 ((rtvec) ggc_alloc_zone (sizeof (struct rtvec_def) + ((NELT) - 1) \
00238 * sizeof (rtx), &rtl_zone))
00239
00240 #define ggc_alloc_tree(LENGTH) ((tree) ggc_alloc_zone (LENGTH, &tree_zone))
00241
00242 #define htab_create_ggc(SIZE, HASH, EQ, DEL) \
00243 htab_create_alloc (SIZE, HASH, EQ, DEL, ggc_calloc, NULL)
00244
00245 #define splay_tree_new_ggc(COMPARE) \
00246 splay_tree_new_with_allocator (COMPARE, NULL, NULL, \
00247 &ggc_splay_alloc, &ggc_splay_dont_free, \
00248 NULL)
00249 extern void *ggc_splay_alloc (int, void *);
00250 extern void ggc_splay_dont_free (void *, void *);
00251
00252
00253
00254
00255 extern const char *ggc_alloc_string (const char *contents, int length);
00256
00257
00258 #define ggc_strdup(S) ggc_alloc_string((S), -1)
00259
00260
00261
00262 extern void ggc_collect (void);
00263
00264
00265 extern size_t ggc_get_size (const void *);
00266
00267
00268 extern void gt_pch_save (FILE *f);
00269
00270
00271 extern void gt_pch_restore (FILE *f);
00272
00273
00274
00275
00276
00277 typedef struct ggc_statistics
00278 {
00279
00280 int unused;
00281 } ggc_statistics;
00282
00283
00284
00285 extern void ggc_print_common_statistics (FILE *, ggc_statistics *);
00286
00287
00288 extern void ggc_print_statistics (void);
00289 extern void stringpool_statistics (void);
00290
00291
00292 extern int ggc_min_expand_heuristic (void);
00293 extern int ggc_min_heapsize_heuristic (void);
00294 extern void init_ggc_heuristics (void);
00295
00296
00297 #if defined (GGC_ZONE) && !defined (GENERATOR_FILE)
00298
00299
00300 extern struct alloc_zone rtl_zone;
00301
00302 extern struct alloc_zone tree_zone;
00303
00304 extern struct alloc_zone tree_id_zone;
00305
00306
00307 extern void *ggc_alloc_zone_stat (size_t, struct alloc_zone * MEM_STAT_DECL);
00308 # define ggc_alloc_zone(s,z) ggc_alloc_zone_stat (s,z MEM_STAT_INFO)
00309 # define ggc_alloc_zone_pass_stat(s,z) ggc_alloc_zone_stat (s,z PASS_MEM_STAT)
00310 #else
00311
00312 # define ggc_alloc_zone(s, z) ggc_alloc (s)
00313 # define ggc_alloc_zone_pass_stat(s, z) ggc_alloc_stat (s PASS_MEM_STAT)
00314
00315 #endif
00316
00317 #endif