Skip to content

Commit cf4f9af

Browse files
author
Paulo Matos
authored
Master merge for 20200605 (#11)
1 parent 2d84ec6 commit cf4f9af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2286
-1115
lines changed

.github/scripts/build.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
#!/bin/bash
22
set -e -o pipefail
3-
echo 'travis_fold:start:build'
43
echo Building Chez Scheme...
5-
./configure -m=$TARGET_MACHINE
4+
./configure -m=$MACH
65
make
7-
case $TARGET_MACHINE in
6+
case $MACH in
87
*a6nt)
98
curl -Ls https://github.com/burgerrg/win-iconv/releases/download/v0.0.9/iconv-x64.dll > $TARGET_MACHINE/bin/$TARGET_MACHINE/iconv.dll
109
;;
1110
*i3nt)
1211
curl -Ls https://github.com/burgerrg/win-iconv/releases/download/v0.0.9/iconv-x86.dll > $TARGET_MACHINE/bin/$TARGET_MACHINE/iconv.dll
1312
;;
1413
esac
15-
echo 'travis_fold:end:build'

.github/scripts/dobootfile.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/scripts/test.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ jobs:
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
mach: ['ta6le']
13+
mach: ['i3le', 'ti3le', 'a6le', 'ta6le']
1414

1515
env:
16-
TARGET_MACHINE: ${{ matrix.mach }}
16+
MACH: ${{ matrix.mach }}
1717

1818
steps:
19+
- uses: Bogdanp/setup-racket@v0.8
20+
with:
21+
distribution: 'minimal' # minimal is enough
22+
variant: 'CS' # lets dog-food CS
23+
version: 'current'
24+
packages: 'cs-bootstrap'
1925
- uses: actions/checkout@v2
2026
with:
2127
submodules: 'recursive'
@@ -33,7 +39,7 @@ jobs:
3339
sudo apt-get update
3440
sudo apt-get install -y libncurses5-dev uuid-dev libssl-dev
3541
- name: Build bootfiles
36-
run: .github/scripts/dobootfile.sh
42+
run: racket -l cs-bootstrap
3743
- name: Build Chez
3844
run: .github/scripts/build.sh
3945
- name: Test Chez

c/Mf-ti3osx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ m = ti3osx
1717
Cpu = I386
1818

1919
mdclib = -liconv -lm ${ncursesLib}
20-
C = ${CC} ${CPPFLAGS} -m32 -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -Werror -O2 -msse2 -I/opt/X11/include/ ${CFLAGS}
20+
C = ${CC} ${CPPFLAGS} -m32 -Wpointer-arith -Wall -Wextra -Wno-implicit-fallthrough -Werror -g -O2 -msse2 -I/opt/X11/include/ ${CFLAGS}
2121
o = o
2222
mdsrc = i3le.c
2323
mdobj = i3le.o

c/externs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ extern void S_immobilize_object PROTO((ptr v));
168168
extern void S_mobilize_object PROTO((ptr v));
169169
extern ptr S_unregister_guardian PROTO((ptr tconc));
170170
extern void S_compact_heap PROTO((void));
171-
extern void S_check_heap PROTO((IBOOL aftergc));
171+
extern void S_check_heap PROTO((IBOOL aftergc, IGEN target_gen));
172172

173173
/* gc-ocd.c */
174174
extern ptr S_gc_ocd PROTO((ptr tc, IGEN mcg, IGEN tg, ptr count_roots));

c/gc.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,11 @@ static ptr sweep_from;
239239

240240
#if ptr_alignment == 2
241241
# define record_full_marked_mask 0x55
242-
# define record_high_marked_mask 0x40
242+
# define record_high_marked_bit 0x40
243243
# define mask_bits_to_list_bits_mask(m) ((m) | ((m) << 1))
244244
#elif ptr_alignment == 1
245245
# define record_full_marked_mask 0xFF
246-
# define record_high_marked_mask 0x80
246+
# define record_high_marked_bit 0x80
247247
# define mask_bits_to_list_bits_mask(m) (m)
248248
#endif
249249

