on master help sign in
Merge pull request #3605 from XeFias/master
c86bf98Ahmad Salim Al-Sibahi
rts/idris_gc.c+2−1
@@ -1,3 +1,4 @@
1+#include "idris_heap.h"
1#include "idris_rts.h"
2#include "idris_rts.h"
2#include "idris_gc.h"
3#include "idris_gc.h"
3#include "idris_bitstring.h"
4#include "idris_bitstring.h"
@@ -73,7 +74,7 @@ VAL copy(VM* vm, VAL x) {
73void cheney(VM *vm) {
74void cheney(VM *vm) {
74 int i;
75 int i;
75 int ar;
76 int ar;
76− char* scan = vm->heap.heap;
77+ char* scan = aligned_heap_pointer(vm->heap.heap);
77
78
78 while(scan < vm->heap.next) {
79 while(scan < vm->heap.next) {
79 size_t inc = *((size_t*)scan);
80 size_t inc = *((size_t*)scan);
rts/idris_heap.c+12−8
@@ -118,14 +118,7 @@ void alloc_heap(Heap * h, size_t heap_size, size_t growth, char * old)
118 }
118 }
119
119
120 h->heap = mem;
120 h->heap = mem;
121−#ifdef FORCE_ALIGNMENT
122− if (((i_int)(h->heap)&1) == 1) {
123− h->next = h->heap + 1;
121+ h->next = aligned_heap_pointer(h->heap);
124− } else
125−#endif
126− {
127− h->next = h->heap;
128− }
129 h->end = h->heap + heap_size;
122 h->end = h->heap + heap_size;
130
123
131 h->size = heap_size;
124 h->size = heap_size;
@@ -169,6 +162,17 @@ int ref_in_heap(Heap * heap, VAL v) {
169 return ((VAL)heap->heap <= v) && (v < (VAL)heap->next);
162 return ((VAL)heap->heap <= v) && (v < (VAL)heap->next);
170}
163}
171
164
165+char* aligned_heap_pointer(char * heap) {
166+#ifdef FORCE_ALIGNMENT
167+ if (((i_int)heap&1) == 1) {
168+ return (heap + 1);
169+ } else
170+#endif
171+ {
172+ return heap;
173+ }
174+}
175+
172// Checks three important properties:
176// Checks three important properties:
173// 1. Closure.
177// 1. Closure.
174// Check if all pointers in the _heap_ points only to heap.
178// Check if all pointers in the _heap_ points only to heap.
rts/idris_heap.h+1−1
@@ -98,7 +98,7 @@ typedef struct {
98
98
99void alloc_heap(Heap * heap, size_t heap_size, size_t growth, char * old);
99void alloc_heap(Heap * heap, size_t heap_size, size_t growth, char * old);
100void free_heap(Heap * heap);
100void free_heap(Heap * heap);
101−
101+char* aligned_heap_pointer(char * heap);
102
102
103#ifdef IDRIS_DEBUG
103#ifdef IDRIS_DEBUG
104void heap_check_all(Heap * heap);
104void heap_check_all(Heap * heap);