YAP 7.1.0
Memory Allocation in YAP

Memory organization and Auxiliary Memory Access Data-structures and routines. More...

Detailed Description

Memory organization and Auxiliary Memory Access Data-structures and routines.

@ section Space Organization: The data areas is divided in the following way:

Lower Addresses
HeapBase \
| Atom and code space
HeapTop-1 /
HeapTop \
| Free Space
HeapMax /
GlobalBase-1/
GlobalBase \
| Global Stack
H /
ASP \
| Local stack
LocalBase /
TRBase /
TR \
| Trail
Higher Adresses

Modules

 Using a scratch buffer
 use a scratch buffer (maybe even many),
 
 Stack Discipline Memory Allocation
 memory who lives during a stack activation
 

Class Documentation

◆ FREEB

struct FREEB

Definition at line 63 of file alloc.h.

Public Attributes

YAP_SEG_SIZE b_size
 
struct FREEBb_next
 
struct FREEBb_next_size
 

Member Data Documentation

◆ b_next

struct FREEB* b_next

Definition at line 65 of file alloc.h.

◆ b_next_size

struct FREEB* b_next_size

Definition at line 66 of file alloc.h.

◆ b_size

YAP_SEG_SIZE b_size

Definition at line 64 of file alloc.h.

◆ scratch_buf_struct_t

struct scratch_buf_struct_t

thread view of the scratch buffer

Definition at line 164 of file alloc.h.

Public Attributes

void * data
 
size_t sz
 

buffer data

More...
 
bool in_use
 

buffer size

More...
 

Member Data Documentation

◆ data

void* data

Definition at line 165 of file alloc.h.

◆ in_use

bool in_use

buffer size

Definition at line 167 of file alloc.h.

◆ sz

size_t sz

buffer data

Definition at line 166 of file alloc.h.

◆ scratch_user_buf_struct_t

struct scratch_user_buf_struct_t

user view of the scratch buffer

Definition at line 171 of file alloc.h.

Public Attributes

void * data
 
bool is_thread_scratch_buf
 

the goods

More...
 
size_t n_of
 

are we using Local_ScratchBuf for this

More...
 
size_t size_of
 

Member Data Documentation

◆ data

void* data

Definition at line 172 of file alloc.h.

◆ is_thread_scratch_buf

bool is_thread_scratch_buf

the goods

Definition at line 173 of file alloc.h.

◆ n_of

size_t n_of

are we using Local_ScratchBuf for this

Definition at line 174 of file alloc.h.

◆ size_of

size_t size_of

Definition at line 174 of file alloc.h.

Macro Definition Documentation

◆ AdjustLargePageSize

#define AdjustLargePageSize (   X)    (((X)+ (LGPAGE_SIZE-1))/LGPAGE_SIZE)*LGPAGE_SIZE;

Definition at line 105 of file alloc.h.

◆ AdjustPageSize

#define AdjustPageSize (   X)    (((X)+ (YAP_ALLOC_SIZE-1))/YAP_ALLOC_SIZE)*YAP_ALLOC_SIZE;

Definition at line 104 of file alloc.h.

◆ AdjustSize

#define AdjustSize (   X)    ((X+YAP_ALIGN) & YAP_ALIGNMASK)

Definition at line 88 of file alloc.h.

◆ ALIGN_SIZE

#define ALIGN_SIZE (   X,
  SIZE 
)    (((CELL)(X)+((SIZE)-1)) & ~((SIZE)-1))

Definition at line 91 of file alloc.h.

◆ BlockTrailer

#define BlockTrailer (   b)    ((YAP_SEG_SIZE *)b)[((BlockHeader *) b)->b_size]

Definition at line 107 of file alloc.h.

◆ InUseFlag

#define InUseFlag   0x80000000

Definition at line 73 of file alloc.h.

◆ K

#define K   ((Int) 1024)

Definition at line 69 of file alloc.h.

◆ LGPAGE_SIZE

#define LGPAGE_SIZE   (16*Yap_page_size)

Definition at line 101 of file alloc.h.

◆ MaxBlockSize

#define MaxBlockSize   0xffffff

Definition at line 72 of file alloc.h.

◆ MaxTmp

#define MaxTmp (   USES_REGS1)    (MaxBlockSize+1)

