tweak copy-vs-mark dispatching

The C compiler doesn't generate a tail call in a place where I
expected one, and maybe it's better to branch at the call site anyway.

original commit: 70fa8e7f7bd891c548c877cabdd15073aa2aa01b
This commit is contained in:
Matthew Flatt 2020-04-24 10:20:50 -06:00
parent 752ee94563
commit 7ba7a815b0
2 changed files with 14 additions and 10 deletions

15
c/gc.c
View File

@ -123,7 +123,7 @@
/* locally defined functions */
static ptr copy PROTO((ptr pp, seginfo *si));
static ptr mark_object PROTO((ptr pp, seginfo *si));
static void mark_object PROTO((ptr pp, seginfo *si));
static void sweep PROTO((ptr tc, ptr p));
static void sweep_in_old PROTO((ptr tc, ptr p));
static IBOOL object_directly_refers_to_self PROTO((ptr p));
@ -352,7 +352,7 @@ static int flonum_is_forwarded_p(ptr p, seginfo *si) {
if (FORWARDEDP(pp, si)) \
*ppp = GET_FWDADDRESS(pp); \
else if (!marked(si, pp)) \
*ppp = copy(pp, si); \
mark_or_copy(*ppp, pp, si); \
}
#define relocate_code(pp, si) { \
@ -360,10 +360,17 @@ static int flonum_is_forwarded_p(ptr p, seginfo *si) {
pp = GET_FWDADDRESS(pp); \
else if (si->old_space) { \
if (!marked(si, pp)) \
pp = copy(pp, si); \
mark_or_copy(pp, pp, si); \
} ELSE_MEASURE_NONOLDSPACE(pp) \
}
#define mark_or_copy(dest, p, si) { \
if (si->use_marks) \
mark_object(p, si); \
else \
dest = copy(p, si); \
}
#ifdef ENABLE_OBJECT_COUNTS
# define is_counting_root(si, p) (si->counting_mask && (si->counting_mask[segment_bitmap_byte(p)] & segment_bitmap_bit(p)))
#endif
@ -820,7 +827,7 @@ ptr GCENTRY(ptr tc, IGEN mcg, IGEN tg, ptr count_roots_ls) {
(SYMVAL(sym) != sunbound || SYMPLIST(sym) != Snil || SYMSPLIST(sym) != Snil)) {
seginfo *sym_si = SegInfo(ptr_get_segment(sym));
if (!marked(sym_si, sym))
(void)copy(sym, sym_si);
mark_or_copy(sym, sym, sym_si);
}
}
S_G.buckets_of_generation[g] = NULL;

View File

@ -1312,12 +1312,13 @@
(code
(format "static ~a ~a(~aptr p~a)"
(case (lookup 'mode config)
[(copy vfasl-copy mark) "ptr"]
[(copy vfasl-copy) "ptr"]
[(size vfasl-sweep) "uptr"]
[(self-test) "IBOOL"]
[(sweep) (if (lookup 'as-dirty? config #f)
"IGEN"
"void")]
[(mark) "void"]
[else "void"])
name
(case (lookup 'mode config)
@ -1363,9 +1364,6 @@
(case (lookup 'mode config)
[(copy)
(code-block
"if (si->use_marks) {"
" return mark_object(p, si);"
"}"
"change = 1;"
"check_triggers(si);"
(code-block
@ -1383,8 +1381,7 @@
"check_triggers(si);"
(ensure-segment-mark-mask "si" "" '())
(body)
"ADD_BACKREFERENCE(p)"
"return p;")]
"ADD_BACKREFERENCE(p)")]
[(sweep)
(code-block
(and (lookup 'maybe-backreferences? config #f)