OpenCores
URL https://opencores.org/ocsvn/altor32/altor32/trunk

Subversion Repositories altor32

[/] [altor32/] [trunk/] [gcc-x64/] [or1knd-elf/] [lib/] [gcc/] [or1knd-elf/] [4.8.0/] [plugin/] [include/] [ggc.h] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 ultra_embe
/* Garbage collection for the GNU compiler.
2
 
3
   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007,
4
   2008, 2009, 2010, 2011 Free Software Foundation, Inc.
5
 
6
This file is part of GCC.
7
 
8
GCC is free software; you can redistribute it and/or modify it under
9
the terms of the GNU General Public License as published by the Free
10
Software Foundation; either version 3, or (at your option) any later
11
version.
12
 
13
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14
WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16
for more details.
17
 
18
You should have received a copy of the GNU General Public License
19
along with GCC; see the file COPYING3.  If not see
20
<http://www.gnu.org/licenses/>.  */
21
 
22
#ifndef GCC_GGC_H
23
#define GCC_GGC_H
24
#include "statistics.h"
25
 
26
/* Symbols are marked with `ggc' for `gcc gc' so as not to interfere with
27
   an external gc library that might be linked in.  */
28
 
29
/* Constants for general use.  */
30
extern const char empty_string[];       /* empty string */
31
 
32
/* Internal functions and data structures used by the GTY
33
   machinery, including the generated gt*.[hc] files.  */
34
 
35
#include "gtype-desc.h"
36
 
37
/* One of these applies its third parameter (with cookie in the fourth
38
   parameter) to each pointer in the object pointed to by the first
39
   parameter, using the second parameter.  */
40
typedef void (*gt_note_pointers) (void *, void *, gt_pointer_operator,
41
                                  void *);
42
 
43
/* One of these is called before objects are re-ordered in memory.
44
   The first parameter is the original object, the second is the
45
   subobject that has had its pointers reordered, the third parameter
46
   can compute the new values of a pointer when given the cookie in
47
   the fourth parameter.  */
48
typedef void (*gt_handle_reorder) (void *, void *, gt_pointer_operator,
49
                                   void *);
50
 
51
/* Used by the gt_pch_n_* routines.  Register an object in the hash table.  */
52
extern int gt_pch_note_object (void *, void *, gt_note_pointers,
53
                               enum gt_types_enum = gt_types_enum_last);
54
 
55
/* Used by the gt_pch_n_* routines.  Register that an object has a reorder
56
   function.  */
57
extern void gt_pch_note_reorder (void *, void *, gt_handle_reorder);
58
 
59
/* Mark the object in the first parameter and anything it points to.  */
60
typedef void (*gt_pointer_walker) (void *);
61
 
62
/* Structures for the easy way to mark roots.
63
   In an array, terminated by having base == NULL.  */
64
struct ggc_root_tab {
65
  void *base;
66
  size_t nelt;
67
  size_t stride;
68
  gt_pointer_walker cb;
69
  gt_pointer_walker pchw;
70
};
71
#define LAST_GGC_ROOT_TAB { NULL, 0, 0, NULL, NULL }
72
/* Pointers to arrays of ggc_root_tab, terminated by NULL.  */
73
extern const struct ggc_root_tab * const gt_ggc_rtab[];
74
extern const struct ggc_root_tab * const gt_ggc_deletable_rtab[];
75
extern const struct ggc_root_tab * const gt_pch_cache_rtab[];
76
extern const struct ggc_root_tab * const gt_pch_scalar_rtab[];
77
 
78
/* Structure for hash table cache marking.  */
79
struct htab;
80
struct ggc_cache_tab {
81
  struct htab * *base;
82
  size_t nelt;
83
  size_t stride;
84
  gt_pointer_walker cb;
85
  gt_pointer_walker pchw;
86
  int (*marked_p) (const void *);
87
};
88
#define LAST_GGC_CACHE_TAB { NULL, 0, 0, NULL, NULL, NULL }
89
/* Pointers to arrays of ggc_cache_tab, terminated by NULL.  */
90
extern const struct ggc_cache_tab * const gt_ggc_cache_rtab[];
91
 
