Chez Scheme: make "immediate" consistently mean type-immediate

Exposing `$immediate?` as just "immediate" will be useful to cptypes.
Meanwhile, introduce "fixmediate" as the term for a union of "fixnum"
and "immediate" (i.e., values that are not allocated).

The new terminology helps avoid internal inconsistencies, such as the
`Simmediatep` kernel macro meaning "immediate" while the `$immediate?`
primitive meant the union.
This commit is contained in:
Matthew Flatt 2021-02-28 08:38:53 -07:00
parent 04e78c4bb7
commit 37ee8a793c
21 changed files with 82 additions and 79 deletions

View File

@ -344,7 +344,7 @@ RACKET_FOR_BOOTFILES = $(RACKET)
RACKET_FOR_BUILD = $(RACKET) RACKET_FOR_BUILD = $(RACKET)
# This branch name changes each time the pb boot files are updated: # This branch name changes each time the pb boot files are updated:
PB_BRANCH == circa-8.0.0.7-1 PB_BRANCH == circa-8.0.0.10-1
PB_REPO = https://github.com/racket/pb PB_REPO = https://github.com/racket/pb
# Alternative source for Chez Scheme boot files, normally set by # Alternative source for Chez Scheme boot files, normally set by

View File

@ -47,7 +47,7 @@ RACKETCS_SUFFIX =
RACKET = RACKET =
RACKET_FOR_BOOTFILES = $(RACKET) RACKET_FOR_BOOTFILES = $(RACKET)
RACKET_FOR_BUILD = $(RACKET) RACKET_FOR_BUILD = $(RACKET)
PB_BRANCH = circa-8.0.0.7-1 PB_BRANCH = circa-8.0.0.10-1
PB_REPO = https://github.com/racket/pb PB_REPO = https://github.com/racket/pb
EXTRA_REPOS_BASE = EXTRA_REPOS_BASE =
CS_CROSS_SUFFIX = CS_CROSS_SUFFIX =
@ -309,18 +309,18 @@ maybe-fetch-pb-as-is:
echo done echo done
fetch-pb-from: fetch-pb-from:
mkdir -p racket/src/ChezScheme/boot mkdir -p racket/src/ChezScheme/boot
if [ ! -d racket/src/ChezScheme/boot/pb ] ; then git clone -q -b circa-8.0.0.7-1 $(PB_REPO) racket/src/ChezScheme/boot/pb ; else cd racket/src/ChezScheme/boot/pb && git fetch -q origin circa-8.0.0.7-1:remotes/origin/circa-8.0.0.7-1 ; fi if [ ! -d racket/src/ChezScheme/boot/pb ] ; then git clone -q -b circa-8.0.0.10-1 $(PB_REPO) racket/src/ChezScheme/boot/pb ; else cd racket/src/ChezScheme/boot/pb && git fetch -q origin circa-8.0.0.10-1:remotes/origin/circa-8.0.0.10-1 ; fi
cd racket/src/ChezScheme/boot/pb && git checkout -q circa-8.0.0.7-1 cd racket/src/ChezScheme/boot/pb && git checkout -q circa-8.0.0.10-1
pb-fetch: pb-fetch:
$(MAKE) fetch-pb EXTRA_REPOS_BASE="$(EXTRA_REPOS_BASE)" PB_REPO="$(PB_REPO)" $(MAKE) fetch-pb EXTRA_REPOS_BASE="$(EXTRA_REPOS_BASE)" PB_REPO="$(PB_REPO)"
pb-build: pb-build:
cd racket/src/ChezScheme && racket rktboot/main.rkt --machine pb cd racket/src/ChezScheme && racket rktboot/main.rkt --machine pb
pb-stage: pb-stage:
cd racket/src/ChezScheme/boot/pb && git branch circa-8.0.0.7-1 cd racket/src/ChezScheme/boot/pb && git branch circa-8.0.0.10-1
cd racket/src/ChezScheme/boot/pb && git checkout circa-8.0.0.7-1 cd racket/src/ChezScheme/boot/pb && git checkout circa-8.0.0.10-1
cd racket/src/ChezScheme/boot/pb && git add . && git commit --amend -m "new build" cd racket/src/ChezScheme/boot/pb && git add . && git commit --amend -m "new build"
pb-push: pb-push:
cd racket/src/ChezScheme/boot/pb && git push -u origin circa-8.0.0.7-1 cd racket/src/ChezScheme/boot/pb && git push -u origin circa-8.0.0.10-1
win-cs-base: win-cs-base:
IF "$(RACKET_FOR_BUILD)" == "" $(MAKE) win-bc-then-cs-base SETUP_BOOT_MODE=--boot WIN32_BUILD_LEVEL=bc PLAIN_RACKET=racket\racketbc DISABLE_STATIC_LIBS="$(DISABLE_STATIC_LIBS)" EXTRA_REPOS_BASE="$(EXTRA_REPOS_BASE)" JOB_OPTIONS="$(JOB_OPTIONS)" PLT_SETUP_OPTIONS="$(PLT_SETUP_OPTIONS)" RACKETBC_SUFFIX="$(RACKETBC_SUFFIX)" RACKETCS_SUFFIX="$(RACKETCS_SUFFIX)" IF "$(RACKET_FOR_BUILD)" == "" $(MAKE) win-bc-then-cs-base SETUP_BOOT_MODE=--boot WIN32_BUILD_LEVEL=bc PLAIN_RACKET=racket\racketbc DISABLE_STATIC_LIBS="$(DISABLE_STATIC_LIBS)" EXTRA_REPOS_BASE="$(EXTRA_REPOS_BASE)" JOB_OPTIONS="$(JOB_OPTIONS)" PLT_SETUP_OPTIONS="$(PLT_SETUP_OPTIONS)" RACKETBC_SUFFIX="$(RACKETBC_SUFFIX)" RACKETCS_SUFFIX="$(RACKETCS_SUFFIX)"
IF not "$(RACKET_FOR_BUILD)" == "" $(MAKE) win-just-cs-base SETUP_BOOT_MODE=--chain DISABLE_STATIC_LIBS="$(DISABLE_STATIC_LIBS)" EXTRA_REPOS_BASE="$(EXTRA_REPOS_BASE)" JOB_OPTIONS="$(JOB_OPTIONS)" PLT_SETUP_OPTIONS="$(PLT_SETUP_OPTIONS)" RACKETCS_SUFFIX="$(RACKETCS_SUFFIX)" RACKET_FOR_BUILD="$(RACKET_FOR_BUILD)" IF not "$(RACKET_FOR_BUILD)" == "" $(MAKE) win-just-cs-base SETUP_BOOT_MODE=--chain DISABLE_STATIC_LIBS="$(DISABLE_STATIC_LIBS)" EXTRA_REPOS_BASE="$(EXTRA_REPOS_BASE)" JOB_OPTIONS="$(JOB_OPTIONS)" PLT_SETUP_OPTIONS="$(PLT_SETUP_OPTIONS)" RACKETCS_SUFFIX="$(RACKETCS_SUFFIX)" RACKET_FOR_BUILD="$(RACKET_FOR_BUILD)"

