Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit b37e6fc

Browse files
committed
ARM64: Enable Function Fragment
Fixes https://github.com/dotnet/coreclr/issues/6064 Fixes https://github.com/dotnet/coreclr/issues/6122 Basically this enable function fragment. Unwind data for arm64 can express only 1MB range. For the large function, we should split unwind data for each fragment of function. Other than the first fragment (the host region), each fragment has a phantom prolog starting with "end_c(0xe5)". I confirmed that this implementation aligns with window's unwinder, and tested with COMPlus_JitSplitFunctionSize=32 for a few test cases which split both main and funclets.
1 parent e977438 commit b37e6fc

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

src/jit/unwind.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const unsigned MAX_EPILOG_SIZE_BYTES = 40;
3030
const unsigned MAX_PROLOG_SIZE_BYTES = 100;
3131
const unsigned MAX_EPILOG_SIZE_BYTES = 100;
3232
#define UWC_END 0xE4 // "end" unwind code
33+
#define UWC_END_C 0xE5 // "end_c" unwind code
3334
#define UW_MAX_FRAGMENT_SIZE_BYTES (1U << 20)
3435
#define UW_MAX_CODE_WORDS_COUNT 31
3536
#define UW_MAX_EPILOG_START_INDEX 0x3FFU

src/jit/unwindarm.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,9 +996,11 @@ void UnwindFragmentInfo::AddEpilog()
996996
void UnwindFragmentInfo::CopyPrologCodes(UnwindFragmentInfo* pCopyFrom)
997997
{
998998
ufiPrologCodes.CopyFrom(&pCopyFrom->ufiPrologCodes);
999+
#ifdef _TARGET_ARM64_
1000+
ufiPrologCodes.AddCode(UWC_END_C);
1001+
#endif
9991002
}
10001003

1001-
10021004
// Split the epilog codes that currently exist in 'pSplitFrom'. The ones that represent
10031005
// epilogs that start at or after the location represented by 'emitLoc' are removed
10041006
// from 'pSplitFrom' and moved to this fragment. Note that this fragment should not have

src/vm/codeman.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -858,39 +858,34 @@ BOOL IsFunctionFragment(TADDR baseAddress, PTR_RUNTIME_FUNCTION pFunctionEntry)
858858
// 1. Prolog only: The host record. Epilog Count and E bit are all 0.
859859
// 2. Prolog and some epilogs: The host record with acompannying epilog-only records
860860
// 3. Epilogs only: First unwind code is Phantom prolog (Starting with an end_c, indicating an empty prolog)
861-
// 4. No prologs or epilogs: Epilog Count = 1 and Epilog Start Index points end_c. (as if it's case #2 with empty epilog codes)
861+
// 4. No prologs or epilogs: First unwind code is Phantom prolog (Starting with an end_c, indicating an empty prolog)
862862
//
863863

864864
int EpilogCount = (int)(unwindHeader >> 22) & 0x1F;
865865
int CodeWords = unwindHeader >> 27;
866866
PTR_DWORD pUnwindCodes = (PTR_DWORD)(baseAddress + pFunctionEntry->UnwindData);
867+
// Skip header.
868+
pUnwindCodes++;
869+
870+
// Skip extended header.
867871
if ((CodeWords == 0) && (EpilogCount == 0))
868-
pUnwindCodes++;
869-
BOOL Ebit = (unwindHeader >> 21) & 0x1;
870-
if (Ebit)
871872
{
872-
// EpilogCount is the index of the first unwind code that describes the one and only epilog
873-
// The unwind codes immediatelly follow the unwindHeader
873+
EpilogCount = (*pUnwindCodes) & 0xFFFF;
874874
pUnwindCodes++;
875875
}
876-
else if (EpilogCount != 0)
876+
877+
// Skip epilog scopes.
878+
BOOL Ebit = (unwindHeader >> 21) & 0x1;
879+
if (!Ebit && (EpilogCount != 0))
877880
{
878881
// EpilogCount is the number of exception scopes defined right after the unwindHeader
879-
pUnwindCodes += EpilogCount+1;
882+
pUnwindCodes += EpilogCount;
880883
}
881-
else
882-
{
883-
return FALSE;
884-
}
885-
886-
if ((*pUnwindCodes & 0xFF) == 0xE5) // Phantom prolog
887-
return TRUE;
888-
889884

