From 4a9de64f81db8377b672c5a20773b3330fc0b0f3 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 20 Aug 2018 08:59:19 +0200 Subject: [PATCH] Fix default code allocator in Lightning * libguile/lightning/lib/lightning.c (_jit_emit): The default code allocator will simply mmap a code buffer, try to emit into that buffer, and if it fails, try again with a larger buffer. However the buffer size starts at 0, for some reason. Why? I can't see the reason. Change the default to 4096. In the future we will need to implement our own allocator anyway so that we can pack multiple JIT runs in one page. --- libguile/lightning/lib/lightning.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libguile/lightning/lib/lightning.c b/libguile/lightning/lib/lightning.c index 613c19f6b..521746643 100644 --- a/libguile/lightning/lib/lightning.c +++ b/libguile/lightning/lib/lightning.c @@ -2070,6 +2070,9 @@ _jit_emit(jit_state_t *_jit) #if defined(__sgi) mmap_fd = open("/dev/zero", O_RDWR); #endif + if (_jit->code.length == 0) + _jit->code.length = 4096; + _jit->code.ptr = mmap(NULL, _jit->code.length, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, mmap_fd, 0);