92
/* If EXPR is not NULL and previously unmarked, mark it and evaluate
93
   to true.  Otherwise evaluate to false.  */
94
#define ggc_test_and_set_mark(EXPR) \
95
  ((EXPR) != NULL && ((void *) (EXPR)) != (void *) 1 && ! ggc_set_mark (EXPR))
96
 
97
#define ggc_mark(EXPR)                          \
98
  do {                                          \
99
    const void *const a__ = (EXPR);             \
100
    if (a__ != NULL && a__ != (void *) 1)       \
101
      ggc_set_mark (a__);                       \
102
  } while (0)
103
 
104
/* Actually set the mark on a particular region of memory, but don't
105
   follow pointers.  This function is called by ggc_mark_*.  It
106
   returns zero if the object was not previously marked; nonzero if
107
   the object was already marked, or if, for any other reason,
108
   pointers in this data structure should not be traversed.  */
109
extern int ggc_set_mark (const void *);
110
 
111
/* Return 1 if P has been marked, zero otherwise.
112
   P must have been allocated by the GC allocator; it mustn't point to
113
   static objects, stack variables, or memory allocated with malloc.  */
114
extern int ggc_marked_p (const void *);
115
 
116
/* PCH and GGC handling for strings, mostly trivial.  */
117
extern void gt_pch_n_S (const void *);
118
extern void gt_ggc_m_S (const void *);
119
 
120
/* End of GTY machinery API.  */
121
 
122
struct alloc_zone;
123
 
124
/* Initialize the string pool.  */
125
extern void init_stringpool (void);
126
 
127
/* Initialize the garbage collector.  */
128
extern void init_ggc (void);
129
 
130
/* When true, identifier nodes are considered as GC roots.  When
131
   false, identifier nodes are treated like any other GC-allocated
132
   object, and the identifier hash table is treated as a weak
133
   hash.  */
134
extern bool ggc_protect_identifiers;
135
 
136
/* Write out all GCed objects to F.  */
137
extern void gt_pch_save (FILE *f);
138
 
139
 
140
/* Allocation.  */
141
 
142
/* The internal primitive.  */
143
extern void *ggc_internal_alloc_stat (size_t MEM_STAT_DECL)
144
  ATTRIBUTE_MALLOC;
145
 
146
extern size_t ggc_round_alloc_size (size_t requested_size);
147
 
148
#define ggc_internal_alloc(s) ggc_internal_alloc_stat (s MEM_STAT_INFO)
149
 
150
/* Allocate an object of the specified type and size.  */
151
extern void *ggc_alloc_typed_stat (enum gt_types_enum, size_t MEM_STAT_DECL)
152
  ATTRIBUTE_MALLOC;
153
 
154
#define ggc_alloc_typed(s, z) ggc_alloc_typed_stat (s, z MEM_STAT_INFO)
155
 
156
/* Allocates cleared memory.  */
157
extern void *ggc_internal_cleared_alloc_stat (size_t MEM_STAT_DECL)
158
  ATTRIBUTE_MALLOC;
159
 
160
/* Resize a block.  */
161
extern void *ggc_realloc_stat (void *, size_t MEM_STAT_DECL);
162
 
163
/* Free a block.  To be used when known for certain it's not reachable.  */
164
extern void ggc_free (void *);
165
 
166
extern void dump_ggc_loc_statistics (bool);
167
 
168
/* Reallocators.  */
169
#define GGC_RESIZEVEC(T, P, N) \
170
    ((T *) ggc_realloc_stat ((P), (N) * sizeof (T) MEM_STAT_INFO))
171
 
172
#define GGC_RESIZEVAR(T, P, N)                          \
173
    ((T *) ggc_realloc_stat ((P), (N) MEM_STAT_INFO))
174
 
175
static inline void *
176
ggc_internal_vec_alloc_stat (size_t s, size_t c MEM_STAT_DECL)
177
{
178
    return ggc_internal_alloc_stat (c * s PASS_MEM_STAT);
179
}
180
 