885+
return ((*pUnwindCodes & 0xFF) == 0xE5);
890886
#else
891887
PORTABILITY_ASSERT("IsFunctionFragnent - NYI on this platform");
892888
#endif
893-
return FALSE;
894889
}
895890

896891
#endif // EXCEPTION_DATA_SUPPORTS_FUNCTION_FRAGMENTS

tests/arm64/Tests.lst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36572,35 +36572,35 @@ RelativePath=JIT\jit64\opt\cse\HugeArray1\HugeArray1.cmd
3657236572
WorkingDir=JIT\jit64\opt\cse\HugeArray1
3657336573
Expected=0
3657436574
MaxAllowedDurationSeconds=600
36575-
Categories=Pri0;JIT;EXPECTED_PASS;LONG_RUNNING;GCSTRESS_FAIL;ISSUE_6064
36575+
Categories=Pri0;JIT;EXPECTED_PASS;LONG_RUNNING
3657636576
HostStyle=0
3657736577
[hugeexpr1.cmd_5297]
3657836578
RelativePath=JIT\jit64\opt\cse\hugeexpr1\hugeexpr1.cmd
3657936579
WorkingDir=JIT\jit64\opt\cse\hugeexpr1
3658036580
Expected=0
3658136581
MaxAllowedDurationSeconds=600
36582-
Categories=Pri0;JIT;EXPECTED_PASS;LONG_RUNNING;GCSTRESS_FAIL;ISSUE_6064
36582+
Categories=Pri0;JIT;EXPECTED_PASS;LONG_RUNNING
3658336583
HostStyle=0
3658436584
[HugeField1.cmd_5298]
3658536585
RelativePath=JIT\jit64\opt\cse\HugeField1\HugeField1.cmd
3658636586
WorkingDir=JIT\jit64\opt\cse\HugeField1
3658736587
Expected=0
3658836588
MaxAllowedDurationSeconds=600
36589-
Categories=Pri0;JIT;EXPECTED_PASS;LONG_RUNNING;GCSTRESS_FAIL;ISSUE_6064
36589+
Categories=Pri0;JIT;EXPECTED_PASS;LONG_RUNNING
3659036590
HostStyle=0
3659136591
[HugeField2.cmd_5299]
3659236592
RelativePath=JIT\jit64\opt\cse\HugeField2\HugeField2.cmd
3659336593
WorkingDir=JIT\jit64\opt\cse\HugeField2
3659436594
Expected=0
3659536595
MaxAllowedDurationSeconds=600
36596-
Categories=Pri0;JIT;EXPECTED_PASS;LONG_RUNNING;GCSTRESS_FAIL;ISSUE_6122
36596+
Categories=Pri0;JIT;EXPECTED_PASS;LONG_RUNNING
3659736597
HostStyle=0
3659836598
[hugeSimpleExpr1.cmd_5300]
3659936599
RelativePath=JIT\jit64\opt\cse\hugeSimpleExpr1\hugeSimpleExpr1.cmd
3660036600
WorkingDir=JIT\jit64\opt\cse\hugeSimpleExpr1
3660136601
Expected=0
3660236602
MaxAllowedDurationSeconds=600
36603-
Categories=Pri0;JIT;EXPECTED_PASS;GCSTRESS_FAIL;ISSUE_6064
36603+
Categories=Pri0;JIT;EXPECTED_PASS
3660436604
HostStyle=0
3660536605
[mixedexpr1_d_loop_try.cmd_5301]
3660636606
RelativePath=JIT\jit64\opt\cse\mixedexpr1_d_loop_try\mixedexpr1_d_loop_try.cmd

0 commit comments

Comments
 (0)