Skip to content

Commit

Permalink
[cling] Disable release of code and data sections
Browse files Browse the repository at this point in the history
This is required until CallFunc is informed about unloading, and can
re-generate the wrapper (if the decl is still available).
  • Loading branch information
hahnjo committed Nov 23, 2022
1 parent bcb380f commit 5a11c16
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion interpreter/cling/lib/Interpreter/IncrementalJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,35 @@ using namespace llvm::orc;

namespace {

class ClingMMapper final : public SectionMemoryManager::MemoryMapper {
public:
sys::MemoryBlock
allocateMappedMemory(SectionMemoryManager::AllocationPurpose Purpose,
size_t NumBytes,
const sys::MemoryBlock* const NearBlock,
unsigned Flags, std::error_code& EC) override {
return sys::Memory::allocateMappedMemory(NumBytes, NearBlock, Flags, EC);
}

std::error_code protectMappedMemory(const sys::MemoryBlock& Block,
unsigned Flags) override {
return sys::Memory::protectMappedMemory(Block, Flags);
}

std::error_code releaseMappedMemory(sys::MemoryBlock& M) override {
// Disabled until CallFunc is informed about unloading, and can
// re-generate the wrapper (if the decl is still available). See
// https://github.com/root-project/root/issues/10898
#if 0
return sys::Memory::releaseMappedMemory(M);
#else
return {};
#endif
}
};

ClingMMapper MMapperInstance;

// A memory manager for Cling that reserves memory for code and data sections
// to keep them contiguous for the emission of one module. This is required
// for working exception handling support since one .eh_frame section will
Expand Down Expand Up @@ -88,7 +117,7 @@ namespace {
AllocInfo m_RWData;

public:
ClingMemoryManager() {}
ClingMemoryManager() : Super(&MMapperInstance) {}

uint8_t* allocateCodeSection(uintptr_t Size, unsigned Alignment,
unsigned SectionID,
Expand Down

0 comments on commit 5a11c16

Please sign in to comment.