[llvm-commits] CVS: llvm/lib/System/Unix/Memory.inc
Andrew Lenharth
alenhar2 at cs.uiuc.edu
Fri Jul 29 16:39:37 PDT 2005
Changes in directory llvm/lib/System/Unix:
Memory.inc updated: 1.3 -> 1.4
---
Log message:
support near allocations for the JIT
---
Diffs of the changes: (+9 -3)
Memory.inc | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
Index: llvm/lib/System/Unix/Memory.inc
diff -u llvm/lib/System/Unix/Memory.inc:1.3 llvm/lib/System/Unix/Memory.inc:1.4
--- llvm/lib/System/Unix/Memory.inc:1.3 Thu May 5 17:33:06 2005
+++ llvm/lib/System/Unix/Memory.inc Fri Jul 29 18:39:25 2005
@@ -25,7 +25,7 @@
/// to emit code to the memory then jump to it. Getting this type of memory
/// is very OS specific.
///
-MemoryBlock Memory::AllocateRWX(unsigned NumBytes) {
+MemoryBlock Memory::AllocateRWX(unsigned NumBytes, const MemoryBlock* NearBlock) {
if (NumBytes == 0) return MemoryBlock();
long pageSize = Process::GetPageSize();
@@ -47,10 +47,16 @@
MAP_ANON
#endif
;
- void *pa = ::mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
+
+ void* start = NearBlock ? (unsigned char*) NearBlock->base() + NearBlock->size() : 0;
+
+ void *pa = ::mmap(start, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
flags, fd, 0);
if (pa == MAP_FAILED) {
- ThrowErrno("Can't allocate RWX Memory");
+ if (NearBlock) //Try again without a near hint
+ return AllocateRWX(NumBytes, 0);
+ else
+ ThrowErrno("Can't allocate RWX Memory");
}
MemoryBlock result;
result.Address = pa;
More information about the llvm-commits
mailing list