Skip to content

Commit

Permalink
Revert "DEBUG-ONLY: FieldInfo"
Browse files Browse the repository at this point in the history
This reverts commit b17817e0354a63319256a0fa0d21b74c2cfbf781.
  • Loading branch information
SingleAccretion committed Feb 23, 2022
1 parent 0789ecb commit 848169f
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 143 deletions.
11 changes: 3 additions & 8 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ var_types Compiler::getJitGCType(BYTE gcType)
// true if the given struct type contains only one pointer-sized integer value type,
// false otherwise.
//
bool Compiler::isTrivialPointerSizedStruct(CORINFO_CLASS_HANDLE clsHnd)
bool Compiler::isTrivialPointerSizedStruct(CORINFO_CLASS_HANDLE clsHnd) const
{
assert(info.compCompHnd->isValueClass(clsHnd));
if (info.compCompHnd->getClassSize(clsHnd) != TARGET_POINTER_SIZE)
Expand All @@ -409,8 +409,6 @@ bool Compiler::isTrivialPointerSizedStruct(CORINFO_CLASS_HANDLE clsHnd)
CORINFO_FIELD_HANDLE fldHnd = info.compCompHnd->getFieldInClass(clsHnd, 0);
CorInfoType fieldType = info.compCompHnd->getFieldType(fldHnd, pClsHnd);

INDEBUG(RecordStructFieldInfo(fldHnd));

var_types vt = JITtype2varType(fieldType);

if (fieldType == CORINFO_TYPE_VALUECLASS)
Expand Down Expand Up @@ -1917,11 +1915,8 @@ void Compiler::compInit(ArenaAllocator* pAlloc,
m_nodeTestData = nullptr;
m_loopHoistCSEClass = FIRST_LOOP_HOIST_CSE_CLASS;
#endif
m_switchDescMap = nullptr;
m_blockToEHPreds = nullptr;
#ifdef DEBUG
m_fieldInfoMap = nullptr;
#endif // DEBUG
m_switchDescMap = nullptr;
m_blockToEHPreds = nullptr;
m_fieldSeqStore = nullptr;
m_zeroOffsetFieldMap = nullptr;
m_arrayInfoMap = nullptr;
Expand Down
70 changes: 9 additions & 61 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2634,7 +2634,7 @@ class Compiler
#endif // FEATURE_MULTIREG_RET

#ifdef TARGET_X86
bool isTrivialPointerSizedStruct(CORINFO_CLASS_HANDLE clsHnd);
bool isTrivialPointerSizedStruct(CORINFO_CLASS_HANDLE clsHnd) const;
#endif // TARGET_X86

//-------------------------------------------------------------------------
Expand Down Expand Up @@ -11053,64 +11053,20 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void JitTestCheckVN(); // Value numbering tests.
#endif // DEBUG

#ifdef DEBUG
FieldInfoMap* m_fieldInfoMap;

FieldInfoMap* GetFieldInfoMap()
{
Compiler* rootCompiler = impInlineRoot();
if (rootCompiler->m_fieldInfoMap == nullptr)
{
CompAllocator allocator = rootCompiler->getAllocator(CMK_DebugOnly);
rootCompiler->m_fieldInfoMap = new (allocator) FieldInfoMap(allocator);
}

return rootCompiler->m_fieldInfoMap;
}

void RecordFieldInfo(CORINFO_FIELD_HANDLE fieldHnd, CORINFO_FIELD_INFO* eeFieldInfo)
{
FieldInfoMap* map = GetFieldInfoMap();

if (!map->Lookup(fieldHnd))
{
map->Set(fieldHnd, new (map->GetAllocator()) FieldInfo(eeFieldInfo));
}
}

void RecordStructFieldInfo(CORINFO_FIELD_HANDLE fieldHnd)
{
FieldInfoMap* map = GetFieldInfoMap();

if (!map->Lookup(fieldHnd))
{
map->Set(fieldHnd, new (map->GetAllocator()) FieldInfo());
}
}

const FieldInfo* GetFieldInfo(CORINFO_FIELD_HANDLE fieldHnd)
{
const FieldInfo* fieldInfo = nullptr;
bool fieldInfoFound = GetFieldInfoMap()->Lookup(fieldHnd, &fieldInfo);
assert(fieldInfoFound);

return fieldInfo;
}
#endif // DEBUG

// The "FieldSeqStore", for canonicalizing field sequences. See the definition of FieldSeqStore for
// operations.
FieldSeqStore* m_fieldSeqStore;

FieldSeqStore* GetFieldSeqStore()
{
Compiler* rootCompiler = impInlineRoot();
if (rootCompiler->m_fieldSeqStore == nullptr)
Compiler* compRoot = impInlineRoot();
if (compRoot->m_fieldSeqStore == nullptr)
{
CompAllocator allocator = getAllocator(CMK_FieldSeqStore);
rootCompiler->m_fieldSeqStore = new (allocator) FieldSeqStore(allocator);
// Create a CompAllocator that labels sub-structure with CMK_FieldSeqStore, and use that for allocation.
CompAllocator ialloc(getAllocator(CMK_FieldSeqStore));
compRoot->m_fieldSeqStore = new (ialloc) FieldSeqStore(ialloc);
}
return rootCompiler->m_fieldSeqStore;
return compRoot->m_fieldSeqStore;
}

typedef JitHashTable<GenTree*, JitPtrKeyFuncs<GenTree>, FieldSeqNode*> NodeToFieldSeqMap;
Expand Down Expand Up @@ -11224,23 +11180,15 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
{
m_refAnyClass = info.compCompHnd->getBuiltinClass(CLASSID_TYPED_BYREF);
}

CORINFO_FIELD_HANDLE dataFieldHnd = info.compCompHnd->getFieldInClass(m_refAnyClass, 0);
INDEBUG(RecordStructFieldInfo(dataFieldHnd));

return dataFieldHnd;
return info.compCompHnd->getFieldInClass(m_refAnyClass, 0);
}
CORINFO_FIELD_HANDLE GetRefanyTypeField()
{
if (m_refAnyClass == nullptr)
{
m_refAnyClass = info.compCompHnd->getBuiltinClass(CLASSID_TYPED_BYREF);
}

CORINFO_FIELD_HANDLE typeFieldHnd = info.compCompHnd->getFieldInClass(m_refAnyClass, 1);
INDEBUG(RecordStructFieldInfo(typeFieldHnd));

return typeFieldHnd;
return info.compCompHnd->getFieldInClass(m_refAnyClass, 1);
}

#if VARSET_COUNTOPS
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/jit/ee_il_dll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ void Compiler::eeGetFieldInfo(CORINFO_RESOLVED_TOKEN* pResolvedToken,
CORINFO_FIELD_INFO* pResult)
{
info.compCompHnd->getFieldInfo(pResolvedToken, info.compMethodHnd, accessFlags, pResult);
INDEBUG(RecordFieldInfo(pResolvedToken->hField, pResult));
}

/*****************************************************************************
Expand All @@ -65,11 +64,7 @@ bool Compiler::eeIsIntrinsic(CORINFO_METHOD_HANDLE ftn)
FORCEINLINE
bool Compiler::eeIsFieldStatic(CORINFO_FIELD_HANDLE fldHnd)
{
#ifdef DEBUG
return GetFieldInfo(fldHnd)->IsStatic();
#else
return info.compCompHnd->isFieldStatic(fldHnd);
#endif
}

FORCEINLINE
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12712,8 +12712,6 @@ GenTree* Compiler::gtFoldBoxNullable(GenTree* tree)
CORINFO_CLASS_HANDLE nullableHnd = gtGetStructHandle(arg->AsOp()->gtOp1);
CORINFO_FIELD_HANDLE fieldHnd = info.compCompHnd->getFieldInClass(nullableHnd, 0);

INDEBUG(RecordStructFieldInfo(fieldHnd));

// Replace the box with an access of the nullable 'hasValue' field.
JITDUMP("\nSuccess: replacing BOX_NULLABLE(&x) [%06u] with x.hasValue\n", dspTreeID(op));
GenTree* newOp = gtNewFieldRef(TYP_BOOL, fieldHnd, arg, 0);
Expand Down
42 changes: 0 additions & 42 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,48 +275,6 @@ struct FieldSeqNode
}
};

#ifdef DEBUG
// This class carries some about fields information neeeded for asserts from imporation to VN.
// Essentially, this is CORINFO_FIELD_INFO but Jit-specific and smaller.
class FieldInfo
{
const unsigned m_flags;
const CORINFO_FIELD_ACCESSOR m_accessor;

public:
FieldInfo(CORINFO_FIELD_INFO* eeFieldInfo)
: m_flags(eeFieldInfo->fieldFlags), m_accessor(eeFieldInfo->fieldAccessor)
{
}

FieldInfo() : m_flags(0), m_accessor(CORINFO_FIELD_INSTANCE)
{
}

bool IsStatic() const
{
return (m_flags & CORINFO_FLG_FIELD_STATIC) != 0;
}

bool IsBoxedStatic() const
{
return (m_flags & CORINFO_FLG_FIELD_STATIC_IN_HEAP) != 0;
}

bool IsSharedStatic() const
{
return m_accessor == CORINFO_FIELD_STATIC_GENERICS_STATIC_HELPER;
}

bool IsReadOnly() const
{
return (m_flags & CORINFO_FLG_FIELD_FINAL) != 0;
}
};

typedef JitHashTable<CORINFO_FIELD_HANDLE, JitPtrKeyFuncs<CORINFO_FIELD_STRUCT_>, const FieldInfo*> FieldInfoMap;
#endif // DEBUG

// This class canonicalizes field sequences.
class FieldSeqStore
{
Expand Down
14 changes: 1 addition & 13 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3712,9 +3712,6 @@ GenTree* Compiler::impCreateSpanIntrinsic(CORINFO_SIG_INFO* sig)
CORINFO_FIELD_HANDLE pointerFieldHnd = info.compCompHnd->getFieldInClass(spanHnd, 0);
CORINFO_FIELD_HANDLE lengthFieldHnd = info.compCompHnd->getFieldInClass(spanHnd, 1);

INDEBUG(RecordStructFieldInfo(pointerFieldHnd));
INDEBUG(RecordStructFieldInfo(lengthFieldHnd));

GenTreeLclFld* pointerField = gtNewLclFldNode(spanTempNum, TYP_BYREF, 0);
pointerField->SetFieldSeq(GetFieldSeqStore()->CreateSingleton(pointerFieldHnd));
GenTree* pointerFieldAsg = gtNewAssignNode(pointerField, pointerValue);
Expand Down Expand Up @@ -3964,8 +3961,6 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
assert(byReferenceStruct != nullptr);
impPushOnStack(byReferenceStruct, typeInfo(TI_STRUCT, clsHnd));
retNode = assign;

INDEBUG(RecordStructFieldInfo(fldHnd));
break;
}

Expand All @@ -3976,8 +3971,6 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
CORINFO_FIELD_HANDLE fldHnd = info.compCompHnd->getFieldInClass(clsHnd, 0);
GenTree* field = gtNewFieldRef(TYP_BYREF, fldHnd, op1, 0);
retNode = field;

INDEBUG(RecordStructFieldInfo(fldHnd));
break;
}

Expand Down Expand Up @@ -4102,8 +4095,6 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
GenTree* length = gtNewFieldRef(TYP_INT, lengthHnd, ptrToSpan, lengthOffset);
GenTree* boundsCheck = new (this, GT_BOUNDS_CHECK) GenTreeBoundsChk(index, length, SCK_RNGCHK_FAIL);

INDEBUG(RecordStructFieldInfo(lengthHnd));

// Element access
index = indexClone;

Expand All @@ -4129,8 +4120,6 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
GenTree* data = gtNewFieldRef(TYP_BYREF, ptrHnd, ptrToSpanClone, ptrOffset);
GenTree* result = gtNewOperNode(GT_ADD, TYP_BYREF, data, index);

INDEBUG(RecordStructFieldInfo(ptrHnd));

// Prepare result
var_types resultType = JITtype2varType(sig->retType);
assert(resultType == result->TypeGet());
Expand Down Expand Up @@ -7061,8 +7050,6 @@ int Compiler::impBoxPatternMatch(CORINFO_RESOLVED_TOKEN* pResolvedToken,
const CORINFO_FIELD_HANDLE hasValueFldHnd =
info.compCompHnd->getFieldInClass(nullableCls, 0);

INDEBUG(RecordStructFieldInfo(hasValueFldHnd));

assert(info.compCompHnd->getFieldOffset(hasValueFldHnd) == 0);
assert(!strcmp(info.compCompHnd->getFieldName(hasValueFldHnd, nullptr),
"hasValue"));
Expand Down Expand Up @@ -8184,6 +8171,7 @@ GenTree* Compiler::impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolvedT
!isBoxedStatic ? GetFieldSeqStore()->CreateSingleton(pResolvedToken->hField) : FieldSeqStore::NotAField();

GenTree* op1;

switch (pFieldInfo->fieldAccessor)
{
case CORINFO_FIELD_STATIC_GENERICS_STATIC_HELPER:
Expand Down
8 changes: 0 additions & 8 deletions src/coreclr/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,8 +1717,6 @@ bool Compiler::StructPromotionHelper::CanPromoteStructType(CORINFO_CLASS_HANDLE
structPromotionInfo.fields[ordinal] = GetFieldInfo(fieldHnd, ordinal);
const lvaStructFieldInfo& fieldInfo = structPromotionInfo.fields[ordinal];

INDEBUG(compiler->RecordStructFieldInfo(fieldHnd));

noway_assert(fieldInfo.fldOffset < structSize);

if (fieldInfo.fldSize == 0)
Expand Down Expand Up @@ -2147,9 +2145,6 @@ bool Compiler::StructPromotionHelper::TryPromoteStructField(lvaStructFieldInfo&
// the struct field.
CORINFO_FIELD_HANDLE innerFieldHndl = compHandle->getFieldInClass(fieldInfo.fldTypeHnd, 0);
unsigned innerFieldOffset = compHandle->getFieldOffset(innerFieldHndl);

INDEBUG(compiler->RecordStructFieldInfo(innerFieldHndl));

if (innerFieldOffset != 0)
{
return false;
Expand Down Expand Up @@ -2791,9 +2786,6 @@ void Compiler::makeExtraStructQueries(CORINFO_CLASS_HANDLE structHandle, int lev
CORINFO_CLASS_HANDLE fieldClassHandle = NO_CLASS_HANDLE;
CorInfoType fieldCorType = info.compCompHnd->getFieldType(fieldHandle, &fieldClassHandle);
var_types fieldVarType = JITtype2varType(fieldCorType);

INDEBUG(RecordStructFieldInfo(fieldHandle));

if (fieldClassHandle != NO_CLASS_HANDLE)
{
if (varTypeIsStruct(fieldVarType))
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/jit/morphblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1239,8 +1239,6 @@ GenTree* MorphCopyBlockHelper::CopyFieldByField()
m_comp->info.compCompHnd->getFieldInClass(classHnd, srcFieldVarDsc->lvFldOrdinal);
FieldSeqNode* curFieldSeq = m_comp->GetFieldSeqStore()->CreateSingleton(fieldHnd);

INDEBUG(m_comp->RecordStructFieldInfo(fieldHnd));

unsigned srcFieldOffset = m_comp->lvaGetDesc(srcFieldLclNum)->lvFldOffset;
var_types srcType = srcFieldVarDsc->TypeGet();

Expand Down Expand Up @@ -1347,8 +1345,6 @@ GenTree* MorphCopyBlockHelper::CopyFieldByField()
FieldSeqNode* curFieldSeq = m_comp->GetFieldSeqStore()->CreateSingleton(fieldHnd);
var_types destType = m_comp->lvaGetDesc(dstFieldLclNum)->lvType;

INDEBUG(m_comp->RecordStructFieldInfo(fieldHnd));

bool done = false;
if (m_comp->lvaGetDesc(dstFieldLclNum)->lvFldOffset == 0)
{
Expand Down

0 comments on commit 848169f

Please sign in to comment.