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.
This commit is contained in:
Edwin Brady 2019-01-06 16:57:39 +00:00
parent 03d9188ffb
commit 1980f49f43
2 changed files with 2 additions and 2 deletions

View File

@ -110,12 +110,14 @@ void c_heap_destroy(CHeap * heap)
void alloc_heap(Heap * h, size_t heap_size, size_t growth, char * old)
{
char * mem = malloc(heap_size);
if (mem == NULL) {
fprintf(stderr,
"RTS ERROR: Unable to allocate heap. Requested %zd bytes.\n",
heap_size);
exit(EXIT_FAILURE);
}
memset(mem, 0, heap_size);
h->heap = mem;
h->next = aligned_heap_pointer(h->heap);

View File

@ -209,7 +209,6 @@ void * allocate(size_t sz, int lock) {
}
void* iallocate(VM * vm, size_t isize, int outerlock) {
// return malloc(isize);
size_t size = aligned(isize);
#ifdef HAS_PTHREAD
@ -225,7 +224,6 @@ void* iallocate(VM * vm, size_t isize, int outerlock) {
char* ptr = vm->heap.next;
vm->heap.next += size;
assert(vm->heap.next <= vm->heap.end);
memset(ptr, 0, size);
((Hdr*)ptr)->sz = isize;
#ifdef HAS_PTHREAD