GCC Middle and Back End API Reference
alloc-pool.c File Reference
#include "config.h"
#include "system.h"
#include "alloc-pool.h"
#include "hash-table.h"
Include dependency graph for alloc-pool.c:

Data Structures

struct  allocation_object_def
struct  alloc_pool_descriptor
struct  alloc_pool_hasher
struct  output_info

Macros

#define align_eight(x)   (((x+7) >> 3) << 3)
#define ALLOCATION_OBJECT_PTR_FROM_USER_PTR(X)
#define USER_PTR_FROM_ALLOCATION_OBJECT_PTR(X)   ((void *) (((allocation_object *) (X))->u.data))

Typedefs

typedef struct
allocation_object_def 
allocation_object

Functions

static struct
alloc_pool_descriptor
allocate_pool_descriptor ()
alloc_pool create_alloc_pool ()
void empty_alloc_pool ()
void free_alloc_pool ()
void free_alloc_pool_if_empty ()
void * pool_alloc ()
void pool_free ()
int print_alloc_pool_statistics (alloc_pool_descriptor **slot, struct output_info *i)
void dump_alloc_pool_statistics ()

Variables

static hash_table
< alloc_pool_hasher
alloc_pool_hash

Macro Definition Documentation

#define align_eight (   x)    (((x+7) >> 3) << 3)

Functions to support a pool of allocatable objects. Copyright (C) 1987-2013 Free Software Foundation, Inc. Contributed by Daniel Berlin dan@c.nosp@m.gsof.nosp@m.tware.nosp@m..com

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/.

Referenced by allocate_pool_descriptor().

#define ALLOCATION_OBJECT_PTR_FROM_USER_PTR (   X)
Value:
((allocation_object *) (((char *) (X)) \

Convert a pointer to allocation_object from a pointer to user data.

#define USER_PTR_FROM_ALLOCATION_OBJECT_PTR (   X)    ((void *) (((allocation_object *) (X))->u.data))

Convert a pointer to user data from a pointer to allocation_object.


Typedef Documentation

The internal allocation object.


Function Documentation

static struct alloc_pool_descriptor* allocate_pool_descriptor ( )
staticread

For given name, return descriptor, create new if needed.

References align_eight, allocation_object_def::data, gcc_checking_assert, and offsetof.

Referenced by free_alloc_pool().

alloc_pool create_alloc_pool ( )

Create a pool of things of size SIZE, with NUM in each block we allocate.

 Make size large enough to store the list header.   
 Now align the size to a multiple of 4.   
 Um, we can't really allocate 0 elements per block.   
 Allocate memory for the pool structure.   
 Now init the various pieces of our pool structure.   
 List header size should be a multiple of 8.   

Referenced by copy_reference(), emit_notes_for_changes(), ira_free_allocno_updated_costs(), and print_allocno_prefs().

void dump_alloc_pool_statistics ( void  )

Output per-alloc_pool memory usage statistics.

void empty_alloc_pool ( )

Free all memory allocated for the given memory pool.

Free each block allocated to the pool.

void free_alloc_pool ( )

Free all memory allocated for the given memory pool and the pool itself.

First empty the pool.

 Lastly, free the pool.   

References allocate_pool_descriptor(), alloc_pool_descriptor::allocated, alloc_pool_descriptor::current, alloc_pool_def::elt_size, alloc_pool_def::name, and alloc_pool_descriptor::peak.

Referenced by debug(), fp_setter_insn(), ira_finish_live_range_list(), lra_set_used_insn_alternative_by_uid(), and process_scc().

void free_alloc_pool_if_empty ( )

Frees the alloc_pool, if it is empty and zero *POOL in this case.

References alloc_pool_def::block_size, and alloc_pool_def::virgin_elts_remaining.

Referenced by et_free_tree().

void* pool_alloc ( )

Allocates one element from the pool specified.

 If there are no more free elements, make some more!.   
         Make the block.   
         Throw it on the block list.   
         Make the block available for allocation.   
         Also update the number of elements we have free/allocated, and
         increment the allocated block count.   
     We now know that we can take the first elt off the virgin list and
     put it on the returned list.  
 Pull the first free element from the free list, and return it.   

Referenced by account_time_size(), asan_mem_ref_init(), build_access_from_expr_1(), canonicalize_values_star(), create_live_range(), dv_from_value(), free_live_range_list(), initialize_lra_reg_info_element(), insert_aux(), ipa_free_all_edge_args(), ipa_free_node_params_substructures(), ira_create_object(), lra_update_dups(), record_store(), set_cond_stmt_execution_predicate(), vn_nary_op_insert_into(), and vt_find_locations().

int print_alloc_pool_statistics ( alloc_pool_descriptor **  slot,
struct output_info i 
)

Called via hash_table.traverse. Output alloc_pool descriptor pointed out by SLOT and update statistics.


Variable Documentation

hash_table<alloc_pool_hasher> alloc_pool_hash
static

Hashtable mapping alloc_pool names to descriptors.