Skip to content

Commit 33146e4

Browse files
committed
do not record Return Kind in GCInfo
1 parent 840ec5f commit 33146e4

File tree

7 files changed

+16
-31
lines changed

7 files changed

+16
-31
lines changed

src/coreclr/gcinfo/gcinfoencoder.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,6 @@ GcInfoEncoder::GcInfoEncoder(
494494
// If the compiler doesn't set the GCInfo, report RT_Unset.
495495
// This is used for compatibility with JITs that aren't updated to use the new API.
496496
m_ReturnKind = RT_Unset;
497-
#else
498-
m_ReturnKind = RT_Illegal;
499497
#endif // TARGET_X86
500498
m_CodeLength = 0;
501499
#ifdef FIXED_STACK_PARAMETER_SCRATCH_AREA
@@ -776,12 +774,14 @@ void GcInfoEncoder::SetReversePInvokeFrameSlot(INT32 spOffset)
776774
m_ReversePInvokeFrameSlot = spOffset;
777775
}
778776

777+
#ifndef TARGET_X86
779778
void GcInfoEncoder::SetReturnKind(ReturnKind returnKind)
780779
{
781780
_ASSERTE(IsValidReturnKind(returnKind));
782781

783782
m_ReturnKind = returnKind;
784783
}
784+
#endif
785785

786786
struct GcSlotDescAndId
787787
{
@@ -1045,16 +1045,15 @@ void GcInfoEncoder::Build()
10451045
BOOL slimHeader = (!m_IsVarArg && !hasGSCookie && (m_PSPSymStackSlot == NO_PSP_SYM) &&
10461046
!hasContextParamType && (m_InterruptibleRanges.Count() == 0) && !hasReversePInvokeFrame &&
10471047
((m_StackBaseRegister == NO_STACK_BASE_REGISTER) || (NORMALIZE_STACK_BASE_REGISTER(m_StackBaseRegister) == 0))) &&
1048-
(m_SizeOfEditAndContinuePreservedArea == NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA) &&
10491048
#ifdef TARGET_AMD64
10501049
!m_WantsReportOnlyLeaf &&
10511050
#elif defined(TARGET_ARM) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
10521051
!m_HasTailCalls &&
10531052
#endif // TARGET_AMD64
1054-
!IsStructReturnKind(m_ReturnKind);
1053+
(m_SizeOfEditAndContinuePreservedArea == NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA);
10551054

10561055
// All new code is generated for the latest GCINFO_VERSION.
1057-
// So, always encode RetunrKind and encode ReversePInvokeFrameSlot where applicable.
1056+
// So, always encode ReversePInvokeFrameSlot where applicable.
10581057
if (slimHeader)
10591058
{
10601059
// Slim encoding means nothing special, partially interruptible, maybe a default frame register
@@ -1065,8 +1064,6 @@ void GcInfoEncoder::Build()
10651064
assert(m_StackBaseRegister == 8 || 2 == m_StackBaseRegister);
10661065
#endif
10671066
GCINFO_WRITE(m_Info1, (m_StackBaseRegister == NO_STACK_BASE_REGISTER) ? 0 : 1, 1, FlagsSize);
1068-
1069-
GCINFO_WRITE(m_Info1, m_ReturnKind, SIZE_OF_RETURN_KIND_IN_SLIM_HEADER, RetKindSize);
10701067
}
10711068
else
10721069
{
@@ -1089,8 +1086,6 @@ void GcInfoEncoder::Build()
10891086
#endif // TARGET_AMD64
10901087
GCINFO_WRITE(m_Info1, ((m_SizeOfEditAndContinuePreservedArea != NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA) ? 1 : 0), 1, FlagsSize);
10911088
GCINFO_WRITE(m_Info1, (hasReversePInvokeFrame ? 1 : 0), 1, FlagsSize);
1092-
1093-
GCINFO_WRITE(m_Info1, m_ReturnKind, SIZE_OF_RETURN_KIND_IN_FAT_HEADER, RetKindSize);
10941089
}
10951090

10961091
_ASSERTE( m_CodeLength > 0 );

src/coreclr/inc/gcinfoencoder.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,13 @@ class GcInfoEncoder
409409
GcSlotState slotState
410410
);
411411

412-
412+
#ifndef TARGET_X86
413413
//------------------------------------------------------------------------
414414
// ReturnKind
415415
//------------------------------------------------------------------------
416416

417417
void SetReturnKind(ReturnKind returnKind);
418+
#endif
418419

