Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/fntableaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ struct FakeHeapList
size_t maxCodeHeapSize;
size_t reserveForJumpStubs;
DWORD_PTR pLoaderAllocator;
#if defined(TARGET_64BIT) && defined(TARGET_WINDOWS)
#if defined(TARGET_64BIT)
DWORD_PTR CLRPersonalityRoutine;
#endif

DWORD_PTR GetModuleBase()
{
#if defined(TARGET_64BIT) && defined(TARGET_WINDOWS)
#if defined(TARGET_64BIT)
return CLRPersonalityRoutine;
#else
return mapBase;
Expand Down
9 changes: 5 additions & 4 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,7 @@ HeapList* LoaderCodeHeap::CreateCodeHeap(CodeHeapRequestInfo *pInfo, LoaderHeap
bool fAllocatedFromEmergencyJumpStubReserve = false;

size_t allocationSize = pCodeHeap->m_LoaderHeap.AllocMem_TotalSize(initialRequestSize);
#if defined(TARGET_64BIT) && defined(TARGET_WINDOWS)
#if defined(TARGET_64BIT)
if (!pInfo->IsInterpreted())
{
allocationSize += pCodeHeap->m_LoaderHeap.AllocMem_TotalSize(JUMP_ALLOCATE_SIZE);
Expand Down Expand Up @@ -2490,14 +2490,15 @@ HeapList* LoaderCodeHeap::CreateCodeHeap(CodeHeapRequestInfo *pInfo, LoaderHeap
// this first allocation is critical as it sets up correctly the loader heap info
HeapList *pHp = new HeapList;

#if defined(TARGET_64BIT) && defined(TARGET_WINDOWS)
#if defined(TARGET_64BIT)
if (pInfo->IsInterpreted())
{
pHp->CLRPersonalityRoutine = NULL;
pCodeHeap->m_LoaderHeap.ReservePages(1);
}
else
{
// Set the personality routine. This is needed even outside Windows because IsIPInEpilog relies on it being set.
pHp->CLRPersonalityRoutine = (BYTE *)pCodeHeap->m_LoaderHeap.AllocMemForCode_NoThrow(0, JUMP_ALLOCATE_SIZE, sizeof(void*), 0);
}
#else
Expand Down Expand Up @@ -2531,7 +2532,7 @@ HeapList* LoaderCodeHeap::CreateCodeHeap(CodeHeapRequestInfo *pInfo, LoaderHeap
pHp->mapBase = ROUND_DOWN_TO_PAGE(pHp->startAddress); // round down to next lower page align
size_t nibbleMapSize = HEAP2MAPSIZE(ROUND_UP_TO_PAGE(heapSize));
pHp->pHdrMap = (DWORD*)(void*)pJitMetaHeap->AllocMem(S_SIZE_T(nibbleMapSize));
#if defined(TARGET_64BIT) && defined(TARGET_WINDOWS)
#if defined(TARGET_64BIT)
if (pHp->CLRPersonalityRoutine != NULL)
{
ExecutableWriterHolder<BYTE> personalityRoutineWriterHolder(pHp->CLRPersonalityRoutine, 12);
Expand Down Expand Up @@ -2660,7 +2661,7 @@ HeapList* EECodeGenManager::NewCodeHeap(CodeHeapRequestInfo *pInfo, DomainCodeHe

size_t reserveSize = initialRequestSize;

#if defined(TARGET_64BIT) && defined(TARGET_WINDOWS)
#if defined(TARGET_64BIT)
if (!pInfo->IsInterpreted())
{
reserveSize += JUMP_ALLOCATE_SIZE;
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/vm/codeman.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,13 +534,13 @@ struct HeapList
size_t reserveForJumpStubs; // Amount of memory reserved for jump stubs in this block

PTR_LoaderAllocator pLoaderAllocator; // LoaderAllocator of HeapList
#if defined(TARGET_64BIT) && defined(TARGET_WINDOWS)
#if defined(TARGET_64BIT)
BYTE* CLRPersonalityRoutine; // jump thunk to personality routine, NULL if there is no personality routine (e.g. interpreter code heap)
#endif

TADDR GetModuleBase()
{
#if defined(TARGET_64BIT) && defined(TARGET_WINDOWS)
#if defined(TARGET_64BIT)
return (CLRPersonalityRoutine != NULL) ? (TADDR)CLRPersonalityRoutine : (TADDR)mapBase;
#else
return (TADDR)mapBase;
Expand Down Expand Up @@ -2281,7 +2281,7 @@ class ExecutionManager
BOOL Acquired();
};

#if defined(TARGET_64BIT) && defined(TARGET_WINDOWS)
#if defined(TARGET_64BIT)
static ULONG GetCLRPersonalityRoutineValue()
{
LIMITED_METHOD_CONTRACT;
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/vm/dynamicmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ HeapList* HostCodeHeap::InitializeHeapList(CodeHeapRequestInfo *pInfo)
// Add TrackAllocation, HeapList and very conservative padding to make sure we have enough for the allocation
ReserveBlockSize += sizeof(TrackAllocation) + HOST_CODEHEAP_SIZE_ALIGN + 0x100;

#if defined(TARGET_64BIT) && defined(TARGET_WINDOWS)
#if defined(TARGET_64BIT)
ReserveBlockSize += JUMP_ALLOCATE_SIZE;
#endif

Expand Down Expand Up @@ -435,7 +435,7 @@ HeapList* HostCodeHeap::InitializeHeapList(CodeHeapRequestInfo *pInfo)

TrackAllocation *pTracker = NULL;

#if defined(TARGET_64BIT) && defined(TARGET_WINDOWS)
#if defined(TARGET_64BIT)
#ifdef FEATURE_INTERPRETER
if (pInfo->IsInterpreted())
{
Expand Down Expand Up @@ -474,7 +474,7 @@ HeapList* HostCodeHeap::InitializeHeapList(CodeHeapRequestInfo *pInfo)
pHp->maxCodeHeapSize = m_TotalBytesAvailable - (pTracker ? pTracker->size : 0);
pHp->reserveForJumpStubs = 0;

#if defined(TARGET_64BIT) && defined(TARGET_WINDOWS)
#if defined(TARGET_64BIT)
if (pHp->CLRPersonalityRoutine != NULL)
{
ExecutableWriterHolder<BYTE> personalityRoutineWriterHolder(pHp->CLRPersonalityRoutine, 12);
Expand Down
19 changes: 11 additions & 8 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11385,7 +11385,7 @@ void CEECodeGenInfo::CompressDebugInfo(PCODE nativeEntry)

void reservePersonalityRoutineSpace(uint32_t &unwindSize)
{
#if defined(TARGET_AMD64)
#ifdef TARGET_AMD64
// Note that the count of unwind codes (2 bytes each) is stored as a UBYTE
// So the largest size could be 510 bytes, plus the header and language
// specific stuff. This can't overflow.
Expand All @@ -11397,10 +11397,10 @@ void reservePersonalityRoutineSpace(uint32_t &unwindSize)
_ASSERTE(IS_ALIGNED(unwindSize, sizeof(ULONG)));
#endif // TARGET_AMD64

#if !defined(TARGET_X86) && defined(TARGET_WINDOWS)
#ifndef TARGET_X86
// Add space for personality routine
unwindSize += sizeof(ULONG);
#endif // !TARGET_X86 && TARGET_WINDOWS
#endif // !TARGET_X86
}

// Reserve memory for the method/funclet's unwind information.
Expand Down Expand Up @@ -11590,19 +11590,22 @@ void CEEJitInfo::allocUnwindInfo (

memcpy(pUnwindInfoRW, pUnwindBlock, unwindSize);

#if !defined(TARGET_X86) && defined(TARGET_WINDOWS)
#ifdef TARGET_AMD64
#if defined(TARGET_AMD64)
pUnwindInfoRW->Flags = UNW_FLAG_EHANDLER | UNW_FLAG_UHANDLER;

ULONG * pPersonalityRoutineRW = (ULONG*)ALIGN_UP(&(pUnwindInfoRW->UnwindCode[pUnwindInfoRW->CountOfUnwindCodes]), sizeof(ULONG));
*pPersonalityRoutineRW = ExecutionManager::GetCLRPersonalityRoutineValue();
#else // TARGET_AMD64
#elif defined(TARGET_64BIT)
*(LONG *)pUnwindInfoRW |= (1 << 20); // X bit

ULONG * pPersonalityRoutineRW = (ULONG*)((BYTE *)pUnwindInfoRW + ALIGN_UP(unwindSize, sizeof(ULONG)));
*pPersonalityRoutineRW = ExecutionManager::GetCLRPersonalityRoutineValue();
#endif // TARGET_AMD64
#endif // !TARGET_X86 && TARGET_WINDOWS
#elif defined(TARGET_ARM)
*(LONG *)pUnwindInfoRW |= (1 << 20); // X bit

ULONG * pPersonalityRoutineRW = (ULONG*)((BYTE *)pUnwindInfoRW + ALIGN_UP(unwindSize, sizeof(ULONG)));
*pPersonalityRoutineRW = (TADDR)ProcessCLRException - baseAddress;
#endif

EE_TO_JIT_TRANSITION();
#else // FEATURE_EH_FUNCLETS
Expand Down
Loading