diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index 2ce97d285206cb..1d13229cf96a19 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -10299,7 +10299,9 @@ void ValueNumStore::vnDumpSimdType(Compiler* comp, VNFuncApp* simdType) int simdSize = ConstantValue(simdType->m_args[0]); CorInfoType baseJitType = (CorInfoType)ConstantValue(simdType->m_args[1]); - printf("%s(simd%d, %s)", VNFuncName(simdType->m_func), simdSize, varTypeName(JitType2PreciseVarType(baseJitType))); + printf("%s(simd%d, %s)", VNFuncName(simdType->m_func), simdSize, + baseJitType == CORINFO_TYPE_UNDEF ? varTypeName(TYP_UNDEF) + : varTypeName(JitType2PreciseVarType(baseJitType))); } #endif // FEATURE_SIMD diff --git a/src/coreclr/vm/corelib.h b/src/coreclr/vm/corelib.h index 4cffd124370fec..38a05866ff3e2c 100644 --- a/src/coreclr/vm/corelib.h +++ b/src/coreclr/vm/corelib.h @@ -1104,6 +1104,7 @@ DEFINE_FIELD_U(_condition, ContractExceptionObject, _Condition) DEFINE_CLASS(MODULEBASE, Reflection, Module) DEFINE_CLASS(STACKALLOCATEDBOX, CompilerServices, StackAllocatedBox`1) +DEFINE_FIELD(STACKALLOCATEDBOX, VALUE, _value) DEFINE_CLASS(UTF8STRINGMARSHALLER, Marshalling, Utf8StringMarshaller) DEFINE_METHOD(UTF8STRINGMARSHALLER, CONVERT_TO_MANAGED, ConvertToManaged, SM_PtrByte_RetStr) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index e7572863016f08..2c470710f0b4c2 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -6168,6 +6168,12 @@ CORINFO_CLASS_HANDLE CEEInfo::getTypeForBoxOnStack(CORINFO_CLASS_HANDLE cls) TypeHandle stackAllocatedBox = CoreLibBinder::GetClass(CLASS__STACKALLOCATEDBOX); TypeHandle stackAllocatedBoxInst = stackAllocatedBox.Instantiate(boxedFieldsInst); result = static_cast(stackAllocatedBoxInst.AsPtr()); + +#ifdef _DEBUG + FieldDesc* pValueFD = CoreLibBinder::GetField(FIELD__STACKALLOCATEDBOX__VALUE); + DWORD index = pValueFD->GetApproxEnclosingMethodTable()->GetIndexForFieldDesc(pValueFD); + _ASSERTE(stackAllocatedBoxInst.GetMethodTable()->GetFieldDescByIndex(index)->GetOffset() == TARGET_POINTER_SIZE); +#endif } EE_TO_JIT_TRANSITION(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/StackAllocatedBox.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/StackAllocatedBox.cs index 868edb18c1594b..33f2131edd115a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/StackAllocatedBox.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/StackAllocatedBox.cs @@ -7,7 +7,7 @@ namespace System.Runtime.CompilerServices { [NonVersionable] - [StructLayout(LayoutKind.Sequential)] + [StructLayout(LayoutKind.Sequential, Pack = 1)] internal unsafe struct StackAllocatedBox { // These fields are only accessed from jitted code