Now that setExecutable() changed to do all the ground work to make
memory executable on the host, we can remove all (redundant) calls
to invalidate instruction cache here.
As an added bonus, this makes invalidateInstructionCache() dead
code, so it can be removed.
Differential Revision: http://reviews.llvm.org/D13631
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253343
91177308-0d34-0410-b5e6-
96231b3b80d8
bool finalizeMemory(std::string *ErrMsg) override { return false; }
bool finalizeMemory(std::string *ErrMsg) override { return false; }
- // Invalidate instruction cache for sections with execute permissions.
- // Some platforms with separate data cache and instruction cache require
- // explicit cache flush, otherwise JIT code manipulations (like resolved
- // relocations) will get to the data cache but not to the instruction cache.
- virtual void invalidateInstructionCache();
-
void addDummySymbol(const std::string &Name, uint64_t Addr) {
DummyExterns[Name] = Addr;
}
void addDummySymbol(const std::string &Name, uint64_t Addr) {
DummyExterns[Name] = Addr;
}
return (uint8_t*)MB.base();
}
return (uint8_t*)MB.base();
}
-void TrivialMemoryManager::invalidateInstructionCache() {
- for (auto &FM : FunctionMemory)
- sys::Memory::InvalidateInstructionCache(FM.base(), FM.size());
-
- for (auto &DM : DataMemory)
- sys::Memory::InvalidateInstructionCache(DM.base(), DM.size());
-}
-
static const char *ProgramName;
static void Message(const char *Type, const Twine &Msg) {
static const char *ProgramName;
static void Message(const char *Type, const Twine &Msg) {
- // Resolve all the relocations we can.
- Dyld.resolveRelocations();
- // Clear instruction cache before code will be executed.
- MemMgr.invalidateInstructionCache();
-
+ // Resove all the relocations we can.
// FIXME: Error out if there are unresolved relocations.
// FIXME: Error out if there are unresolved relocations.
+ Dyld.resolveRelocations();
// Get the address of the entry point (_main by default).
void *MainAddress = Dyld.getSymbolLocalAddress(EntryPoint);
// Get the address of the entry point (_main by default).
void *MainAddress = Dyld.getSymbolLocalAddress(EntryPoint);
// Invalidate the instruction cache for each loaded function.
for (auto &FM : MemMgr.FunctionMemory) {
// Invalidate the instruction cache for each loaded function.
for (auto &FM : MemMgr.FunctionMemory) {
// Make sure the memory is executable.
// Make sure the memory is executable.
+ // setExecutable will call InvalidateInstructionCache.
- sys::Memory::InvalidateInstructionCache(FM.base(), FM.size());
if (!sys::Memory::setExecutable(FM, &ErrorStr))
return Error("unable to mark function executable: '" + ErrorStr + "'");
}
if (!sys::Memory::setExecutable(FM, &ErrorStr))
return Error("unable to mark function executable: '" + ErrorStr + "'");
}