aboutsummaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/JIT/JIT.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2008-08-07 01:30:15 +0000
committerDale Johannesen <dalej@apple.com>2008-08-07 01:30:15 +0000
commitdd947ea3c5e020c33c58a31939561265b980a3ad (patch)
tree1ed06d324e47916a3ffaecc9f5d8978562c16a56 /lib/ExecutionEngine/JIT/JIT.cpp
parent39fd6e81b1b0de8b820155dc6a0dae226c109de6 (diff)
Rewrite JIT handling of GlobalVariables so they
are allocated in the same buffer as the code, jump tables, etc. The default JIT memory manager does not handle buffer overflow well. I didn't introduce this and I'm not attempting to fix it here, but it is more likely to be hit now since we're putting more stuff in the buffer. This affects one test that I know of so far, MultiSource/Benchmarks/NPB-serial/is. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT/JIT.cpp')
-rw-r--r--lib/ExecutionEngine/JIT/JIT.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp
index 940434c731..d4f190bfc7 100644
--- a/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/lib/ExecutionEngine/JIT/JIT.cpp
@@ -415,30 +415,22 @@ void *JIT::getOrEmitGlobalVariable(const GlobalVariable *GV) {
cerr << "Could not resolve external global address: "
<< GV->getName() << "\n";
abort();
+ addGlobalMapping(GV, Ptr);
}
} else {
- // If the global hasn't been emitted to memory yet, allocate space. We will
- // actually initialize the global after current function has finished
- // compilation.
+ // If the global hasn't been emitted to memory yet, allocate space and
+ // emit it into memory. It goes in the same array as the generated
+ // code, jump tables, etc.
const Type *GlobalType = GV->getType()->getElementType();
size_t S = getTargetData()->getABITypeSize(GlobalType);
size_t A = getTargetData()->getPreferredAlignment(GV);
- if (A <= 8) {
- Ptr = malloc(S);
- } else {
- // Allocate S+A bytes of memory, then use an aligned pointer within that
- // space.
- Ptr = malloc(S+A);
- unsigned MisAligned = ((intptr_t)Ptr & (A-1));
- Ptr = (char*)Ptr + (MisAligned ? (A-MisAligned) : 0);
- }
- jitstate->getPendingGlobals(locked).push_back(GV);
+ Ptr = MCE->allocateSpace(S, A);
+ addGlobalMapping(GV, Ptr);
+ EmitGlobalVariable(GV);
}
- addGlobalMapping(GV, Ptr);
return Ptr;
}
-
/// recompileAndRelinkFunction - This method is used to force a function
/// which has already been compiled, to be compiled again, possibly
/// after it has been modified. Then the entry to the old copy is overwritten