Mercurial > hg > CbC > CbC_gcc
comparison gcc/ggc.h @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 /* Garbage collection for the GNU compiler. | 1 /* Garbage collection for the GNU compiler. |
2 | 2 |
3 Copyright (C) 1998-2018 Free Software Foundation, Inc. | 3 Copyright (C) 1998-2020 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
8 the terms of the GNU General Public License as published by the Free | 8 the terms of the GNU General Public License as published by the Free |
147 extern void *ggc_realloc (void *, size_t CXX_MEM_STAT_INFO); | 147 extern void *ggc_realloc (void *, size_t CXX_MEM_STAT_INFO); |
148 | 148 |
149 /* Free a block. To be used when known for certain it's not reachable. */ | 149 /* Free a block. To be used when known for certain it's not reachable. */ |
150 extern void ggc_free (void *); | 150 extern void ggc_free (void *); |
151 | 151 |
152 extern void dump_ggc_loc_statistics (bool); | 152 extern void dump_ggc_loc_statistics (); |
153 | 153 |
154 /* Reallocator. */ | 154 /* Reallocator. */ |
155 #define GGC_RESIZEVEC(T, P, N) \ | 155 #define GGC_RESIZEVEC(T, P, N) \ |
156 ((T *) ggc_realloc ((P), (N) * sizeof (T) MEM_STAT_INFO)) | 156 ((T *) ggc_realloc ((P), (N) * sizeof (T) MEM_STAT_INFO)) |
157 | 157 |
181 return static_cast<T *> (ggc_internal_alloc (sizeof (T), finalize<T>, 0, 1 | 181 return static_cast<T *> (ggc_internal_alloc (sizeof (T), finalize<T>, 0, 1 |
182 PASS_MEM_STAT)); | 182 PASS_MEM_STAT)); |
183 else | 183 else |
184 return static_cast<T *> (ggc_internal_alloc (sizeof (T), NULL, 0, 1 | 184 return static_cast<T *> (ggc_internal_alloc (sizeof (T), NULL, 0, 1 |
185 PASS_MEM_STAT)); | 185 PASS_MEM_STAT)); |
186 } | |
187 | |
188 /* GGC allocation function that does not call finalizer for type | |
189 that have need_finalization_p equal to true. User is responsible | |
190 for calling of the destructor. */ | |
191 | |
192 template<typename T> | |
193 inline T * | |
194 ggc_alloc_no_dtor (ALONE_CXX_MEM_STAT_INFO) | |
195 { | |
196 return static_cast<T *> (ggc_internal_alloc (sizeof (T), NULL, 0, 1 | |
197 PASS_MEM_STAT)); | |
186 } | 198 } |
187 | 199 |
188 template<typename T> | 200 template<typename T> |
189 inline T * | 201 inline T * |
190 ggc_cleared_alloc (ALONE_CXX_MEM_STAT_INFO) | 202 ggc_cleared_alloc (ALONE_CXX_MEM_STAT_INFO) |
228 ggc_alloc_atomic (size_t s CXX_MEM_STAT_INFO) | 240 ggc_alloc_atomic (size_t s CXX_MEM_STAT_INFO) |
229 { | 241 { |
230 return ggc_internal_alloc (s PASS_MEM_STAT); | 242 return ggc_internal_alloc (s PASS_MEM_STAT); |
231 } | 243 } |
232 | 244 |
245 /* Call destructor and free the garbage collected memory. */ | |
246 | |
247 template <typename T> | |
248 inline void | |
249 ggc_delete (T *ptr) | |
250 { | |
251 ptr->~T (); | |
252 ggc_free (ptr); | |
253 } | |
254 | |
233 /* Allocate a gc-able string, and fill it with LENGTH bytes from CONTENTS. | 255 /* Allocate a gc-able string, and fill it with LENGTH bytes from CONTENTS. |
234 If LENGTH is -1, then CONTENTS is assumed to be a | 256 If LENGTH is -1, then CONTENTS is assumed to be a |
235 null-terminated string and the memory sized accordingly. */ | 257 null-terminated string and the memory sized accordingly. */ |
236 extern const char *ggc_alloc_string (const char *contents, int length | 258 extern const char *ggc_alloc_string (const char *contents, int length |
237 CXX_MEM_STAT_INFO); | 259 CXX_MEM_STAT_INFO); |
241 | 263 |
242 /* Invoke the collector. Garbage collection occurs only when this | 264 /* Invoke the collector. Garbage collection occurs only when this |
243 function is called, not during allocations. */ | 265 function is called, not during allocations. */ |
244 extern void ggc_collect (void); | 266 extern void ggc_collect (void); |
245 | 267 |
268 /* Return unused memory pages to the system. */ | |
269 extern void ggc_trim (void); | |
270 | |
246 /* Assume that all GGC memory is reachable and grow the limits for next collection. */ | 271 /* Assume that all GGC memory is reachable and grow the limits for next collection. */ |
247 extern void ggc_grow (void); | 272 extern void ggc_grow (void); |
248 | 273 |
249 /* Register an additional root table. This can be useful for some | 274 /* Register an additional root table. This can be useful for some |
250 plugins. Does nothing if the passed pointer is NULL. */ | 275 plugins. Does nothing if the passed pointer is NULL. */ |
261 extern void stringpool_statistics (void); | 286 extern void stringpool_statistics (void); |
262 | 287 |
263 /* Heuristics. */ | 288 /* Heuristics. */ |
264 extern void init_ggc_heuristics (void); | 289 extern void init_ggc_heuristics (void); |
265 | 290 |
291 /* Report current heap memory use to stderr. */ | |
292 extern void report_heap_memory_use (void); | |
293 | |
266 #define ggc_alloc_rtvec_sized(NELT) \ | 294 #define ggc_alloc_rtvec_sized(NELT) \ |
267 (rtvec_def *) ggc_internal_alloc (sizeof (struct rtvec_def) \ | 295 (rtvec_def *) ggc_internal_alloc (sizeof (struct rtvec_def) \ |
268 + ((NELT) - 1) * sizeof (rtx)) \ | 296 + ((NELT) - 1) * sizeof (rtx)) \ |
269 | 297 |
270 /* Memory statistics passing versions of some allocators. Too few of them to | 298 /* Memory statistics passing versions of some allocators. Too few of them to |