aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2009-12-28 23:33:10 +0100
committerMike Pall <mike>2009-12-28 23:33:10 +0100
commit61abf342a3242d8f667eed2fd718dd1f170da7c0 (patch)
tree2a144ad34ea686893e95ff859b1ce32960ee5e21 /src
parent9c8f42573f138eee095eea9f6100dbb75800b2f6 (diff)
downloadluajit-61abf342a3242d8f667eed2fd718dd1f170da7c0.tar.gz
luajit-61abf342a3242d8f667eed2fd718dd1f170da7c0.tar.bz2
luajit-61abf342a3242d8f667eed2fd718dd1f170da7c0.zip
Linux/x64 mremap() does not obey MAP_32BIT, so make it non-moving.
Diffstat (limited to 'src')
-rw-r--r--src/lj_alloc.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/lj_alloc.c b/src/lj_alloc.c
index 6d8b4ccb..e4a9d356 100644
--- a/src/lj_alloc.c
+++ b/src/lj_alloc.c
@@ -137,6 +137,13 @@ static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size)
137#ifdef __linux__ 137#ifdef __linux__
138/* Need to define _GNU_SOURCE to get the mremap prototype. */ 138/* Need to define _GNU_SOURCE to get the mremap prototype. */
139#define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv)) 139#define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv))
140#define CALL_MREMAP_NOMOVE 0
141#define CALL_MREMAP_MAYMOVE 1
142#if LJ_64
143#define CALL_MREMAP_MV CALL_MREMAP_NOMOVE
144#else
145#define CALL_MREMAP_MV CALL_MREMAP_MAYMOVE
146#endif
140#endif 147#endif
141 148
142#endif 149#endif
@@ -612,7 +619,7 @@ static mchunkptr direct_resize(mchunkptr oldp, size_t nb)
612 size_t oldmmsize = oldsize + offset + DIRECT_FOOT_PAD; 619 size_t oldmmsize = oldsize + offset + DIRECT_FOOT_PAD;
613 size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); 620 size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK);
614 char *cp = (char *)CALL_MREMAP((char *)oldp - offset, 621 char *cp = (char *)CALL_MREMAP((char *)oldp - offset,
615 oldmmsize, newmmsize, 1); 622 oldmmsize, newmmsize, CALL_MREMAP_MV);
616 if (cp != CMFAIL) { 623 if (cp != CMFAIL) {
617 mchunkptr newp = (mchunkptr)(cp + offset); 624 mchunkptr newp = (mchunkptr)(cp + offset);
618 size_t psize = newmmsize - offset - DIRECT_FOOT_PAD; 625 size_t psize = newmmsize - offset - DIRECT_FOOT_PAD;
@@ -857,7 +864,7 @@ static int alloc_trim(mstate m, size_t pad)
857 !has_segment_link(m, sp)) { /* can't shrink if pinned */ 864 !has_segment_link(m, sp)) { /* can't shrink if pinned */
858 size_t newsize = sp->size - extra; 865 size_t newsize = sp->size - extra;
859 /* Prefer mremap, fall back to munmap */ 866 /* Prefer mremap, fall back to munmap */
860 if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || 867 if ((CALL_MREMAP(sp->base, sp->size, newsize, CALL_MREMAP_NOMOVE) != MFAIL) ||
861 (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { 868 (CALL_MUNMAP(sp->base + newsize, extra) == 0)) {
862 released = extra; 869 released = extra;
863 } 870 }