summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/JIT/Emitter.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
commit6ac7fe7dc009ab9b338c15014500cd4973074035 (patch)
treecedc930027477a81e04e42a5bc30acc1c01e10a2 /llvm/lib/ExecutionEngine/JIT/Emitter.cpp
parent239ff501acd6e0e03756415c5ca281cdea2b3d80 (diff)
downloadbcm5719-llvm-6ac7fe7dc009ab9b338c15014500cd4973074035.tar.gz
bcm5719-llvm-6ac7fe7dc009ab9b338c15014500cd4973074035.zip
* 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. llvm-svn: 6527
Diffstat (limited to 'llvm/lib/ExecutionEngine/JIT/Emitter.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/JIT/Emitter.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/Emitter.cpp b/llvm/lib/ExecutionEngine/JIT/Emitter.cpp
index 4138e75148f..91fee458ed1 100644
--- a/llvm/lib/ExecutionEngine/JIT/Emitter.cpp
+++ b/llvm/lib/ExecutionEngine/JIT/Emitter.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;
}
OpenPOWER on IntegriCloud