Skip to content

Commit 0de4f60

Browse files
authored
Revert "Allocate boxed static structs on Frozen Object Heap and remove getFieldAddress (#77737)" (#78296)
This reverts commit cabb8b0.
1 parent b6deba5 commit 0de4f60

39 files changed

+515
-293
lines changed

src/coreclr/inc/CrstTypes.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,3 @@ End
577577
Crst PgoData
578578
AcquiredBefore LoaderHeap
579579
End
580-
581-
Crst StaticBoxInit
582-
AcquiredBefore LoaderHeap FrozenObjectHeap
583-
End

src/coreclr/inc/corinfo.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ The first 4 options are mutually exclusive
141141
have managed thread local statics, which work through the HELPER. Support for this is considered
142142
legacy, and going forward, the EE should
143143
144-
* <NONE> This is a normal static field. Its address in memory is determined by getFieldInfo. (see
144+
* <NONE> This is a normal static field. Its address in memory is determined by getFieldAddress. (see
145145
also CORINFO_FLG_STATIC_IN_HEAP).
146146
147147
@@ -1719,7 +1719,7 @@ struct CORINFO_FIELD_INFO
17191719
CorInfoIsAccessAllowedResult accessAllowed;
17201720
CORINFO_HELPER_DESC accessCalloutHelper;
17211721

1722-
CORINFO_CONST_LOOKUP fieldLookup;
1722+
CORINFO_CONST_LOOKUP fieldLookup; // Used by Ready-to-Run
17231723
};
17241724

17251725
//----------------------------------------------------------------------------
@@ -3200,6 +3200,13 @@ class ICorDynamicInfo : public ICorStaticInfo
32003200
void **ppIndirection = NULL
32013201
) = 0;
32023202

3203+
3204+
// return the data's address (for static fields only)
3205+
virtual void* getFieldAddress(
3206+
CORINFO_FIELD_HANDLE field,
3207+
void **ppIndirection = NULL
3208+
) = 0;
3209+
32033210
//------------------------------------------------------------------------------
32043211
// getReadonlyStaticFieldValue: returns true and the actual field's value if the given
32053212
// field represents a statically initialized readonly field of any type.

src/coreclr/inc/crsttypes_generated.h

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -112,29 +112,28 @@ enum CrstType
112112
CrstSingleUseLock = 94,
113113
CrstSpecialStatics = 95,
114114
CrstStackSampler = 96,
115-
CrstStaticBoxInit = 97,
116-
CrstStressLog = 98,
117-
CrstStubCache = 99,
118-
CrstStubDispatchCache = 100,
119-
CrstStubUnwindInfoHeapSegments = 101,
120-
CrstSyncBlockCache = 102,
121-
CrstSyncHashLock = 103,
122-
CrstSystemBaseDomain = 104,
123-
CrstSystemDomain = 105,
124-
CrstSystemDomainDelayedUnloadList = 106,
125-
CrstThreadIdDispenser = 107,
126-
CrstThreadStore = 108,
127-
CrstTieredCompilation = 109,
128-
CrstTypeEquivalenceMap = 110,
129-
CrstTypeIDMap = 111,
130-
CrstUMEntryThunkCache = 112,
131-
CrstUMEntryThunkFreeListLock = 113,
132-
CrstUniqueStack = 114,
133-
CrstUnresolvedClassLock = 115,
134-
CrstUnwindInfoTableLock = 116,
135-
CrstVSDIndirectionCellLock = 117,
136-
CrstWrapperTemplate = 118,
137-
kNumberOfCrstTypes = 119
115+
CrstStressLog = 97,
116+
CrstStubCache = 98,
117+
CrstStubDispatchCache = 99,
118+
CrstStubUnwindInfoHeapSegments = 100,
119+
CrstSyncBlockCache = 101,
120+
CrstSyncHashLock = 102,
121+
CrstSystemBaseDomain = 103,
122+
CrstSystemDomain = 104,
123+
CrstSystemDomainDelayedUnloadList = 105,
124+
CrstThreadIdDispenser = 106,
125+
CrstThreadStore = 107,
126+
CrstTieredCompilation = 108,
127+
CrstTypeEquivalenceMap = 109,
128+
CrstTypeIDMap = 110,
129+
CrstUMEntryThunkCache = 111,
130+
CrstUMEntryThunkFreeListLock = 112,
131+
CrstUniqueStack = 113,
132+
CrstUnresolvedClassLock = 114,
133+
CrstUnwindInfoTableLock = 115,
134+
CrstVSDIndirectionCellLock = 116,
135+
CrstWrapperTemplate = 117,
136+
kNumberOfCrstTypes = 118
138137
};
139138

140139
#endif // __CRST_TYPES_INCLUDED
@@ -242,7 +241,6 @@ int g_rgCrstLevelMap[] =
242241
5, // CrstSingleUseLock
243242
0, // CrstSpecialStatics
244243
0, // CrstStackSampler
245-
-1, // CrstStaticBoxInit
246244
-1, // CrstStressLog
247245
5, // CrstStubCache
248246
0, // CrstStubDispatchCache
@@ -366,7 +364,6 @@ LPCSTR g_rgCrstNameMap[] =
366364
"CrstSingleUseLock",
367365
"CrstSpecialStatics",
368366
"CrstStackSampler",
369-
"CrstStaticBoxInit",
370367
"CrstStressLog",
371368
"CrstStubCache",
372369
"CrstStubDispatchCache",

