potion  0.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gc.h File Reference

non-API GC internals More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define POTION_BIRTH_SIZE   (PN_SIZE_T << 21)
 
#define POTION_MIN_BIRTH_SIZE   (PN_SIZE_T << 15)
 
#define POTION_MAX_BIRTH_SIZE   (16 * POTION_BIRTH_SIZE)
 
#define POTION_GC_THRESHOLD   (3 * POTION_BIRTH_SIZE)
 
#define POTION_GC_PERIOD   256
 
#define POTION_NB_ROOTS   64
 
#define SET_GEN(t, p, s)
 
#define SET_STOREPTR(n)   M->birth_storeptr = (void *)(((void **)M->birth_hi) - (n))
 
#define GC_KEEP(p)   *(M->birth_storeptr--) = (void *)p
 
#define DEL_BIRTH_REGION()
 
#define IS_GC_PROTECTED(p)   ((_PN)(p) >= (_PN)M && (_PN)(p) < (_PN)M->protect)
 
#define IN_BIRTH_REGION(p)   ((_PN)(p) > (_PN)M->birth_lo && (_PN)(p) < (_PN)M->birth_hi)
 
#define IN_OLDER_REGION(p)   ((_PN)(p) > (_PN)M->old_lo && (_PN)(p) < (_PN)M->old_hi)
 
#define IS_NEW_PTR(p)   (PN_IS_PTR(p) && IN_BIRTH_REGION(p) && !IS_GC_PROTECTED(p))
 
#define GC_FORWARD(p, v)
 
#define GC_MINOR_UPDATE(p)
 
#define GC_MAJOR_UPDATE(p)
 
#define GC_MINOR_UPDATE_TABLE(name, kh, is_map)
 
#define GC_MAJOR_UPDATE_TABLE(name, kh, is_map)
 
#define GC_MINOR_STRINGS()
 
#define GC_MAJOR_STRINGS()
 

Functions

static int potion_birth_suggest (int need, volatile void *oldlo, volatile void *oldhi)
 
PN_SIZE potion_stack_len (Potion *, _PN **)
 
PN_SIZE potion_mark_stack (Potion *, int)
 
void * potion_gc_copy (Potion *, struct PNObject *)
 
void * pngc_page_new (int *, const char)
 
void * potion_mark_minor (Potion *, const struct PNObject *)
 
void * potion_mark_major (Potion *, const struct PNObject *)
 
void potion_gc_release (Potion *)
 

Detailed Description

non-API GC internals

(c) 2008 why the lucky stiff, the freelance professor

Definition in file gc.h.

Macro Definition Documentation

#define POTION_BIRTH_SIZE   (PN_SIZE_T << 21)

Definition at line 9 of file gc.h.

#define POTION_MIN_BIRTH_SIZE   (PN_SIZE_T << 15)

Definition at line 13 of file gc.h.

#define POTION_MAX_BIRTH_SIZE   (16 * POTION_BIRTH_SIZE)

Definition at line 17 of file gc.h.

#define POTION_GC_THRESHOLD   (3 * POTION_BIRTH_SIZE)

Definition at line 24 of file gc.h.

#define POTION_GC_PERIOD   256

Definition at line 25 of file gc.h.

#define POTION_NB_ROOTS   64

Definition at line 26 of file gc.h.

#define SET_GEN (   t,
  p,
 
)
Value:
M->t##_lo = p; \
M->t##_cur = p + (sizeof(PN) * 2); \
M->t##_hi = p + (s); \
p = 0
#define M
Definition: mt19937ar.c:53
volatile _PN PN
Definition: potion.h:81

Definition at line 28 of file gc.h.

#define SET_STOREPTR (   n)    M->birth_storeptr = (void *)(((void **)M->birth_hi) - (n))

Definition at line 34 of file gc.h.

#define GC_KEEP (   p)    *(M->birth_storeptr--) = (void *)p

Definition at line 37 of file gc.h.

#define DEL_BIRTH_REGION ( )
Value:
if (M->birth_lo == M && IN_BIRTH_REGION(M->protect)) { \
void *protend = (void *)PN_ALIGN((_PN)M->protect, POTION_PAGESIZE); \
pngc_page_delete(protend, (char *)M->birth_hi - (char *)protend); \
} else { \
void *protend = (void *)M->birth_lo; \
pngc_page_delete(protend, (char *)M->birth_hi - (char *)protend); \
}
unsigned long _PN
Definition: potion.h:78
#define IN_BIRTH_REGION(p)
Definition: gc.h:52
#define PN_ALIGN(o, x)
Definition: potion.h:223
#define M
Definition: mt19937ar.c:53
void pngc_page_delete(void *mem, int sz)
Definition: gc.c:119
#define POTION_PAGESIZE
Definition: config.h:36

