[PATCH] D61599: MemoryBlock objects now expose their allocated size in addition to the requested size.

Machiel van Hooren via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 6 07:25:32 PDT 2019


mvhooren created this revision.
mvhooren added reviewers: chandlerc, lhames, andrewng, Bigcheese.
Herald added subscribers: llvm-commits, kristina, dexonsmith.
Herald added a project: LLVM.

Added a member 'AllocatedSize' to MemoryBlock  that holds the size that was actually allocated for this block in addition to the 'Size' member which holds the size requested through allocateMappedMemory.

Recently, MemoryBlock was changed so that its 'Size' member holds the size that was requested with allocateMappedMemory instead of the size that was actually allocated by allocateMappedMemory. The allocated size is usually  (much) larger than the requested size.
This caused a large waste of memory, as in 100s of MBs in my use case, because on Windows allocateMappedMemory returns memory with a granularity of 64kb (16 pages) and SectionMemoryManager previously assumed that the blocks were multiples of the page size (4kb) as it would be on Unix/Linux systems, in the worst case causing 60kb of wasted memory for each allocation on Windows. SectionMemoryManager was updated to now correctly use the allocated size.

Also see bug: https://bugs.llvm.org/show_bug.cgi?id=41690


Repository:
  rL LLVM

https://reviews.llvm.org/D61599

Files:
  include/llvm/Support/Memory.h
  lib/ExecutionEngine/Orc/OrcABISupport.cpp
  lib/ExecutionEngine/SectionMemoryManager.cpp
  lib/Support/Memory.cpp
  lib/Support/Unix/Memory.inc
  lib/Support/Windows/Memory.inc
  tools/llvm-rtdyld/llvm-rtdyld.cpp
  unittests/Support/MemoryTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61599.198268.patch
Type: text/x-patch
Size: 23758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190506/7ad8d2b3/attachment.bin>


More information about the llvm-commits mailing list