summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix/Memory.inc
diff options
context:
space:
mode:
authorAndrew Lenharth <andrewl@lenharth.org>2005-07-29 23:40:16 +0000
committerAndrew Lenharth <andrewl@lenharth.org>2005-07-29 23:40:16 +0000
commit0940218ccaba85b05825bacd4a1b187c3595be3e (patch)
tree2df0ca9f6e70b7873f925b4454e5a51f958cd986 /llvm/lib/System/Unix/Memory.inc
parent2f9c52e194a4dc0155879c80bff29f6c9c7aa7ed (diff)
downloadbcm5719-llvm-0940218ccaba85b05825bacd4a1b187c3595be3e.tar.gz
bcm5719-llvm-0940218ccaba85b05825bacd4a1b187c3595be3e.zip
support near allocations for the JIT
llvm-svn: 22554
Diffstat (limited to 'llvm/lib/System/Unix/Memory.inc')
-rw-r--r--llvm/lib/System/Unix/Memory.inc12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/System/Unix/Memory.inc b/llvm/lib/System/Unix/Memory.inc
index a89fd22d2e9..4475960e117 100644
--- a/llvm/lib/System/Unix/Memory.inc
+++ b/llvm/lib/System/Unix/Memory.inc
@@ -25,7 +25,7 @@ namespace llvm {
/// 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 @@ MemoryBlock Memory::AllocateRWX(unsigned NumBytes) {
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;
OpenPOWER on IntegriCloud