GcInfo: Don't use slim header for struct-returns
authorSwaroop Sridhar <swaroops@microsoft.com>
Thu, 25 Aug 2016 01:53:42 +0000 (18:53 -0700)
committerSwaroop Sridhar <swaroops@microsoft.com>
Thu, 25 Aug 2016 02:41:43 +0000 (19:41 -0700)
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().

src/gcinfo/gcinfoencoder.cpp
src/inc/gcinfotypes.h
src/vm/threadsuspend.cpp

index 3e587ea..6785222 100644 (file)
@@ -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.
index c08dd79..cd7afa4 100644 (file)
@@ -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
 
index 5785ad7..cd4203b 100644 (file)
@@ -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_