|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "lib/ilist.h"#include "port/pg_bitutils.h"#include "utils/memdebug.h"#include "utils/memutils.h"#include "utils/memutils_memorychunk.h"#include "utils/memutils_internal.h"
Go to the source code of this file.
Data Structures | |
| struct | BumpContext |
| struct | BumpBlock |
Macros | |
| #define | Bump_BLOCKHDRSZ MAXALIGN(sizeof(BumpBlock)) |
| #define | FIRST_BLOCKHDRSZ |
| #define | Bump_CHUNKHDRSZ 0 |
| #define | Bump_CHUNK_FRACTION 8 |
| #define | KeeperBlock(set) |
| #define | IsKeeperBlock(set, blk) (KeeperBlock(set) == (blk)) |
| #define | BumpIsValid(set) ((set) && IsA(set, BumpContext)) |
| #define | ExternalChunkGetBlock(chunk) (BumpBlock *) ((char *) chunk - Bump_BLOCKHDRSZ) |
Typedefs | |
| typedef struct BumpBlock | BumpBlock |
| typedef struct BumpContext | BumpContext |
Functions | |
| static void | BumpBlockInit (BumpContext *context, BumpBlock *block, Size blksize) |
| static bool | BumpBlockIsEmpty (BumpBlock *block) |
| static void | BumpBlockMarkEmpty (BumpBlock *block) |
| static Size | BumpBlockFreeBytes (BumpBlock *block) |
| static void | BumpBlockFree (BumpContext *set, BumpBlock *block) |
| MemoryContext | BumpContextCreate (MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize) |
| void | BumpReset (MemoryContext context) |
| void | BumpDelete (MemoryContext context) |
| static pg_noinline void * | BumpAllocLarge (MemoryContext context, Size size, int flags) |
| static void * | BumpAllocChunkFromBlock (MemoryContext context, BumpBlock *block, Size size, Size chunk_size) |
| static pg_noinline void * | BumpAllocFromNewBlock (MemoryContext context, Size size, int flags, Size chunk_size) |
| void * | BumpAlloc (MemoryContext context, Size size, int flags) |
| void | BumpFree (void *pointer) |
| void * | BumpRealloc (void *pointer, Size size, int flags) |
| MemoryContext | BumpGetChunkContext (void *pointer) |
| Size | BumpGetChunkSpace (void *pointer) |
| bool | BumpIsEmpty (MemoryContext context) |
| void | BumpStats (MemoryContext context, MemoryStatsPrintFunc printfunc, void *passthru, MemoryContextCounters *totals, bool print_to_stderr) |
| #define BumpIsValid | ( | set | ) | ((set) && IsA(set, BumpContext)) |
| #define ExternalChunkGetBlock | ( | chunk | ) | (BumpBlock *) ((char *) chunk - Bump_BLOCKHDRSZ) |
| #define FIRST_BLOCKHDRSZ |
| #define IsKeeperBlock | ( | set, | |
| blk | |||
| ) | (KeeperBlock(set) == (blk)) |
| #define KeeperBlock | ( | set | ) |
| typedef struct BumpContext BumpContext |
| void * BumpAlloc | ( | MemoryContext | context, |
| Size | size, | ||
| int | flags | ||
| ) |
Definition at line 517 of file bump.c.
References BumpContext::allocChunkLimit, Assert(), BumpContext::blocks, Bump_CHUNKHDRSZ, BumpAllocChunkFromBlock(), BumpAllocFromNewBlock(), BumpAllocLarge(), BumpBlockFreeBytes(), BumpIsValid, dlist_container, dlist_head_node(), and MAXALIGN.
|
inlinestatic |
Definition at line 394 of file bump.c.
References Assert(), Bump_CHUNKHDRSZ, BumpBlock::endptr, BumpBlock::freeptr, MCTX_BUMP_ID, MemoryChunkGetPointer, MemoryChunkSetHdrMask(), VALGRIND_MAKE_MEM_NOACCESS, and VALGRIND_MAKE_MEM_UNDEFINED.
Referenced by BumpAlloc(), and BumpAllocFromNewBlock().
|
static |
Definition at line 453 of file bump.c.
References BumpContext::blocks, Bump_BLOCKHDRSZ, Bump_CHUNKHDRSZ, BumpAllocChunkFromBlock(), BumpBlockInit(), dlist_push_head(), malloc, BumpContext::maxBlockSize, MemoryContextData::mem_allocated, MemoryContextAllocationFailure(), BumpContext::nextBlockSize, BumpBlock::node, pg_nextpower2_size_t, and VALGRIND_MEMPOOL_ALLOC.
Referenced by BumpAlloc().
|
static |
Definition at line 313 of file bump.c.
References Assert(), BumpContext::blocks, Bump_BLOCKHDRSZ, Bump_CHUNKHDRSZ, dlist_push_tail(), BumpBlock::endptr, BumpBlock::freeptr, malloc, MAXALIGN, MCTX_BUMP_ID, MemoryContextData::mem_allocated, MemoryChunkGetPointer, MemoryChunkSetHdrMaskExternal(), MemoryContextAllocationFailure(), MemoryContextCheckSize(), BumpBlock::node, VALGRIND_MAKE_MEM_NOACCESS, and VALGRIND_MEMPOOL_ALLOC.
Referenced by BumpAlloc().
|
inlinestatic |
Definition at line 621 of file bump.c.
References Assert(), dlist_delete(), BumpBlock::endptr, free, IsKeeperBlock, BumpBlock::node, and VALGRIND_MEMPOOL_FREE.
Referenced by BumpReset().
Definition at line 611 of file bump.c.
References BumpBlock::endptr, and BumpBlock::freeptr.
Referenced by BumpAlloc().
|
inlinestatic |
Definition at line 561 of file bump.c.
References Bump_BLOCKHDRSZ, BumpBlock::endptr, BumpBlock::freeptr, and VALGRIND_MAKE_MEM_NOACCESS.
Referenced by BumpAllocFromNewBlock(), and BumpContextCreate().
|
inlinestatic |
Definition at line 578 of file bump.c.
References Bump_BLOCKHDRSZ, and BumpBlock::freeptr.
Referenced by BumpIsEmpty().
|
inlinestatic |
Definition at line 589 of file bump.c.
References Bump_BLOCKHDRSZ, BumpBlock::freeptr, and VALGRIND_MAKE_MEM_NOACCESS.
Referenced by BumpReset().
| MemoryContext BumpContextCreate | ( | MemoryContext | parent, |
| const char * | name, | ||
| Size | minContextSize, | ||
| Size | initBlockSize, | ||
| Size | maxBlockSize | ||
| ) |
Definition at line 133 of file bump.c.
References BumpContext::allocChunkLimit, AllocHugeSizeIsValid, Assert(), BumpContext::blocks, Bump_BLOCKHDRSZ, Bump_CHUNK_FRACTION, Bump_CHUNKHDRSZ, BumpBlockInit(), dlist_init(), dlist_push_head(), ereport, errcode(), errdetail(), errmsg(), ERROR, FIRST_BLOCKHDRSZ, BumpContext::initBlockSize, KeeperBlock, malloc, Max, MAXALIGN, BumpContext::maxBlockSize, MCTX_BUMP_ID, MEMORYCHUNK_MAX_BLOCKOFFSET, MEMORYCHUNK_MAX_VALUE, MemoryContextCreate(), MemoryContextStats(), Min, name, BumpContext::nextBlockSize, BumpBlock::node, StaticAssertDecl, TopMemoryContext, VALGRIND_CREATE_MEMPOOL, and VALGRIND_MEMPOOL_ALLOC.
Referenced by ExecInitRecursiveUnion(), ExecInitSetOp(), ExecInitSubPlan(), hash_create_memory(), TidStoreCreateLocal(), and tuplesort_begin_batch().
| void BumpDelete | ( | MemoryContext | context | ) |
Definition at line 294 of file bump.c.
References BumpReset(), free, and VALGRIND_DESTROY_MEMPOOL.
| void BumpFree | ( | void * | pointer | ) |
| MemoryContext BumpGetChunkContext | ( | void * | pointer | ) |
| Size BumpGetChunkSpace | ( | void * | pointer | ) |
| bool BumpIsEmpty | ( | MemoryContext | context | ) |
Definition at line 689 of file bump.c.
References Assert(), BumpContext::blocks, BumpBlockIsEmpty(), BumpIsValid, dlist_iter::cur, dlist_container, and dlist_foreach.
| void * BumpRealloc | ( | void * | pointer, |
| Size | size, | ||
| int | flags | ||
| ) |
| void BumpReset | ( | MemoryContext | context | ) |
Definition at line 251 of file bump.c.
References Assert(), BumpContext::blocks, BumpBlockFree(), BumpBlockMarkEmpty(), BumpIsValid, dlist_mutable_iter::cur, dlist_container, dlist_foreach_modify, dlist_has_next(), dlist_head_node(), dlist_is_empty(), FIRST_BLOCKHDRSZ, BumpContext::initBlockSize, IsKeeperBlock, BumpContext::nextBlockSize, and VALGRIND_MEMPOOL_TRIM.
Referenced by BumpDelete().
| void BumpStats | ( | MemoryContext | context, |
| MemoryStatsPrintFunc | printfunc, | ||
| void * | passthru, | ||
| MemoryContextCounters * | totals, | ||
| bool | print_to_stderr | ||
| ) |
Definition at line 717 of file bump.c.
References Assert(), BumpContext::blocks, BumpIsValid, dlist_iter::cur, dlist_container, dlist_foreach, BumpBlock::endptr, BumpBlock::freeptr, MemoryContextCounters::freespace, MemoryContextCounters::nblocks, snprintf, and MemoryContextCounters::totalspace.