GCC Middle and Back End API Reference
ggc-common.c File Reference

Data Structures

struct  ptr_data
struct  saving_hasher
struct  traversal_state
struct  mmap_info
struct  loc_descriptor
struct  loc_desc_hasher
struct  ptr_hash_entry
struct  ptr_hash_hasher

Typedefs

typedef struct ggc_root_tabconst_ggc_root_tab_t
typedef struct ggc_cache_tabconst_ggc_cache_tab_t

Functions

static int ggc_htab_delete (void **, void *)
static int compare_ptr_data (const void *, const void *)
static void relocate_ptrs (void *, void *)
static void write_pch_globals (const struct ggc_root_tab *const *tab, struct traversal_state *state)
static int ggc_htab_delete ()
void ggc_register_root_tab ()
void ggc_register_cache_tab ()
static void ggc_scan_cache_tab ()
static void ggc_mark_root_tab ()
void ggc_mark_roots ()
void * ggc_internal_cleared_alloc_stat ()
void * ggc_realloc_stat ()
void * ggc_cleared_alloc_htab_ignore_args (size_t c, size_t n)
void * ggc_cleared_alloc_ptr_array_two_args ()
void * ggc_splay_alloc ()
void ggc_splay_dont_free ()
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)
void gt_pch_note_reorder (void *obj, void *note_ptr_cookie, gt_handle_reorder reorder_fn)
int ggc_call_count ()
int ggc_call_alloc ()
static int compare_ptr_data ()
static void relocate_ptrs ()
void gt_pch_save ()
void gt_pch_restore ()
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 * mmap_gt_pch_get_address ()
int mmap_gt_pch_use_address ()
static double ggc_rlimit_bound ()
static int ggc_min_expand_heuristic ()
static int ggc_min_heapsize_heuristic ()
void init_ggc_heuristics ()
static struct loc_descriptormake_loc_descriptor ()
void ggc_record_overhead (size_t allocated, size_t overhead, void *ptr, const char *name, int line, const char *function)
int ggc_prune_ptr ()
void ggc_prune_overhead_list ()
void ggc_free_overhead ()
static int final_cmp_statistic ()
static int cmp_statistic ()
int ggc_add_statistics ()
void dump_ggc_loc_statistics ()

Variables

bool ggc_force_collect
bool ggc_protect_identifiers = true
static ggc_statisticsggc_stats
static vec< const_ggc_root_tab_textra_root_vec
static vec< const_ggc_cache_tab_textra_cache_vec
static hash_table< saving_hashersaving_htab
static hash_table
< loc_desc_hasher
loc_hash
static hash_table
< ptr_hash_hasher
ptr_hash
static struct loc_descriptor ** loc_array

Typedef Documentation

This extra vector of dynamically registered cache_tab-s is used by
   ggc_mark_roots and gives the ability to dynamically add new GGC cache
   tables, for instance from some plugins; this vector is on the heap
   since it is used by GGC internally.   
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.   

Function Documentation

static int cmp_statistic ( )
static
Helper for qsort; sort descriptors by amount of memory consumed.   

References loc_descriptor::allocated, loc_descriptor::collected, loc_descriptor::freed, and loc_descriptor::overhead.

Referenced by dump_ggc_loc_statistics().

static int compare_ptr_data ( const void *  ,
const void *   
)
static

Referenced by gt_pch_save().

static int compare_ptr_data ( )
static
Callback for qsort.   

References ptr_data::new_addr.

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.   

References getpagesize().

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.   
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.   
static int final_cmp_statistic ( )
static
Helper for qsort; sort descriptors by amount of memory consumed.   

References loc_descriptor::allocated, loc_descriptor::freed, and loc_descriptor::overhead.

Referenced by dump_ggc_loc_statistics().

int ggc_add_statistics ( )

Referenced by dump_ggc_loc_statistics().

int ggc_call_count ( )
void* ggc_cleared_alloc_htab_ignore_args ( size_t  c,
size_t  n 
)
void* ggc_cleared_alloc_ptr_array_two_args ( )
TODO: once we actually use type information in GGC, create a new tag
   gt_gcc_ptr_array and use it for pointer arrays.   
static int ggc_htab_delete ( void **  ,
void *   
)
static

Referenced by ggc_scan_cache_tab().

static int ggc_htab_delete ( )
static
Maintain global roots that are preserved during GC.   
Process a slot of an htab by deleting it if it has not been marked.   

References ggc_cache_tab::base, ggc_cache_tab::cb, and ggc_cache_tab::marked_p.

void* ggc_internal_cleared_alloc_stat ( )
static void ggc_mark_root_tab ( )
static
Mark all the roots in the table RT.   

References ggc_root_tab::base, ggc_root_tab::cb, ggc_root_tab::nelt, and ggc_root_tab::stride.

