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