mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-12 22:26:14 +00:00
[JIT] TrivialMemoryManager: Fail if we can't allocate memory.
TrivialMemoryManager currently doesn't check the return type of AllocateRWX -- and returns a 'null' MemoryBlock to its caller. As pointed out by Lang, this exposes some serious issues with the MemoryManager interface. There's, in fact, no way to report back an error to clients rather than aborting in case memory can't be allocated. Eventually the interface will grow to support this, but for now, fail sooner rather than later. Differential Revision: http://reviews.llvm.org/D13627 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250350 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
82dd03ed9d
commit
d88454bff7
@ -181,7 +181,10 @@ uint8_t *TrivialMemoryManager::allocateCodeSection(uintptr_t Size,
|
||||
unsigned Alignment,
|
||||
unsigned SectionID,
|
||||
StringRef SectionName) {
|
||||
sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, nullptr);
|
||||
std::string Err;
|
||||
sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, &Err);
|
||||
if (!MB.base())
|
||||
report_fatal_error("MemoryManager allocation failed: " + Err);
|
||||
FunctionMemory.push_back(MB);
|
||||
return (uint8_t*)MB.base();
|
||||
}
|
||||
@ -191,7 +194,10 @@ uint8_t *TrivialMemoryManager::allocateDataSection(uintptr_t Size,
|
||||
unsigned SectionID,
|
||||
StringRef SectionName,
|
||||
bool IsReadOnly) {
|
||||
sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, nullptr);
|
||||
std::string Err;
|
||||
sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, &Err);
|
||||
if (!MB.base())
|
||||
report_fatal_error("MemoryManager allocation failed: " + Err);
|
||||
DataMemory.push_back(MB);
|
||||
return (uint8_t*)MB.base();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user