Definition at line 75 of file alloc.h.

◆ MinBlockSize

#define MinBlockSize   (sizeof(BlockHeader)+sizeof(YAP_SEG_SIZE))

Definition at line 71 of file alloc.h.

◆ SCRATCH_INC_SIZE

#define SCRATCH_INC_SIZE   K64

Definition at line 153 of file alloc.h.

◆ SCRATCH_START_SIZE

#define SCRATCH_START_SIZE   K64

Definition at line 152 of file alloc.h.

◆ YAP_ALIGN

#define YAP_ALIGN   7

Definition at line 84 of file alloc.h.

◆ YAP_ALIGNMASK

#define YAP_ALIGNMASK   ((CELL)(-8))

Definition at line 85 of file alloc.h.

◆ YAP_ALLOC_SIZE

#define YAP_ALLOC_SIZE   Yap_page_size

Definition at line 100 of file alloc.h.

Typedef Documentation

◆ YAP_SEG_SIZE

typedef CELL YAP_SEG_SIZE

definitions required by saver/restorer and memory manager

Definition at line 61 of file alloc.h.

Function Documentation

◆ Yap_add_memory_hole()

void Yap_add_memory_hole ( ADDR  Start,
ADDR  End 
)

Definition at line 1540 of file alloc.c.

◆ Yap_AllocHole()

void Yap_AllocHole ( UInt  actual_request,
UInt  total_size 
)

Definition at line 1597 of file alloc.c.

◆ Yap_InitHeap()

void Yap_InitHeap ( void *  heap_addr)

Definition at line 1463 of file alloc.c.

Variable Documentation

◆ Yap_page_size

size_t Yap_page_size
extern

Definition at line 97 of file init.c.

Macros

#define K   ((Int) 1024)
 
#define MinBlockSize   (sizeof(BlockHeader)+sizeof(YAP_SEG_SIZE))
 
#define MaxBlockSize   0xffffff
 
#define InUseFlag   0x80000000
 
#define MaxTmp(USES_REGS1)   (MaxBlockSize+1)
 
#define YAP_ALIGN   7
 
#define YAP_ALIGNMASK   ((CELL)(-8))
 
#define AdjustSize(X)   ((X+YAP_ALIGN) & YAP_ALIGNMASK)
 
#define ALIGN_SIZE(X, SIZE)   (((CELL)(X)+((SIZE)-1)) & ~((SIZE)-1))
 
#define YAP_ALLOC_SIZE   Yap_page_size
 
#define LGPAGE_SIZE   (16*Yap_page_size)
 
#define AdjustPageSize(X)   (((X)+ (YAP_ALLOC_SIZE-1))/YAP_ALLOC_SIZE)*YAP_ALLOC_SIZE;
 
#define AdjustLargePageSize(X)   (((X)+ (LGPAGE_SIZE-1))/LGPAGE_SIZE)*LGPAGE_SIZE;
 
#define BlockTrailer(b)   ((YAP_SEG_SIZE *)b)[((BlockHeader *) b)->b_size]
 
#define SCRATCH_START_SIZE   K64
 
#define SCRATCH_INC_SIZE   K64
 

Typedefs

typedef CELL YAP_SEG_SIZE
 definitions required by saver/restorer and memory manager More...
 
typedef struct FREEB BlockHeader
 
typedef struct scratch_buf_struct_t scratch_sys_struct_t
 thread view of the scratch buffer
 
typedef struct scratch_user_buf_struct_t scratch_struct_t
 user view of the scratch buffer
 

Functions

void Yap_InitHeap (void *)
 
UInt Yap_ExtendWorkSpaceThroughHole (UInt)
 
void Yap_AllocHole (UInt, UInt)
 
size_t Yap_HeapUsed (void)
 
void Yap_add_memory_hole (ADDR, ADDR)
 
bool get_scratch (scratch_struct_t *handle)
 
bool Yap_get_scratch_buf (scratch_struct_t *handle, size_t nof, size_t each)
 
bool Yap_realloc_scratch_buf (scratch_struct_t *handle, size_t nof)
 
bool Yap_release_scratch_buf (scratch_struct_t *handle)
 

Variables

size_t Yap_page_size