From: Swaroop Sridhar Date: Thu, 25 Aug 2016 01:53:42 +0000 (-0700) Subject: GcInfo: Don't use slim header for struct-returns X-Git-Tag: submit/tizen/20210909.063632~11030^2~9561^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=245843fef66eba9502071ca2aba13a04781842e9;p=platform%2Fupstream%2Fdotnet%2Fruntime.git GcInfo: Don't use slim header for struct-returns This checkin has two changes: 1) Add a check to ensure that methods with struct-returns are use the fat header which encodes ReturnKind in 4 bits. 2) Fix a bug in GetReturnKind(). Commit migrated from https://github.com/dotnet/coreclr/commit/a12ba4633d0fea6792fcb73ed363f49e336f3f62 --- diff --git a/src/coreclr/src/gcinfo/gcinfoencoder.cpp b/src/coreclr/src/gcinfo/gcinfoencoder.cpp index 3e587ea..6785222 100644 --- a/src/coreclr/src/gcinfo/gcinfoencoder.cpp +++ b/src/coreclr/src/gcinfo/gcinfoencoder.cpp @@ -1019,7 +1019,8 @@ void GcInfoEncoder::Build() BOOL slimHeader = (!m_IsVarArg && !hasSecurityObject && !hasGSCookie && (m_PSPSymStackSlot == NO_PSP_SYM) && !hasContextParamType && !m_WantsReportOnlyLeaf && (m_InterruptibleRanges.Count() == 0) && !hasReversePInvokeFrame && ((m_StackBaseRegister == NO_STACK_BASE_REGISTER) || (NORMALIZE_STACK_BASE_REGISTER(m_StackBaseRegister) == 0))) && - (m_SizeOfEditAndContinuePreservedArea == NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA); + (m_SizeOfEditAndContinuePreservedArea == NO_SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA) && + !IsStructReturnKind(m_ReturnKind); // All new code is generated for the latest GCINFO_VERSION. // So, always encode RetunrKind and encode ReversePInvokeFrameSlot where applicable. diff --git a/src/coreclr/src/inc/gcinfotypes.h b/src/coreclr/src/inc/gcinfotypes.h index c08dd79..cd7afa4 100644 --- a/src/coreclr/src/inc/gcinfotypes.h +++ b/src/coreclr/src/inc/gcinfotypes.h @@ -289,6 +289,13 @@ inline bool IsValidReturnRegister(size_t regNo) ; } +inline bool IsStructReturnKind(ReturnKind returnKind) +{ + // Two bits encode integer/ref/float return-kinds. + // Encodings needing more than two bits are (non-scalar) struct-returns. + return returnKind > 3; +} + // Helpers for combining/extracting individual ReturnKinds from/to Struct ReturnKinds. // Encoding is two bits per register diff --git a/src/coreclr/src/vm/threadsuspend.cpp b/src/coreclr/src/vm/threadsuspend.cpp index 5785ad7f..cd4203b 100644 --- a/src/coreclr/src/vm/threadsuspend.cpp +++ b/src/coreclr/src/vm/threadsuspend.cpp @@ -7286,7 +7286,7 @@ ReturnKind GetReturnKind(Thread *pThread, EECodeInfo *codeInfo) if (gcInfoToken.IsReturnKindAvailable()) { GcInfoDecoder gcInfoDecoder(gcInfoToken, DECODE_RETURN_KIND); - ReturnKind returnKind = gcInfoDecoder.GetReturnKind(); + returnKind = gcInfoDecoder.GetReturnKind(); } #endif // _TARGET_X86_