Definition at line 40 of file gc.h.

#define IS_GC_PROTECTED (   p)    ((_PN)(p) >= (_PN)M && (_PN)(p) < (_PN)M->protect)

Definition at line 49 of file gc.h.

#define IN_BIRTH_REGION (   p)    ((_PN)(p) > (_PN)M->birth_lo && (_PN)(p) < (_PN)M->birth_hi)

Definition at line 52 of file gc.h.

#define IN_OLDER_REGION (   p)    ((_PN)(p) > (_PN)M->old_lo && (_PN)(p) < (_PN)M->old_hi)

Definition at line 55 of file gc.h.

#define IS_NEW_PTR (   p)    (PN_IS_PTR(p) && IN_BIRTH_REGION(p) && !IS_GC_PROTECTED(p))

Definition at line 58 of file gc.h.

#define GC_FORWARD (   p,
 
)
Value:
do { \
struct PNFwd *_pnobj = (struct PNFwd *)v; \
if (_pnobj->fwd == POTION_COPIED) \
*(p) = _pnobj->ptr; \
else \
*(p) = (_PN)potion_gc_copy(P, (struct PNObject *)v); \
} while(0)
forwarding pointer (in case of reallocation)
Definition: potion.h:304
PN ptr
Definition: potion.h:307
unsigned long _PN
Definition: potion.h:78
standard objects act like C structs the fields are defined by the type and it's a fixed size...
Definition: potion.h:295
void * potion_gc_copy(Potion *, struct PNObject *)
Definition: gc.c:394
#define POTION_COPIED
Definition: potion.h:147

Definition at line 61 of file gc.h.

#define GC_MINOR_UPDATE (   p)
Value:
do { \
if (PN_IS_PTR(p)) { \
PN _pnv = potion_fwd((_PN)p); \
if (IN_BIRTH_REGION(_pnv) && !IS_GC_PROTECTED(_pnv)) \
{ GC_FORWARD((_PN *)&(p), _pnv); } \
} \
} while(0)
unsigned long _PN
Definition: potion.h:78
#define IN_BIRTH_REGION(p)
Definition: gc.h:52
static PN potion_fwd(PN)
the potion type is the 't' in the vtable tuple (m,t)
Definition: potion.h:561
#define PN_IS_PTR(v)
Definition: potion.h:159
#define GC_FORWARD(p, v)
Definition: gc.h:61
#define IS_GC_PROTECTED(p)
Definition: gc.h:49
volatile _PN PN
Definition: potion.h:81

Definition at line 69 of file gc.h.

#define GC_MAJOR_UPDATE (   p)
Value:
do { \
if (PN_IS_PTR(p)) { \
PN _pnv = potion_fwd((_PN)p); \
if (!IS_GC_PROTECTED(_pnv) && \
(IN_BIRTH_REGION(_pnv) || IN_OLDER_REGION(_pnv))) \
{GC_FORWARD((_PN *)&(p), _pnv);} \
} \
} while(0)
unsigned long _PN
Definition: potion.h:78
#define IN_BIRTH_REGION(p)
Definition: gc.h:52
static PN potion_fwd(PN)
the potion type is the 't' in the vtable tuple (m,t)
Definition: potion.h:561
#define IN_OLDER_REGION(p)
Definition: gc.h:55
#define PN_IS_PTR(v)
Definition: potion.h:159
#define GC_FORWARD(p, v)
Definition: gc.h:61
#define IS_GC_PROTECTED(p)
Definition: gc.h:49
volatile _PN PN
Definition: potion.h:81

Definition at line 77 of file gc.h.

#define GC_MINOR_UPDATE_TABLE (   name,
  kh,
  is_map 
)
Value:
do { \
unsigned k; \
for (k = kh_begin(kh); k != kh_end(kh); ++k) \
if (kh_exist(name, kh, k)) { \
PN v1 = kh_key(name, kh, k); \
kh_key(name, kh, k) = v1; \
if (is_map) { \
PN v2 = kh_val(name, kh, k); \
kh_val(name, kh, k) = v2; \
} \
} \
} while (0)
#define kh_end(h)
Definition: khash.h:229
#define kh_begin(h)
Definition: khash.h:228
#define GC_MINOR_UPDATE(p)
Definition: gc.h:69
#define kh_val(name, h, x)
Definition: khash.h:227
#define kh_key(name, h, x)
Definition: khash.h:226
const char * name
Definition: compile.c:30
volatile _PN PN
Definition: potion.h:81
#define kh_exist(name, h, x)
Definition: khash.h:225

Definition at line 86 of file gc.h.

