Change MAPMapPEFile to use ExecutableAllcator instead of mmap to reserve VA
authorSergiy Kuryata <sergeyk@microsoft.com>
Thu, 18 Feb 2016 01:40:30 +0000 (17:40 -0800)
committerSergiy Kuryata <sergeyk@microsoft.com>
Thu, 18 Feb 2016 01:40:30 +0000 (17:40 -0800)
commit2fb620a2fde01087b78761a5092cefb4695e0f58
tree62989691fee497008603ebd8d9b50bbd86e57bd5
parent41e46658249df9a54476c2624b21b4f0496ac1cc
Change MAPMapPEFile to use ExecutableAllcator instead of mmap to reserve VA

This change modifies the MAPMapPEFile in PAL to use ExecutableAllcator
instead of mmap in order to reserve VA for managed executable images. This
allows all NI images to be located near each other and close to the
coreclr library, which also allows the runtime to generate code that is
more efficient (by avoiding usage of jump stubs).

It also fixes an issue (https://github.com/dotnet/cli/issues/652) where
CLI fails with OutOfMemoryException which turned out to be related to
loading NI files. Due to a certain allocation pattern, mmap can place an
NI file at a region of virtual address space that does not have any free
memory around the NI images. As a result, when the runtime needs to
allocate memory for jump stubs for the image it cannot find any available
memory near the image and fails with OutOfMemoryException.

Commit migrated from https://github.com/dotnet/coreclr/commit/b1e9fa4403180ab5298008efb24142ff164c4b57
src/coreclr/src/pal/src/include/pal/virtual.h
src/coreclr/src/pal/src/map/map.cpp
src/coreclr/src/pal/src/map/virtual.cpp