aboutsummaryrefslogtreecommitdiff
path: root/src/lj_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_alloc.c')
-rw-r--r--src/lj_alloc.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lj_alloc.c b/src/lj_alloc.c
index 82b4e5b1..8f285d17 100644
--- a/src/lj_alloc.c
+++ b/src/lj_alloc.c
@@ -188,21 +188,24 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
188 return ptr; 188 return ptr;
189} 189}
190 190
191#elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) 191#elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__sun__)
192 192
193/* OSX and FreeBSD mmap() use a naive first-fit linear search. 193/* OSX and FreeBSD mmap() use a naive first-fit linear search.
194** That's perfect for us. Except that -pagezero_size must be set for OSX, 194** That's perfect for us. Except that -pagezero_size must be set for OSX,
195** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs 195** otherwise the lower 4GB are blocked. And the 32GB RLIMIT_DATA needs
196** to be reduced to 250MB on FreeBSD. 196** to be reduced to 250MB on FreeBSD.
197*/ 197*/
198#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) 198#if LJ_TARGET_OSX
199#include <sys/resource.h>
200#define MMAP_REGION_START ((uintptr_t)0x10000000)
201#else
202#define MMAP_REGION_START ((uintptr_t)0x10000) 199#define MMAP_REGION_START ((uintptr_t)0x10000)
200#else
201#define MMAP_REGION_START ((uintptr_t)0x10000000)
203#endif 202#endif
204#define MMAP_REGION_END ((uintptr_t)0x80000000) 203#define MMAP_REGION_END ((uintptr_t)0x80000000)
205 204
205#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
206#include <sys/resource.h>
207#endif
208
206static LJ_AINLINE void *CALL_MMAP(size_t size) 209static LJ_AINLINE void *CALL_MMAP(size_t size)
207{ 210{
208 int olderr = errno; 211 int olderr = errno;
@@ -227,6 +230,10 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
227 return p; 230 return p;
228 } 231 }
229 if (p != CMFAIL) munmap(p, size); 232 if (p != CMFAIL) munmap(p, size);
233#ifdef __sun__
234 alloc_hint += 0x1000000; /* Need near-exhaustive linear scan. */
235 if (alloc_hint + size < MMAP_REGION_END) continue;
236#endif
230 if (retry) break; 237 if (retry) break;
231 retry = 1; 238 retry = 1;
232 alloc_hint = MMAP_REGION_START; 239 alloc_hint = MMAP_REGION_START;