src/coreclr/inc/icorjitinfoimpl_generated.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,10 @@ unsigned getClassDomainID(
616616
CORINFO_CLASS_HANDLE cls,
617617
void** ppIndirection) override;
618618

619+
void* getFieldAddress(
620+
CORINFO_FIELD_HANDLE field,
621+
void** ppIndirection) override;
622+
619623
bool getReadonlyStaticFieldValue(
620624
CORINFO_FIELD_HANDLE field,
621625
uint8_t* buffer,

src/coreclr/inc/jiteeversionguid.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
4343
#define GUID_DEFINED
4444
#endif // !GUID_DEFINED
4545

46-
constexpr GUID JITEEVersionIdentifier = { /* c0c94f6c-5358-4a3d-be83-b2a9d1b2545e */
47-
0xc0c94f6c,
48-
0x5358,
49-
0x4a3d,
50-
{0xbe, 0x83, 0xb2, 0xa9, 0xd1, 0xb2, 0x54, 0x5e}
46+
constexpr GUID JITEEVersionIdentifier = { /* e3c98d96-6e67-459a-9750-ebe799cfb788 */
47+
0xe3c98d96,
48+
0x6e67,
49+
0x459a,
50+
{0x97, 0x50, 0xeb, 0xe7, 0x99, 0xcf, 0xb7, 0x88}
5151
};
5252

5353
//////////////////////////////////////////////////////////////////////////////////////////////////////////

src/coreclr/jit/ICorJitInfo_names_generated.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ DEF_CLR_API(getCallInfo)
155155
DEF_CLR_API(canAccessFamily)
156156
DEF_CLR_API(isRIDClassDomainID)
157157
DEF_CLR_API(getClassDomainID)
158+
DEF_CLR_API(getFieldAddress)
158159
DEF_CLR_API(getReadonlyStaticFieldValue)
159160
DEF_CLR_API(getStaticFieldCurrentClass)
160161
DEF_CLR_API(getVarArgsHandle)

src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,16 @@ unsigned WrapICorJitInfo::getClassDomainID(
14791479
return temp;
14801480
}
14811481

1482+
void* WrapICorJitInfo::getFieldAddress(
1483+
CORINFO_FIELD_HANDLE field,
1484+
void** ppIndirection)
1485+
{
1486+
API_ENTER(getFieldAddress);
1487+
void* temp = wrapHnd->getFieldAddress(field, ppIndirection);
1488+
API_LEAVE(getFieldAddress);
1489+
return temp;
1490+
}
1491+
14821492
bool WrapICorJitInfo::getReadonlyStaticFieldValue(
14831493
CORINFO_FIELD_HANDLE field,
14841494
uint8_t* buffer,

src/coreclr/jit/assertionprop.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3197,7 +3197,8 @@ GenTree* Compiler::optVNConstantPropOnTree(BasicBlock* block, GenTree* tree)
31973197

31983198
case TYP_SIMD32:
31993199
{
3200-
simd32_t value = vnStore->ConstantValue<simd32_t>(vnCns);
3200+
simd32_t value = vnStore->ConstantValue<simd32_t>(vnCns);
3201+
32013202
GenTreeVecCon* vecCon = gtNewVconNode(tree->TypeGet());
32023203
vecCon->gtSimd32Val = value;
32033204

src/coreclr/jit/compiler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5733,6 +5733,7 @@ class Compiler
57335733
GenTree* fgMorphField(GenTree* tree, MorphAddrContext* mac);
57345734
GenTree* fgMorphExpandInstanceField(GenTree* tree, MorphAddrContext* mac);
57355735
GenTree* fgMorphExpandTlsFieldAddr(GenTree* tree);
5736+
GenTree* fgMorphExpandStaticField(GenTree* tree);
57365737
bool fgCanFastTailCall(GenTreeCall* call, const char** failReason);
57375738
#if FEATURE_FASTTAILCALL
57385739
bool fgCallHasMustCopyByrefParameter(GenTreeCall* callee);

src/coreclr/jit/emitarm.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4012,7 +4012,10 @@ void emitter::emitIns_R_C(instruction ins, emitAttr attr, regNumber reg, CORINFO
40124012
}
40134013
else
40144014
{
4015-
assert(!"Normal statics are expected to be handled in the importer");
4015+
assert(!jitStaticFldIsGlobAddr(fldHnd));
4016+
addr = (ssize_t)emitComp->info.compCompHnd->getFieldAddress(fldHnd, NULL);
4017+
if (addr == NULL)
4018+
NO_WAY("could not obtain address of static field");
40164019
}
40174020

40184021
// We can use reg to load the constant address,

0 commit comments

Comments
 (0)