1*38fd1498Szrj /* Garbage collection for the GNU compiler.  Internal definitions
2*38fd1498Szrj    for ggc-*.c and stringpool.c.
3*38fd1498Szrj 
4*38fd1498Szrj    Copyright (C) 2009-2018 Free Software Foundation, Inc.
5*38fd1498Szrj 
6*38fd1498Szrj This file is part of GCC.
7*38fd1498Szrj 
8*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under
9*38fd1498Szrj the terms of the GNU General Public License as published by the Free
10*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later
11*38fd1498Szrj version.
12*38fd1498Szrj 
13*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or
15*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16*38fd1498Szrj for more details.
17*38fd1498Szrj 
18*38fd1498Szrj You should have received a copy of the GNU General Public License
19*38fd1498Szrj along with GCC; see the file COPYING3.  If not see
20*38fd1498Szrj <http://www.gnu.org/licenses/>.  */
21*38fd1498Szrj 
22*38fd1498Szrj #ifndef GCC_GGC_INTERNAL_H
23*38fd1498Szrj #define GCC_GGC_INTERNAL_H
24*38fd1498Szrj 
25*38fd1498Szrj 
26*38fd1498Szrj /* Call ggc_set_mark on all the roots.  */
27*38fd1498Szrj extern void ggc_mark_roots (void);
28*38fd1498Szrj 
29*38fd1498Szrj /* Stringpool.  */
30*38fd1498Szrj 
31*38fd1498Szrj /* Mark the entries in the string pool.  */
32*38fd1498Szrj extern void ggc_mark_stringpool	(void);
33*38fd1498Szrj 
34*38fd1498Szrj /* Purge the entries in the string pool.  */
35*38fd1498Szrj extern void ggc_purge_stringpool (void);
36*38fd1498Szrj 
37*38fd1498Szrj /* Save and restore the string pool entries for PCH.  */
38*38fd1498Szrj 
39*38fd1498Szrj extern void gt_pch_save_stringpool (void);
40*38fd1498Szrj extern void gt_pch_fixup_stringpool (void);
41*38fd1498Szrj extern void gt_pch_restore_stringpool (void);
42*38fd1498Szrj 
43*38fd1498Szrj /* PCH and GGC handling for strings, mostly trivial.  */
44*38fd1498Szrj extern void gt_pch_p_S (void *, void *, gt_pointer_operator, void *);
45*38fd1498Szrj 
46*38fd1498Szrj /* PCH.  */
47*38fd1498Szrj 
48*38fd1498Szrj struct ggc_pch_data;
49*38fd1498Szrj 
50*38fd1498Szrj /* Return a new ggc_pch_data structure.  */
51*38fd1498Szrj extern struct ggc_pch_data *init_ggc_pch (void);
52*38fd1498Szrj 
53*38fd1498Szrj /* The second parameter and third parameters give the address and size
54*38fd1498Szrj    of an object.  Update the ggc_pch_data structure with as much of
55*38fd1498Szrj    that information as is necessary. The bool argument should be true
56*38fd1498Szrj    if the object is a string.  */
57*38fd1498Szrj extern void ggc_pch_count_object (struct ggc_pch_data *, void *, size_t, bool);
58*38fd1498Szrj 
59*38fd1498Szrj /* Return the total size of the data to be written to hold all
60*38fd1498Szrj    the objects previously passed to ggc_pch_count_object.  */
61*38fd1498Szrj extern size_t ggc_pch_total_size (struct ggc_pch_data *);
62*38fd1498Szrj 
63*38fd1498Szrj /* The objects, when read, will most likely be at the address
64*38fd1498Szrj    in the second parameter.  */
65*38fd1498Szrj extern void ggc_pch_this_base (struct ggc_pch_data *, void *);
66*38fd1498Szrj 
67*38fd1498Szrj /* Assuming that the objects really do end up at the address
68*38fd1498Szrj    passed to ggc_pch_this_base, return the address of this object.
69*38fd1498Szrj    The bool argument should be true if the object is a string.  */
70*38fd1498Szrj extern char *ggc_pch_alloc_object (struct ggc_pch_data *, void *, size_t, bool);
71*38fd1498Szrj 
72*38fd1498Szrj /* Write out any initial information required.  */
73*38fd1498Szrj extern void ggc_pch_prepare_write (struct ggc_pch_data *, FILE *);
74*38fd1498Szrj 
75*38fd1498Szrj /* Write out this object, including any padding.  The last argument should be
76*38fd1498Szrj    true if the object is a string.  */
77*38fd1498Szrj extern void ggc_pch_write_object (struct ggc_pch_data *, FILE *, void *,
78*38fd1498Szrj 				  void *, size_t, bool);
79*38fd1498Szrj 
80*38fd1498Szrj /* All objects have been written, write out any final information
81*38fd1498Szrj    required.  */
82*38fd1498Szrj extern void ggc_pch_finish (struct ggc_pch_data *, FILE *);
83*38fd1498Szrj 
84*38fd1498Szrj /* A PCH file has just been read in at the address specified second
85*38fd1498Szrj    parameter.  Set up the GC implementation for the new objects.  */
86*38fd1498Szrj extern void ggc_pch_read (FILE *, void *);
87*38fd1498Szrj 
88*38fd1498Szrj 
89*38fd1498Szrj /* Allocation and collection.  */
90*38fd1498Szrj 
91*38fd1498Szrj /* When set, ggc_collect will do collection.  */
92*38fd1498Szrj extern bool ggc_force_collect;
93*38fd1498Szrj 
94*38fd1498Szrj extern void ggc_record_overhead (size_t, size_t, void * FINAL_MEM_STAT_DECL);
95*38fd1498Szrj 
96*38fd1498Szrj extern void ggc_free_overhead (void *);
97*38fd1498Szrj 
98*38fd1498Szrj extern void ggc_prune_overhead_list (void);
99*38fd1498Szrj 
100*38fd1498Szrj /* Return the number of bytes allocated at the indicated address.  */
101*38fd1498Szrj extern size_t ggc_get_size (const void *);
102*38fd1498Szrj 
103*38fd1498Szrj 
104*38fd1498Szrj /* Statistics.  */
105*38fd1498Szrj 
106*38fd1498Szrj /* This structure contains the statistics common to all collectors.
107*38fd1498Szrj    Particular collectors can extend this structure.  */
108*38fd1498Szrj struct ggc_statistics
109*38fd1498Szrj {
110*38fd1498Szrj   /* At present, we don't really gather any interesting statistics.  */
111*38fd1498Szrj   int unused;
112*38fd1498Szrj };
113*38fd1498Szrj 
114*38fd1498Szrj /* Used by the various collectors to gather and print statistics that
115*38fd1498Szrj    do not depend on the collector in use.  */
116*38fd1498Szrj extern void ggc_print_common_statistics (FILE *, ggc_statistics *);
117*38fd1498Szrj 
118*38fd1498Szrj #endif
119