419420
//------------------------------------------------------------------------
420421
// Miscellaneous method information
@@ -509,7 +510,9 @@ class GcInfoEncoder
509510
INT32 m_PSPSymStackSlot;
510511
INT32 m_GenericsInstContextStackSlot;
511512
GENERIC_CONTEXTPARAM_TYPE m_contextParamType;
513+
#ifndef TARGET_X86
512514
ReturnKind m_ReturnKind;
515+
#endif
513516
UINT32 m_CodeLength;
514517
UINT32 m_StackBaseRegister;
515518
UINT32 m_SizeOfEditAndContinuePreservedArea;

src/coreclr/inc/gcinfotypes.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,6 @@ void FASTCALL decodeCallPattern(int pattern,
637637
#define SECURITY_OBJECT_STACK_SLOT_ENCBASE 6
638638
#define GS_COOKIE_STACK_SLOT_ENCBASE 6
639639
#define CODE_LENGTH_ENCBASE 8
640-
#define SIZE_OF_RETURN_KIND_IN_SLIM_HEADER 2
641-
#define SIZE_OF_RETURN_KIND_IN_FAT_HEADER 4
642640
#define STACK_BASE_REGISTER_ENCBASE 3
643641
#define SIZE_OF_STACK_AREA_ENCBASE 3
644642
#define SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA_ENCBASE 4
@@ -695,8 +693,6 @@ void FASTCALL decodeCallPattern(int pattern,
695693
#define SECURITY_OBJECT_STACK_SLOT_ENCBASE 5
696694
#define GS_COOKIE_STACK_SLOT_ENCBASE 5
697695
#define CODE_LENGTH_ENCBASE 7
698-
#define SIZE_OF_RETURN_KIND_IN_SLIM_HEADER 2
699-
#define SIZE_OF_RETURN_KIND_IN_FAT_HEADER 2
700696
#define STACK_BASE_REGISTER_ENCBASE 1
701697
#define SIZE_OF_STACK_AREA_ENCBASE 3
702698
#define SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA_ENCBASE 3
@@ -750,8 +746,6 @@ void FASTCALL decodeCallPattern(int pattern,
750746
#define SECURITY_OBJECT_STACK_SLOT_ENCBASE 6
751747
#define GS_COOKIE_STACK_SLOT_ENCBASE 6
752748
#define CODE_LENGTH_ENCBASE 8
753-
#define SIZE_OF_RETURN_KIND_IN_SLIM_HEADER 2
754-
#define SIZE_OF_RETURN_KIND_IN_FAT_HEADER 4
755749
#define STACK_BASE_REGISTER_ENCBASE 2 // FP encoded as 0, SP as 2.
756750
#define SIZE_OF_STACK_AREA_ENCBASE 3
757751
#define SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA_ENCBASE 4
@@ -805,8 +799,6 @@ void FASTCALL decodeCallPattern(int pattern,
805799
#define SECURITY_OBJECT_STACK_SLOT_ENCBASE 6
806800
#define GS_COOKIE_STACK_SLOT_ENCBASE 6
807801
#define CODE_LENGTH_ENCBASE 8
808-
#define SIZE_OF_RETURN_KIND_IN_SLIM_HEADER 2
809-
#define SIZE_OF_RETURN_KIND_IN_FAT_HEADER 4
810802
// FP/SP encoded as 0 or 1.
811803
#define STACK_BASE_REGISTER_ENCBASE 2
812804
#define SIZE_OF_STACK_AREA_ENCBASE 3
@@ -860,8 +852,6 @@ void FASTCALL decodeCallPattern(int pattern,
860852
#define SECURITY_OBJECT_STACK_SLOT_ENCBASE 6
861853
#define GS_COOKIE_STACK_SLOT_ENCBASE 6
862854
#define CODE_LENGTH_ENCBASE 8
863-
#define SIZE_OF_RETURN_KIND_IN_SLIM_HEADER 2
864-
#define SIZE_OF_RETURN_KIND_IN_FAT_HEADER 4
865855
#define STACK_BASE_REGISTER_ENCBASE 2
866856
// FP encoded as 0, SP as 1
867857
#define SIZE_OF_STACK_AREA_ENCBASE 3
@@ -924,8 +914,6 @@ PORTABILITY_WARNING("Please specialize these definitions for your platform!")
924914
#define SECURITY_OBJECT_STACK_SLOT_ENCBASE 6
925915
#define GS_COOKIE_STACK_SLOT_ENCBASE 6
926916
#define CODE_LENGTH_ENCBASE 6
927-
#define SIZE_OF_RETURN_KIND_IN_SLIM_HEADER 2
928-
#define SIZE_OF_RETURN_KIND_IN_FAT_HEADER 2
929917
#define STACK_BASE_REGISTER_ENCBASE 3
930918
#define SIZE_OF_STACK_AREA_ENCBASE 6
931919
#define SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA_ENCBASE 3

src/coreclr/inc/readytorun.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
// uses GCInfo v3, which makes safe points in partially interruptible code interruptible.
3939
// R2R Version 10.0 adds support for the statics being allocated on a per type basis instead of on a per module basis, disable support for LogMethodEnter helper
4040
// R2R Version 10.1 adds Unbox_TypeTest helper
41-
// R2R Version 11 uses GCInfo v4, which encodes safe points without -1 offset
41+
// R2R Version 11 uses GCInfo v4, which encodes safe points without -1 offset and does not track return kinds in GCInfo
4242

4343
struct READYTORUN_CORE_HEADER
4444
{

src/coreclr/jit/gcencode.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3709,6 +3709,7 @@ class GcInfoEncoderWithLogging
37093709
}
37103710
}
37113711

3712+
#ifndef TARGET_X86
37123713
void SetReturnKind(ReturnKind returnKind)
37133714
{
37143715
m_gcInfoEncoder->SetReturnKind(returnKind);
@@ -3717,6 +3718,7 @@ class GcInfoEncoderWithLogging
37173718
printf("Set ReturnKind to %s.\n", ReturnKindToString(returnKind));
37183719
}
37193720
}
3721+
#endif
37203722

37213723
void SetStackBaseRegister(UINT32 registerNumber)
37223724
{
@@ -3832,7 +3834,9 @@ void GCInfo::gcInfoBlockHdrSave(GcInfoEncoder* gcInfoEncoder, unsigned methodSiz
38323834

38333835
gcInfoEncoderWithLog->SetCodeLength(methodSize);
38343836

3837+
#ifndef TARGET_X86
38353838
gcInfoEncoderWithLog->SetReturnKind(getReturnKind());
3839+
#endif
38363840

38373841
if (compiler->isFramePointerUsed())
38383842
{

src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/Amd64/GcInfo.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public SafePointOffset(int index, uint value)
4747
}
4848

4949
private const int MIN_GCINFO_VERSION_WITH_RETURN_KIND = 2;
50+
private const int MAX_GCINFO_VERSION_WITH_RETURN_KIND = 3;
5051
private const int MIN_GCINFO_VERSION_WITH_REV_PINVOKE_FRAME = 2;
5152
private const int MIN_GCINFO_VERSION_WITH_NORMALIZED_CODE_OFFSETS = 3;
5253

@@ -107,7 +108,7 @@ public GcInfo(byte[] image, int offset, Machine machine, ushort majorVersion, us
107108

108109
ParseHeaderFlags(image, ref bitOffset);
109110

110-
if (Version >= MIN_GCINFO_VERSION_WITH_RETURN_KIND) // IsReturnKindAvailable
111+
if (Version >= MIN_GCINFO_VERSION_WITH_RETURN_KIND && Version <= MAX_GCINFO_VERSION_WITH_RETURN_KIND) // IsReturnKindAvailable
111112
{
112113
int returnKindBits = (_slimHeader) ? _gcInfoTypes.SIZE_OF_RETURN_KIND_SLIM : _gcInfoTypes.SIZE_OF_RETURN_KIND_FAT;
113114
ReturnKind = (ReturnKinds)NativeReader.ReadBits(image, returnKindBits, ref bitOffset);
@@ -405,7 +406,7 @@ private int ReadyToRunVersionToGcInfoVersion(int readyToRunMajorVersion, int rea
405406

406407
// R2R 11.0+ uses GCInfo v4
407408
if (readyToRunMajorVersion < 11)
408-
return 3;
409+
return 3;
409410

410411
return 4;
411412
}

src/coreclr/vm/gcinfodecoder.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ bool GcInfoDecoder::PredecodeFatHeader(int remainingFlags)
9191
int numFlagBits = (m_Version == 1) ? GC_INFO_FLAGS_BIT_SIZE_VERSION_1 : GC_INFO_FLAGS_BIT_SIZE;
9292
m_headerFlags = (GcInfoHeaderFlags)m_Reader.Read(numFlagBits);
9393

94-
// skip over the unused return kind.
95-
m_Reader.Read(SIZE_OF_RETURN_KIND_IN_FAT_HEADER);
96-
9794
remainingFlags &= ~DECODE_VARARG;
9895
#if defined(TARGET_ARM) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
9996
remainingFlags &= ~DECODE_HAS_TAILCALLS;
@@ -299,9 +296,6 @@ GcInfoDecoder::GcInfoDecoder(
299296
m_StackBaseRegister = NO_STACK_BASE_REGISTER;
300297
}
301298

302-
// skip over the unused return kind.
303-
m_Reader.Read(SIZE_OF_RETURN_KIND_IN_SLIM_HEADER);
304-
305299
remainingFlags &= ~DECODE_VARARG;
306300
#if defined(TARGET_ARM) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
307301
remainingFlags &= ~DECODE_HAS_TAILCALLS;

0 commit comments

Comments
 (0)