Skip to content

Commit

Permalink
Add in a header flag for whether we turn on the precise GC or not.
Browse files Browse the repository at this point in the history
  • Loading branch information
Whiteknight committed Sep 26, 2011
1 parent fc619a6 commit a2f669b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
19 changes: 19 additions & 0 deletions include/parrot/gc_api.h
Expand Up @@ -11,6 +11,14 @@

#include "parrot/parrot.h"

/* Flag to turn on precise GC
0 = no precise GC (use only stack walking)
1 = precise GC + stack walking
2 = precise GC only (this is what we want)
*/

#define GC_USE_PRECISE 1

/*
* we need an alignment that is the same as malloc(3) have for
* allocating Buffer items like FLOATVAL (double)
Expand Down Expand Up @@ -123,6 +131,8 @@ typedef struct __gc_anchor_storage {
size_t elements;
} gc_anchor_storage;

#if GC_USE_PRECISE != 0

#define GC_SETUP_ANCHOR_STORAGE(i, n) { \
const size_t __num_slots = n; \
const size_t __pmc_storage_size = (n) * sizeof (PMC *); \
Expand Down Expand Up @@ -159,6 +169,15 @@ typedef struct __gc_anchor_storage {
__anchor_storage[(n)] = (p); \
}

#else

#define GC_SETUP_ANCHOR_STORAGE(i, n)
#define GC_CLEANUP_ANCHOR_STORAGE(i)
#define GC_GET_ANCHOR_STORAGE(n, p)
#define GC_SET_ANCHOR_STORAGE(n, p)

#endif


/* HEADERIZER BEGIN: src/gc/api.c */
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
Expand Down
7 changes: 7 additions & 0 deletions src/gc/mark_sweep.c
Expand Up @@ -178,10 +178,13 @@ Parrot_gc_trace_root(PARROT_INTERP,
= interp->iglobals;
}

#if GC_USE_PRECISE != 2

if (trace == GC_TRACE_FULL)
trace_system_areas(interp, mem_pools);

#endif

mark_interp(interp);

/* quick check to see if we have already marked all impatient PMCs. If we
Expand Down Expand Up @@ -257,6 +260,8 @@ mark_interp(PARROT_INTERP)
if (interp->parent_interpreter)
mark_interp(interp->parent_interpreter);

#if GC_USE_PRECISE != 0

{
gc_anchor_storage * s = interp->gc_anchor_storage;
while(s) {
Expand All @@ -271,6 +276,8 @@ mark_interp(PARROT_INTERP)
s = s->prev;
}
}

#endif
}


Expand Down

0 comments on commit a2f669b

Please sign in to comment.