GCC Middle and Back End API Reference
|
#include <memory-block.h>
Data Structures | |
struct | block_list |
Public Member Functions | |
memory_block_pool () | |
void | reduce_free_list (int) |
Static Public Member Functions | |
static void * | allocate () ATTRIBUTE_MALLOC |
static void | release (void *) |
static void | trim (int nblocks=freelist_size) |
Static Public Attributes | |
static const size_t | block_size = 64 * 1024 |
static const size_t | freelist_size = 1024 * 1024 / block_size |
Private Attributes | |
block_list * | m_blocks |
Static Private Attributes | |
static memory_block_pool | instance |
Shared pool of memory blocks for pool allocators. Copyright (C) 2015-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/>.
Shared pool which allows other memory pools to reuse each others' allocated memory blocks instead of calling free/malloc again.
memory_block_pool::memory_block_pool | ( | ) |
|
inlinestatic |
Allocate a single block. Reuse a previously returned block, if possible.
References block_size, instance, m_blocks, memory_block_pool::block_list::m_next, NULL, and VALGRIND_DISCARD.
Referenced by mempool_obstack_chunk_alloc().
void memory_block_pool::reduce_free_list | ( | int | num | ) |
Reduce free list to NUM blocks and return remaining to malloc.
References m_blocks, memory_block_pool::block_list::m_next, and NULL.
Referenced by trim().
|
inlinestatic |
Return UNCAST_BLOCK to the pool.
References block_size, instance, m_blocks, memory_block_pool::block_list::m_next, and VALGRIND_DISCARD.
Referenced by mempool_obstack_chunk_free().
|
static |
Return allocated memory back to malloc (and to system).
References instance, and reduce_free_list().
Referenced by ggc_collect().
|
static |
Referenced by allocate(), mempool_obstack_chunk_alloc(), mempool_obstack_chunk_free(), and release().
|
static |
|
staticprivate |
Shared pool of memory blocks for pool allocators. Copyright (C) 2015-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/>.
Global singleton-like instance.
Referenced by allocate(), release(), and trim().
|
private |
Referenced by allocate(), reduce_free_list(), and release().