181
static inline void *
182
ggc_internal_cleared_vec_alloc_stat (size_t s, size_t c MEM_STAT_DECL)
183
{
184
    return ggc_internal_cleared_alloc_stat (c * s PASS_MEM_STAT);
185
}
186
 
187
#define ggc_internal_cleared_vec_alloc(s, c) \
188
    (ggc_internal_cleared_vec_alloc_stat ((s), (c) MEM_STAT_INFO))
189
 
190
static inline void *
191
ggc_alloc_atomic_stat (size_t s MEM_STAT_DECL)
192
{
193
    return ggc_internal_alloc_stat (s PASS_MEM_STAT);
194
}
195
 
196
#define ggc_alloc_atomic(S)  (ggc_alloc_atomic_stat ((S) MEM_STAT_INFO))
197
 
198
#define ggc_alloc_cleared_atomic(S)             \
199
    (ggc_internal_cleared_alloc_stat ((S) MEM_STAT_INFO))
200
 
201
extern void *ggc_cleared_alloc_htab_ignore_args (size_t, size_t)
202
  ATTRIBUTE_MALLOC;
203
 
204
extern void *ggc_cleared_alloc_ptr_array_two_args (size_t, size_t)
205
  ATTRIBUTE_MALLOC;
206
 
207
#define htab_create_ggc(SIZE, HASH, EQ, DEL) \
208
  htab_create_typed_alloc (SIZE, HASH, EQ, DEL, \
209
                           ggc_cleared_alloc_htab_ignore_args,          \
210
                           ggc_cleared_alloc_ptr_array_two_args,        \
211
                           ggc_free)
212
 
213
#define splay_tree_new_ggc(COMPARE, ALLOC_TREE, ALLOC_NODE)                  \
214
  splay_tree_new_typed_alloc (COMPARE, NULL, NULL, &ALLOC_TREE, &ALLOC_NODE, \
215
                              &ggc_splay_dont_free, NULL)
216
 
217
extern void *ggc_splay_alloc (enum gt_types_enum, int, void *)
218
  ATTRIBUTE_MALLOC;
219
 
220
extern void ggc_splay_dont_free (void *, void *);
221
 
222
/* Allocate a gc-able string, and fill it with LENGTH bytes from CONTENTS.
223
   If LENGTH is -1, then CONTENTS is assumed to be a
224
   null-terminated string and the memory sized accordingly.  */
225
extern const char *ggc_alloc_string_stat (const char *contents, int length
226
                                          MEM_STAT_DECL);
227
 
228
#define ggc_alloc_string(c, l) ggc_alloc_string_stat (c, l MEM_STAT_INFO)
229
 
230
/* Make a copy of S, in GC-able memory.  */
231
#define ggc_strdup(S) ggc_alloc_string_stat ((S), -1 MEM_STAT_INFO)
232
 
233
/* Invoke the collector.  Garbage collection occurs only when this
234
   function is called, not during allocations.  */
235
extern void ggc_collect (void);
236
 
237
/* Register an additional root table.  This can be useful for some
238
   plugins.  Does nothing if the passed pointer is NULL. */
239
extern void ggc_register_root_tab (const struct ggc_root_tab *);
240
 
241
/* Register an additional cache table.  This can be useful for some
242
   plugins.  Does nothing if the passed pointer is NULL. */
243
extern void ggc_register_cache_tab (const struct ggc_cache_tab *);
244
 
245
/* Read objects previously saved with gt_pch_save from F.  */
246
extern void gt_pch_restore (FILE *f);
247
 
248
/* Statistics.  */
249
 
250
/* Print allocation statistics.  */
251
extern void ggc_print_statistics (void);
252
 
253
extern void stringpool_statistics (void);
254
 
255
/* Heuristics.  */
256
extern void init_ggc_heuristics (void);
257
 
258
/* Zone collection.  */
259
 
260
/* For regular rtl allocations.  */
261
extern struct alloc_zone rtl_zone;
262
 
263
/* For regular tree allocations.  */
264
extern struct alloc_zone tree_zone;
265
 
266
/* For IDENTIFIER_NODE allocations.  */
267
extern struct alloc_zone tree_id_zone;
268
 
