-
Notifications
You must be signed in to change notification settings - Fork 5.3k
VM: Better strategy for TryReserveInitialMemory on arm64 (jump stubs) #70707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
704b749
335e3cc
d252971
f9fb6ac
5897d6d
6d0cdf1
1fc5970
909cf7c
db57294
a5c76a3
c9e36ed
eab1661
42b0ed6
5ddfd68
168fe20
94146e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ SET_DEFAULT_DEBUG_CHANNEL(VIRTUAL); // some headers have code with asserts, so d | |
| #include <string.h> | ||
| #include <unistd.h> | ||
| #include <limits.h> | ||
| #include <clrconfignocache.h> | ||
|
|
||
| #if HAVE_VM_ALLOCATE | ||
| #include <mach/vm_map.h> | ||
|
|
@@ -2140,7 +2141,17 @@ void ExecutableMemoryAllocator::TryReserveInitialMemory() | |
| int32_t preferredStartAddressIncrement; | ||
| UINT_PTR preferredStartAddress; | ||
| UINT_PTR coreclrLoadAddress; | ||
| const int32_t MemoryProbingIncrement = 128 * 1024 * 1024; | ||
|
|
||
| #if TARGET_XARCH | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const int32_t AddressProbingIncrement = 128 * 1024 * 1024; | ||
| const int32_t AllocSizeProbingDecrement = 128 * 1024 * 1024; | ||
| #else | ||
| // Smaller steps on ARM becuase we try hard finding a spare memory in a 128Mb | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // distance from coreclr so e.g. all calls from corelib to coreclr could use relocs | ||
| const int32_t AddressProbingIncrement = 8 * 1024 * 1024; | ||
| const int32_t AllocSizeProbingDecrement = 64 * 1024 * 1024; | ||
|
||
| #endif | ||
| const int32_t MinAllocSize = 128 * 1024 * 1024; | ||
|
|
||
| // Try to find and reserve an available region of virtual memory that is located | ||
| // within 2GB range (defined by the MaxExecutableMemorySizeNearCoreClr constant) from the | ||
|
|
@@ -2161,12 +2172,18 @@ void ExecutableMemoryAllocator::TryReserveInitialMemory() | |
| { | ||
| // Try to allocate above the location of libcoreclr | ||
| preferredStartAddress = coreclrLoadAddress + CoreClrLibrarySize; | ||
| preferredStartAddressIncrement = MemoryProbingIncrement; | ||
| preferredStartAddressIncrement = AddressProbingIncrement; | ||
| } | ||
| else | ||
| { | ||
| // Try to allocate below the location of libcoreclr | ||
| preferredStartAddress = coreclrLoadAddress - MaxExecutableMemorySizeNearCoreClr; | ||
| #ifndef TARGET_XARCH | ||
| // For arm for the "high addresss" case it only makes sense to try to reserve 128Mb | ||
EgorBo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // and if it doesn't work - we'll reserve a full-sized region in a random location | ||
| sizeOfAllocation = MinAllocSize; | ||
| #endif | ||
|
|
||
| preferredStartAddress = coreclrLoadAddress - sizeOfAllocation; | ||
| preferredStartAddressIncrement = 0; | ||
| } | ||
|
|
||
|
|
@@ -2180,10 +2197,10 @@ void ExecutableMemoryAllocator::TryReserveInitialMemory() | |
| } | ||
|
|
||
| // Try to allocate a smaller region | ||
| sizeOfAllocation -= MemoryProbingIncrement; | ||
| sizeOfAllocation -= AllocSizeProbingDecrement; | ||
| preferredStartAddress += preferredStartAddressIncrement; | ||
|
|
||
| } while (sizeOfAllocation >= MemoryProbingIncrement); | ||
| } while (sizeOfAllocation >= MinAllocSize); | ||
|
|
||
| if (m_startAddress == nullptr) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ifdef is incorrect, we don't define TARGET_XARCH out of JIT. Can you please use
#if defined(TARGET_ARM) || defined(TARGET_ARM64)here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, again I am using JIT's flags in the VM 😞 the incorrect define slightly regressed x64/x86 by decreasing preferable size from 2Gb to 1Gb. Thanks, fixed