on master help sign in
Zero whole heap on initialisation

Instead of doing it on every allocation. A small thing, but a noticeable performance gain on building the Blodwen libraries in particular.

commit1980f49f43aabecb046f16c82acfab5f70133014 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateSun 6 Jan 2019, 16:57 (8 years ago) parent03d9188
2 files changed+2−2
rts/idris_heap.c+2 rts/idris_rts.c−2
rts/idris_heap.c+2
@@ -110,12 +110,14 @@ void c_heap_destroy(CHeap * heap)
110110void alloc_heap(Heap * h, size_t heap_size, size_t growth, char * old)
111111{
112112 char * mem = malloc(heap_size);
113+
113114 if (mem == NULL) {
114115 fprintf(stderr,
115116 "RTS ERROR: Unable to allocate heap. Requested %zd bytes.\n",
116117 heap_size);
117118 exit(EXIT_FAILURE);
118119 }
120+ memset(mem, 0, heap_size);
119121
120122 h->heap = mem;
121123 h->next = aligned_heap_pointer(h->heap);
rts/idris_rts.c−2
@@ -209,7 +209,6 @@ void * allocate(size_t sz, int lock) {
209209}
210210
211211void* iallocate(VM * vm, size_t isize, int outerlock) {
212−// return malloc(isize);
213212 size_t size = aligned(isize);
214213
215214#ifdef HAS_PTHREAD
@@ -225,7 +224,6 @@ void* iallocate(VM * vm, size_t isize, int outerlock) {
225224 char* ptr = vm->heap.next;
226225 vm->heap.next += size;
227226 assert(vm->heap.next <= vm->heap.end);
228− memset(ptr, 0, size);
229227 ((Hdr*)ptr)->sz = isize;
230228
231229#ifdef HAS_PTHREAD