Referenced by ggc_mark_roots().

static int ggc_min_expand_heuristic ( )
static
Heuristic to set a default for GGC_MIN_EXPAND.   

References ggc_rlimit_bound().

Referenced by ggc_min_heapsize_heuristic(), and init_ggc_heuristics().

static int ggc_min_heapsize_heuristic ( )
static
Heuristic to set a default for GGC_MIN_HEAPSIZE.   

References getrlimit(), ggc_min_expand_heuristic(), and ggc_rlimit_bound().

Referenced by init_ggc_heuristics().

void ggc_print_common_statistics ( FILE *  ,
ggc_statistics  
)
Used by the various collectors to gather and print statistics that
   do not depend on the collector in use.   

References ggc_collect(), 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 ggc_prune_ptr(), and hash_table< Descriptor, Allocator >::traverse().

Referenced by ggc_collect().

int ggc_prune_ptr ( )
Helper function for prune_overhead_list.  See if SLOT is still marked and
   remove it from hashtable if it is not.   

References hash_table< Descriptor, Allocator >::clear_slot(), loc_descriptor::collected, free(), ggc_marked_p(), ptr_hash_entry::loc, ptr_hash_entry::ptr, and ptr_hash_entry::size.

Referenced by ggc_prune_overhead_list().

void* ggc_realloc_stat ( )
Resize a block of memory, possibly re-allocating it.   

References ggc_free(), ggc_get_size(), ggc_internal_alloc_stat(), and memcpy().

Referenced by va_gc::reserve().

void ggc_record_overhead ( size_t  allocated,
size_t  overhead,
void *  ptr,
const char *  name,
int  line,
const char *  function 
)
void ggc_register_cache_tab ( )
Dynamically register a new GGC cache table CT. This is useful for
   plugins.  

Referenced by register_callback().

void ggc_register_root_tab ( )
Dynamically register a new GGC root table RT. This is useful for
   plugins.  

Referenced by register_callback().

static double ggc_rlimit_bound ( )
static
Modify the bound based on rlimits.   

References getrlimit(), and limit.

Referenced by ggc_min_expand_heuristic(), and ggc_min_heapsize_heuristic().

static void ggc_scan_cache_tab ( )
static
Scan a hash table that has objects which are to be deleted if they are not
   already marked.   

References ggc_cache_tab::base, ggc_htab_delete(), and ggc_set_mark().

Referenced by ggc_mark_roots().

void* ggc_splay_alloc ( )
These are for splay_tree_new_ggc.   
void ggc_splay_dont_free ( )
int gt_pch_note_object ( void *  obj,
void *  note_ptr_cookie,
gt_note_pointers  note_ptr_fn 
)
void gt_pch_note_reorder ( void *  obj,
void *  note_ptr_cookie,
gt_handle_reorder  reorder_fn 
)
void init_ggc_heuristics ( void  )
void* mmap_gt_pch_get_address ( )
Default version of HOST_HOOKS_GT_PCH_GET_ADDRESS when mmap is present.
   We temporarily allocate SIZE bytes, and let the kernel place the data
   wherever it will.  If it worked, that's our spot, if not we're likely
   to be in trouble.   
int mmap_gt_pch_use_address ( )
Default version of HOST_HOOKS_GT_PCH_USE_ADDRESS when mmap is present.
   Map SIZE bytes of FD+OFFSET at BASE.  Return 1 if we succeeded at
   mapping the data at BASE, -1 if we couldn't.

   This version assumes that the kernel honors the START operand of mmap
   even without MAP_FIXED if START through START+SIZE are not currently
   mapped with something.   
static void relocate_ptrs ( void *  ,
void *   
)
static

Referenced by gt_pch_save().

static void relocate_ptrs ( )
static
static void write_pch_globals ( const struct ggc_root_tab *const *  tab,
struct traversal_state state 
)
static

Variable Documentation

vec<const_ggc_cache_tab_t> extra_cache_vec
static
vec<const_ggc_root_tab_t> extra_root_vec
static
bool ggc_force_collect
@verbatim Simple garbage collection for the GNU compiler.

Copyright (C) 1999-2013 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.   
When set, ggc_collect will do collection.   

Referenced by dump_ggc_loc_statistics(), and ggc_collect().

bool ggc_protect_identifiers = true
When true, protect the contents of the identifier hash table.   

Referenced by compile_file(), do_compile(), and ggc_mark_roots().

ggc_statistics* ggc_stats
static
Statistics about the allocation.   
struct loc_descriptor** loc_array
static
Collect array of the descriptors from hashtable.   
hash_table<loc_desc_hasher> loc_hash
static
Hashtable used for statistics.   
hash_table<ptr_hash_hasher> ptr_hash
static
Hashtable converting address of allocated field to loc descriptor.   
hash_table<saving_hasher> saving_htab
static