History

cons flags: fix wrong alignment on 64-bit platforms

Sigrid Solveig Haflínudóttir committed 3 months ago

Commit fb512ba1 parent 13e6bd84 files · +14 −11Browse files

Showing the changes to src (3 of 4 files). Show all

Unified · Split

3 files
  1. src/print.c +2 −2
  2. src/sl.c +2 −2
  3. src/slpriv.h +3 −0
src/print.c+2−2
@@ -13,7 +13,7 @@ enum { · 12 unmodified lines
1313
1414 #define LOG2_10 3.321928094887362347870319429489
1515
16−#define cons_index(c) (ptr(sl_cons, c)-(sl_cons*)slvm.fromspace)
16+#define cons_index(c) (ptr(sl_aligned, c)-(sl_aligned*)slvm.fromspace)
1717 #define ismarked(c) bitvector_get(sl.consflags, cons_index(c))
1818 #define mark_cons(c) bitvector_set(sl.consflags, cons_index(c))
1919 #define unmark_cons(c) bitvector_reset(sl.consflags, cons_index(c))
@@ -1094,7 +1094,7 @@ sl_print(sl_v v) · 1074 unmodified lines
10941094 if(iscons(v) || isvec(v) || isfn(v) || (iscvalue(v) && !isstr(v))){
10951095 htable_reset(&sl.pr.conses, HT_N_INLINE);
10961096 if(sl.pr.circle)
1097− memset(sl.consflags, 0, sizeof(u32int)*bitvector_nwords(slvm.heapsize/sizeof(sl_cons)));
1097+ memset(sl.consflags, 0, sizeof(u32int)*bitvector_nwords(slvm.heapsize/sizeof(sl_aligned)));
10981098 }
10991099 }
11001100
src/sl.c+2−2
@@ -614,7 +614,7 @@ sl_gc(bool mustgrow) · 613 unmodified lines
614614 cthrow(raise(sl_erroom), mustgrow);
615615 }
616616 if(slvm.grew){
617− u64int sz = slvm.heapsize/sizeof(sl_cons);
617+ u64int sz = slvm.heapsize/sizeof(sl_aligned);
618618 if(sl_unlikely(sz < 1))
619619 sz = 1;
620620 temp = bitvector_resize(sl.consflags, sz, sz*2);
@@ -1401,7 +1401,7 @@ failed: · 780 unmodified lines
14011401 if((slvm.gchandles = MEM_ALLOC(slvm.maxgchandles * sizeof(sl_v*))) == nil)
14021402 goto failed;
14031403
1404− if((sl.consflags = bitvector_new(slvm.heapsize/sizeof(sl_cons))) == nil)
1404+ if((sl.consflags = bitvector_new(slvm.heapsize/sizeof(sl_aligned))) == nil)
14051405 goto failed;
14061406 if((htable_new(&sl.pr.conses, HT_N_INLINE)) == nil)
14071407 goto failed;
src/slpriv.h+3−0
@@ -5,6 +5,9 @@ · 4 unmodified lines
55 #include "htable_h.h"
66 HTPROT(ptrhash)
77
8+// all allocations on the heap are 8-byte aligned
9+typedef u64int sl_aligned;
10+
811 #if defined(BITS64)
912 #define FIXNUM_BITS (64-TAG_BITS)
1013 #define UNBOXED_BITS (64-TAG_EXT_BITS)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t