From 720ae033fa8c8b9e933f198e03c4b16e8a432387 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Sat, 3 Dec 2022 12:06:27 +0100 Subject: [PATCH] Remove getFieldAddress (#79060) --- src/coreclr/inc/corinfo.h | 11 +-- src/coreclr/inc/icorjitinfoimpl_generated.h | 4 - src/coreclr/inc/jiteeversionguid.h | 10 +- src/coreclr/jit/ICorJitInfo_names_generated.h | 1 - .../jit/ICorJitInfo_wrapper_generated.hpp | 10 -- src/coreclr/jit/compiler.h | 1 - src/coreclr/jit/emitarm.cpp | 5 +- src/coreclr/jit/emitxarch.cpp | 7 +- src/coreclr/jit/fginline.cpp | 3 +- src/coreclr/jit/gentree.cpp | 10 ++ src/coreclr/jit/gentree.h | 6 ++ src/coreclr/jit/importer.cpp | 93 ++++++++---------- src/coreclr/jit/morph.cpp | 98 +------------------ .../tools/Common/JitInterface/CorInfoImpl.cs | 19 ---- .../JitInterface/CorInfoImpl_generated.cs | 78 ++++++--------- .../ThunkGenerator/ThunkInput.txt | 1 - .../JitInterface/CorInfoImpl.ReadyToRun.cs | 4 + .../JitInterface/CorInfoImpl.RyuJit.cs | 4 + .../aot/jitinterface/jitinterface_generated.h | 11 --- .../tools/superpmi/superpmi-shared/agnostic.h | 6 -- .../superpmi-shared/compileresult.cpp | 2 +- .../tools/superpmi/superpmi-shared/lwmlist.h | 1 - .../superpmi-shared/methodcontext.cpp | 34 ------- .../superpmi/superpmi-shared/methodcontext.h | 6 +- .../superpmi-shim-collector/icorjitinfo.cpp | 13 --- .../icorjitinfo_generated.cpp | 8 -- .../icorjitinfo_generated.cpp | 7 -- .../tools/superpmi/superpmi/icorjitinfo.cpp | 7 -- src/coreclr/vm/jitinterface.cpp | 93 +++--------------- src/coreclr/vm/jitinterface.h | 1 - 30 files changed, 129 insertions(+), 425 deletions(-) diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 0feb8619a8108..e906373fdbb18 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -141,7 +141,7 @@ The first 4 options are mutually exclusive have managed thread local statics, which work through the HELPER. Support for this is considered legacy, and going forward, the EE should - * This is a normal static field. Its address in memory is determined by getFieldAddress. (see + * This is a normal static field. Its address in memory is determined by getFieldInfo. (see also CORINFO_FLG_STATIC_IN_HEAP). @@ -1611,7 +1611,7 @@ struct CORINFO_CALL_INFO CORINFO_LOOKUP codePointerLookup; }; - CORINFO_CONST_LOOKUP instParamLookup; // Used by Ready-to-Run + CORINFO_CONST_LOOKUP instParamLookup; bool wrapperDelegateInvoke; }; @@ -3188,13 +3188,6 @@ class ICorDynamicInfo : public ICorStaticInfo void **ppIndirection = NULL ) = 0; - - // return the data's address (for static fields only) - virtual void* getFieldAddress( - CORINFO_FIELD_HANDLE field, - void **ppIndirection = NULL - ) = 0; - //------------------------------------------------------------------------------ // getReadonlyStaticFieldValue: returns true and the actual field's value if the given // field represents a statically initialized readonly field of any type. diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h index 86ac07f8117dd..1d7f394dd1658 100644 --- a/src/coreclr/inc/icorjitinfoimpl_generated.h +++ b/src/coreclr/inc/icorjitinfoimpl_generated.h @@ -617,10 +617,6 @@ unsigned getClassDomainID( CORINFO_CLASS_HANDLE cls, void** ppIndirection) override; -void* getFieldAddress( - CORINFO_FIELD_HANDLE field, - void** ppIndirection) override; - bool getReadonlyStaticFieldValue( CORINFO_FIELD_HANDLE field, uint8_t* buffer, diff --git a/src/coreclr/inc/jiteeversionguid.h b/src/coreclr/inc/jiteeversionguid.h index b999fff982f96..63e1ce6c8f7cf 100644 --- a/src/coreclr/inc/jiteeversionguid.h +++ b/src/coreclr/inc/jiteeversionguid.h @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID; #define GUID_DEFINED #endif // !GUID_DEFINED -constexpr GUID JITEEVersionIdentifier = { /* 0330a175-dd05-4760-840f-a1a4c47284d3 */ - 0x330a175, - 0xdd05, - 0x4760, - {0x84, 0xf, 0xa1, 0xa4, 0xc4, 0x72, 0x84, 0xd3} +constexpr GUID JITEEVersionIdentifier = { /* aaa9536e-1295-4741-a7d9-6c09a5b01512 */ + 0xaaa9536e, + 0x1295, + 0x4741, + {0xa7, 0xd9, 0x6c, 0x9, 0xa5, 0xb0, 0x15, 0x12} }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/coreclr/jit/ICorJitInfo_names_generated.h b/src/coreclr/jit/ICorJitInfo_names_generated.h index d6deb87c17ed4..dcdb90d6f3117 100644 --- a/src/coreclr/jit/ICorJitInfo_names_generated.h +++ b/src/coreclr/jit/ICorJitInfo_names_generated.h @@ -154,7 +154,6 @@ DEF_CLR_API(getCallInfo) DEF_CLR_API(canAccessFamily) DEF_CLR_API(isRIDClassDomainID) DEF_CLR_API(getClassDomainID) -DEF_CLR_API(getFieldAddress) DEF_CLR_API(getReadonlyStaticFieldValue) DEF_CLR_API(getStaticFieldCurrentClass) DEF_CLR_API(getVarArgsHandle) diff --git a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp index 25b78bba0cae3..3494d49102994 100644 --- a/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp +++ b/src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp @@ -1474,16 +1474,6 @@ unsigned WrapICorJitInfo::getClassDomainID( return temp; } -void* WrapICorJitInfo::getFieldAddress( - CORINFO_FIELD_HANDLE field, - void** ppIndirection) -{ - API_ENTER(getFieldAddress); - void* temp = wrapHnd->getFieldAddress(field, ppIndirection); - API_LEAVE(getFieldAddress); - return temp; -} - bool WrapICorJitInfo::getReadonlyStaticFieldValue( CORINFO_FIELD_HANDLE field, uint8_t* buffer, diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index d338dba2d5bd8..92d7ad8a59bd1 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -5711,7 +5711,6 @@ class Compiler GenTree* fgMorphField(GenTree* tree, MorphAddrContext* mac); GenTree* fgMorphExpandInstanceField(GenTree* tree, MorphAddrContext* mac); GenTree* fgMorphExpandTlsFieldAddr(GenTree* tree); - GenTree* fgMorphExpandStaticField(GenTree* tree); bool fgCanFastTailCall(GenTreeCall* call, const char** failReason); #if FEATURE_FASTTAILCALL bool fgCallHasMustCopyByrefParameter(GenTreeCall* callee); diff --git a/src/coreclr/jit/emitarm.cpp b/src/coreclr/jit/emitarm.cpp index a546d5aaab940..741d2d50dfbac 100644 --- a/src/coreclr/jit/emitarm.cpp +++ b/src/coreclr/jit/emitarm.cpp @@ -4012,10 +4012,7 @@ void emitter::emitIns_R_C(instruction ins, emitAttr attr, regNumber reg, CORINFO } else { - assert(!jitStaticFldIsGlobAddr(fldHnd)); - addr = (ssize_t)emitComp->info.compCompHnd->getFieldAddress(fldHnd, NULL); - if (addr == NULL) - NO_WAY("could not obtain address of static field"); + assert(!"Normal statics are expected to be handled in the importer"); } // We can use reg to load the constant address, diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 6d654f115ff48..a0008218ecf6b 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -12967,11 +12967,8 @@ BYTE* emitter::emitOutputCV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) } else { - addr = (BYTE*)emitComp->info.compCompHnd->getFieldAddress(fldh, nullptr); - if (addr == nullptr) - { - NO_WAY("could not obtain address of static field"); - } + assert(jitStaticFldIsGlobAddr(fldh)); + addr = nullptr; } } diff --git a/src/coreclr/jit/fginline.cpp b/src/coreclr/jit/fginline.cpp index ad96acf4b92d9..b56069e2273a8 100644 --- a/src/coreclr/jit/fginline.cpp +++ b/src/coreclr/jit/fginline.cpp @@ -1601,7 +1601,8 @@ Statement* Compiler::fgInlinePrependStatements(InlineInfo* inlineInfo) GenTree* op2 = argNode->AsOp()->gtOp2; if (op1->IsCall() && ((op1->AsCall()->gtCallMoreFlags & GTF_CALL_M_HELPER_SPECIAL_DCE) != 0) && - (op2->gtOper == GT_FIELD) && ((op2->gtFlags & GTF_EXCEPT) == 0)) + op2->OperIs(GT_IND) && op2->gtGetOp1()->IsIconHandle() && + ((op2->gtFlags & GTF_EXCEPT) == 0)) { JITDUMP("\nPerforming special dce on unused arg [%06u]:" " actual arg [%06u] helper call [%06u]\n", diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 45ede8a98c226..288a69d66d913 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -18073,6 +18073,16 @@ CORINFO_CLASS_HANDLE Compiler::gtGetClassHandle(GenTree* tree, bool* pIsExact, b } } } + else if (base->IsIconHandle(GTF_ICON_CONST_PTR, GTF_ICON_STATIC_HDL)) + { + // Check if we have IND(ICON_HANDLE) that represents a static field + FieldSeq* fldSeq = base->AsIntCon()->gtFieldSeq; + if ((fldSeq != nullptr) && (fldSeq->GetOffset() == base->AsIntCon()->IconValue())) + { + CORINFO_FIELD_HANDLE fldHandle = base->AsIntCon()->gtFieldSeq->GetFieldHandle(); + objClass = gtGetFieldClassHandle(fldHandle, pIsExact, pIsNonNull); + } + } } break; diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index 1e993060fa075..9c2007df0ea83 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -2211,6 +2211,12 @@ struct GenTree return (gtOper == GT_CNS_INT) && ((gtFlags & GTF_ICON_HDL_MASK) == handleType); } + template + bool IsIconHandle(GenTreeFlags handleType, T... rest) const + { + return IsIconHandle(handleType) || IsIconHandle(rest...); + } + // Return just the part of the flags corresponding to the GTF_ICON_*_HDL flag. // For non-icon handle trees, returns GTF_EMPTY. GenTreeFlags GetIconHandleFlag() const diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index 82923b68b1bce..be1d49b62fc64 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -1443,9 +1443,9 @@ GenTree* Compiler::impNormStructVal(GenTree* structVal, CORINFO_CLASS_HANDLE str // In case of a chained GT_COMMA case, we sink the last // GT_COMMA below the blockNode addr. GenTree* blockNodeAddr = blockNode->AsOp()->gtOp1; - assert(blockNodeAddr->gtType == TYP_BYREF); + assert(blockNodeAddr->TypeIs(TYP_BYREF, TYP_I_IMPL)); GenTree* commaNode = parent; - commaNode->gtType = TYP_BYREF; + commaNode->gtType = blockNodeAddr->gtType; commaNode->AsOp()->gtOp2 = blockNodeAddr; blockNode->AsOp()->gtOp1 = commaNode; if (parent == structVal) @@ -4199,6 +4199,9 @@ GenTree* Compiler::impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolvedT FieldSeq::FieldKind fieldKind = isSharedStatic ? FieldSeq::FieldKind::SharedStatic : FieldSeq::FieldKind::SimpleStatic; + bool hasConstAddr = (pFieldInfo->fieldAccessor == CORINFO_FIELD_STATIC_ADDRESS) || + (pFieldInfo->fieldAccessor == CORINFO_FIELD_STATIC_RVA_ADDRESS); + FieldSeq* innerFldSeq; FieldSeq* outerFldSeq; if (isBoxedStatic) @@ -4208,18 +4211,15 @@ GenTree* Compiler::impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolvedT } else { - bool hasKnownAddr = (pFieldInfo->fieldAccessor == CORINFO_FIELD_STATIC_ADDRESS) || - (pFieldInfo->fieldAccessor == CORINFO_FIELD_STATIC_RVA_ADDRESS); - ssize_t offset; - if (hasKnownAddr) + if (hasConstAddr) { // Change SimpleStatic to SimpleStaticKnownAddress assert(fieldKind == FieldSeq::FieldKind::SimpleStatic); fieldKind = FieldSeq::FieldKind::SimpleStaticKnownAddress; - offset = reinterpret_cast(info.compCompHnd->getFieldAddress(pResolvedToken->hField)); - assert(offset != 0); + assert(pFieldInfo->fieldLookup.accessType == IAT_VALUE); + offset = reinterpret_cast(pFieldInfo->fieldLookup.addr); } else { @@ -4230,6 +4230,7 @@ GenTree* Compiler::impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolvedT outerFldSeq = nullptr; } + bool isStaticReadOnlyInitedRef = false; GenTree* op1; switch (pFieldInfo->fieldAccessor) { @@ -4322,53 +4323,41 @@ GenTree* Compiler::impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolvedT default: { - // Do we need the address of a static field? - // - if (access & CORINFO_ACCESS_ADDRESS) +// TODO-CQ: enable this optimization for 32 bit targets. +#ifdef TARGET_64BIT + if (!isBoxedStatic && (lclTyp == TYP_REF) && ((access & CORINFO_ACCESS_ADDRESS) == 0)) { - void** pFldAddr = nullptr; - void* fldAddr = info.compCompHnd->getFieldAddress(pResolvedToken->hField, (void**)&pFldAddr); - - // We should always be able to access this static's address directly. - assert(pFldAddr == nullptr); - - // Create the address node. - GenTreeFlags handleKind = isBoxedStatic ? GTF_ICON_STATIC_BOX_PTR : GTF_ICON_STATIC_HDL; - op1 = gtNewIconHandleNode((size_t)fldAddr, handleKind, innerFldSeq); - INDEBUG(op1->AsIntCon()->gtTargetHandle = reinterpret_cast(pResolvedToken->hField)); - - if (pFieldInfo->fieldFlags & CORINFO_FLG_FIELD_INITCLASS) + bool isSpeculative = true; + if ((info.compCompHnd->getStaticFieldCurrentClass(pResolvedToken->hField, &isSpeculative) != + NO_CLASS_HANDLE)) { - op1->gtFlags |= GTF_ICON_INITCLASS; + isStaticReadOnlyInitedRef = !isSpeculative; } } - else // We need the value of a static field - { - op1 = gtNewFieldRef(lclTyp, pResolvedToken->hField); - - if (pFieldInfo->fieldFlags & CORINFO_FLG_FIELD_INITCLASS) - { - op1->gtFlags |= GTF_FLD_INITCLASS; - } - - if (isBoxedStatic) - { - op1->ChangeType(TYP_REF); // points at boxed object - op1 = gtNewOperNode(GT_ADD, TYP_BYREF, op1, gtNewIconNode(TARGET_POINTER_SIZE, outerFldSeq)); - - if (varTypeIsStruct(lclTyp)) - { - // Constructor adds GTF_GLOB_REF. Note that this is *not* GTF_EXCEPT. - op1 = gtNewObjNode(pFieldInfo->structType, op1); - } - else - { - op1 = gtNewOperNode(GT_IND, lclTyp, op1); - op1->gtFlags |= (GTF_GLOB_REF | GTF_IND_NONFAULTING); - } - } +#endif // TARGET_64BIT - return op1; + assert(hasConstAddr); + assert(pFieldInfo->fieldLookup.addr != nullptr); + assert(pFieldInfo->fieldLookup.accessType == IAT_VALUE); + size_t fldAddr = reinterpret_cast(pFieldInfo->fieldLookup.addr); + GenTreeFlags handleKind; + if (isBoxedStatic) + { + handleKind = GTF_ICON_STATIC_BOX_PTR; + } + else if (isStaticReadOnlyInitedRef) + { + handleKind = GTF_ICON_CONST_PTR; + } + else + { + handleKind = GTF_ICON_STATIC_HDL; + } + op1 = gtNewIconHandleNode(fldAddr, handleKind, innerFldSeq); + INDEBUG(op1->AsIntCon()->gtTargetHandle = reinterpret_cast(pResolvedToken->hField)); + if (pFieldInfo->fieldFlags & CORINFO_FLG_FIELD_INITCLASS) + { + op1->gtFlags |= GTF_ICON_INITCLASS; } break; } @@ -4392,6 +4381,10 @@ GenTree* Compiler::impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolvedT op1 = gtNewOperNode(GT_IND, lclTyp, op1); op1->gtFlags |= GTF_GLOB_REF; } + if (isStaticReadOnlyInitedRef) + { + op1->gtFlags |= (GTF_IND_INVARIANT | GTF_IND_NONFAULTING | GTF_IND_NONNULL); + } } return op1; diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index fc21a67489b6c..06be610e35f50 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -4927,7 +4927,7 @@ GenTree* Compiler::fgMorphField(GenTree* tree, MorphAddrContext* mac) } else { - tree = fgMorphExpandStaticField(tree); + assert(!"Normal statics are expected to be handled in the importer"); } // Pass down the current mac; if non null we are computing an address @@ -5273,102 +5273,6 @@ GenTree* Compiler::fgMorphExpandTlsFieldAddr(GenTree* tree) return tree; } -//------------------------------------------------------------------------ -// fgMorphExpandStaticField: Expand a simple static field load. -// -// Transforms the field into an explicit indirection off of a constant -// address. -// -// Arguments: -// tree - The GT_FIELD tree -// -// Return Value: -// The expanded tree - a GT_IND. -// -GenTree* Compiler::fgMorphExpandStaticField(GenTree* tree) -{ - // Note we do not support "FIELD_ADDR"s for simple statics. - assert(tree->OperIs(GT_FIELD) && tree->AsField()->IsStatic()); - - // If we can we access the static's address directly - // then pFldAddr will be NULL and - // fldAddr will be the actual address of the static field - // - CORINFO_FIELD_HANDLE fieldHandle = tree->AsField()->gtFldHnd; - void** pFldAddr = nullptr; - void* fldAddr = info.compCompHnd->getFieldAddress(fieldHandle, (void**)&pFldAddr); - - // We should always be able to access this static field address directly - // - assert(pFldAddr == nullptr); - - // For boxed statics, this direct address will be for the box. We have already added - // the indirection for the field itself and attached the sequence, in importation. - FieldSeq* fieldSeq = nullptr; - bool isBoxedStatic = gtIsStaticFieldPtrToBoxedStruct(tree->TypeGet(), fieldHandle); - if (!isBoxedStatic) - { - // Only simple statics get importred as GT_FIELDs. - fieldSeq = GetFieldSeqStore()->Create(fieldHandle, reinterpret_cast(fldAddr), - FieldSeq::FieldKind::SimpleStaticKnownAddress); - } - - // TODO-CQ: enable this optimization for 32 bit targets. - bool isStaticReadOnlyInited = false; -#ifdef TARGET_64BIT - if (tree->TypeIs(TYP_REF) && !isBoxedStatic) - { - bool pIsSpeculative = true; - if (info.compCompHnd->getStaticFieldCurrentClass(fieldHandle, &pIsSpeculative) != NO_CLASS_HANDLE) - { - isStaticReadOnlyInited = !pIsSpeculative; - } - } -#endif // TARGET_64BIT - - GenTreeFlags handleKind = GTF_EMPTY; - if (isBoxedStatic) - { - handleKind = GTF_ICON_STATIC_BOX_PTR; - } - else if (isStaticReadOnlyInited) - { - handleKind = GTF_ICON_CONST_PTR; - } - else - { - handleKind = GTF_ICON_STATIC_HDL; - } - GenTreeIntCon* addr = gtNewIconHandleNode((size_t)fldAddr, handleKind, fieldSeq); - INDEBUG(addr->gtTargetHandle = reinterpret_cast(fieldHandle)); - - // Translate GTF_FLD_INITCLASS to GTF_ICON_INITCLASS, if we need to. - if (((tree->gtFlags & GTF_FLD_INITCLASS) != 0) && !isStaticReadOnlyInited) - { - tree->gtFlags &= ~GTF_FLD_INITCLASS; - addr->gtFlags |= GTF_ICON_INITCLASS; - } - - tree->SetOper(GT_IND); - tree->AsOp()->gtOp1 = addr; - - if (isBoxedStatic) - { - // The box for the static cannot be null, and is logically invariant, since it - // represents (a base for) the static's address. - tree->gtFlags |= (GTF_IND_INVARIANT | GTF_IND_NONFAULTING | GTF_IND_NONNULL); - } - else if (isStaticReadOnlyInited) - { - JITDUMP("Marking initialized static read-only field '%s' as invariant.\n", eeGetFieldName(fieldHandle, false)); - - // Static readonly field is not null at this point (see getStaticFieldCurrentClass impl). - tree->gtFlags |= (GTF_IND_INVARIANT | GTF_IND_NONFAULTING | GTF_IND_NONNULL); - } - - return tree; -} - //------------------------------------------------------------------------------ // fgMorphCallInline: attempt to inline a call // diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index fa33a55b7098d..5f2aa030dca74 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -3313,25 +3313,6 @@ private bool isRIDClassDomainID(CORINFO_CLASS_STRUCT_* cls) private uint getClassDomainID(CORINFO_CLASS_STRUCT_* cls, ref void* ppIndirection) { throw new NotImplementedException("getClassDomainID"); } - private void* getFieldAddress(CORINFO_FIELD_STRUCT_* field, void** ppIndirection) - { - FieldDesc fieldDesc = HandleToObject(field); - Debug.Assert(fieldDesc.HasRva); - ISymbolNode node = _compilation.GetFieldRvaData(fieldDesc); - void *handle = (void *)ObjectToHandle(node); - if (node.RepresentsIndirectionCell) - { - *ppIndirection = handle; - return null; - } - else - { - if (ppIndirection != null) - *ppIndirection = null; - return handle; - } - } - private CORINFO_CLASS_STRUCT_* getStaticFieldCurrentClass(CORINFO_FIELD_STRUCT_* field, byte* pIsSpeculative) { if (pIsSpeculative != null) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs index bfca28ea85737..584e0df9e5482 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl_generated.cs @@ -2228,21 +2228,6 @@ private static uint _getClassDomainID(IntPtr thisHandle, IntPtr* ppException, CO } } - [UnmanagedCallersOnly] - private static void* _getFieldAddress(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, void** ppIndirection) - { - var _this = GetThis(thisHandle); - try - { - return _this.getFieldAddress(field, ppIndirection); - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - [UnmanagedCallersOnly] private static byte _getReadonlyStaticFieldValue(IntPtr thisHandle, IntPtr* ppException, CORINFO_FIELD_STRUCT_* field, byte* buffer, int bufferSize, int valueOffset, byte ignoreMovableObjects) { @@ -2685,7 +2670,7 @@ private static uint _getJitFlags(IntPtr thisHandle, IntPtr* ppException, CORJIT_ private static IntPtr GetUnmanagedCallbacks() { - void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 181); + void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 180); callbacks[0] = (delegate* unmanaged)&_isIntrinsic; callbacks[1] = (delegate* unmanaged)&_getMethodAttribs; @@ -2837,37 +2822,36 @@ private static IntPtr GetUnmanagedCallbacks() callbacks[147] = (delegate* unmanaged)&_canAccessFamily; callbacks[148] = (delegate* unmanaged)&_isRIDClassDomainID; callbacks[149] = (delegate* unmanaged)&_getClassDomainID; - callbacks[150] = (delegate* unmanaged)&_getFieldAddress; - callbacks[151] = (delegate* unmanaged)&_getReadonlyStaticFieldValue; - callbacks[152] = (delegate* unmanaged)&_getStaticFieldCurrentClass; - callbacks[153] = (delegate* unmanaged)&_getVarArgsHandle; - callbacks[154] = (delegate* unmanaged)&_canGetVarArgsHandle; - callbacks[155] = (delegate* unmanaged)&_constructStringLiteral; - callbacks[156] = (delegate* unmanaged)&_emptyStringLiteral; - callbacks[157] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; - callbacks[158] = (delegate* unmanaged)&_addActiveDependency; - callbacks[159] = (delegate* unmanaged)&_GetDelegateCtor; - callbacks[160] = (delegate* unmanaged)&_MethodCompileComplete; - callbacks[161] = (delegate* unmanaged)&_getTailCallHelpers; - callbacks[162] = (delegate* unmanaged)&_convertPInvokeCalliToCall; - callbacks[163] = (delegate* unmanaged)&_notifyInstructionSetUsage; - callbacks[164] = (delegate* unmanaged)&_updateEntryPointForTailCall; - callbacks[165] = (delegate* unmanaged)&_allocMem; - callbacks[166] = (delegate* unmanaged)&_reserveUnwindInfo; - callbacks[167] = (delegate* unmanaged)&_allocUnwindInfo; - callbacks[168] = (delegate* unmanaged)&_allocGCInfo; - callbacks[169] = (delegate* unmanaged)&_setEHcount; - callbacks[170] = (delegate* unmanaged)&_setEHinfo; - callbacks[171] = (delegate* unmanaged)&_logMsg; - callbacks[172] = (delegate* unmanaged)&_doAssert; - callbacks[173] = (delegate* unmanaged)&_reportFatalError; - callbacks[174] = (delegate* unmanaged)&_getPgoInstrumentationResults; - callbacks[175] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; - callbacks[176] = (delegate* unmanaged)&_recordCallSite; - callbacks[177] = (delegate* unmanaged)&_recordRelocation; - callbacks[178] = (delegate* unmanaged)&_getRelocTypeHint; - callbacks[179] = (delegate* unmanaged)&_getExpectedTargetArchitecture; - callbacks[180] = (delegate* unmanaged)&_getJitFlags; + callbacks[150] = (delegate* unmanaged)&_getReadonlyStaticFieldValue; + callbacks[151] = (delegate* unmanaged)&_getStaticFieldCurrentClass; + callbacks[152] = (delegate* unmanaged)&_getVarArgsHandle; + callbacks[153] = (delegate* unmanaged)&_canGetVarArgsHandle; + callbacks[154] = (delegate* unmanaged)&_constructStringLiteral; + callbacks[155] = (delegate* unmanaged)&_emptyStringLiteral; + callbacks[156] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; + callbacks[157] = (delegate* unmanaged)&_addActiveDependency; + callbacks[158] = (delegate* unmanaged)&_GetDelegateCtor; + callbacks[159] = (delegate* unmanaged)&_MethodCompileComplete; + callbacks[160] = (delegate* unmanaged)&_getTailCallHelpers; + callbacks[161] = (delegate* unmanaged)&_convertPInvokeCalliToCall; + callbacks[162] = (delegate* unmanaged)&_notifyInstructionSetUsage; + callbacks[163] = (delegate* unmanaged)&_updateEntryPointForTailCall; + callbacks[164] = (delegate* unmanaged)&_allocMem; + callbacks[165] = (delegate* unmanaged)&_reserveUnwindInfo; + callbacks[166] = (delegate* unmanaged)&_allocUnwindInfo; + callbacks[167] = (delegate* unmanaged)&_allocGCInfo; + callbacks[168] = (delegate* unmanaged)&_setEHcount; + callbacks[169] = (delegate* unmanaged)&_setEHinfo; + callbacks[170] = (delegate* unmanaged)&_logMsg; + callbacks[171] = (delegate* unmanaged)&_doAssert; + callbacks[172] = (delegate* unmanaged)&_reportFatalError; + callbacks[173] = (delegate* unmanaged)&_getPgoInstrumentationResults; + callbacks[174] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; + callbacks[175] = (delegate* unmanaged)&_recordCallSite; + callbacks[176] = (delegate* unmanaged)&_recordRelocation; + callbacks[177] = (delegate* unmanaged)&_getRelocTypeHint; + callbacks[178] = (delegate* unmanaged)&_getExpectedTargetArchitecture; + callbacks[179] = (delegate* unmanaged)&_getJitFlags; return (IntPtr)callbacks; } diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index 9be26985000fc..c8c3dab00b643 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -307,7 +307,6 @@ FUNCTIONS bool canAccessFamily(CORINFO_METHOD_HANDLE hCaller, CORINFO_CLASS_HANDLE hInstanceType); bool isRIDClassDomainID(CORINFO_CLASS_HANDLE cls); unsigned getClassDomainID (CORINFO_CLASS_HANDLE cls, void **ppIndirection); - void* getFieldAddress(CORINFO_FIELD_HANDLE field, VOIDSTARSTAR ppIndirection); bool getReadonlyStaticFieldValue(CORINFO_FIELD_HANDLE field, uint8_t *buffer, int bufferSize, int valueOffset, bool ignoreMovableObjects); CORINFO_CLASS_HANDLE getStaticFieldCurrentClass(CORINFO_FIELD_HANDLE field, BoolStar pIsSpeculative); CORINFO_VARARGS_HANDLE getVarArgsHandle(CORINFO_SIG_INFO *pSig, void **ppIndirection); diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs index 263815aa54574..907a6245c5326 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs @@ -1500,6 +1500,10 @@ private void getFieldInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_MET // TODO: Handle the case when the RVA is in the TLS range fieldAccessor = CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_STATIC_RVA_ADDRESS; + ISymbolNode node = _compilation.GetFieldRvaData(field); + pResult->fieldLookup.addr = (void*)ObjectToHandle(node); + pResult->fieldLookup.accessType = node.RepresentsIndirectionCell ? InfoAccessType.IAT_PVALUE : InfoAccessType.IAT_VALUE; + // We are not going through a helper. The constructor has to be triggered explicitly. if (!IsClassPreInited(field.OwningType)) { diff --git a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs index 55c08d549de0b..9911a0f3c21e1 100644 --- a/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs +++ b/src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs @@ -2063,6 +2063,10 @@ private void getFieldInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_MET // TODO: Handle the case when the RVA is in the TLS range fieldAccessor = CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_STATIC_RVA_ADDRESS; + ISymbolNode node = _compilation.GetFieldRvaData(field); + pResult->fieldLookup.addr = (void*)ObjectToHandle(node); + pResult->fieldLookup.accessType = node.RepresentsIndirectionCell ? InfoAccessType.IAT_PVALUE : InfoAccessType.IAT_VALUE; + // We are not going through a helper. The constructor has to be triggered explicitly. if (_compilation.HasLazyStaticConstructor(field.OwningType)) { diff --git a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h index c37d7aff4e907..07789969b0fa1 100644 --- a/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h +++ b/src/coreclr/tools/aot/jitinterface/jitinterface_generated.h @@ -161,7 +161,6 @@ struct JitInterfaceCallbacks bool (* canAccessFamily)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_METHOD_HANDLE hCaller, CORINFO_CLASS_HANDLE hInstanceType); bool (* isRIDClassDomainID)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls); unsigned (* getClassDomainID)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_CLASS_HANDLE cls, void** ppIndirection); - void* (* getFieldAddress)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE field, void** ppIndirection); bool (* getReadonlyStaticFieldValue)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE field, uint8_t* buffer, int bufferSize, int valueOffset, bool ignoreMovableObjects); CORINFO_CLASS_HANDLE (* getStaticFieldCurrentClass)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_FIELD_HANDLE field, bool* pIsSpeculative); CORINFO_VARARGS_HANDLE (* getVarArgsHandle)(void * thisHandle, CorInfoExceptionClass** ppException, CORINFO_SIG_INFO* pSig, void** ppIndirection); @@ -1651,16 +1650,6 @@ class JitInterfaceWrapper : public ICorJitInfo return temp; } - virtual void* getFieldAddress( - CORINFO_FIELD_HANDLE field, - void** ppIndirection) -{ - CorInfoExceptionClass* pException = nullptr; - void* temp = _callbacks->getFieldAddress(_thisHandle, &pException, field, ppIndirection); - if (pException != nullptr) throw pException; - return temp; -} - virtual bool getReadonlyStaticFieldValue( CORINFO_FIELD_HANDLE field, uint8_t* buffer, diff --git a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h index dd66096a5eded..91e5d04af5bc2 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h @@ -198,12 +198,6 @@ struct Agnostic_GetOSRInfo unsigned ilOffset; }; -struct Agnostic_GetFieldAddress -{ - DWORDLONG ppIndirection; - DWORDLONG fieldAddress; -}; - struct Agnostic_GetStaticFieldCurrentClass { DWORDLONG classHandle; diff --git a/src/coreclr/tools/superpmi/superpmi-shared/compileresult.cpp b/src/coreclr/tools/superpmi/superpmi-shared/compileresult.cpp index 327435391fc95..e0cb6a6020e3a 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/compileresult.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/compileresult.cpp @@ -926,7 +926,7 @@ void CompileResult::applyRelocs(RelocContext* rc, unsigned char* block1, ULONG b if (index == -1) { // See if the original address is in the replay address map. This happens for - // relocations on static field addresses found via getFieldAddress(). + // relocations on static field addresses found via getFieldInfo(). void* origAddr = repAddressMap((void*)tmp.target); if ((origAddr != (void*)-1) && (origAddr != nullptr)) { diff --git a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h index 4bb576b284b77..e602fba183951 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h @@ -77,7 +77,6 @@ LWM(GetDefaultEqualityComparerClass, DWORDLONG, DWORDLONG) LWM(GetDelegateCtor, Agnostic_GetDelegateCtorIn, Agnostic_GetDelegateCtorOut) LWM(GetEEInfo, DWORD, Agnostic_CORINFO_EE_INFO) LWM(GetEHinfo, DLD, Agnostic_CORINFO_EH_CLAUSE) -LWM(GetFieldAddress, DWORDLONG, Agnostic_GetFieldAddress) LWM(GetReadonlyStaticFieldValue, DLDDD, DD) LWM(GetStaticFieldCurrentClass, DWORDLONG, Agnostic_GetStaticFieldCurrentClass) LWM(GetFieldClass, DWORDLONG, DWORDLONG) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index fd078673e717d..647746a793fe9 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -3535,40 +3535,6 @@ CORINFO_METHOD_HANDLE MethodContext::repEmbedMethodHandle(CORINFO_METHOD_HANDLE return (CORINFO_METHOD_HANDLE)value.B; } -void MethodContext::recGetFieldAddress(CORINFO_FIELD_HANDLE field, void** ppIndirection, void* result, CorInfoType cit) -{ - if (GetFieldAddress == nullptr) - GetFieldAddress = new LightWeightMap(); - - Agnostic_GetFieldAddress value; - if (ppIndirection == nullptr) - value.ppIndirection = 0; - else - value.ppIndirection = CastPointer(*ppIndirection); - value.fieldAddress = CastPointer(result); - - DWORDLONG key = CastHandle(field); - GetFieldAddress->Add(key, value); - DEBUG_REC(dmpGetFieldAddress(key, value)); -} -void MethodContext::dmpGetFieldAddress(DWORDLONG key, const Agnostic_GetFieldAddress& value) -{ - printf("GetFieldAddress key fld-%016llX, value ppi-%016llX addr-%016llX", key, value.ppIndirection, value.fieldAddress); -} -void* MethodContext::repGetFieldAddress(CORINFO_FIELD_HANDLE field, void** ppIndirection) -{ - DWORDLONG key = CastHandle(field); - Agnostic_GetFieldAddress value = LookupByKeyOrMiss(GetFieldAddress, key, ": key %016llX", key); - - DEBUG_REP(dmpGetFieldAddress(key, value)); - - if (ppIndirection != nullptr) - { - *ppIndirection = (void*)value.ppIndirection; - } - return (void*)value.fieldAddress; -} - void MethodContext::recGetReadonlyStaticFieldValue(CORINFO_FIELD_HANDLE field, uint8_t* buffer, int bufferSize, int valueOffset, bool ignoreMovableObjects, bool result) { if (GetReadonlyStaticFieldValue == nullptr) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h index d943d3f7f3950..941dc009bb533 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.h @@ -488,10 +488,6 @@ class MethodContext void dmpEmbedMethodHandle(DWORDLONG key, DLDL value); CORINFO_METHOD_HANDLE repEmbedMethodHandle(CORINFO_METHOD_HANDLE handle, void** ppIndirection); - void recGetFieldAddress(CORINFO_FIELD_HANDLE field, void** ppIndirection, void* result, CorInfoType cit); - void dmpGetFieldAddress(DWORDLONG key, const Agnostic_GetFieldAddress& value); - void* repGetFieldAddress(CORINFO_FIELD_HANDLE field, void** ppIndirection); - void recGetReadonlyStaticFieldValue(CORINFO_FIELD_HANDLE field, uint8_t* buffer, int bufferSize, int valueOffset, bool ignoreMovableObjects, bool result); void dmpGetReadonlyStaticFieldValue(DLDDD key, DD value); bool repGetReadonlyStaticFieldValue(CORINFO_FIELD_HANDLE field, uint8_t* buffer, int bufferSize, int valueOffset, bool ignoreMovableObjects); @@ -1016,7 +1012,7 @@ enum mcPackets Packet_GetDelegateCtor = 49, Packet_GetEEInfo = 50, Packet_GetEHinfo = 51, - Packet_GetFieldAddress = 52, + //Packet_GetFieldAddress = 52, Packet_GetFieldClass = 53, Packet_GetFieldInClass = 54, Packet_GetFieldInfo = 55, diff --git a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp index 90b5b4d448e92..0beba3442cad2 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -1700,19 +1700,6 @@ unsigned interceptor_ICJI::getClassDomainID(CORINFO_CLASS_HANDLE cls, void** ppI return temp; } -// return the data's address (for static fields only) -void* interceptor_ICJI::getFieldAddress(CORINFO_FIELD_HANDLE field, void** ppIndirection) -{ - mc->cr->AddCall("getFieldAddress"); - void* temp = original_ICorJitInfo->getFieldAddress(field, ppIndirection); - - // Figure out the element type so we know how much we can load - CORINFO_CLASS_HANDLE cch; - CorInfoType cit = getFieldType(field, &cch, NULL); - mc->recGetFieldAddress(field, ppIndirection, temp, cit); - return temp; -} - bool interceptor_ICJI::getReadonlyStaticFieldValue(CORINFO_FIELD_HANDLE field, uint8_t* buffer, int bufferSize, int valueOffset, bool ignoreMovableObjects) { mc->cr->AddCall("getReadonlyStaticFieldValue"); diff --git a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp index 9bea437e950ef..1c35b1a78cdf3 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp @@ -1208,14 +1208,6 @@ unsigned interceptor_ICJI::getClassDomainID( return original_ICorJitInfo->getClassDomainID(cls, ppIndirection); } -void* interceptor_ICJI::getFieldAddress( - CORINFO_FIELD_HANDLE field, - void** ppIndirection) -{ - mcs->AddCall("getFieldAddress"); - return original_ICorJitInfo->getFieldAddress(field, ppIndirection); -} - bool interceptor_ICJI::getReadonlyStaticFieldValue( CORINFO_FIELD_HANDLE field, uint8_t* buffer, diff --git a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp index b9c55b95d98d0..ae2629141d870 100644 --- a/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp @@ -1058,13 +1058,6 @@ unsigned interceptor_ICJI::getClassDomainID( return original_ICorJitInfo->getClassDomainID(cls, ppIndirection); } -void* interceptor_ICJI::getFieldAddress( - CORINFO_FIELD_HANDLE field, - void** ppIndirection) -{ - return original_ICorJitInfo->getFieldAddress(field, ppIndirection); -} - bool interceptor_ICJI::getReadonlyStaticFieldValue( CORINFO_FIELD_HANDLE field, uint8_t* buffer, diff --git a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp index 9dc9f922b527e..fb0ed8f01b6b2 100644 --- a/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/tools/superpmi/superpmi/icorjitinfo.cpp @@ -1481,13 +1481,6 @@ unsigned MyICJI::getClassDomainID(CORINFO_CLASS_HANDLE cls, void** ppIndirection return jitInstance->mc->repGetClassDomainID(cls, ppIndirection); } -// return the data's address (for static fields only) -void* MyICJI::getFieldAddress(CORINFO_FIELD_HANDLE field, void** ppIndirection) -{ - jitInstance->mc->cr->AddCall("getFieldAddress"); - return jitInstance->mc->repGetFieldAddress(field, ppIndirection); -} - bool MyICJI::getReadonlyStaticFieldValue(CORINFO_FIELD_HANDLE field, uint8_t* buffer, int bufferSize, int valueOffset, bool ignoreMovableObjects) { jitInstance->mc->cr->AddCall("getReadonlyStaticFieldValue"); diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 5bc558cd3db1f..7c675d1a38957 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -1480,6 +1480,8 @@ void CEEInfo::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken, DWORD fieldFlags = 0; pResult->offset = pField->GetOffset(); + pResult->fieldLookup.addr = nullptr; + if (pField->IsStatic()) { fieldFlags |= CORINFO_FLG_FIELD_STATIC; @@ -1502,10 +1504,12 @@ void CEEInfo::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken, else { fieldAccessor = CORINFO_FIELD_STATIC_RVA_ADDRESS; + pResult->fieldLookup.addr = pField->GetStaticAddressHandle(NULL); + pResult->fieldLookup.accessType = IAT_VALUE; } // We are not going through a helper. The constructor has to be triggered explicitly. - if (!pFieldMT->IsClassPreInited()) + if (!pFieldMT->IsClassInited()) fieldFlags |= CORINFO_FLG_FIELD_INITCLASS; } else @@ -1545,9 +1549,19 @@ void CEEInfo::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken, { fieldAccessor = CORINFO_FIELD_STATIC_ADDRESS; + // Allocate space for the local class if necessary, but don't trigger + // class construction. + DomainLocalModule* pLocalModule = pFieldMT->GetDomainLocalModule(); + pLocalModule->PopulateClass(pFieldMT); + // We are not going through a helper. The constructor has to be triggered explicitly. - if (!pFieldMT->IsClassPreInited()) + if (!pFieldMT->IsClassInited()) fieldFlags |= CORINFO_FLG_FIELD_INITCLASS; + + GCX_COOP(); + + pResult->fieldLookup.addr = pField->GetStaticAddressHandle((void*)pField->GetBase()); + pResult->fieldLookup.accessType = IAT_VALUE; } } @@ -11908,54 +11922,6 @@ InfoAccessType CEEJitInfo::emptyStringLiteral(void ** ppValue) return result; } -/*********************************************************************/ -void* CEEJitInfo::getFieldAddress(CORINFO_FIELD_HANDLE fieldHnd, - void **ppIndirection) -{ - CONTRACTL { - THROWS; - GC_TRIGGERS; - MODE_PREEMPTIVE; - } CONTRACTL_END; - - void *result = NULL; - - if (ppIndirection != NULL) - *ppIndirection = NULL; - - JIT_TO_EE_TRANSITION(); - - FieldDesc* field = (FieldDesc*) fieldHnd; - - MethodTable* pMT = field->GetEnclosingMethodTable(); - - _ASSERTE(!pMT->ContainsGenericVariables()); - - void *base = NULL; - - if (!field->IsRVA()) - { - // @todo: assert that the current method being compiled is unshared - // We must not call here for statics of collectible types. - _ASSERTE(!pMT->Collectible()); - - // Allocate space for the local class if necessary, but don't trigger - // class construction. - DomainLocalModule *pLocalModule = pMT->GetDomainLocalModule(); - pLocalModule->PopulateClass(pMT); - - GCX_COOP(); - - base = (void *) field->GetBase(); - } - - result = field->GetStaticAddressHandle(base); - - EE_TO_JIT_TRANSITION(); - - return result; -} - bool CEEInfo::getReadonlyStaticFieldValue(CORINFO_FIELD_HANDLE fieldHnd, uint8_t* buffer, int bufferSize, int valueOffset, bool ignoreMovableObjects) { CONTRACTL { @@ -14518,33 +14484,6 @@ InfoAccessType CEEInfo::emptyStringLiteral(void ** ppValue) UNREACHABLE(); // only called on derived class. } -void* CEEInfo::getFieldAddress(CORINFO_FIELD_HANDLE fieldHnd, - void **ppIndirection) -{ - CONTRACTL{ - THROWS; - GC_TRIGGERS; - MODE_PREEMPTIVE; - } CONTRACTL_END; - - void *result = NULL; - - if (ppIndirection != NULL) - *ppIndirection = NULL; - - JIT_TO_EE_TRANSITION(); - - FieldDesc* field = (FieldDesc*)fieldHnd; - - _ASSERTE(field->IsRVA()); - - result = field->GetStaticAddressHandle(NULL); - - EE_TO_JIT_TRANSITION(); - - return result; -} - CORINFO_CLASS_HANDLE CEEInfo::getStaticFieldCurrentClass(CORINFO_FIELD_HANDLE fieldHnd, bool* pIsSpeculative) { diff --git a/src/coreclr/vm/jitinterface.h b/src/coreclr/vm/jitinterface.h index c0fcb0a92fb72..4460c413b76e6 100644 --- a/src/coreclr/vm/jitinterface.h +++ b/src/coreclr/vm/jitinterface.h @@ -944,7 +944,6 @@ class CEEJitInfo : public CEEInfo InfoAccessType constructStringLiteral(CORINFO_MODULE_HANDLE scopeHnd, mdToken metaTok, void **ppValue) override final; InfoAccessType emptyStringLiteral(void ** ppValue) override final; - void* getFieldAddress(CORINFO_FIELD_HANDLE field, void **ppIndirection) override final; CORINFO_CLASS_HANDLE getStaticFieldCurrentClass(CORINFO_FIELD_HANDLE field, bool* pIsSpeculative) override final; void* getMethodSync(CORINFO_METHOD_HANDLE ftnHnd, void **ppIndirection) override final;