GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "timevar.h"
#include "diagnostic-core.h"
#include "ggc-internal.h"
#include "hosthooks.h"
#include "plugin.h"
#include "options.h"
Data Structures | |
struct | ptr_data |
struct | saving_hasher |
struct | traversal_state |
struct | mmap_info |
class | ggc_usage |
Macros | |
#define | INCLUDE_MALLOC_H |
#define | POINTER_HASH(x) |
Typedefs | |
typedef const struct ggc_root_tab * | const_ggc_root_tab_t |
Functions | |
static int | compare_ptr_data (const void *, const void *) |
static void | relocate_ptrs (void *, void *, void *) |
static void | write_pch_globals (const struct ggc_root_tab *const *tab, struct traversal_state *state) |
void | ggc_register_root_tab (const struct ggc_root_tab *rt) |
static void | ggc_mark_root_tab (const_ggc_root_tab_t rt) |
static void | ggc_zero_rtab_roots (const_ggc_root_tab_t rt) |
void | ggc_mark_roots (void) |
void * | ggc_internal_cleared_alloc (size_t size, void(*f)(void *), size_t s, size_t n MEM_STAT_DECL) |
void * | ggc_realloc (void *x, size_t size MEM_STAT_DECL) |
void * | ggc_cleared_alloc_htab_ignore_args (size_t c, size_t n) |
void * | ggc_cleared_alloc_ptr_array_two_args (size_t c, size_t n) |
void * | ggc_splay_alloc (int sz, void *nl) |
void | ggc_splay_dont_free (void *x, void *nl) |
void | ggc_print_common_statistics (FILE *stream, ggc_statistics *stats) |
int | gt_pch_note_object (void *obj, void *note_ptr_cookie, gt_note_pointers note_ptr_fn, size_t length_override) |
void | gt_pch_note_callback (void *obj, void *base) |
void | gt_pch_note_reorder (void *obj, void *note_ptr_cookie, gt_handle_reorder reorder_fn) |
int | ggc_call_count (ptr_data **slot, traversal_state *state) |
int | ggc_call_alloc (ptr_data **slot, traversal_state *state) |
static int | compare_ptr (const void *p1_p, const void *p2_p) |
static unsigned char * | read_uleb128 (unsigned char *p, size_t *val) |
static size_t | write_uleb128 (unsigned char *p, size_t val) |
void | gt_pch_save (FILE *f) |
void | gt_pch_restore (FILE *f) |
void * | default_gt_pch_get_address (size_t size, int fd) |
int | default_gt_pch_use_address (void *&base, size_t size, int fd, size_t offset) |
size_t | default_gt_pch_alloc_granularity (void) |
static double | ggc_rlimit_bound (double limit) |
static int | ggc_min_expand_heuristic (void) |
static int | ggc_min_heapsize_heuristic (void) |
void | init_ggc_heuristics (void) |
void | dump_ggc_loc_statistics () |
void | ggc_record_overhead (size_t allocated, size_t overhead, void *ptr MEM_STAT_DECL) |
void | ggc_free_overhead (void *ptr) |
void | ggc_prune_overhead_list (void) |
void | report_heap_memory_use () |
void | ggc_common_finalize () |
Variables | |
bool | ggc_protect_identifiers = true |
static ggc_statistics * | ggc_stats |
static vec< const_ggc_root_tab_t > | extra_root_vec |
static hash_table< saving_hasher > * | saving_htab |
static vec< void * > | callback_vec |
static vec< void * > | reloc_addrs_vec |
static mem_alloc_description< ggc_usage > | ggc_mem_desc |
#define INCLUDE_MALLOC_H |
Simple garbage collection for the GNU compiler. Copyright (C) 1999-2024 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
Generic garbage collection (GC) functions and data, not specific to any particular GC implementation.
#define POINTER_HASH | ( | x | ) |
Referenced by gt_pch_note_callback(), gt_pch_note_object(), gt_pch_note_reorder(), saving_hasher::hash(), relocate_ptrs(), and write_pch_globals().
typedef const struct ggc_root_tab* const_ggc_root_tab_t |
Maintain global roots that are preserved during GC.
This extra vector of dynamically registered root_tab-s is used by ggc_mark_roots and gives the ability to dynamically add new GGC root tables, for instance from some plugins; this vector is on the heap since it is used by GGC internally.
|
static |
Callback for qsort.
Referenced by ipa_icf_gimple::func_checker::compatible_polymorphic_types_p(), and gt_pch_save().
|
static |
size_t default_gt_pch_alloc_granularity | ( | void | ) |
Default version of HOST_HOOKS_GT_PCH_GET_ADDRESS. Return the alignment required for allocating virtual memory. Usually this is the same as pagesize.
void * default_gt_pch_get_address | ( | size_t | size, |
int | fd ) |
Default version of HOST_HOOKS_GT_PCH_GET_ADDRESS when mmap is not present. Select no address whatsoever, and let gt_pch_save choose what it will with malloc, presumably.
References NULL.
int default_gt_pch_use_address | ( | void *& | base, |
size_t | size, | ||
int | fd, | ||
size_t | offset ) |
Default version of HOST_HOOKS_GT_PCH_USE_ADDRESS when mmap is not present. Allocate SIZE bytes with malloc. Return 0 if the address we got is the same as base, indicating that the memory has been allocated but needs to be read in from the file. Return -1 if the address differs, to relocation of the PCH file would be required.
void dump_ggc_loc_statistics | ( | ) |
Dump per-site memory statistics.
References GGC_COLLECT_FORCE, ggc_mem_desc, and GGC_ORIGIN.
Referenced by dump_memory_report().
int ggc_call_alloc | ( | ptr_data ** | slot, |
traversal_state * | state ) |
References ggc_pch_alloc_object(), ptr_data::new_addr, ptr_data::obj, and ptr_data::size.
Referenced by gt_pch_save().
int ggc_call_count | ( | ptr_data ** | slot, |
traversal_state * | state ) |
Callbacks for htab_traverse.
References ggc_pch_count_object(), ptr_data::obj, and ptr_data::size.
Referenced by gt_pch_save().
void * ggc_cleared_alloc_htab_ignore_args | ( | size_t | c, |
size_t | n ) |
References gcc_assert, and ggc_cleared_alloc().
void * ggc_cleared_alloc_ptr_array_two_args | ( | size_t | c, |
size_t | n ) |
TODO: once we actually use type information in GGC, create a new tag gt_gcc_ptr_array and use it for pointer arrays.
References gcc_assert, and ggc_cleared_vec_alloc().
void ggc_common_finalize | ( | ) |
Forcibly clear all GTY roots.
References ggc_root_tab::base, ggc_zero_rtab_roots(), gt_ggc_deletable_rtab, gt_ggc_rtab, gt_pch_scalar_rtab, ggc_root_tab::nelt, NULL, and ggc_root_tab::stride.
Referenced by toplev::finalize().
void ggc_free_overhead | ( | void * | ptr | ) |
void * ggc_internal_cleared_alloc | ( | size_t | size, |
void(* | f )(void *), | ||
size_t | s, | ||
size_t n | MEM_STAT_DECL ) |
Allocate a block of memory, then clear it.
References ggc_internal_alloc(), and PASS_MEM_STAT.
|
static |
Mark all the roots in the table RT.
References ggc_root_tab::base, ggc_root_tab::cb, i, ggc_root_tab::nelt, NULL, and ggc_root_tab::stride.
Referenced by ggc_mark_roots().
void ggc_mark_roots | ( | void | ) |
Iterate through all registered roots and mark each element.
References ggc_root_tab::base, extra_root_vec, FOR_EACH_VEC_ELT, ggc_mark_root_tab(), ggc_mark_stringpool(), ggc_protect_identifiers, ggc_purge_stringpool(), gt_clear_caches(), gt_ggc_deletable_rtab, gt_ggc_rtab, i, invoke_plugin_callbacks(), ggc_root_tab::nelt, NULL, and ggc_root_tab::stride.
Referenced by ggc_collect().
|
static |
Heuristic to set a default for GGC_MIN_EXPAND.
References ggc_rlimit_bound(), MIN, and ONE_G.
Referenced by ggc_min_heapsize_heuristic(), and init_ggc_heuristics().
|
static |
Heuristic to set a default for GGC_MIN_HEAPSIZE.
References ggc_min_expand_heuristic(), ggc_rlimit_bound(), MAX, MIN, and ONE_K.
Referenced by init_ggc_heuristics().
void ggc_print_common_statistics | ( | FILE * | stream, |
ggc_statistics * | stats ) |
Used by the various collectors to gather and print statistics that do not depend on the collector in use.
References ggc_stats, NULL, and stats.
Referenced by ggc_print_statistics().
void ggc_prune_overhead_list | ( | void | ) |
After live values has been marked, walk all recorded pointers and see if they are still live.
References hash_map< KeyId, Value, Traits >::begin(), ggc_marked_p(), and ggc_mem_desc.
Referenced by ggc_collect().
void * ggc_realloc | ( | void * | x, |
size_t size | MEM_STAT_DECL ) |
Resize a block of memory, possibly re-allocating it.
References ggc_free(), ggc_get_size(), ggc_internal_alloc(), NULL, PASS_MEM_STAT, r, and VALGRIND_DISCARD.
Referenced by grow_tree_vec(), and realloc_for_line_map().
void ggc_record_overhead | ( | size_t | allocated, |
size_t | overhead, | ||
void *ptr | MEM_STAT_DECL ) |
Record ALLOCATED and OVERHEAD bytes to descriptor NAME:LINE (FUNCTION).
References FINAL_PASS_MEM_STAT, ggc_mem_desc, GGC_ORIGIN, ggc_usage::register_overhead(), and usage().
Referenced by ggc_internal_alloc().
void ggc_register_root_tab | ( | const struct ggc_root_tab * | rt | ) |
Dynamically register a new GGC root table RT. This is useful for plugins.
References extra_root_vec.
Referenced by register_callback().
|
static |
Modify the bound based on rlimits.
References ONE_M.
Referenced by ggc_min_expand_heuristic(), and ggc_min_heapsize_heuristic().
void * ggc_splay_alloc | ( | int | sz, |
void * | nl ) |
These are for splay_tree_new_ggc.
References gcc_assert, and ggc_internal_alloc().
void ggc_splay_dont_free | ( | void * | x, |
void * | nl ) |
References gcc_assert.
|
static |
Zero out all the roots in the table RT.
References ggc_root_tab::base, i, ggc_root_tab::nelt, NULL, and ggc_root_tab::stride.
Referenced by ggc_common_finalize().
void gt_pch_note_callback | ( | void * | obj, |
void * | base ) |
Register address of a callback pointer.
References callback_vec, gcc_assert, NULL, ptr_data::obj, POINTER_HASH, and saving_htab.
int gt_pch_note_object | ( | void * | obj, |
void * | note_ptr_cookie, | ||
gt_note_pointers | note_ptr_fn, | ||
size_t | length_override ) |
Register an object in the hash table.
References gcc_assert, ggc_get_size(), gt_pch_p_S(), ptr_data::note_ptr_cookie, ptr_data::note_ptr_fn, NULL, ptr_data::obj, POINTER_HASH, and saving_htab.
Referenced by gt_pch_n_S(), gt_pch_n_S2(), and gt_pch_nx().
void gt_pch_note_reorder | ( | void * | obj, |
void * | note_ptr_cookie, | ||
gt_handle_reorder | reorder_fn ) |
Register an object in the hash table.
References gcc_assert, gcc_checking_assert, gt_pch_p_S(), ptr_data::note_ptr_cookie, NULL, ptr_data::obj, POINTER_HASH, ptr_data::reorder_fn, and saving_htab.
void gt_pch_restore | ( | FILE * | f | ) |
Read the state of the compiler back in from F.
References ggc_root_tab::base, fatal_error(), gcc_assert, ggc_pch_read(), gt_ggc_deletable_rtab, gt_ggc_rtab, gt_pch_restore_stringpool(), gt_pch_save(), gt_pch_scalar_rtab, host_hooks::gt_pch_use_address, i, input_location, line_table, MIN, ggc_root_tab::nelt, NULL, mmap_info::offset, mmap_info::preferred_base, read_uleb128(), SEEK_CUR, SEEK_SET, mmap_info::size, sorry_at(), and ggc_root_tab::stride.
void gt_pch_save | ( | FILE * | f | ) |
Write out the state of the compiler to F.
References ggc_root_tab::base, callback_vec, compare_ptr(), compare_ptr_data(), fatal_error(), gcc_assert, gcc_checking_assert, ggc_call_alloc(), ggc_call_count(), ggc_pch_finish(), ggc_pch_prepare_write(), ggc_pch_this_base(), ggc_pch_total_size(), ggc_pch_write_object(), gt_ggc_rtab, host_hooks::gt_pch_alloc_granularity, gt_pch_fixup_stringpool(), host_hooks::gt_pch_get_address, gt_pch_p_S(), gt_pch_save(), gt_pch_save_stringpool(), gt_pch_scalar_rtab, i, init_ggc_pch(), input_location, ggc_root_tab::nelt, NULL, mmap_info::offset, ggc_root_tab::pchw, mmap_info::preferred_base, qsort, reloc_addrs_vec, relocate_ptrs(), saving_htab, SEEK_SET, mmap_info::size, ggc_root_tab::stride, timevar_pop(), timevar_push(), UNLIKELY, VALGRIND_DISCARD, vNULL, write_pch_globals(), and write_uleb128().
Referenced by gt_pch_restore(), and gt_pch_save().
void init_ggc_heuristics | ( | void | ) |
Heuristics.
References ggc_min_expand_heuristic(), and ggc_min_heapsize_heuristic().
Referenced by toplev::main().
|
static |
Decode one uleb128 from P, return first byte after it, store decoded value into *VAL.
References shift.
Referenced by gt_pch_restore().
|
static |
Callbacks for note_ptr_fn.
References gcc_assert, ptr_data::new_addr, NULL, POINTER_HASH, reloc_addrs_vec, and saving_htab.
Referenced by gt_pch_save().
void report_heap_memory_use | ( | void | ) |
Print memory used by heap if this info is available.
References PRsa, and SIZE_AMOUNT.
Referenced by execute_one_pass(), ipa_read_optimization_summaries_1(), and ipa_read_summaries_1().
|
static |
Write out, after relocation, the pointers in TAB.
References ggc_root_tab::base, fatal_error(), i, input_location, ggc_root_tab::nelt, ptr_data::new_addr, NULL, POINTER_HASH, saving_htab, and ggc_root_tab::stride.
Referenced by gt_pch_save().
|
static |
Store VAL as uleb128 at P, return length in bytes.
Referenced by gt_pch_save().
|
static |
Referenced by gt_pch_note_callback(), and gt_pch_save().
|
static |
Referenced by ggc_mark_roots(), and ggc_register_root_tab().
|
static |
GCC memory description.
Referenced by dump_ggc_loc_statistics(), ggc_free_overhead(), ggc_prune_overhead_list(), and ggc_record_overhead().
When true, protect the contents of the identifier hash table.
Referenced by compile_file(), do_compile(), and ggc_mark_roots().
|
static |
Statistics about the allocation.
Referenced by ggc_print_common_statistics().
|
static |
Referenced by gt_pch_save(), and relocate_ptrs().
|
static |
Referenced by gt_pch_note_callback(), gt_pch_note_object(), gt_pch_note_reorder(), gt_pch_save(), relocate_ptrs(), and write_pch_globals().