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_internal.h"
#include "utils/memutils_memorychunk.h"
Go to the source code of this file.
Data Structures | |
struct | GenerationContext |
struct | GenerationBlock |
Macros | |
#define | Generation_BLOCKHDRSZ MAXALIGN(sizeof(GenerationBlock)) |
#define | Generation_CHUNKHDRSZ sizeof(MemoryChunk) |
#define | Generation_CHUNK_FRACTION 8 |
#define | GenerationIsValid(set) (PointerIsValid(set) && IsA(set, GenerationContext)) |
#define | GenerationBlockIsValid(block) (PointerIsValid(block) && GenerationIsValid((block)->context)) |
#define | GenerationBlockIsEmpty(b) ((b)->nchunks == 0) |
#define | ExternalChunkGetBlock(chunk) (GenerationBlock *) ((char *) chunk - Generation_BLOCKHDRSZ) |
#define | KeeperBlock(set) |
#define | IsKeeperBlock(set, block) ((block) == (KeeperBlock(set))) |
Typedefs | |
typedef struct GenerationBlock | GenerationBlock |
typedef void * | GenerationPointer |
typedef struct GenerationContext | GenerationContext |
#define ExternalChunkGetBlock | ( | chunk | ) | (GenerationBlock *) ((char *) chunk - Generation_BLOCKHDRSZ) |
Definition at line 123 of file generation.c.
#define Generation_BLOCKHDRSZ MAXALIGN(sizeof(GenerationBlock)) |
Definition at line 46 of file generation.c.
#define Generation_CHUNK_FRACTION 8 |
Definition at line 49 of file generation.c.
#define Generation_CHUNKHDRSZ sizeof(MemoryChunk) |
Definition at line 47 of file generation.c.
Definition at line 116 of file generation.c.
#define GenerationBlockIsValid | ( | block | ) | (PointerIsValid(block) && GenerationIsValid((block)->context)) |
Definition at line 109 of file generation.c.
#define GenerationIsValid | ( | set | ) | (PointerIsValid(set) && IsA(set, GenerationContext)) |
Definition at line 102 of file generation.c.
#define IsKeeperBlock | ( | set, | |
block | |||
) | ((block) == (KeeperBlock(set))) |
Definition at line 132 of file generation.c.
#define KeeperBlock | ( | set | ) |
Definition at line 127 of file generation.c.
typedef struct GenerationBlock GenerationBlock |
Definition at line 1 of file generation.c.
typedef struct GenerationContext GenerationContext |
typedef void* GenerationPointer |
Definition at line 53 of file generation.c.
void* GenerationAlloc | ( | MemoryContext | context, |
Size | size, | ||
int | flags | ||
) |
Definition at line 527 of file generation.c.
References GenerationContext::allocChunkLimit, Assert, GenerationContext::block, context, GenerationContext::freeblock, Generation_CHUNKHDRSZ, GenerationAllocChunkFromBlock(), GenerationAllocFromNewBlock(), GenerationAllocLarge(), GenerationBlockFreeBytes(), GenerationBlockIsEmpty, GenerationIsValid, MAXALIGN, size, and unlikely.
Referenced by GenerationRealloc().
|
inlinestatic |
Definition at line 413 of file generation.c.
References Assert, chunk, GenerationBlock::endptr, GenerationBlock::freeptr, Generation_CHUNKHDRSZ, MCTX_GENERATION_ID, MemoryChunkGetPointer, MemoryChunkSetHdrMask(), GenerationBlock::nchunks, size, VALGRIND_MAKE_MEM_NOACCESS, and VALGRIND_MAKE_MEM_UNDEFINED.
Referenced by GenerationAlloc(), and GenerationAllocFromNewBlock().
|
static |
Definition at line 461 of file generation.c.
References GenerationContext::block, GenerationContext::blocks, context, dlist_push_head(), Generation_BLOCKHDRSZ, Generation_CHUNKHDRSZ, GenerationAllocChunkFromBlock(), GenerationBlockInit(), malloc, GenerationContext::maxBlockSize, MemoryContextAllocationFailure(), GenerationContext::nextBlockSize, GenerationBlock::node, pg_nextpower2_size_t, and size.
Referenced by GenerationAlloc().
|
static |
Definition at line 343 of file generation.c.
References Assert, GenerationBlock::blksize, GenerationContext::blocks, chunk, GenerationBlock::context, context, dlist_push_head(), GenerationBlock::endptr, GenerationBlock::freeptr, Generation_BLOCKHDRSZ, Generation_CHUNKHDRSZ, malloc, MAXALIGN, MCTX_GENERATION_ID, MemoryChunkGetPointer, MemoryChunkSetHdrMaskExternal(), MemoryContextAllocationFailure(), MemoryContextCheckSize(), GenerationBlock::nchunks, GenerationBlock::nfree, GenerationBlock::node, size, and VALGRIND_MAKE_MEM_NOACCESS.
Referenced by GenerationAlloc().
|
inlinestatic |
Definition at line 664 of file generation.c.
References Assert, GenerationBlock::blksize, dlist_delete(), free, GenerationContext::freeblock, IsKeeperBlock, and GenerationBlock::node.
Referenced by GenerationFree(), and GenerationReset().
|
inlinestatic |
Definition at line 654 of file generation.c.
References GenerationBlock::endptr, and GenerationBlock::freeptr.
Referenced by GenerationAlloc().
|
inlinestatic |
Definition at line 609 of file generation.c.
References GenerationBlock::blksize, GenerationBlock::context, context, GenerationBlock::endptr, GenerationBlock::freeptr, Generation_BLOCKHDRSZ, GenerationBlock::nchunks, GenerationBlock::nfree, and VALGRIND_MAKE_MEM_NOACCESS.
Referenced by GenerationAllocFromNewBlock(), and GenerationContextCreate().
|
inlinestatic |
Definition at line 630 of file generation.c.
References GenerationBlock::freeptr, Generation_BLOCKHDRSZ, GenerationBlock::nchunks, GenerationBlock::nfree, and VALGRIND_MAKE_MEM_NOACCESS.
Referenced by GenerationFree(), and GenerationReset().
MemoryContext GenerationContextCreate | ( | MemoryContext | parent, |
const char * | name, | ||
Size | minContextSize, | ||
Size | initBlockSize, | ||
Size | maxBlockSize | ||
) |
Definition at line 160 of file generation.c.
References GenerationContext::allocChunkLimit, AllocHugeSizeIsValid, Assert, GenerationContext::block, GenerationContext::blocks, dlist_init(), dlist_push_head(), ereport, errcode(), errdetail(), errmsg(), ERROR, GenerationContext::freeblock, Generation_BLOCKHDRSZ, Generation_CHUNK_FRACTION, Generation_CHUNKHDRSZ, GenerationBlockInit(), GenerationContext::initBlockSize, KeeperBlock, malloc, Max, MAXALIGN, GenerationContext::maxBlockSize, MCTX_GENERATION_ID, MEMORYCHUNK_MAX_BLOCKOFFSET, MEMORYCHUNK_MAX_VALUE, MemoryContextCreate(), MemoryContextStats(), Min, name, GenerationContext::nextBlockSize, GenerationBlock::node, StaticAssertDecl, and TopMemoryContext.
Referenced by gistvacuumscan(), ReorderBufferAllocate(), and tuplestore_begin_common().
void GenerationDelete | ( | MemoryContext | context | ) |
void GenerationFree | ( | void * | pointer | ) |
Definition at line 689 of file generation.c.
References Assert, GenerationContext::block, chunk, GenerationBlock::context, elog, GenerationBlock::endptr, ERROR, ExternalChunkGetBlock, GenerationContext::freeblock, Generation_CHUNKHDRSZ, GenerationBlockFree(), GenerationBlockIsValid, GenerationBlockMarkEmpty(), InvalidAllocSize, IsKeeperBlock, likely, MemoryChunkGetBlock(), MemoryChunkGetValue(), MemoryChunkIsExternal(), GenerationBlock::nchunks, GenerationBlock::nfree, PointerGetMemoryChunk, VALGRIND_MAKE_MEM_DEFINED, and WARNING.
Referenced by GenerationRealloc().
MemoryContext GenerationGetChunkContext | ( | void * | pointer | ) |
Definition at line 947 of file generation.c.
References Assert, chunk, GenerationBlock::context, ExternalChunkGetBlock, Generation_CHUNKHDRSZ, GenerationBlockIsValid, GenerationContext::header, MemoryChunkGetBlock(), MemoryChunkIsExternal(), PointerGetMemoryChunk, VALGRIND_MAKE_MEM_DEFINED, and VALGRIND_MAKE_MEM_NOACCESS.
Size GenerationGetChunkSpace | ( | void * | pointer | ) |
Definition at line 973 of file generation.c.
References Assert, chunk, GenerationBlock::endptr, ExternalChunkGetBlock, Generation_CHUNKHDRSZ, GenerationBlockIsValid, MemoryChunkGetValue(), MemoryChunkIsExternal(), PointerGetMemoryChunk, VALGRIND_MAKE_MEM_DEFINED, and VALGRIND_MAKE_MEM_NOACCESS.
bool GenerationIsEmpty | ( | MemoryContext | context | ) |
Definition at line 1002 of file generation.c.
References Assert, GenerationContext::blocks, context, dlist_iter::cur, dlist_container, dlist_foreach, GenerationIsValid, and GenerationBlock::nchunks.
void* GenerationRealloc | ( | void * | pointer, |
Size | size, | ||
int | flags | ||
) |
Definition at line 800 of file generation.c.
References Assert, chunk, GenerationBlock::context, elog, GenerationBlock::endptr, ERROR, ExternalChunkGetBlock, Generation_CHUNKHDRSZ, GenerationAlloc(), GenerationBlockIsValid, GenerationFree(), MemoryChunkGetBlock(), MemoryChunkGetValue(), MemoryChunkIsExternal(), MemoryContextAllocationFailure(), name, PointerGetMemoryChunk, size, VALGRIND_MAKE_MEM_DEFINED, VALGRIND_MAKE_MEM_NOACCESS, VALGRIND_MAKE_MEM_UNDEFINED, and WARNING.
void GenerationReset | ( | MemoryContext | context | ) |
Definition at line 283 of file generation.c.
References Assert, GenerationContext::block, GenerationContext::blocks, context, dlist_mutable_iter::cur, dlist_container, dlist_foreach_modify, dlist_has_next(), dlist_head_node(), dlist_is_empty(), GenerationContext::freeblock, GenerationBlockFree(), GenerationBlockMarkEmpty(), GenerationIsValid, GenerationContext::initBlockSize, IsKeeperBlock, KeeperBlock, and GenerationContext::nextBlockSize.
Referenced by GenerationDelete().
void GenerationStats | ( | MemoryContext | context, |
MemoryStatsPrintFunc | printfunc, | ||
void * | passthru, | ||
MemoryContextCounters * | totals, | ||
bool | print_to_stderr | ||
) |
Definition at line 1033 of file generation.c.
References Assert, GenerationBlock::blksize, GenerationContext::blocks, context, dlist_iter::cur, dlist_container, dlist_foreach, GenerationBlock::endptr, MemoryContextCounters::freechunks, GenerationBlock::freeptr, MemoryContextCounters::freespace, GenerationIsValid, MAXALIGN, MemoryContextCounters::nblocks, GenerationBlock::nchunks, GenerationBlock::nfree, snprintf, and MemoryContextCounters::totalspace.