Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void Init()
};

// The ArgDestination class represents a destination location of an argument.
internal class ArgDestination
internal readonly struct ArgDestination
{
/// <summary>
/// Transition block context.
Expand Down Expand Up @@ -309,8 +309,6 @@ private int GetStructGenRegDestinationAddress()
// fieldBytes - size of the structure
internal void ReportPointersFromStructInRegisters(TypeDesc type, int delta, CORCOMPILE_GCREFMAP_TOKENS[] frame)
{
// SPAN-TODO: GC reporting - https://github.com/dotnet/runtime/issues/7103

Debug.Assert(IsStructPassedInRegs());

int genRegDest = GetStructGenRegDestinationAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private void FakeGcScanRoots(MethodDesc method, ArgIterator argit, CORCOMPILE_GC
{
ArgLocDesc? argLocDescForStructInRegs = argit.GetArgLoc(argOffset);
ArgDestination argDest = new ArgDestination(_transitionBlock, argOffset, argLocDescForStructInRegs);
GcScanRoots(method.Signature[argIndex], in argDest, delta: 0, frame);
GcScanRoots(method.Signature[argIndex], in argDest, delta: 0, frame, topLevel: true);
argIndex++;
}
}
Expand All @@ -211,7 +211,8 @@ private void FakeGcScanRoots(MethodDesc method, ArgIterator argit, CORCOMPILE_GC
/// <param name="type">Parameter type</param>
/// <param name="argDest">Location of the parameter</param>
/// <param name="frame">Frame map to update by marking GC locations</param>
private void GcScanRoots(TypeDesc type, in ArgDestination argDest, int delta, CORCOMPILE_GCREFMAP_TOKENS[] frame)
/// <param name="topLevel">Indicates if the call is for a type or inner member</param>
private void GcScanRoots(TypeDesc type, in ArgDestination argDest, int delta, CORCOMPILE_GCREFMAP_TOKENS[] frame, bool topLevel)
{
switch (type.Category)
{
Expand Down Expand Up @@ -252,60 +253,39 @@ private void GcScanRoots(TypeDesc type, in ArgDestination argDest, int delta, CO
// TYPE_GC_OTHER
case TypeFlags.ValueType:
case TypeFlags.Nullable:
GcScanValueType(type, argDest, delta, frame);
GcScanValueType(type, in argDest, delta, frame, topLevel);
break;

default:
throw new NotImplementedException();
}
}

private void GcScanValueType(TypeDesc type, ArgDestination argDest, int delta, CORCOMPILE_GCREFMAP_TOKENS[] frame)
private void GcScanValueType(TypeDesc type, in ArgDestination argDest, int delta, CORCOMPILE_GCREFMAP_TOKENS[] frame, bool topLevel)
{
if (_transitionBlock.IsArgPassedByRef(new TypeHandle(type)))
if (topLevel)
{
argDest.GcMark(frame, delta, interior: true);
return;
}
if (_transitionBlock.IsArgPassedByRef(new TypeHandle(type)))
{
argDest.GcMark(frame, delta, interior: true);
return;
}

// ReportPointersFromValueTypeArg
if (argDest.IsStructPassedInRegs())
{
argDest.ReportPointersFromStructInRegisters(type, delta, frame);
return;
}
// ReportPointersFromValueType
if (type.IsByRefLike)
{
FindByRefPointerOffsetsInByRefLikeObject(type, argDest, delta, frame);
if (argDest.IsStructPassedInRegs())
{
argDest.ReportPointersFromStructInRegisters(type, delta, frame);
return;
}
}

Debug.Assert(type is DefType);
DefType defType = (DefType)type;
foreach (FieldDesc field in defType.GetFields())
{
if (!field.IsStatic)
{
GcScanRoots(field.FieldType, argDest, delta + field.Offset.AsInt, frame);
}
}
}
if (field.IsStatic)
continue;

private void FindByRefPointerOffsetsInByRefLikeObject(TypeDesc type, ArgDestination argDest, int delta, CORCOMPILE_GCREFMAP_TOKENS[] frame)
{
if (type.IsByRef)
{
argDest.GcMark(frame, delta, interior: true);
return;
}

foreach (FieldDesc field in type.GetFields())
{
if (!field.IsStatic && field.FieldType.IsByRefLike)
{
Debug.Assert(field.FieldType.IsValueType);
FindByRefPointerOffsetsInByRefLikeObject(field.FieldType, argDest, delta + field.Offset.AsInt, frame);
}
GcScanRoots(field.FieldType, in argDest, delta + field.Offset.AsInt, frame, topLevel: false);
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/argdestination.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ class ArgDestination
{
LIMITED_METHOD_CONTRACT;

// SPAN-TODO: GC reporting - https://github.com/dotnet/runtime/issues/7103

_ASSERTE(IsStructPassedInRegs());

TADDR genRegDest = dac_cast<TADDR>(GetStructGenRegDestinationAddress());
Expand Down
16 changes: 8 additions & 8 deletions src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2500,7 +2500,7 @@ bool MethodTable::ClassifyEightBytesWithNativeLayout(SystemVStructRegisterPassin

if ((strcmp(className, "Vector`1") == 0) && (strcmp(namespaceName, "System.Numerics") == 0))
{
LOG((LF_JIT, LL_EVERYTHING, "%*s**** ClassifyEightBytesWithManagedLayout: struct %s is a SIMD intrinsic type; will not be enregistered\n",
LOG((LF_JIT, LL_EVERYTHING, "%*s**** ClassifyEightBytesWithNativeLayout: struct %s is a SIMD intrinsic type; will not be enregistered\n",
nestingLevel * 5, "", this->GetDebugClassName()));

return false;
Expand Down Expand Up @@ -5500,33 +5500,33 @@ namespace
for (; it.IsValid() && candidateMaybe == NULL; it.Next())
{
MethodDesc *pDeclMD = it.GetMethodDesc();

// Is this the right slot?
if (pDeclMD->GetSlot() != targetSlot)
continue;

// Is this the right interface?
if (!pDeclMD->HasSameMethodDefAs(interfaceMD))
continue;

if (interfaceMD->HasClassInstantiation())
{
// pInterfaceMD will be in the canonical form, so we need to check the specific
// instantiation against pInterfaceMT.
//
// The parent of pDeclMD is unreliable for this purpose because it may or
// may not be canonicalized. Let's go from the metadata.

SigTypeContext typeContext = SigTypeContext(pMT);

mdTypeRef tkParent;
IfFailThrow(pMD->GetModule()->GetMDImport()->GetParentToken(it.GetToken(), &tkParent));

MethodTable *pDeclMT = ClassLoader::LoadTypeDefOrRefOrSpecThrowing(
pMD->GetModule(),
tkParent,
&typeContext).AsMethodTable();

// We do CanCastToInterface to also cover variance.
// We already know this is a method on the same type definition as the (generic)
// interface but we need to make sure the instantiations match.
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8343,11 +8343,19 @@ void MethodTableBuilder::SystemVAmd64CheckForPassStructInRegister()
SystemVStructRegisterPassingHelper helper((unsigned int)totalStructSize);
if (GetHalfBakedMethodTable()->ClassifyEightBytes(&helper, 0, 0, useNativeLayout))
{
LOG((LF_JIT, LL_EVERYTHING, "**** SystemVAmd64CheckForPassStructInRegister: struct %s is enregisterable\n",
this->GetDebugClassName()));

// All the above tests passed. It's registers passed struct!
GetHalfBakedMethodTable()->SetRegPassedStruct();

StoreEightByteClassification(&helper);
}
else
{
LOG((LF_JIT, LL_EVERYTHING, "**** SystemVAmd64CheckForPassStructInRegister: struct %s is _not_ enregisterable\n",
this->GetDebugClassName()));
}
}

// Store the eightbyte classification into the EEClass
Expand Down
16 changes: 7 additions & 9 deletions src/coreclr/vm/siginfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ DEFINEELEMENTTYPEINFO(ELEMENT_TYPE_ARRAY, TARGET_POINTER_SIZE, TYPE_GC

DEFINEELEMENTTYPEINFO(ELEMENT_TYPE_GENERICINST, -1, TYPE_GC_OTHER, 0)

DEFINEELEMENTTYPEINFO(ELEMENT_TYPE_TYPEDBYREF, TARGET_POINTER_SIZE*2,TYPE_GC_BYREF, 0)
DEFINEELEMENTTYPEINFO(ELEMENT_TYPE_TYPEDBYREF, TARGET_POINTER_SIZE*2,TYPE_GC_OTHER, 0)
DEFINEELEMENTTYPEINFO(ELEMENT_TYPE_VALUEARRAY_UNSUPPORTED, -1, TYPE_GC_NONE, 0)
DEFINEELEMENTTYPEINFO(ELEMENT_TYPE_I, TARGET_POINTER_SIZE, TYPE_GC_NONE, 1)
DEFINEELEMENTTYPEINFO(ELEMENT_TYPE_U, TARGET_POINTER_SIZE, TYPE_GC_NONE, 1)
Expand All @@ -135,13 +135,6 @@ unsigned GetSizeForCorElementType(CorElementType etyp)
return gElementTypeInfo[etyp].m_cbSize;
}

const ElementTypeInfo* GetElementTypeInfo(CorElementType etyp)
{
LIMITED_METHOD_CONTRACT;
_ASSERTE(gElementTypeInfo[etyp].m_elementType == etyp);
return &gElementTypeInfo[etyp];
}

#ifndef DACCESS_COMPILE

void SigPointer::ConvertToInternalExactlyOne(Module* pSigModule, SigTypeContext *pTypeContext, SigBuilder * pSigBuilder, BOOL bSkipCustomModifier)
Expand Down Expand Up @@ -2374,6 +2367,11 @@ CorElementType SigPointer::PeekElemTypeNormalized(Module* pModule, const SigType
*pthValueType = th;
}
}
else if (type == ELEMENT_TYPE_TYPEDBYREF)
{
if (pthValueType != NULL)
*pthValueType = TypeHandle(g_TypedReferenceMT);
}

return(type);
}
Expand Down Expand Up @@ -5120,7 +5118,7 @@ VOID MetaSig::GcScanRoots(ArgDestination *pValue,
// for value classes describes the state of the instance in its boxed
// state. Here we are dealing with an unboxed instance, so we must adjust
// the object size and series offsets appropriately.
_ASSERTE(etype == ELEMENT_TYPE_VALUETYPE);
_ASSERTE(etype == ELEMENT_TYPE_VALUETYPE || etype == ELEMENT_TYPE_TYPEDBYREF);
{
PTR_MethodTable pMT = thValueType.AsMethodTable();

Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/siginfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ struct ElementTypeInfo {
extern const ElementTypeInfo gElementTypeInfo[];

unsigned GetSizeForCorElementType(CorElementType etyp);
const ElementTypeInfo* GetElementTypeInfo(CorElementType etyp);

class SigBuilder;
class ArgDestination;
Expand Down