Skip to content
Snippets Groups Projects
Commit 7e5d26f4 authored by Philippe Canal's avatar Philippe Canal
Browse files

Remove unnecessary overallocation in Azog::reserveAllocationSpace

Thanks to Roman mentioning: "My reading of the code that computes size and calls reserveAllocationSpace has already factored in the worst case scenarios due to alignment."
parent a9650dd4
No related branches found
No related tags found
No related merge requests found
......@@ -70,7 +70,7 @@ class Azog: public RTDyldMemoryManager {
uintptr_t Size, uint32_t Align,
bool code, bool isReadOnly) {
uintptr_t RequiredSize = 2*Size; // Space for internal alignment.
uintptr_t RequiredSize = Size;
if (code)
m_Start = exeMM->allocateCodeSection(RequiredSize, Align,
0 /* SectionID */,
......@@ -95,11 +95,17 @@ class Azog: public RTDyldMemoryManager {
uintptr_t RequiredSize = Alignment * ((Size + Alignment - 1)/Alignment + 1);
if ( (m_Current + RequiredSize) > m_End ) {
cling::errs() << "Error in block allocation by Azog. "
<< "Not enough memory was reserved for the current module. "
<< Size << " (round to " << RequiredSize << " ) was need but\n"
<< "We only have " << (m_End - m_Current) << ".\n";
return nullptr;
// This must be the last block.
if ((m_Current + Size) <= m_End) {
RequiredSize = Size;
} else {
cling::errs() << "Error in block allocation by Azog. "
<< "Not enough memory was reserved for the current module. "
<< Size << " (with alignment: " << RequiredSize
<< " ) is needed but\n"
<< "we only have " << (m_End - m_Current) << ".\n";
return nullptr;
}
}
uintptr_t Addr = (uintptr_t)m_Current;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment