Ticket #980: generational_ms.h

File generational_ms.h, 2.9 KB (added by jrtayloriv, 5 years ago)

src/gc/generational_ms.h

Line 
1#ifndef PARROT_GC_GMS_H_GUARD
2#define PARROT_GC_GMS_H_GUARD
3
4/*
5 * all objects have this header in front of the actual
6 * object pointer. The prev/next pointers chain all existing
7 * objects for one pool (sizeclass) together.
8 *
9 * XXX this could lead to unaligned FLOATVALs in the adjacent PMC
10 *     if that's true either insert a dummy or reorder PMC members
11 *     ??? How is that possible?
12 */
13typedef struct _gc_gms_hdr {
14    struct _gc_gms_hdr *prev;
15    struct _gc_gms_hdr *next;
16    struct _gc_gms_gen *gen;
17    void *gc_dummy_align;       /* see above */
18} Gc_gms_hdr;
19
20#  define PObj_to_GMSH(o) (((Gc_gms_hdr*)(o))-1)
21#  define GMSH_to_PObj(p) ((PObj*) ((p)+1))
22
23/* the structure uses 2 ptrs itself */
24#  define GC_GMS_STORE_SIZE (64-2)
25
26typedef struct _gc_gms_hdr_store {
27    struct _gc_gms_hdr_store *next;
28    Gc_gms_hdr **ptr;                           /* insert location */
29    Gc_gms_hdr * (store[GC_GMS_STORE_SIZE]);    /* array of hdr pointers */
30} Gc_gms_hdr_store;
31
32typedef struct _gc_gms_hdr_list {
33    Gc_gms_hdr_store *first;
34    Gc_gms_hdr_store *last;
35} Gc_gms_hdr_list;
36
37
38/*
39 * all objects belong to one generation
40 */
41typedef struct _gc_gms_gen {
42    UINTVAL gen_no;                     /* generation number */
43    UINTVAL timely_destruct_obj_sofar;  /* sum up to this generation */
44    UINTVAL black_color;                /* live color of this generation */
45    struct _gc_gms_hdr *first;          /* first header in this generation */
46    struct _gc_gms_hdr *last;           /* last header in this generation */
47    struct _gc_gms_hdr *fin;            /* need destruction/finalization */
48    struct Small_Object_Pool *pool;     /* where this generation belongs to */
49    Gc_gms_hdr_list igp;                /* IGPs for this generation */
50    UINTVAL n_possibly_dead;            /* overwritten count */
51    UINTVAL n_objects;                  /* live objects count */
52    struct _gc_gms_gen *prev;
53    struct _gc_gms_gen *next;
54} Gc_gms_gen;
55
56/* System-specific data for the Small_Object_Pool struct's gc_sys_private_data field. */
57struct gc_gms_smallobjpool_data {
58    Gc_gms_hdr marker;          /* limit of list ... also the anchor of the "header chain"
59                                   -- see gc_gms_chain_objects() */
60    Gc_gms_hdr *black;          /* alive */
61    Gc_gms_hdr *black_fin;      /* alive, needs destruction */
62    Gc_gms_hdr *gray;           /* to be scanned */
63    Gc_gms_hdr *white;          /* unprocessed */
64    Gc_gms_hdr *white_fin;      /* unprocesse, needs destruction */
65
66    Gc_gms_gen *first_gen;      /* linked list of generations */
67    Gc_gms_gen *last_gen;
68};
69
70
71/*For arenas->gc_private*/
72typedef struct Gc_gms_private {
73    UINTVAL current_gen_no;             /* the nursery generation number */
74} Gc_gms_private;
75
76
77/*For gc_sys_priv_data in interp*/
78struct gc_gms_sys_data {
79  UINTVAL gc_generation;        /* GC generation number */
80} gc_gms_sys_data;
81
82#endif /*PARROT_GC_GMS_H_GUARD*/