Skip to content

Commit

Permalink
Fix collection of objects referenced only from GC_mark_stack_X variables
Browse files Browse the repository at this point in the history
(Apply commit a7a5666 from 'release-7_2' branch.)

* include/private/gc_pmark.h (mse): Move to gc_priv.h (as used by
GC_mark_stack_limit, GC_mark_stack_top, GC_mark_stack).
* include/private/gc_pmark.h (GC_mark_stack_limit, GC_mark_stack_top,
GC_mark_stack): Remove variable declaration.
* include/private/gc_priv.h (_GC_arrays): Add _mark_stack,
_mark_stack_limit, _mark_stack_top fields.
* include/private/gc_priv.h (GC_mark_stack_limit, GC_mark_stack_top,
GC_mark_stack): Define macro (redirecting to the corresponding field
of GC_arrays).
* mark.c (GC_mark_stack, GC_mark_stack_limit, GC_mark_stack_top):
Remove variable; move comment to gc_priv.h.
* mark.c (GC_push_marked1, GC_push_marked2, GC_push_marked4): Undefine
GC_mark_stack_top and GC_mark_stack_limit macros (before redefining
them to local variables) at function start, redefine them back to the
corresponding field of GC_arrays at function exit.

Conflicts:

    include/private/gc_pmark.h
  • Loading branch information
ivmai committed Sep 7, 2013
1 parent dd2e6ce commit efd5d49
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
18 changes: 0 additions & 18 deletions include/private/gc_pmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,8 @@ GC_EXTERN unsigned GC_n_mark_procs;
/* Number of mark stack entries to discard on overflow. */
#define GC_MARK_STACK_DISCARDS (INITIAL_MARK_STACK_SIZE/8)

typedef struct GC_ms_entry {
ptr_t mse_start; /* First word of object, word aligned. */
union word_ptr_ao_u mse_descr;
/* Descriptor; low order two bits are tags, */
/* as described in gc_mark.h. */
} mse;

GC_EXTERN size_t GC_mark_stack_size;

GC_EXTERN mse * GC_mark_stack_limit;

#ifdef PARALLEL_MARK
GC_EXTERN mse * volatile GC_mark_stack_top;
/* FIXME: Use union to avoid casts to AO_t */
#else
GC_EXTERN mse * GC_mark_stack_top;
#endif

GC_EXTERN mse * GC_mark_stack;

#ifdef PARALLEL_MARK
/*
* Allow multiple threads to participate in the marking process.
Expand Down
22 changes: 22 additions & 0 deletions include/private/gc_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,13 @@ struct roots {
# endif
#endif /* !MAX_HEAP_SECTS */

typedef struct GC_ms_entry {
ptr_t mse_start; /* First word of object, word aligned. */
union word_ptr_ao_u mse_descr;
/* Descriptor; low order two bits are tags, */
/* as described in gc_mark.h. */
} mse;