@@ -273,7 +273,7 @@ uptr list_length(ptr ls) {
273273
#define marked(si, p) (si->marked_mask && (si->marked_mask[segment_bitmap_byte(p)] & segment_bitmap_bit(p)))
274274

275275
static void init_fully_marked_mask() {
276-
init_mask(fully_marked_mask, 0, 0xFF);
276+
init_mask(fully_marked_mask, target_generation, 0xFF);
277277
}
278278

279279
#ifdef PRESERVE_FLONUM_EQ
@@ -287,11 +287,8 @@ static void flonum_set_forwarded(ptr p, seginfo *si) {
287287
static int flonum_is_forwarded_p(ptr p, seginfo *si) {
288288
if (!si->forwarded_flonums)
289289
return 0;
290-
else {
291-
uptr delta = (uptr)UNTYPE(p, type_flonum) - (uptr)build_ptr(si->number, 0);
292-
delta >>= log2_ptr_bytes;
293-
return si->forwarded_flonums[delta >> 3] & (1 << (delta & 0x7));
294-
}
290+
else
291+
return si->forwarded_flonums[segment_bitmap_byte(p)] & segment_bitmap_bit(p);
295292
}
296293

297294
# define FLONUM_FWDADDRESS(p) *(ptr*)(UNTYPE(p, type_flonum))
@@ -539,7 +536,7 @@ ptr GCENTRY(ptr tc, IGEN mcg, IGEN tg, ptr count_roots_ls) {
539536
}
540537

541538
/* perform after ScanDirty */
542-
if (S_checkheap) S_check_heap(0);
539+
if (S_checkheap) S_check_heap(0, mcg);
543540

544541
#ifdef DEBUG
545542
(void)printf("mcg = %x; go? ", mcg); (void)fflush(stdout); (void)getc(stdin);
@@ -639,7 +636,7 @@ ptr GCENTRY(ptr tc, IGEN mcg, IGEN tg, ptr count_roots_ls) {
639636
seginfo *si = SegInfo(ptr_get_segment(p));
640637
if (si->space == space_new) {
641638
if (!si->marked_mask)
642-
init_mask(si->marked_mask, 0, 0);
639+
init_mask(si->marked_mask, tg, 0);
643640
si->marked_mask[segment_bitmap_byte(p)] |= segment_bitmap_bit(p);
644641
}
645642
}
@@ -1207,7 +1204,7 @@ ptr GCENTRY(ptr tc, IGEN mcg, IGEN tg, ptr count_roots_ls) {
12071204

12081205
S_flush_instruction_cache(tc);
12091206

1210-
if (S_checkheap) S_check_heap(1);
1207+
if (S_checkheap) S_check_heap(1, mcg);
12111208

12121209
/* post-collection rehashing of tlcs.
12131210
must come after any use of relocate.
@@ -1659,7 +1656,7 @@ static void sweep_dirty(void) {
16591656
if (si->marked_mask[byte-1] == record_full_marked_mask) {
16601657
/* next byte is full, so keep looking */
16611658
byte--;
1662-
} else if (si->marked_mask[byte-1] & record_high_marked_mask) {
1659+
} else if (si->marked_mask[byte-1] & record_high_marked_bit) {
16631660
/* next byte continues, but is not full, so we can start
16641661
there */
16651662
if (at_seg != seg) {
@@ -1671,6 +1668,7 @@ static void sweep_dirty(void) {
16711668
si = SegInfo(at_seg);
16721669
} else {
16731670
byte--;
1671+
bit = record_high_marked_bit;
16741672
/* find bit contiguous with highest bit */
16751673
while (si->marked_mask[byte] & (bit >> ptr_alignment))
16761674
bit >>= ptr_alignment;
@@ -2080,14 +2078,14 @@ void copy_and_clear_list_bits(seginfo *oldspacesegments, IGEN tg) {
20802078
} else {
20812079
if (si->marked_mask) {
20822080
/* Besides marking or copying `si->list_bits`, clear bits
2083-
where there's no corresopnding mark bit, so we don't try to
2081+
where there's no corresponding mark bit, so we don't try to
20842082
check forwarding in a future GC */
20852083
seginfo *bits_si = SegInfo(ptr_get_segment((ptr)si->list_bits));
20862084

20872085
if (bits_si->old_space) {
20882086
if (bits_si->use_marks) {
20892087
if (!bits_si->marked_mask)
2090-
init_mask(bits_si->marked_mask, 0, 0);
2088+
init_mask(bits_si->marked_mask, tg, 0);
20912089
bits_si->marked_mask[segment_bitmap_byte((ptr)si->list_bits)] |= segment_bitmap_bit((ptr)si->list_bits);
20922090
} else {
20932091
octet *copied_bits;

c/gcwrapper.c

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static void check_heap_dirty_msg PROTO((char *msg, ptr *x));
2222
static IBOOL dirty_listedp PROTO((seginfo *x, IGEN from_g, IGEN to_g));
2323
static void check_dirty_space PROTO((ISPC s));
2424
static void check_dirty PROTO((void));
25+
static void check_locked_object PROTO((ptr p, IBOOL locked, IGEN g, IBOOL aftergc, IGEN mcg));
2526

2627
static IBOOL checkheap_noisy;
2728

@@ -510,6 +511,8 @@ static void segment_tell(seg) uptr seg; {
510511
else {
511512
printf(" space-%s", spacename[s1]);
512513
if (si->old_space) printf(" oldspace");
514+
if (si->must_mark) printf(" mustmark");
515+
if (si->marked_mask) printf(" marked");
513516
}
514517
printf("\n");
515518
}
@@ -534,7 +537,7 @@ static void check_heap_dirty_msg(msg, x) char *msg; ptr *x; {
534537
printf("to "); segment_tell(addr_get_segment(*x));
535538
}
536539

537-
void S_check_heap(aftergc) IBOOL aftergc; {
540+
void S_check_heap(aftergc, mcg) IBOOL aftergc; IGEN mcg; {
538541
uptr seg; INT d; ISPC s; IGEN g; IDIRTYBYTE dirty; IBOOL found_eos; IGEN pg;
539542
ptr p, *pp1, *pp2, *nl;
540543
iptr i;
@@ -573,6 +576,10 @@ void S_check_heap(aftergc) IBOOL aftergc; {
573576
seginfo *si;
574577
for (g = 0; g <= S_G.max_nonstatic_generation; INCRGEN(g)) {
575578
for (si = S_G.occupied_segments[s][g]; si != NULL; si = si->next) {
579+
if (si->generation != g) {
580+
S_checkheap_errors += 1;
581+
printf("!!! segment in wrong occupied_segments list\n");
582+
}
576583
nonstatic_segments += 1;
577584
}
578585
}
@@ -619,8 +626,11 @@ void S_check_heap(aftergc) IBOOL aftergc; {
619626
s = si->space;
620627
g = si->generation;
621628

629+
if (si->use_marks)
630+
printf("!!! use_marks set on generation %d segment %#tx\n", g, (ptrdiff_t)seg);
631+
622632
if (s == space_new) {
623-
if (g != 0) {
633+
if (g != 0 && !si->marked_mask) {
624634
S_checkheap_errors += 1;
625635
printf("!!! unexpected generation %d segment %#tx in space_new\n", g, (ptrdiff_t)seg);
626636
}
@@ -654,9 +664,18 @@ void S_check_heap(aftergc) IBOOL aftergc; {
654664
|| psi->old_space
655665
|| (psi->marked_mask && !(psi->marked_mask[segment_bitmap_byte(p)] & segment_bitmap_bit(p)))) {
656666
S_checkheap_errors += 1;
657-
printf("!!! dangling reference at %#tx to %#tx\n", (ptrdiff_t)pp1, (ptrdiff_t)p);
667+
printf("!!! dangling reference at %#tx to %#tx%s\n", (ptrdiff_t)pp1, (ptrdiff_t)p, (aftergc ? " after gc" : ""));
658668
printf("from: "); segment_tell(seg);
659669
printf("to: "); segment_tell(ptr_get_segment(p));
670+
{
671+
ptr l;
672+
for (l = S_G.locked_objects[psi->generation]; l != Snil; l = Scdr(l))
673+
if (Scar(l) == p)
674+
printf(" in locked\n");
675+
for (l = S_G.unlocked_objects[psi->generation]; l != Snil; l = Scdr(l))
676+
if (Scar(l) == p)
677+
printf(" in unlocked\n");
678+
}
660679
}
661680
}
662681
}
@@ -745,8 +764,9 @@ void S_check_heap(aftergc) IBOOL aftergc; {
745764
if (aftergc
746765
&& (s != space_empty)
747766
&& (g == 0
748-
|| (s != space_impure && s != space_symbol && s != space_port && s != space_weakpair && s != space_ephemeron
749-
&& s != space_impure_record && s != space_immobile_impure && s != space_count_impure && s != space_closure))) {
767+
|| (s != space_new && s != space_impure && s != space_symbol && s != space_port && s != space_weakpair && s != space_ephemeron
768+
&& s != space_impure_record && s != space_impure_typed_object
769+
&& s != space_immobile_impure && s != space_count_impure && s != space_closure))) {
750770
for (d = 0; d < cards_per_segment; d += 1) {
751771
if (si->dirty_bytes[d] != 0xff) {
752772
S_checkheap_errors += 1;
@@ -760,6 +780,21 @@ void S_check_heap(aftergc) IBOOL aftergc; {
760780
chunk = chunk->next;
761781
}
762782
}
783+
784+
{
785+
for (g = 0; g <= S_G.max_nonstatic_generation; INCRGEN(g)) {
786+
ptr l;
787+
for (l = S_G.locked_objects[g]; l != Snil; l = Scdr(l))
788+
check_locked_object(Scar(l), 1, g, aftergc, mcg);
789+
for (l = S_G.unlocked_objects[g]; l != Snil; l = Scdr(l))
790+
check_locked_object(Scar(l), 0, g, aftergc, mcg);
791+
}
792+
}
793+
794+
if (S_checkheap_errors) {
795+
printf("heap check failed%s\n", (aftergc ? " after gc" : ""));
796+
exit(1);
797+
}
763798
}
764799

765800
static IBOOL dirty_listedp(seginfo *x, IGEN from_g, IGEN to_g) {
@@ -826,7 +861,9 @@ static void check_dirty() {
826861
S_checkheap_errors += 1;
827862
printf("!!! (check_dirty): dirty byte = %d for segment %#tx in %d -> %d dirty list\n", mingval, (ptrdiff_t)(si->number), from_g, to_g);
828863
}
829-
if (s != space_new && s != space_impure && s != space_symbol && s != space_port && s != space_impure_record && s != space_weakpair && s != space_ephemeron) {
864+
if (s != space_new && s != space_impure && s != space_symbol && s != space_port
865+
&& s != space_impure_record && s != space_impure_typed_object && s != space_immobile_impure
866+
&& s != space_weakpair && s != space_ephemeron) {
830867
S_checkheap_errors += 1;
831868
printf("!!! (check_dirty): unexpected space %d for dirty segment %#tx\n", s, (ptrdiff_t)(si->number));
832869
}
@@ -842,10 +879,40 @@ static void check_dirty() {
842879
check_dirty_space(space_impure_record);
843880
check_dirty_space(space_weakpair);
844881
check_dirty_space(space_ephemeron);
882+
check_dirty_space(space_immobile_impure);
845883

846884
fflush(stdout);
847885
}
848886

887+
static void check_locked_object(ptr p, IBOOL locked, IGEN g, IBOOL aftergc, IGEN mcg)
888+
{
889+
const char *what = (locked ? "locked" : "unlocked");
890+
seginfo *psi = MaybeSegInfo(ptr_get_segment(p));
891+
if (!psi) {
892+
S_checkheap_errors += 1;
893+
printf("!!! generation %d %s object has no segment: %p\n", g, what, p);
894+
} else {
895+
if (psi->generation != g) {
896+
S_checkheap_errors += 1;
897+
printf("!!! generation %d %s object in generation %d segment: %p\n", g, what, psi->generation, p);
898+
}
899+
if (!psi->must_mark && locked) {
900+
S_checkheap_errors += 1;
901+
printf("!!! generation %d %s object not on must-mark page: %p\n", g, what, p);
902+
}
903+
if (!psi->marked_mask) {
904+
if (aftergc && (psi->generation <= mcg)) {
905+
S_checkheap_errors += 1;
906+
printf("!!! %s object not in marked segment: %p\n", what, p);
907+
printf(" in: "); segment_tell(psi->number);
908+
}
909+
} else if (!(psi->marked_mask[segment_bitmap_byte(p)] & segment_bitmap_bit(p))) {
910+
S_checkheap_errors += 1;
911+
printf("!!! generation %d %s object not marked: %p\n", g, what, p);
912+
}
913+
}
914+
}
915+
849916
void S_fixup_counts(ptr counts) {
850917
IGEN g; U64 timestamp;
851918

c/prim.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ static void create_c_entry_vector() {
150150

151151
for (i = 0; i < c_entry_vector_size; i++) {
152152
#ifndef PTHREADS
153-
if (i == CENTRY_raw_collect_cond || i == CENTRY_raw_tc_mutex
153+
if (i == CENTRY_raw_collect_cond || i == CENTRY_raw_collect_thread0_cond
154+
|| i == CENTRY_raw_tc_mutex
154155
|| i == CENTRY_activate_thread || i == CENTRY_deactivate_thread
155156
|| i == CENTRY_unactivate_thread)
156157
continue;

c/prim5.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ static ptr s_make_immobile_vector(uptr len, ptr fill) {
222222
for (i = 0; i < len; i++)
223223
INITVECTIT(v, i) = fill;
224224

225+
if (!(len & 0x1)) {
226+
/* pad, since we're not going to copy on a GC */
227+
INITVECTIT(v, len) = FIX(0);
228+
}
229+
225230
return v;
226231
}
227232

0 commit comments

Comments
 (0)