aboutsummaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/JIT/JITEmitter.cpp
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2003-06-02 03:23:16 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2003-06-02 03:23:16 +0000
commit906f5fa5c8bb790201c79a33ea6d906f9f57f827 (patch)
tree2808ec093801a8e0306f3df67e2f9768d338288f /lib/ExecutionEngine/JIT/JITEmitter.cpp
parentcf135cbc77bf8638bdbfeb1160ef42ce1bf02404 (diff)
* Removed SparcEmitter.cpp; rolled into lib/Target/Sparc/SparcV9CodeEmitter.cpp
* No more createX86Emitter() vs. createSparcEmitter() -- there can be only one * As a result, the memory management semantics must be handled according to platform -- the parameters to mmap() are particularly sensitive to the host architecture. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6527 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT/JITEmitter.cpp')
-rw-r--r--lib/ExecutionEngine/JIT/JITEmitter.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp
index 4138e75148..91fee458ed 100644
--- a/lib/ExecutionEngine/JIT/JITEmitter.cpp
+++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp
@@ -55,7 +55,7 @@ namespace {
};
}
-MachineCodeEmitter *VM::createX86Emitter(VM &V) {
+MachineCodeEmitter *VM::createEmitter(VM &V) {
return new Emitter(V);
}
@@ -67,8 +67,25 @@ MachineCodeEmitter *VM::createX86Emitter(VM &V) {
// FIXME: This should be rewritten to support a real memory manager for
// executable memory pages!
static void *getMemory(unsigned NumPages) {
- return mmap(0, 4096*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+#if defined(i386) || defined(__i386__) || defined(__x86__)
+ static const int fd = 0;
+#elif defined(sparc) || defined(__sparc__) || defined(__sparcv9)
+ static const int fd = -1;
+#else
+ // This is an unsupported architecture.
+ static const int fd = 0;
+#endif
+
+ void *pa;
+ if (NumPages == 0) return 0;
+ static const long pageSize = sysconf (_SC_PAGESIZE);
+ pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
+ MAP_PRIVATE|MAP_ANONYMOUS, fd, 0);
+ if (pa == MAP_FAILED) {
+ perror("mmap");
+ abort();
+ }
+ return pa;
}