269
#define ggc_alloc_rtvec_sized(NELT)                                     \
270
  ggc_alloc_zone_rtvec_def (sizeof (struct rtvec_def)                   \
271
                            + ((NELT) - 1) * sizeof (rtx),              \
272
                            &rtl_zone)
273
 
274
#if defined (GGC_ZONE) && !defined (GENERATOR_FILE)
275
 
276
/* Allocate an object into the specified allocation zone.  */
277
extern void *ggc_internal_alloc_zone_stat (size_t,
278
                                          struct alloc_zone * MEM_STAT_DECL)
279
  ATTRIBUTE_MALLOC;
280
 
281
extern void *ggc_internal_cleared_alloc_zone_stat (size_t,
282
                                          struct alloc_zone * MEM_STAT_DECL)
283
  ATTRIBUTE_MALLOC;
284
 
285
static inline void *
286
ggc_internal_zone_alloc_stat (struct alloc_zone * z, size_t s MEM_STAT_DECL)
287
{
288
    return ggc_internal_alloc_zone_stat (s, z PASS_MEM_STAT);
289
}
290
 
291
static inline void *
292
ggc_internal_zone_cleared_alloc_stat (struct alloc_zone * z, size_t s
293
                                      MEM_STAT_DECL)
294
{
295
    return ggc_internal_cleared_alloc_zone_stat (s, z PASS_MEM_STAT);
296
}
297
 
298
static inline void *
299
ggc_internal_zone_vec_alloc_stat (struct alloc_zone * z, size_t s, size_t n
300
                                  MEM_STAT_DECL)
301
{
302
    return ggc_internal_alloc_zone_stat (s * n, z PASS_MEM_STAT);
303
}
304
 
305
 
306
#else
307
 
308
static inline void *
309
ggc_internal_zone_alloc_stat (struct alloc_zone * z ATTRIBUTE_UNUSED,
310
                              size_t s MEM_STAT_DECL)
311
{
312
    return ggc_internal_alloc_stat (s PASS_MEM_STAT);
313
}
314
 
315
static inline void *
316
ggc_internal_zone_cleared_alloc_stat (struct alloc_zone * z ATTRIBUTE_UNUSED,
317
                                      size_t s MEM_STAT_DECL)
318
{
319
    return ggc_internal_cleared_alloc_stat (s PASS_MEM_STAT);
320
}
321
 
322
static inline void *
323
ggc_internal_zone_vec_alloc_stat (struct alloc_zone * z ATTRIBUTE_UNUSED,
324
                                  size_t s, size_t n MEM_STAT_DECL)
325
{
326
    return ggc_internal_vec_alloc_stat (s, n PASS_MEM_STAT);
327
}
328
 
329
#endif
330
 
331
/* Memory statistics passing versions of some allocators.  Too few of them to
332
   make gengtype produce them, so just define the needed ones here.  */
333
static inline struct rtx_def *
334
ggc_alloc_zone_rtx_def_stat (struct alloc_zone * z, size_t s MEM_STAT_DECL)
335
{
336
  return (struct rtx_def *) ggc_internal_zone_alloc_stat (z, s PASS_MEM_STAT);
337
}
338
 
339
static inline union tree_node *
340
ggc_alloc_zone_tree_node_stat (struct alloc_zone * z, size_t s MEM_STAT_DECL)
341
{
342
  return (union tree_node *) ggc_internal_zone_alloc_stat (z, s PASS_MEM_STAT);
343
}
344
 
345
static inline union tree_node *
346
ggc_alloc_zone_cleared_tree_node_stat (struct alloc_zone * z, size_t s
347
                                       MEM_STAT_DECL)
348
{
349
  return (union tree_node *)
350
    ggc_internal_zone_cleared_alloc_stat (z, s PASS_MEM_STAT);
351
}
352
 
353
static inline union gimple_statement_d *
354
ggc_alloc_cleared_gimple_statement_d_stat (size_t s MEM_STAT_DECL)
355
{
356
  return (union gimple_statement_d *)
357
    ggc_internal_cleared_alloc_stat (s PASS_MEM_STAT);
358
}
359
 
360
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.