that is located close to the coreclr library. The memory comes from the virtual
address range that is managed by ExecutableMemoryAllocator.
--*/
-void* ReserveMemoryFromExecutableAllocator(SIZE_T allocationSize);
+void* ReserveMemoryFromExecutableAllocator(CorUnix::CPalThread* pthrCurrent, SIZE_T allocationSize);
#endif /* _PAL_VIRTUAL_H_ */
// First try to reserve virtual memory using ExecutableAllcator. This allows all PE images to be
// near each other and close to the coreclr library which also allows the runtime to generate
// more efficient code (by avoiding usage of jump stubs).
- loadedBase = ReserveMemoryFromExecutableAllocator(virtualSize);
+ loadedBase = ReserveMemoryFromExecutableAllocator(pThread, virtualSize);
if (loadedBase == NULL)
{
// MAC64 requires we pass MAP_SHARED (or MAP_PRIVATE) flags - otherwise, the call is failed.
if (allocationType != MEM_COMMIT)
{
// Commit the pages
- void * pRet = MAP_FAILED;
-#ifndef __APPLE__
if (mprotect((void *) StartBoundary, MemSize, PROT_WRITE | PROT_READ) == 0)
- pRet = (void *)StartBoundary;
-#else // __APPLE__
- // Using mprotect above on MacOS is suspect to cause intermittent crashes
- // https://github.com/dotnet/coreclr/issues/5672
- pRet = mmap((void *) StartBoundary, MemSize, PROT_WRITE | PROT_READ,
- MAP_ANON | MAP_FIXED | MAP_PRIVATE, -1, 0);
-#endif // __APPLE__
- if (pRet != MAP_FAILED)
{
#if MMAP_DOESNOT_ALLOW_REMAP
SIZE_T i;
that is located close to the coreclr library. The memory comes from the virtual
address range that is managed by ExecutableMemoryAllocator.
--*/
-void* ReserveMemoryFromExecutableAllocator(SIZE_T allocationSize)
+void* ReserveMemoryFromExecutableAllocator(CPalThread* pThread, SIZE_T allocationSize)
{
- return g_executableMemoryAllocator.AllocateMemory(allocationSize);
+ InternalEnterCriticalSection(pThread, &virtual_critsec);
+ void* mem = g_executableMemoryAllocator.AllocateMemory(allocationSize);
+ InternalLeaveCriticalSection(pThread, &virtual_critsec);
+
+ return mem;
}
/*++