#define GC_MAJOR_UPDATE_TABLE (   name,
  kh,
  is_map 
)
Value:
do { \
unsigned k; \
for (k = kh_begin(kh); k != kh_end(kh); ++k) \
if (kh_exist(name, kh, k)) { \
PN v1 = kh_key(name, kh, k); \
kh_key(name, kh, k) = v1; \
if (is_map) { \
PN v2 = kh_val(name, kh, k); \
kh_val(name, kh, k) = v2; \
} \
} \
} while (0)
#define kh_end(h)
Definition: khash.h:229
#define kh_begin(h)
Definition: khash.h:228
#define GC_MAJOR_UPDATE(p)
Definition: gc.h:77
#define kh_val(name, h, x)
Definition: khash.h:227
#define kh_key(name, h, x)
Definition: khash.h:226
const char * name
Definition: compile.c:30
volatile _PN PN
Definition: potion.h:81
#define kh_exist(name, h, x)
Definition: khash.h:225

Definition at line 101 of file gc.h.

#define GC_MINOR_STRINGS ( )
Value:
do { \
unsigned k; \
GC_MINOR_UPDATE(P->strings); \
for (k = kh_begin(P->strings); k != kh_end(P->strings); ++k) \
if (kh_exist(str, P->strings, k)) { \
PN v = kh_key(str, P->strings, k); \
if (IN_BIRTH_REGION(v) && !IS_GC_PROTECTED(v)) { \
if (((struct PNFwd *)v)->fwd == POTION_COPIED) \
kh_key(str, P->strings, k) = ((struct PNFwd *)v)->ptr; \
kh_del(str, P->strings, k); \
} \
} \
} while (0)
forwarding pointer (in case of reallocation)
Definition: potion.h:304
#define IN_BIRTH_REGION(p)
Definition: gc.h:52
#define kh_end(h)
Definition: khash.h:229
#define kh_begin(h)
Definition: khash.h:228
unsigned int fwd
Definition: potion.h:305
#define kh_del(name, h, k)
Definition: khash.h:223
#define GC_MINOR_UPDATE(p)
Definition: gc.h:69
#define kh_key(name, h, x)
Definition: khash.h:226
#define IS_GC_PROTECTED(p)
Definition: gc.h:49
#define POTION_COPIED
Definition: potion.h:147
volatile _PN PN
Definition: potion.h:81
#define kh_exist(name, h, x)
Definition: khash.h:225

Definition at line 116 of file gc.h.

#define GC_MAJOR_STRINGS ( )
Value:
do { \
unsigned k; \
GC_MAJOR_UPDATE(P->strings); \
for (k = kh_begin(P->strings); k != kh_end(P->strings); ++k) \
if (kh_exist(str, P->strings, k)) { \
PN v = kh_key(str, P->strings, k); \
if (!IS_GC_PROTECTED(v) && \
if (((struct PNFwd *)v)->fwd == POTION_COPIED) \
kh_key(str, P->strings, k) = ((struct PNFwd *)v)->ptr; \
kh_del(str, P->strings, k); \
} \
} \
} while (0)
forwarding pointer (in case of reallocation)
Definition: potion.h:304
#define IN_BIRTH_REGION(p)
Definition: gc.h:52
#define kh_end(h)
Definition: khash.h:229
#define kh_begin(h)
Definition: khash.h:228
#define IN_OLDER_REGION(p)
Definition: gc.h:55
unsigned int fwd
Definition: potion.h:305
#define GC_MAJOR_UPDATE(p)
Definition: gc.h:77
#define kh_del(name, h, k)
Definition: khash.h:223
#define kh_key(name, h, x)
Definition: khash.h:226
#define IS_GC_PROTECTED(p)
Definition: gc.h:49
#define POTION_COPIED
Definition: potion.h:147
volatile _PN PN
Definition: potion.h:81
#define kh_exist(name, h, x)
Definition: khash.h:225

Definition at line 131 of file gc.h.

Function Documentation

static int potion_birth_suggest ( int  need,
volatile void *  oldlo,
volatile void *  oldhi 
)
inlinestatic

Definition at line 147 of file gc.h.

PN_SIZE potion_stack_len ( Potion ,
_PN **   
)

Definition at line 50 of file gc.c.

PN_SIZE potion_mark_stack ( Potion ,
int   
)

Definition at line 98 of file gc.c.

void* potion_gc_copy ( Potion ,
struct PNObject  
)

Definition at line 394 of file gc.c.

void* pngc_page_new ( int *  ,
const char   
)

Definition at line 114 of file gc.c.

void* potion_mark_minor ( Potion ,
const struct PNObject  
)

Definition at line 413 of file gc.c.

void* potion_mark_major ( Potion ,
const struct PNObject  
)

Definition at line 519 of file gc.c.

void potion_gc_release ( Potion )

Definition at line 691 of file gc.c.