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) (hashval_t)((intptr_t)x >> 3) |
Typedefs | |
typedef const struct ggc_root_tab * | const_ggc_root_tab_t |
#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.
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.
Callback for qsort.
References ggc_alloc().
Referenced by ipa_icf_gimple::func_checker::compatible_polymorphic_types_p(), and gt_pch_save().
Default version of HOST_HOOKS_GT_PCH_GET_ADDRESS. Return the alignment required for allocating virtual memory. Usually this is the same as pagesize.
References ggc_alloc().
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.
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.
References ggc_alloc().
void dump_ggc_loc_statistics | ( | ) |
Dump per-site memory statistics.
References ggc_alloc(), 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().
References gcc_assert, and ggc_alloc().
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_alloc().
void ggc_common_finalize | ( | ) |
Forcibly clear all GTY roots.
References ggc_alloc(), ggc_zero_rtab_roots(), gt_ggc_deletable_rtab, gt_ggc_rtab, gt_pch_scalar_rtab, and NULL.
Referenced by toplev::finalize().
void * ggc_internal_cleared_alloc | ( | size_t | size, |
void(*)(void *) | f, | ||
size_t | s, | ||
size_t n | MEM_STAT_DECL ) |
Allocate a block of memory, then clear it.
References ggc_alloc(), ggc_internal_alloc(), and PASS_MEM_STAT.
|
static |
Mark all the roots in the table RT.
References ggc_alloc(), i, and NULL.
Referenced by ggc_mark_roots().
Iterate through all registered roots and mark each element.
References extra_root_vec, FOR_EACH_VEC_ELT, ggc_alloc(), 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(), and NULL.
Referenced by ggc_collect().
Heuristic to set a default for GGC_MIN_EXPAND.
References ggc_alloc(), ggc_rlimit_bound(), MIN, and ONE_G.
Referenced by ggc_min_heapsize_heuristic(), and init_ggc_heuristics().
Heuristic to set a default for GGC_MIN_HEAPSIZE.
References ggc_alloc(), 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().
After live values has been marked, walk all recorded pointers and see if they are still live.
References ggc_alloc(), ggc_marked_p(), and ggc_mem_desc.
Referenced by ggc_collect().
Resize a block of memory, possibly re-allocating it.
References ggc_alloc(), 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().
Record ALLOCATED and OVERHEAD bytes to descriptor NAME:LINE (FUNCTION).
References FINAL_PASS_MEM_STAT, ggc_alloc(), 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, and ggc_alloc().
Referenced by register_callback().
Modify the bound based on rlimits.
References ggc_alloc(), and ONE_M.
Referenced by ggc_min_expand_heuristic(), and ggc_min_heapsize_heuristic().
These are for splay_tree_new_ggc.
References gcc_assert, and ggc_internal_alloc().
References gcc_assert.
|
static |
Zero out all the roots in the table RT.
References ggc_alloc(), i, and NULL.
Referenced by ggc_common_finalize().
Register address of a callback pointer.
References callback_vec, gcc_assert, ggc_alloc(), 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_alloc(), 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.
Read the state of the compiler back in from F.
References fatal_error(), gcc_assert, ggc_alloc(), 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, NULL, read_uleb128(), SEEK_CUR, SEEK_SET, and sorry_at().
Write out the state of the compiler to F.
References callback_vec, compare_ptr(), compare_ptr_data(), fatal_error(), gcc_assert, gcc_checking_assert, ggc_alloc(), 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, NULL, qsort, reloc_addrs_vec, relocate_ptrs(), saving_htab, SEEK_SET, timevar_pop(), timevar_push(), UNLIKELY, VALGRIND_DISCARD, vNULL, write_pch_globals(), and write_uleb128().
Referenced by gt_pch_restore(), and gt_pch_save().
Heuristics.
References ggc_alloc(), ggc_min_expand_heuristic(), and ggc_min_heapsize_heuristic().
Referenced by toplev::main().
Decode one uleb128 from P, return first byte after it, store decoded value into *VAL.
References ggc_alloc(), and shift.
Referenced by gt_pch_restore().
Callbacks for note_ptr_fn.
References gcc_assert, ggc_alloc(), ptr_data::new_addr, NULL, POINTER_HASH, reloc_addrs_vec, and saving_htab.
Referenced by gt_pch_save().
Print memory used by heap if this info is available.
References ggc_alloc(), 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 fatal_error(), ggc_alloc(), i, input_location, NULL, POINTER_HASH, and saving_htab.
Referenced by gt_pch_save().
Store VAL as uleb128 at P, return length in bytes.
Referenced by gt_pch_save().
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().
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().