Skip to content

Commit

Permalink
Check pointer tag in all mark procedures (E2K)
Browse files Browse the repository at this point in the history
Issue ivmai#411 (bdwgc).

Do not mark objects if its pointer tag is non-zero, not only in
GC_mark_from and GC_push_all_eager, but also in add_back_edges,
GC_ignore_self_finalize_mark_proc, GC_typed_mark_proc and
GC_push_conditional_eager.

* backgraph.c [MAKE_BACK_GRAPH] (add_back_edges): Change type of
current_p local variable from word* to ptr_t.
* typd_mlc.c (GC_typed_mark_proc): Likewise.
* backgraph.c [MAKE_BACK_GRAPH] (add_back_edges): Use
LOAD_WORD_OR_CONTINUE() instead of direct dereference of current_p.
* finalize.c (GC_ignore_self_finalize_mark_proc): Likewise.
* mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager):
Likewise.
* typd_mlc.c (GC_typed_mark_proc): Likewise.
* finalize.c (GC_ignore_self_finalize_mark_proc): Rename q and r local
variables to current_p and q, respectively.
  • Loading branch information
ivmai committed Jan 12, 2022
1 parent 7797312 commit 9b4ac36
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
9 changes: 6 additions & 3 deletions backgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,17 @@ static void reset_back_edge(ptr_t p, size_t n_bytes GC_ATTR_UNUSED,

static void add_back_edges(ptr_t p, size_t n_bytes, word gc_descr)
{
word *currentp = (word *)(p + sizeof(oh));
ptr_t current_p = p + sizeof(oh);

/* For now, fix up non-length descriptors conservatively. */
if((gc_descr & GC_DS_TAGS) != GC_DS_LENGTH) {
gc_descr = n_bytes;
}
while ((word)currentp < (word)(p + gc_descr)) {
word current = *currentp++;

for (; (word)current_p < (word)(p + gc_descr); current_p += sizeof(word)) {
word current;

LOAD_WORD_OR_CONTINUE(current, current_p);
FIXUP_POINTER(current);
if (current >= (word)GC_least_plausible_heap_addr &&
current <= (word)GC_greatest_plausible_heap_addr) {
Expand Down
12 changes: 7 additions & 5 deletions finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ STATIC void GC_ignore_self_finalize_mark_proc(ptr_t p)
{
hdr * hhdr = HDR(p);
word descr = hhdr -> hb_descr;
ptr_t q;
ptr_t current_p;
ptr_t scan_limit;
ptr_t target_limit = p + hhdr -> hb_sz - 1;

Expand All @@ -626,11 +626,13 @@ STATIC void GC_ignore_self_finalize_mark_proc(ptr_t p)
} else {
scan_limit = target_limit + 1 - sizeof(word);
}
for (q = p; (word)q <= (word)scan_limit; q += ALIGNMENT) {
word r = *(word *)q;
for (current_p = p; (word)current_p <= (word)scan_limit;
current_p += ALIGNMENT) {
word q;

if (r < (word)p || r > (word)target_limit) {
GC_PUSH_ONE_HEAP(r, q, GC_mark_stack_top);
LOAD_WORD_OR_CONTINUE(q, current_p);
if (q < (word)p || q > (word)target_limit) {
GC_PUSH_ONE_HEAP(q, current_p, GC_mark_stack_top);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -1626,8 +1626,9 @@ GC_INNER void GC_push_all_stack(ptr_t bottom, ptr_t top)
lim = (word *)(((word)top) & ~(ALIGNMENT-1)) - 1;
for (current_p = (ptr_t)(((word)bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
(word)current_p <= (word)lim; current_p += ALIGNMENT) {
REGISTER word q = *(word *)current_p;
REGISTER word q;

LOAD_WORD_OR_CONTINUE(q, current_p);
GC_PUSH_ONE_HEAP(q, current_p, GC_mark_stack_top);
}
# undef GC_greatest_plausible_heap_addr
Expand Down
11 changes: 6 additions & 5 deletions typd_mlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,20 +344,21 @@ STATIC mse * GC_typed_mark_proc(word * addr, mse * mark_stack_ptr,
mse * mark_stack_limit, word env)
{
word bm = GC_ext_descriptors[env].ed_bitmap;
word * current_p = addr;
word current;
ptr_t current_p = (ptr_t)addr;
ptr_t greatest_ha = (ptr_t)GC_greatest_plausible_heap_addr;
ptr_t least_ha = (ptr_t)GC_least_plausible_heap_addr;
DECLARE_HDR_CACHE;

INIT_HDR_CACHE;
for (; bm != 0; bm >>= 1, current_p++) {
for (; bm != 0; bm >>= 1, current_p += sizeof(word)) {
if (bm & 1) {
current = *current_p;
word current;

LOAD_WORD_OR_CONTINUE(current, current_p);
FIXUP_POINTER(current);
if (current >= (word)least_ha && current <= (word)greatest_ha) {
PUSH_CONTENTS((ptr_t)current, mark_stack_ptr,
mark_stack_limit, (ptr_t)current_p);
mark_stack_limit, current_p);
}
}
}
Expand Down

0 comments on commit 9b4ac36

Please sign in to comment.