Skip to content

Commit cabb8b0

Browse files
EgorBojkotas
andauthored
Allocate boxed static structs on Frozen Object Heap and remove getFieldAddress (#77737)
Co-authored-by: Jan Kotas <[email protected]>
1 parent cc712fd commit cabb8b0

39 files changed

+293
-515
lines changed

src/coreclr/inc/CrstTypes.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,3 +577,7 @@ 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: 2 additions & 9 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 getFieldAddress. (see
144+
* <NONE> This is a normal static field. Its address in memory is determined by getFieldInfo. (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; // Used by Ready-to-Run
1722+
CORINFO_CONST_LOOKUP fieldLookup;
17231723
};
17241724

17251725
//----------------------------------------------------------------------------
@@ -3200,13 +3200,6 @@ 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-
32103203
//------------------------------------------------------------------------------
32113204
// getReadonlyStaticFieldValue: returns true and the actual field's value if the given
32123205
// field represents a statically initialized readonly field of any type.

src/coreclr/inc/crsttypes_generated.h

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,28 +112,29 @@ enum CrstType
112112
CrstSingleUseLock = 94,
113113
CrstSpecialStatics = 95,
114114
CrstStackSampler = 96,
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
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
137138
};
138139

139140
#endif // __CRST_TYPES_INCLUDED
@@ -241,6 +242,7 @@ int g_rgCrstLevelMap[] =
241242
5, // CrstSingleUseLock
242243
0, // CrstSpecialStatics
243244
0, // CrstStackSampler
245+
-1, // CrstStaticBoxInit
244246
-1, // CrstStressLog
245247
5, // CrstStubCache
246248
0, // CrstStubDispatchCache
@@ -364,6 +366,7 @@ LPCSTR g_rgCrstNameMap[] =
364366
"CrstSingleUseLock",
365367
"CrstSpecialStatics",
366368
"CrstStackSampler",
369+
"CrstStaticBoxInit",
367370
"CrstStressLog",
368371
"CrstStubCache",
369372
"CrstStubDispatchCache",

src/coreclr/inc/icorjitinfoimpl_generated.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,6 @@ 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-
623619
bool getReadonlyStaticFieldValue(
624620
CORINFO_FIELD_HANDLE field,
625621
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 = { /* e452af1d-0a1a-44a8-a5b3-ef6074b8ab4a */
47-
0xe452af1d,
48-
0x0a1a,
49-
0x44a8,
50-
{0xa5, 0xb3, 0xef, 0x60, 0x74, 0xb8, 0xab, 0x4a}
46+
constexpr GUID JITEEVersionIdentifier = { /* c0c94f6c-5358-4a3d-be83-b2a9d1b2545e */
47+
0xc0c94f6c,
48+
0x5358,
49+
0x4a3d,
50+
{0xbe, 0x83, 0xb2, 0xa9, 0xd1, 0xb2, 0x54, 0x5e}
5151
};
5252

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

src/coreclr/jit/ICorJitInfo_names_generated.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ DEF_CLR_API(getCallInfo)
155155
DEF_CLR_API(canAccessFamily)
156156
DEF_CLR_API(isRIDClassDomainID)
157157
DEF_CLR_API(getClassDomainID)
158-
DEF_CLR_API(getFieldAddress)
159158
DEF_CLR_API(getReadonlyStaticFieldValue)
160159
DEF_CLR_API(getStaticFieldCurrentClass)
161160
DEF_CLR_API(getVarArgsHandle)

src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,16 +1479,6 @@ 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-
14921482
bool WrapICorJitInfo::getReadonlyStaticFieldValue(
14931483
CORINFO_FIELD_HANDLE field,
14941484
uint8_t* buffer,

src/coreclr/jit/assertionprop.cpp

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

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

src/coreclr/jit/compiler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5733,7 +5733,6 @@ 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);
57375736
bool fgCanFastTailCall(GenTreeCall* call, const char** failReason);
57385737
#if FEATURE_FASTTAILCALL
57395738
bool fgCallHasMustCopyByrefParameter(GenTreeCall* callee);

src/coreclr/jit/emitarm.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4012,10 +4012,7 @@ void emitter::emitIns_R_C(instruction ins, emitAttr attr, regNumber reg, CORINFO
40124012
}
40134013
else
40144014
{
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");
4015+
assert(!"Normal statics are expected to be handled in the importer");
40194016
}
40204017

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

0 commit comments

Comments
 (0)