/* Lists of all heap blocks and free lists */
/* as well as other random data structures */
/* that should not be scanned by the */
Expand Down Expand Up @@ -1127,6 +1134,18 @@ struct _GC_arrays {
ptr_t _scratch_last_end_ptr;
/* Used by headers.c, and can easily appear to point to */
/* heap. */
mse *_mark_stack;
/* Limits of stack for GC_mark routine. All ranges */
/* between GC_mark_stack (incl.) and GC_mark_stack_top */
/* (incl.) still need to be marked from. */
mse *_mark_stack_limit;
# ifdef PARALLEL_MARK
mse *volatile _mark_stack_top;
/* Updated only with mark lock held, but read asynchronously. */
/* TODO: Use union to avoid casts to AO_t */
# else
mse *_mark_stack_top;
# endif
GC_mark_proc _mark_procs[MAX_MARK_PROCS];
/* Table of user-defined mark procedures. There is */
/* a small number of these, which can be referenced */
Expand Down Expand Up @@ -1276,6 +1295,9 @@ GC_API_PRIV GC_FAR struct _GC_arrays GC_arrays;
#define GC_large_allocd_bytes GC_arrays._large_allocd_bytes
#define GC_large_free_bytes GC_arrays._large_free_bytes
#define GC_last_heap_addr GC_arrays._last_heap_addr
#define GC_mark_stack GC_arrays._mark_stack
#define GC_mark_stack_limit GC_arrays._mark_stack_limit
#define GC_mark_stack_top GC_arrays._mark_stack_top
#define GC_mark_procs GC_arrays._mark_procs
#define GC_max_large_allocd_bytes GC_arrays._max_large_allocd_bytes
#define GC_modws_valid_offsets GC_arrays._modws_valid_offsets
Expand Down
28 changes: 14 additions & 14 deletions mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,18 @@ GC_INNER unsigned GC_n_kinds = GC_N_KINDS_INITIAL_VALUE;
/* grow dynamically. */
# endif

/*
* Limits of stack for GC_mark routine.
* All ranges between GC_mark_stack(incl.) and GC_mark_stack_top(incl.) still
* need to be marked from.
*/

STATIC word GC_n_rescuing_pages = 0;
/* Number of dirty pages we marked from */
/* excludes ptrfree pages, etc. */

GC_INNER mse * GC_mark_stack = NULL;
GC_INNER mse * GC_mark_stack_limit = NULL;
GC_INNER size_t GC_mark_stack_size = 0;

#ifdef PARALLEL_MARK
GC_INNER mse * volatile GC_mark_stack_top = NULL;
/* Updated only with mark lock held, but read asynchronously. */
STATIC volatile AO_t GC_first_nonempty = 0;
/* Lowest entry on mark stack */
/* that may be nonempty. */
/* Updated only by initiating */
/* thread. */
#else
GC_INNER mse * GC_mark_stack_top = NULL;
#endif

GC_INNER mark_state_t GC_mark_state = MS_NONE;
Expand Down Expand Up @@ -1582,6 +1570,9 @@ STATIC void GC_push_marked1(struct hblk *h, hdr *hhdr)
ptr_t least_ha = GC_least_plausible_heap_addr;
mse * mark_stack_top = GC_mark_stack_top;
mse * mark_stack_limit = GC_mark_stack_limit;

# undef GC_mark_stack_top
# undef GC_mark_stack_limit
# define GC_mark_stack_top mark_stack_top
# define GC_mark_stack_limit mark_stack_limit
# define GC_greatest_plausible_heap_addr greatest_ha
Expand All @@ -1608,7 +1599,8 @@ STATIC void GC_push_marked1(struct hblk *h, hdr *hhdr)
# undef GC_least_plausible_heap_addr
# undef GC_mark_stack_top
# undef GC_mark_stack_limit

# define GC_mark_stack_limit GC_arrays._mark_stack_limit
# define GC_mark_stack_top GC_arrays._mark_stack_top
GC_mark_stack_top = mark_stack_top;
}

Expand All @@ -1630,6 +1622,8 @@ STATIC void GC_push_marked2(struct hblk *h, hdr *hhdr)
mse * mark_stack_top = GC_mark_stack_top;
mse * mark_stack_limit = GC_mark_stack_limit;

# undef GC_mark_stack_top
# undef GC_mark_stack_limit
# define GC_mark_stack_top mark_stack_top
# define GC_mark_stack_limit mark_stack_limit
# define GC_greatest_plausible_heap_addr greatest_ha
Expand Down Expand Up @@ -1657,7 +1651,8 @@ STATIC void GC_push_marked2(struct hblk *h, hdr *hhdr)
# undef GC_least_plausible_heap_addr
# undef GC_mark_stack_top
# undef GC_mark_stack_limit

# define GC_mark_stack_limit GC_arrays._mark_stack_limit
# define GC_mark_stack_top GC_arrays._mark_stack_top
GC_mark_stack_top = mark_stack_top;
}

Expand All @@ -1678,6 +1673,9 @@ STATIC void GC_push_marked4(struct hblk *h, hdr *hhdr)
ptr_t least_ha = GC_least_plausible_heap_addr;
mse * mark_stack_top = GC_mark_stack_top;
mse * mark_stack_limit = GC_mark_stack_limit;

# undef GC_mark_stack_top
# undef GC_mark_stack_limit
# define GC_mark_stack_top mark_stack_top
# define GC_mark_stack_limit mark_stack_limit
# define GC_greatest_plausible_heap_addr greatest_ha
Expand Down Expand Up @@ -1706,6 +1704,8 @@ STATIC void GC_push_marked4(struct hblk *h, hdr *hhdr)
# undef GC_least_plausible_heap_addr
# undef GC_mark_stack_top
# undef GC_mark_stack_limit
# define GC_mark_stack_limit GC_arrays._mark_stack_limit
# define GC_mark_stack_top GC_arrays._mark_stack_top
GC_mark_stack_top = mark_stack_top;
}

Expand Down

0 comments on commit efd5d49

Please sign in to comment.