aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2013-05-25 10:20:46 +0200
committerMike Pall <mike>2013-05-25 10:20:46 +0200
commit26e4287e60f636af93493ccb16b7173110db9087 (patch)
tree0f638112910ccd515aea3b5471b96c72f4bcb191
parent992f7d4b71d0f39266c9b2d7f8ce28c278afb667 (diff)
parent5a261dd92c72d8f9d2aab0714ce9e051f0d70219 (diff)
downloadluajit-26e4287e60f636af93493ccb16b7173110db9087.tar.gz
luajit-26e4287e60f636af93493ccb16b7173110db9087.tar.bz2
luajit-26e4287e60f636af93493ccb16b7173110db9087.zip
Merge branch 'master' into v2.1
-rw-r--r--src/lj_alloc.c17
-rw-r--r--src/luajit.c15
-rw-r--r--src/vm_x86.dasc4
3 files changed, 23 insertions, 13 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;
diff --git a/src/luajit.c b/src/luajit.c
index 35496339..680984da 100644
--- a/src/luajit.c
+++ b/src/luajit.c
@@ -498,15 +498,15 @@ static int handle_luainit(lua_State *L)
498 return dostring(L, init, "=" LUA_INIT); 498 return dostring(L, init, "=" LUA_INIT);
499} 499}
500 500
501struct Smain { 501static struct Smain {
502 char **argv; 502 char **argv;
503 int argc; 503 int argc;
504 int status; 504 int status;
505}; 505} smain;
506 506
507static int pmain(lua_State *L) 507static int pmain(lua_State *L)
508{ 508{
509 struct Smain *s = (struct Smain *)lua_touserdata(L, 1); 509 struct Smain *s = &smain;
510 char **argv = s->argv; 510 char **argv = s->argv;
511 int script; 511 int script;
512 int flags = 0; 512 int flags = 0;
@@ -555,17 +555,16 @@ static int pmain(lua_State *L)
555int main(int argc, char **argv) 555int main(int argc, char **argv)
556{ 556{
557 int status; 557 int status;
558 struct Smain s;
559 lua_State *L = lua_open(); /* create state */ 558 lua_State *L = lua_open(); /* create state */
560 if (L == NULL) { 559 if (L == NULL) {
561 l_message(argv[0], "cannot create state: not enough memory"); 560 l_message(argv[0], "cannot create state: not enough memory");
562 return EXIT_FAILURE; 561 return EXIT_FAILURE;
563 } 562 }
564 s.argc = argc; 563 smain.argc = argc;
565 s.argv = argv; 564 smain.argv = argv;
566 status = lua_cpcall(L, pmain, &s); 565 status = lua_cpcall(L, pmain, NULL);
567 report(L, status); 566 report(L, status);
568 lua_close(L); 567 lua_close(L);
569 return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; 568 return (status || smain.status) ? EXIT_FAILURE : EXIT_SUCCESS;
570} 569}
571 570
diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc
index 6c8302a0..62a5e139 100644
--- a/src/vm_x86.dasc
+++ b/src/vm_x86.dasc
@@ -5659,7 +5659,11 @@ static void emit_asm_debug(BuildCtx *ctx)
5659 ".LEFDE1:\n\n", (int)ctx->codesz - fcofs); 5659 ".LEFDE1:\n\n", (int)ctx->codesz - fcofs);
5660#endif 5660#endif
5661#if (defined(__sun__) && defined(__svr4__)) 5661#if (defined(__sun__) && defined(__svr4__))
5662#if LJ_64
5663 fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@unwind\n");
5664#else
5662 fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n"); 5665 fprintf(ctx->fp, "\t.section .eh_frame,\"aw\",@progbits\n");
5666#endif
5663#else 5667#else
5664 fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n"); 5668 fprintf(ctx->fp, "\t.section .eh_frame,\"a\",@progbits\n");
5665#endif 5669#endif