View File

@ -374,7 +374,7 @@ void S_dirty_set(ptr *loc, ptr x) {
seginfo *si = SegInfo(addr_get_segment(TO_PTR(loc))); seginfo *si = SegInfo(addr_get_segment(TO_PTR(loc)));
if (si->use_marks) { if (si->use_marks) {
/* GC must be in progress */ /* GC must be in progress */
if (!IMMEDIATE(x)) { if (!FIXMEDIATE(x)) {
seginfo *t_si = SegInfo(ptr_get_segment(x)); seginfo *t_si = SegInfo(ptr_get_segment(x));
if (t_si->generation < si->generation) if (t_si->generation < si->generation)
S_record_new_dirty_card(THREAD_GC(get_thread_context()), loc, t_si->generation); S_record_new_dirty_card(THREAD_GC(get_thread_context()), loc, t_si->generation);

View File

@ -563,7 +563,7 @@ static int flonum_is_forwarded_p(ptr p, seginfo *si) {
#define relocate_pure_help(ppp, pp) do { \ #define relocate_pure_help(ppp, pp) do { \
seginfo *SI; \ seginfo *SI; \
if (!IMMEDIATE(pp) && (SI = MaybeSegInfo(ptr_get_segment(pp))) != NULL) { \ if (!FIXMEDIATE(pp) && (SI = MaybeSegInfo(ptr_get_segment(pp))) != NULL) { \
if (SI->old_space) \ if (SI->old_space) \
relocate_pure_help_help(ppp, pp, SI); \ relocate_pure_help_help(ppp, pp, SI); \
ELSE_MEASURE_NONOLDSPACE(pp) \ ELSE_MEASURE_NONOLDSPACE(pp) \
@ -609,7 +609,7 @@ static int flonum_is_forwarded_p(ptr p, seginfo *si) {
static void do_relocate_pure_in_owner(thread_gc *tgc, ptr *ppp) { static void do_relocate_pure_in_owner(thread_gc *tgc, ptr *ppp) {
seginfo *si; seginfo *si;
ptr pp = *ppp; ptr pp = *ppp;
if (!IMMEDIATE(pp) if (!FIXMEDIATE(pp)
&& (si = MaybeSegInfo(ptr_get_segment(pp))) != NULL && (si = MaybeSegInfo(ptr_get_segment(pp))) != NULL
&& si->old_space) { && si->old_space) {
BLOCK_SET_THREAD(si->creator); BLOCK_SET_THREAD(si->creator);
@ -639,7 +639,7 @@ static void do_relocate_pure_in_owner(thread_gc *tgc, ptr *ppp) {
#define relocate_impure_help(ppp, pp, from_g) do { \ #define relocate_impure_help(ppp, pp, from_g) do { \
seginfo *SI; \ seginfo *SI; \
if (!IMMEDIATE(pp) && (SI = MaybeSegInfo(ptr_get_segment(pp))) != NULL) { \ if (!FIXMEDIATE(pp) && (SI = MaybeSegInfo(ptr_get_segment(pp))) != NULL) { \
if (SI->old_space) \ if (SI->old_space) \
relocate_impure_help_help(ppp, pp, from_g, SI); \ relocate_impure_help_help(ppp, pp, from_g, SI); \
ELSE_MEASURE_NONOLDSPACE(pp) \ ELSE_MEASURE_NONOLDSPACE(pp) \
@ -673,7 +673,7 @@ static void do_relocate_pure_in_owner(thread_gc *tgc, ptr *ppp) {
#define relocate_dirty(PPP, YOUNGEST) do { \ #define relocate_dirty(PPP, YOUNGEST) do { \
seginfo *_si; ptr *_ppp = PPP, _pp = *_ppp; IGEN _pg; \ seginfo *_si; ptr *_ppp = PPP, _pp = *_ppp; IGEN _pg; \
if (!IMMEDIATE(_pp) && (_si = MaybeSegInfo(ptr_get_segment(_pp))) != NULL) { \ if (!FIXMEDIATE(_pp) && (_si = MaybeSegInfo(ptr_get_segment(_pp))) != NULL) { \
if (!_si->old_space) { \ if (!_si->old_space) { \
_pg = _si->generation; \ _pg = _si->generation; \
} else { \ } else { \
@ -815,7 +815,7 @@ static ptr copy_stack(thread_gc *tgc, ptr old, iptr *length, iptr clength) {
} }
} }
#define NONSTATICINHEAP(si, x) (!IMMEDIATE(x) && (si = MaybeSegInfo(ptr_get_segment(x))) != NULL && si->generation != static_generation) #define NONSTATICINHEAP(si, x) (!FIXMEDIATE(x) && (si = MaybeSegInfo(ptr_get_segment(x))) != NULL && si->generation != static_generation)
#define ALWAYSTRUE(si, x) (si = SegInfo(ptr_get_segment(x)), 1) #define ALWAYSTRUE(si, x) (si = SegInfo(ptr_get_segment(x)), 1)
#define partition_guardians(LS, FILTER) do { \ #define partition_guardians(LS, FILTER) do { \
ptr ls; seginfo *si; \ ptr ls; seginfo *si; \
@ -1070,7 +1070,7 @@ ptr GCENTRY(ptr tc, ptr count_roots_ls) {
for (ls = count_roots_ls, i = 0; ls != Snil; ls = Scdr(ls), i++) { for (ls = count_roots_ls, i = 0; ls != Snil; ls = Scdr(ls), i++) {
ptr p = Scar(ls); ptr p = Scar(ls);
if (IMMEDIATE(p)) { if (FIXMEDIATE(p)) {
count_roots[i].p = p; count_roots[i].p = p;
count_roots[i].weak = 0; count_roots[i].weak = 0;
} else { } else {
@ -1106,7 +1106,7 @@ ptr GCENTRY(ptr tc, ptr count_roots_ls) {
for (i = 0; i < count_roots_len; i++) { for (i = 0; i < count_roots_len; i++) {
uptr total; uptr total;
ptr p = count_roots[i].p; ptr p = count_roots[i].p;
if (IMMEDIATE(p)) { if (FIXMEDIATE(p)) {
/* nothing to do */ /* nothing to do */
} else { } else {
seginfo *si = SegInfo(ptr_get_segment(p)); seginfo *si = SegInfo(ptr_get_segment(p));
@ -1152,7 +1152,7 @@ ptr GCENTRY(ptr tc, ptr count_roots_ls) {
/* clear `counting_mask`s */ /* clear `counting_mask`s */
for (i = 0; i < count_roots_len; i++) { for (i = 0; i < count_roots_len; i++) {
ptr p = count_roots[i].p; ptr p = count_roots[i].p;
if (!IMMEDIATE(p)) { if (!FIXMEDIATE(p)) {
seginfo *si = SegInfo(ptr_get_segment(p)); seginfo *si = SegInfo(ptr_get_segment(p));
si->counting_mask = NULL; si->counting_mask = NULL;
} }
@ -1368,7 +1368,7 @@ ptr GCENTRY(ptr tc, ptr count_roots_ls) {
pend_hold_ls = ls; pend_hold_ls = ls;
} else { } else {
seginfo *si; seginfo *si;
if (!IMMEDIATE(rep) && (si = MaybeSegInfo(ptr_get_segment(rep))) != NULL && si->old_space) { if (!FIXMEDIATE(rep) && (si = MaybeSegInfo(ptr_get_segment(rep))) != NULL && si->old_space) {
/* mark things reachable from `rep`, but not `rep` itself, unless /* mark things reachable from `rep`, but not `rep` itself, unless
`rep` is immediately reachable from itself */ `rep` is immediately reachable from itself */
PUSH_BACKREFERENCE(ls) PUSH_BACKREFERENCE(ls)
@ -1885,7 +1885,7 @@ static void resweep_weak_pairs(seginfo *oldweakspacesegments) {
static void forward_or_bwp(pp, p) ptr *pp; ptr p; { static void forward_or_bwp(pp, p) ptr *pp; ptr p; {
seginfo *si; seginfo *si;
/* adapted from relocate */ /* adapted from relocate */
if (!IMMEDIATE(p) && (si = MaybeSegInfo(ptr_get_segment(p))) != NULL && si->old_space && !new_marked(si, p)) { if (!FIXMEDIATE(p) && (si = MaybeSegInfo(ptr_get_segment(p))) != NULL && si->old_space && !new_marked(si, p)) {
if (FORWARDEDP(p, si)) { if (FORWARDEDP(p, si)) {
*pp = GET_FWDADDRESS(p); *pp = GET_FWDADDRESS(p);
} else { } else {
@ -2526,7 +2526,7 @@ static void resweep_dirty_weak_pairs(thread_gc *tgc) {
seginfo *si; seginfo *si;
/* handle car field */ /* handle car field */
if (!IMMEDIATE(p) && (si = MaybeSegInfo(ptr_get_segment(p))) != NULL) { if (!FIXMEDIATE(p) && (si = MaybeSegInfo(ptr_get_segment(p))) != NULL) {
if (si->old_space) { if (si->old_space) {
if (new_marked(si, p)) { if (new_marked(si, p)) {
youngest = TARGET_GENERATION(si); youngest = TARGET_GENERATION(si);
@ -2637,7 +2637,7 @@ static void check_ephemeron(thread_gc *tgc, ptr pe) {
from_g = GENERATION(pe); from_g = GENERATION(pe);
p = Scar(pe); p = Scar(pe);
if (!IMMEDIATE(p) && (si = MaybeSegInfo(ptr_get_segment(p))) != NULL && si->old_space) { if (!FIXMEDIATE(p) && (si = MaybeSegInfo(ptr_get_segment(p))) != NULL && si->old_space) {
if (SEGMENT_IS_LOCAL(si, p)) { if (SEGMENT_IS_LOCAL(si, p)) {
if (new_marked(si, p)) { if (new_marked(si, p)) {
#ifndef NO_DIRTY_NEWSPACE_POINTERS #ifndef NO_DIRTY_NEWSPACE_POINTERS
@ -2696,7 +2696,7 @@ static IGEN check_dirty_ephemeron(thread_gc *tgc, ptr pe, IGEN youngest) {
PUSH_BACKREFERENCE(pe); PUSH_BACKREFERENCE(pe);
p = Scar(pe); p = Scar(pe);
if (!IMMEDIATE(p) && (si = MaybeSegInfo(ptr_get_segment(p))) != NULL) { if (!FIXMEDIATE(p) && (si = MaybeSegInfo(ptr_get_segment(p))) != NULL) {
if (si->old_space) { if (si->old_space) {
if (SEGMENT_IS_LOCAL(si, p)) { if (SEGMENT_IS_LOCAL(si, p)) {
if (new_marked(si, p)) { if (new_marked(si, p)) {
@ -3305,7 +3305,7 @@ static void add_ephemeron_to_pending_measure(thread_gc *tgc, ptr pe) {
seginfo *si; seginfo *si;
ptr p = Scar(pe); ptr p = Scar(pe);
if (!IMMEDIATE(p) && (si = MaybeSegInfo(ptr_get_segment(p))) != NULL && si->old_space) if (!FIXMEDIATE(p) && (si = MaybeSegInfo(ptr_get_segment(p))) != NULL && si->old_space)
add_ephemeron_to_pending(tgc, pe); add_ephemeron_to_pending(tgc, pe);
else { else {
if (EPHEMERONPREVREF(pe)) if (EPHEMERONPREVREF(pe))
@ -3326,7 +3326,7 @@ static void check_ephemeron_measure(thread_gc *tgc, ptr pe) {
EPHEMERONNEXT(pe) = 0; EPHEMERONNEXT(pe) = 0;
p = Scar(pe); p = Scar(pe);
if (!IMMEDIATE(p) && (si = MaybeSegInfo(ptr_get_segment(p))) != NULL if (!FIXMEDIATE(p) && (si = MaybeSegInfo(ptr_get_segment(p))) != NULL
&& (si->generation <= max_measure_generation) && (si->generation <= max_measure_generation)
&& (si->generation >= min_measure_generation) && (si->generation >= min_measure_generation)
&& (!(si->old_space) || !FORWARDEDP(p, si)) && (!(si->old_space) || !FORWARDEDP(p, si))
@ -3341,7 +3341,7 @@ static void check_ephemeron_measure(thread_gc *tgc, ptr pe) {
} }
p = Scdr(pe); p = Scdr(pe);
if (!IMMEDIATE(p)) if (!FIXMEDIATE(p))
push_measure(tgc, p); push_measure(tgc, p);
} }
@ -3398,7 +3398,7 @@ ptr S_count_size_increments(ptr ls, IGEN generation) {
for (l = ls; l != Snil; l = Scdr(l)) { for (l = ls; l != Snil; l = Scdr(l)) {
ptr p = Scar(l); ptr p = Scar(l);
if (!IMMEDIATE(p)) { if (!FIXMEDIATE(p)) {
seginfo *si = SegInfo(ptr_get_segment(p)); seginfo *si = SegInfo(ptr_get_segment(p));
if (!si->measured_mask) if (!si->measured_mask)
@ -3416,7 +3416,7 @@ ptr S_count_size_increments(ptr ls, IGEN generation) {
measure_total = 0; measure_total = 0;
if (!IMMEDIATE(p)) { if (!FIXMEDIATE(p)) {
seginfo *si = SegInfo(ptr_get_segment(p)); seginfo *si = SegInfo(ptr_get_segment(p));
measure_mask_unset(si->counting_mask, si, p); measure_mask_unset(si->counting_mask, si, p);
gc_measure_one(tgc, p); gc_measure_one(tgc, p);
@ -3432,7 +3432,7 @@ ptr S_count_size_increments(ptr ls, IGEN generation) {
for (l = ls; l != Snil; l = Scdr(l)) { for (l = ls; l != Snil; l = Scdr(l)) {
ptr p = Scar(l); ptr p = Scar(l);
if (!IMMEDIATE(p)) { if (!FIXMEDIATE(p)) {
seginfo *si = SegInfo(ptr_get_segment(p)); seginfo *si = SegInfo(ptr_get_segment(p));
si->counting_mask = NULL; si->counting_mask = NULL;
} }

View File

@ -185,7 +185,7 @@ void S_set_minmarkgen(IGEN g) {
void S_immobilize_object(x) ptr x; { void S_immobilize_object(x) ptr x; {
seginfo *si; seginfo *si;
if (IMMEDIATE(x)) if (FIXMEDIATE(x))
si = NULL; si = NULL;
else else
si = MaybeSegInfo(ptr_get_segment(x)); si = MaybeSegInfo(ptr_get_segment(x));
@ -212,7 +212,7 @@ void S_immobilize_object(x) ptr x; {
void S_mobilize_object(x) ptr x; { void S_mobilize_object(x) ptr x; {
seginfo *si; seginfo *si;
if (IMMEDIATE(x)) if (FIXMEDIATE(x))
si = NULL; si = NULL;
else else
si = MaybeSegInfo(ptr_get_segment(x)); si = MaybeSegInfo(ptr_get_segment(x));
@ -261,7 +261,7 @@ static IBOOL remove_first_nomorep(x, pls, look) ptr x, *pls; IBOOL look; {
IBOOL Slocked_objectp(x) ptr x; { IBOOL Slocked_objectp(x) ptr x; {
seginfo *si; IGEN g; IBOOL ans; ptr ls; seginfo *si; IGEN g; IBOOL ans; ptr ls;
if (IMMEDIATE(x) || (si = MaybeSegInfo(ptr_get_segment(x))) == NULL || (g = si->generation) == static_generation) return 1; if (FIXMEDIATE(x) || (si = MaybeSegInfo(ptr_get_segment(x))) == NULL || (g = si->generation) == static_generation) return 1;
tc_mutex_acquire(); tc_mutex_acquire();
@ -299,7 +299,7 @@ void Slock_object(x) ptr x; {
seginfo *si; IGEN g; seginfo *si; IGEN g;
/* weed out pointers that won't be relocated */ /* weed out pointers that won't be relocated */
if (!IMMEDIATE(x) && (si = MaybeSegInfo(ptr_get_segment(x))) != NULL && (g = si->generation) != static_generation) { if (!FIXMEDIATE(x) && (si = MaybeSegInfo(ptr_get_segment(x))) != NULL && (g = si->generation) != static_generation) {
ptr tc = get_thread_context(); ptr tc = get_thread_context();
tc_mutex_acquire(); tc_mutex_acquire();
THREAD_GC(tc)->during_alloc += 1; THREAD_GC(tc)->during_alloc += 1;
@ -323,7 +323,7 @@ void Slock_object(x) ptr x; {
void Sunlock_object(x) ptr x; { void Sunlock_object(x) ptr x; {
seginfo *si; IGEN g; seginfo *si; IGEN g;
if (!IMMEDIATE(x) && (si = MaybeSegInfo(ptr_get_segment(x))) != NULL && (g = si->generation) != static_generation) { if (!FIXMEDIATE(x) && (si = MaybeSegInfo(ptr_get_segment(x))) != NULL && (g = si->generation) != static_generation) {
ptr tc = get_thread_context(); ptr tc = get_thread_context();
tc_mutex_acquire(); tc_mutex_acquire();
THREAD_GC(tc)->during_alloc += 1; THREAD_GC(tc)->during_alloc += 1;
@ -550,7 +550,7 @@ void S_addr_tell(ptr p) {
static void check_pointer(ptr *pp, IBOOL address_is_meaningful, ptr base, uptr seg, ISPC s, IBOOL aftergc) { static void check_pointer(ptr *pp, IBOOL address_is_meaningful, ptr base, uptr seg, ISPC s, IBOOL aftergc) {
ptr p = *pp; ptr p = *pp;
if (!IMMEDIATE(p)) { if (!FIXMEDIATE(p)) {
seginfo *psi = MaybeSegInfo(ptr_get_segment(p)); seginfo *psi = MaybeSegInfo(ptr_get_segment(p));
if (psi != NULL) { if (psi != NULL) {
if ((psi->space == space_empty) if ((psi->space == space_empty)
@ -945,7 +945,7 @@ void S_check_heap(aftergc, mcg) IBOOL aftergc; IGEN mcg; {
found_eos = 1; found_eos = 1;
pp1 = pp2; pp1 = pp2;
break; break;
} else if (!IMMEDIATE(p)) { } else if (!FIXMEDIATE(p)) {
seginfo *psi = MaybeSegInfo(ptr_get_segment(p)); seginfo *psi = MaybeSegInfo(ptr_get_segment(p));
if ((psi != NULL) && ((pg = psi->generation) < g)) { if ((psi != NULL) && ((pg = psi->generation) < g)) {
if (pg < dirty) dirty = pg; if (pg < dirty) dirty = pg;

View File

@ -216,7 +216,7 @@ void S_call_help(tc_in, singlep, lock_ts) ptr tc_in; IBOOL singlep; IBOOL lock_t
the C stack and we may end up in a garbage collection */ the C stack and we may end up in a garbage collection */
code = CP(tc); code = CP(tc);
if (Sprocedurep(code)) code = CLOSCODE(code); if (Sprocedurep(code)) code = CLOSCODE(code);
if (!IMMEDIATE(code) && !Scodep(code)) if (!FIXMEDIATE(code) && !Scodep(code))
S_error_abort("S_call_help: invalid code pointer"); S_error_abort("S_call_help: invalid code pointer");
S_immobilize_object(code); S_immobilize_object(code);

View File

@ -277,7 +277,7 @@ static IBOOL destroy_thread(tc) ptr tc; {
for (ges = GUARDIANENTRIES(tc); ges != Snil; ges = next) { for (ges = GUARDIANENTRIES(tc); ges != Snil; ges = next) {
obj = GUARDIANOBJ(ges); obj = GUARDIANOBJ(ges);
next = GUARDIANNEXT(ges); next = GUARDIANNEXT(ges);
if (!IMMEDIATE(obj) && (si = MaybeSegInfo(ptr_get_segment(obj))) != NULL && si->generation != static_generation) { if (!FIXMEDIATE(obj) && (si = MaybeSegInfo(ptr_get_segment(obj))) != NULL && si->generation != static_generation) {
INITGUARDIANNEXT(ges) = target; INITGUARDIANNEXT(ges) = target;
target = ges; target = ges;
} }

View File

@ -552,7 +552,7 @@ typedef struct thread_gc {
#define SETPTRFIELD(x,disp,y) DIRTYSET(((ptr *)TO_VOIDP((uptr)(x)+disp)),(y)) #define SETPTRFIELD(x,disp,y) DIRTYSET(((ptr *)TO_VOIDP((uptr)(x)+disp)),(y))
#define INCRGEN(g) (g = g == S_G.max_nonstatic_generation ? static_generation : g+1) #define INCRGEN(g) (g = g == S_G.max_nonstatic_generation ? static_generation : g+1)
#define IMMEDIATE(x) (Sfixnump(x) || Simmediatep(x)) #define FIXMEDIATE(x) (Sfixnump(x) || Simmediatep(x))
/* For `memcpy_aligned, that the first two arguments are word-aligned /* For `memcpy_aligned, that the first two arguments are word-aligned
and it would be ok to round up the length to a word size. But and it would be ok to round up the length to a word size. But

View File

@ -519,7 +519,7 @@ static void relink_code(ptr co, ptr sym_base, ptr *vspaces, uptr *vspace_offsets
/* offset is stored in place of constant-loading code: */ /* offset is stored in place of constant-loading code: */
memcpy(&obj, TO_VOIDP((ptr)((uptr)co + a)), sizeof(ptr)); memcpy(&obj, TO_VOIDP((ptr)((uptr)co + a)), sizeof(ptr));
if (IMMEDIATE(obj)) { if (FIXMEDIATE(obj)) {
if (Sfixnump(obj)) { if (Sfixnump(obj)) {
int tag = VFASL_RELOC_TAG(obj); int tag = VFASL_RELOC_TAG(obj);
iptr pos = VFASL_RELOC_POS(obj); iptr pos = VFASL_RELOC_POS(obj);

View File

@ -1174,8 +1174,8 @@
'(lambda (v) '(lambda (v)
(let loop ([i 0]) (let loop ([i 0])
(when (fx< i (vector-length v)) (when (fx< i (vector-length v))
(vector-set! v i (#3%$immediate i)) (vector-set! v i (#3%$fixmediate i))
(loop (fx+ i 1)))))) (loop (fx+ i 1))))))
(cptypes-equivalent-expansion? (cptypes-equivalent-expansion?
'(lambda (x y) (set-box! x (if (vector? y) #t (error 't)))) '(lambda (x y) (set-box! x (if (vector? y) #t (error 't))))
'(lambda (x y) (set-box! x (#3%$immediate (if (vector? y) #t (error 't))))))) '(lambda (x y) (set-box! x (#3%$fixmediate (if (vector? y) #t (error 't)))))))

View File

@ -353,7 +353,7 @@
(set! assv (set! assv
(lambda (x alist) (lambda (x alist)
(if (or (symbol? x) (#%$immediate? x)) (if (or (symbol? x) (fixmediate? x))
(ass-eq? x alist 'assv) (ass-eq? x alist 'assv)
(do-assoc x alist 'assv eqv?)))) (do-assoc x alist 'assv eqv?))))
@ -363,7 +363,7 @@
[(string? x) [(string? x)
(do-assoc x alist 'assoc (do-assoc x alist 'assoc
(lambda (x y) (and (string? x) (string=? x y))))] (lambda (x y) (and (string? x) (string=? x y))))]
[(or (symbol? x) (#%$immediate? x)) [(or (symbol? x) (fixmediate? x))
(ass-eq? x alist 'assoc)] (ass-eq? x alist 'assoc)]
[else [else
(do-assoc x alist 'assoc equal?)]))) (do-assoc x alist 'assoc equal?)])))

View File

@ -2197,6 +2197,11 @@
(define-constant time-collector-cpu 5) (define-constant time-collector-cpu 5)
(define-constant time-collector-real 6) (define-constant time-collector-real 6)
(define-syntax fixmediate?
(lambda (stx)
(syntax-case stx ()
[(_ e) #'(let ([v e]) (or (fixnum? v) ($immediate? v)))])))
;; --------------------------------------------------------------------- ;; ---------------------------------------------------------------------
;; vfasl ;; vfasl

View File

@ -5244,7 +5244,7 @@
[else [else
`(call ,preinfo ,pr ,e1 ,e2 ,e3)]))] `(call ,preinfo ,pr ,e1 ,e2 ,e3)]))]
[(call ,preinfo ,pr ,e) [(call ,preinfo ,pr ,e)
(guard (eq? (primref-name pr) '$immediate)) (guard (eq? (primref-name pr) '$fixmediate))
(context-case ctxt (context-case ctxt
[(ignored) (cp0 e ctxt env sc wd name moi)] [(ignored) (cp0 e ctxt env sc wd name moi)]
[else [else

View File

@ -3846,7 +3846,7 @@
(lambda (multiple-ref? type e) (lambda (multiple-ref? type e)
(nanopass-case (L7 Expr) e (nanopass-case (L7 Expr) e
[(call ,info ,mdcl ,pr ,e) [(call ,info ,mdcl ,pr ,e)
(guard (eq? (primref-name pr) '$immediate)) (guard (eq? (primref-name pr) '$fixmediate))
(let-values ([(t dobind) (binder multiple-ref? type e)]) (let-values ([(t dobind) (binder multiple-ref? type e)])
(values `(call ,info ,mdcl ,pr ,t) dobind))] (values `(call ,info ,mdcl ,pr ,t) dobind))]
[else [else
@ -4124,7 +4124,7 @@
[(base index offset e build-assign build-remember-seq) [(base index offset e build-assign build-remember-seq)
(nanopass-case (L7 Expr) e (nanopass-case (L7 Expr) e
[(call ,info ,mdcl ,pr ,e) [(call ,info ,mdcl ,pr ,e)
(guard (eq? (primref-name pr) '$immediate)) (guard (eq? (primref-name pr) '$fixmediate))
(build-assign base index offset e)] (build-assign base index offset e)]
[else [else
(if (nanopass-case (L7 Expr) e (if (nanopass-case (L7 Expr) e
@ -6098,11 +6098,8 @@
,(%constant strue) ,(%constant strue)
,(%typed-object-check mask-inexactnum type-inexactnum ,e)))]) ,(%typed-object-check mask-inexactnum type-inexactnum ,e)))])
(define-inline 2 $immediate? (define-inline 2 $immediate?
[(e) (bind #t (e) [(e) (bind #t (e) (%type-check mask-immediate type-immediate ,e))])
`(if ,(%type-check mask-fixnum type-fixnum ,e) (define-inline 3 $fixmediate
,(%constant strue)
,(%type-check mask-immediate type-immediate ,e)))])
(define-inline 3 $immediate
[(e) e]) [(e) e])
(define-inline 3 $inexactnum-real-part (define-inline 3 $inexactnum-real-part

View File

@ -698,17 +698,16 @@ Notes:
(define (primref->unsafe-primref pr) (define (primref->unsafe-primref pr)
(lookup-primref 3 (primref-name pr))) (lookup-primref 3 (primref-name pr)))
(define (predicate-implies-immediate? x) (define (predicate-implies-fixmediate? x)
(and (not (eq? x 'ptr)) ;fast path to avoid duplicated computation (and (not (eq? x 'ptr)) ;fast path to avoid duplicated computation
(or (check-constant-is? x (lambda (x) (and ($immediate? x) (or (check-constant-is? x $immediate?)
(not (fixnum? x)))))
(predicate-implies? x 'fixnum) (predicate-implies? x 'fixnum)
(predicate-implies? x 'boolean) (predicate-implies? x 'boolean)
(predicate-implies? x 'char)))) (predicate-implies? x 'char))))
(define (non-literal-immediate? e x) (define (non-literal-fixmediate? e x)
(and (not (check-constant-is? e (lambda (e) #t))) (and (not (check-constant-is? e (lambda (e) #t)))
(predicate-implies-immediate? x))) (predicate-implies-fixmediate? x)))
(module () (module ()
@ -917,9 +916,9 @@ Notes:
(define-specialize 2 set (define-specialize 2 set
[(args ... val) (values `(call ,preinfo ,pr [(args ... val) (values `(call ,preinfo ,pr
,args ... ,args ...
,(if (non-literal-immediate? val (get-type val)) ,(if (non-literal-fixmediate? val (get-type val))
`(call ,(make-preinfo-call) `(call ,(make-preinfo-call)
,(lookup-primref 3 '$immediate) ,(lookup-primref 3 '$fixmediate)
,val) ,val)
val)) val))
ret ntypes #f #f)])])) ret ntypes #f #f)])]))
@ -1550,8 +1549,8 @@ Notes:
types1 types1
new-types)])))])))])] new-types)])))])))])]
[(set! ,maybe-src ,x ,[e 'value types plxc -> e ret types t-types f-types]) [(set! ,maybe-src ,x ,[e 'value types plxc -> e ret types t-types f-types])
(values `(set! ,maybe-src ,x ,(if (non-literal-immediate? e ret) (values `(set! ,maybe-src ,x ,(if (non-literal-fixmediate? e ret)
`(call ,(make-preinfo-call) ,(lookup-primref 3 '$immediate) ,e) `(call ,(make-preinfo-call) ,(lookup-primref 3 '$fixmediate) ,e)
e)) e))
void-rec types #f #f)] void-rec types #f #f)]
[(call ,preinfo ,pr ,e* ...) [(call ,preinfo ,pr ,e* ...)
@ -1622,9 +1621,9 @@ Notes:
(values `(record-set! ,rtd ,type ,index ,e1 (values `(record-set! ,rtd ,type ,index ,e1
,(cond ,(cond
[(and (eq? type 'scheme-object) [(and (eq? type 'scheme-object)
(non-literal-immediate? e2 ret2)) (non-literal-fixmediate? e2 ret2))
`(call ,(make-preinfo-call) `(call ,(make-preinfo-call)
,(lookup-primref 3 '$immediate) ,(lookup-primref 3 '$fixmediate)
,e2)] ,e2)]
[else e2])) [else e2]))
void-rec void-rec

View File

@ -2591,7 +2591,7 @@
(define cookie (cons 'date 'nut)) ; recreate on each call to $compute-size (define cookie (cons 'date 'nut)) ; recreate on each call to $compute-size
(define compute-size (define compute-size
(lambda (x) (lambda (x)
(if (or ($immediate? x) (if (or (fixmediate? x)
(let ([g ($generation x)]) (let ([g ($generation x)])
(or (not g) (fx> g maxgen)))) (or (not g) (fx> g maxgen))))
0 0
@ -2784,7 +2784,7 @@
rtd-counts phantom) rtd-counts phantom)
(define compute-composition! (define compute-composition!
(lambda (x) (lambda (x)
(unless (or ($immediate? x) (unless (or (fixmediate? x)
(let ([g ($generation x)]) (let ([g ($generation x)])
(or (not g) (fx> g maxgen)))) (or (not g) (fx> g maxgen))))
(let ([a (eq-hashtable-cell seen-ht x #f)]) (let ([a (eq-hashtable-cell seen-ht x #f)])
@ -2945,7 +2945,7 @@
(lambda (x path next-proc) (lambda (x path next-proc)
(let ([path (cons x path)]) (let ([path (cons x path)])
(cond (cond
[(or ($immediate? x) (let ([g ($generation x)]) (or (not g) (fx> g maxgen)))) [(or (fixmediate? x) (let ([g ($generation x)]) (or (not g) (fx> g maxgen))))
(if (pred x) (if (pred x)
(begin (set! saved-next-proc next-proc) path) (begin (set! saved-next-proc next-proc) path)
(next-proc))] (next-proc))]

View File

@ -1473,7 +1473,7 @@
[else #f]))) [else #f])))
(define-library-entry (memv x ls) (define-library-entry (memv x ls)
(if (or (symbol? x) (#%$immediate? x)) (if (or (symbol? x) (fixmediate? x))
(memq x ls) (memq x ls)
(let memv ([ls ls]) (let memv ([ls ls])
(and (not (null? ls)) (and (not (null? ls))

View File

@ -2058,7 +2058,7 @@
(code (code
"{ /* measure */" "{ /* measure */"
(format " ptr r_p = ~a;" e) (format " ptr r_p = ~a;" e)
" if (!IMMEDIATE(r_p))" " if (!FIXMEDIATE(r_p))"
" push_measure(tgc, r_p);" " push_measure(tgc, r_p);"
"}")) "}"))

View File

@ -1964,6 +1964,7 @@
($filter-conv [flags single-valued]) ($filter-conv [flags single-valued])
($filter-foreign-type [flags single-valued]) ($filter-foreign-type [flags single-valued])
($fixed-path? [sig [(string) -> (boolean)]] [flags pure safeongoodargs]) ($fixed-path? [sig [(string) -> (boolean)]] [flags pure safeongoodargs])
($fixmediate [sig [(ptr) -> (ptr)]] [flags pure discard])
($flvector-ref-check? [sig [(ptr ptr) -> (boolean)]] [flags unrestricted pure]) ($flvector-ref-check? [sig [(ptr ptr) -> (boolean)]] [flags unrestricted pure])
($flvector-set!-check? [sig [(ptr ptr) -> (boolean)]] [flags unrestricted discard]) ($flvector-set!-check? [sig [(ptr ptr) -> (boolean)]] [flags unrestricted discard])
($<= [flags single-valued]) ($<= [flags single-valued])
@ -2165,8 +2166,7 @@
($hashtable-veclen [flags discard]) ($hashtable-veclen [flags discard])
($ht-minlen [flags single-valued discard]) ($ht-minlen [flags single-valued discard])
($ht-veclen [flags single-valued discard]) ($ht-veclen [flags single-valued discard])
($immediate [sig [(ptr) -> (ptr)]] [flags pure discard]) ($immediate? [sig [(ptr) -> (boolean)]] [flags pure unrestricted mifoldable])
($immediate? [sig [(ptr) -> (boolean)]] [flags pure unrestricted]) ; no mifoldable due to fixnum
($impoops [flags abort-op]) ($impoops [flags abort-op])
($import-library [flags single-valued]) ($import-library [flags single-valued])
($inexactnum? [sig [(ptr) -> (boolean)]] [flags pure unrestricted mifoldable]) ($inexactnum? [sig [(ptr) -> (boolean)]] [flags pure unrestricted mifoldable])

View File

@ -1412,12 +1412,6 @@
(lambda (b) (lambda (b)
(#3%immutable-box? b))) (#3%immutable-box? b)))
(define-who $immediate
(lambda (x)
(if ($immediate? x)
x
($oops who "~s is not an immediate value" x))))
(define pair? (lambda (x) (pair? x))) (define pair? (lambda (x) (pair? x)))
(define box? (lambda (x) (box? x))) (define box? (lambda (x) (box? x)))
@ -1593,6 +1587,14 @@
(display-string s)])) (display-string s)]))
(define $immediate? (lambda (x) ($immediate? x))) (define $immediate? (lambda (x) ($immediate? x)))
;; Used to communicate fixmediateness from cptypes to cpnanopass:
(define-who $fixmediate
(lambda (x)
(if (fixmediate? x)
x
($oops who "~s is not a fixnum or immediate value" x))))
(define $inexactnum? (lambda (x) ($inexactnum? x))) (define $inexactnum? (lambda (x) ($inexactnum? x)))
(define $inexactnum-real-part (define $inexactnum-real-part

View File

@ -95,7 +95,7 @@
(define hashable? (define hashable?
(lambda (x) (lambda (x)
(if ($immediate? x) (if (fixmediate? x)
(eq? x black-hole) (eq? x black-hole)
(and (and
($object-in-heap? x) ($object-in-heap? x)
@ -203,7 +203,7 @@
(define cyclic? (define cyclic?
(lambda (x curlev lstlen) (lambda (x curlev lstlen)
(if ($immediate? x) (if (fixmediate? x)
(if (eq? x black-hole) (not lev) #f) (if (eq? x black-hole) (not lev) #f)
(and ($object-in-heap? x) (and ($object-in-heap? x)
(cond (cond
@ -279,7 +279,7 @@
(constant cycle-node-max))]) (constant cycle-node-max))])
(cond (cond
[(fx= xlev 0) (or (not lev) (fx> lev (constant cycle-node-max)))] [(fx= xlev 0) (or (not lev) (fx> lev (constant cycle-node-max)))]
[($immediate? x) (if (eq? x black-hole) (not lev) #f)] [(fixmediate? x) (if (eq? x black-hole) (not lev) #f)]
[else [else
(and ($object-in-heap? x) (and ($object-in-heap? x)
(cond (cond
@ -322,7 +322,7 @@
(set! $make-graph-env (set! $make-graph-env
(lambda (who x lev len) (lambda (who x lev len)
(and (if ($immediate? x) (and (if (fixmediate? x)
(eq? x black-hole) (eq? x black-hole)
(and ($object-in-heap? x) (and ($object-in-heap? x)
(or (pair? x) (vector? x) (stencil-vector? x) (box? x) (and ($record? x) (not (eq? x #!base-rtd)))))) (or (pair? x) (vector? x) (stencil-vector? x) (box? x) (and ($record? x) (not (eq? x #!base-rtd))))))
@ -634,7 +634,6 @@ floating point returns with (1 0 -1 ...).
(cond (cond
[($immediate? x) [($immediate? x)
(type-case x (type-case x
[(fixnum?) (wrfixnum x r d? p)]
[(null?) (display-string "()" p)] [(null?) (display-string "()" p)]
[(boolean?) (display-string (if x "#t" "#f") p)] [(boolean?) (display-string (if x "#t" "#f") p)]
[(char?) (if d? (write-char x p) (wrchar x p))] [(char?) (if d? (write-char x p) (wrchar x p))]
@ -644,6 +643,7 @@ floating point returns with (1 0 -1 ...).
[(void?) (display-string "#<void>" p)] [(void?) (display-string "#<void>" p)]
[(black-hole?) (wrblack-hole x r lev len d? env p)] [(black-hole?) (wrblack-hole x r lev len d? env p)]
[else (display-string "#<garbage>" p)])] [else (display-string "#<garbage>" p)])]
[(fixnum? x) (wrfixnum x r d? p)]
[($object-in-heap? x) [($object-in-heap? x)
(type-case x (type-case x
[(symbol?) [(symbol?)