Skip to content

Commit c635ae2

Browse files
BrianBoheBrian BohejakobbotschMichalStrehovsky
authored
Adding new ReadyToRun helper for static cctor (#76898)
* Adding new ReadyToRun helper for static cctor When accessing a static field the static cctor of the class is called. Then the helper CORINFO_HELP_READYTORUN_STATIC_BASE was printed twice during the same block, the first for the cctor and the second for the getter, as if they were two calls for the same method. * Removing helper CORINFO_HELP_STRCNS_CURRENT_MODULE * Removing CORINFO_HELP_STRCNS_CURRENT_MODULE * Changing TYP_BYREF to TYP_VOID * Formatting files * Splitting up R2R STATIC_BASE in more helpers * Updating STATIC_BASE R2R helper with new helpers * Extending getReadyToRunHelper support Consider the new R2R helpers that were group in CORINFO_HELP_READYTORUN_STATIC_BASE. * Keeping the preffered R2R helper constructor In some cases the R2R helpers already call to the constructor. In those cases we can insert a repeated call that will be eliminated by CSE. There are still cases in which we may need to call the constructor. * Extending value numbering with new helpers * Renaming helper * Replacing STATIC_BASE helper in ilc for NON_GC * Fixing helper order * Refactoring code * Supporting R2R_STATIC_BASE helper in nativeaot * Moving compiler var initialization to compCompile * Using new helper names in ILC * Encapsulating common method * Removing CORINFO_HELP_READYTORUN_STATIC_BASE helper * Removing comment * Moving new helper function to shared code * Setting undef helper as default * Repeating same helper call for CSE optimization Avoid hardcoding the Non-GC helper call, which is used just to trigger the constructor if it is needed, and use the existing helper call in the code, so CSE would persist only one. * Update src/coreclr/jit/compiler.cpp Co-authored-by: Jakob Botsch Nielsen <[email protected]> * Update src/coreclr/tools/Common/Compiler/DependencyAnalysis/CorInfoHelpers.cs Co-authored-by: Jakob Botsch Nielsen <[email protected]> * Update src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs Co-authored-by: Michal Strehovský <[email protected]> * Update src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs Co-authored-by: Michal Strehovský <[email protected]> * Formatting jithelpers.h * Renaming function * Moving CorInfoHelper function to R2R/AOT interface * Updating preferred helper when is not thread type * Removing some helper value nums Static base helper was removed and cctor returns void. * Formatting file * Ensuring void return when the helper is cctor * Updating preferred helper when when classes matches * Removing cctor trigger helper from aot,vm and jit * Updating m_prefferedInitCctor default value It is initialized with CORINFO_HELP_UNDEF and set to R2R GC or NON GC Static Base later. * Updating comments * Updating comments Co-authored-by: Brian Bohe <[email protected]> Co-authored-by: Jakob Botsch Nielsen <[email protected]> Co-authored-by: Michal Strehovský <[email protected]>
1 parent ba3ee73 commit c635ae2

File tree

16 files changed

+138
-47
lines changed

16 files changed

+138
-47
lines changed

src/coreclr/inc/corinfo.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ enum CorInfoHelpFunc
416416
CORINFO_HELP_NEWARR_1_ALIGN8, // like VC, but aligns the array start
417417

418418
CORINFO_HELP_STRCNS, // create a new string literal
419-
CORINFO_HELP_STRCNS_CURRENT_MODULE, // create a new string literal from the current module (used by NGen code)
420419

421420
/* Object model */
422421

@@ -591,7 +590,10 @@ enum CorInfoHelpFunc
591590
CORINFO_HELP_READYTORUN_NEWARR_1,
592591
CORINFO_HELP_READYTORUN_ISINSTANCEOF,
593592
CORINFO_HELP_READYTORUN_CHKCAST,
594-
CORINFO_HELP_READYTORUN_STATIC_BASE,
593+
CORINFO_HELP_READYTORUN_GCSTATIC_BASE, // static gc field access
594+
CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE, // static non gc field access
595+
CORINFO_HELP_READYTORUN_THREADSTATIC_BASE,
596+
CORINFO_HELP_READYTORUN_NONGCTHREADSTATIC_BASE,
595597
CORINFO_HELP_READYTORUN_VIRTUAL_FUNC_PTR,
596598
CORINFO_HELP_READYTORUN_GENERIC_HANDLE,
597599
CORINFO_HELP_READYTORUN_DELEGATE_CTOR,

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 = { /* aaa9536e-1295-4741-a7d9-6c09a5b01512 */
47-
0xaaa9536e,
48-
0x1295,
49-
0x4741,
50-
{0xa7, 0xd9, 0x6c, 0x9, 0xa5, 0xb0, 0x15, 0x12}
46+
constexpr GUID JITEEVersionIdentifier = { /* fd13d4e1-9815-4336-8232-b27878b9ebd4 */
47+
0xfd13d4e1,
48+
0x9815,
49+
0x4336,
50+
{0x82, 0x32, 0xb2, 0x78, 0x78, 0xb9, 0xeb, 0xd4}
5151
};
5252

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

src/coreclr/inc/jithelpers.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
DYNAMICJITHELPER(CORINFO_HELP_NEWARR_1_ALIGN8, JIT_NewArr1,CORINFO_HELP_SIG_REG_ONLY)
8383

8484
JITHELPER(CORINFO_HELP_STRCNS, JIT_StrCns, CORINFO_HELP_SIG_REG_ONLY)
85-
JITHELPER(CORINFO_HELP_STRCNS_CURRENT_MODULE, NULL, CORINFO_HELP_SIG_REG_ONLY)
8685

8786
// Object model
8887
JITHELPER(CORINFO_HELP_INITCLASS, JIT_InitClass, CORINFO_HELP_SIG_REG_ONLY)
@@ -259,7 +258,10 @@
259258
JITHELPER(CORINFO_HELP_READYTORUN_NEWARR_1, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB)
260259
JITHELPER(CORINFO_HELP_READYTORUN_ISINSTANCEOF, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB)
261260
JITHELPER(CORINFO_HELP_READYTORUN_CHKCAST, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB)
262-
JITHELPER(CORINFO_HELP_READYTORUN_STATIC_BASE, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB)
261+
JITHELPER(CORINFO_HELP_READYTORUN_GCSTATIC_BASE, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB)
262+
JITHELPER(CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB)
263+
JITHELPER(CORINFO_HELP_READYTORUN_THREADSTATIC_BASE, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB)
264+
JITHELPER(CORINFO_HELP_READYTORUN_NONGCTHREADSTATIC_BASE, NULL,CORINFO_HELP_SIG_NO_ALIGN_STUB)
263265
JITHELPER(CORINFO_HELP_READYTORUN_VIRTUAL_FUNC_PTR, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB)
264266
JITHELPER(CORINFO_HELP_READYTORUN_GENERIC_HANDLE, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB)
265267
JITHELPER(CORINFO_HELP_READYTORUN_DELEGATE_CTOR, NULL, CORINFO_HELP_SIG_NO_ALIGN_STUB)

src/coreclr/jit/compiler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,6 +1968,8 @@ void Compiler::compInit(ArenaAllocator* pAlloc,
19681968
#endif // FEATURE_SIMD
19691969

19701970
compUsesThrowHelper = false;
1971+
1972+
m_preferredInitCctor = CORINFO_HELP_UNDEF;
19711973
}
19721974

19731975
/*****************************************************************************

src/coreclr/jit/compiler.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4661,6 +4661,12 @@ class Compiler
46614661
PhaseStatus placeLoopAlignInstructions();
46624662
#endif
46634663

4664+
// This field keep the R2R helper call that would be inserted to trigger the constructor
4665+
// of the static class. It is set as nongc or gc static base if they are imported, so
4666+
// CSE can eliminate the repeated call, or the chepeast helper function that triggers it.
4667+
CorInfoHelpFunc m_preferredInitCctor;
4668+
void fgSetPreferredInitCctor();
4669+
46644670
GenTree* fgInitThisClass();
46654671

46664672
GenTreeCall* fgGetStaticsCCtorHelper(CORINFO_CLASS_HANDLE cls, CorInfoHelpFunc helper);

src/coreclr/jit/compiler.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3597,7 +3597,9 @@ inline bool Compiler::IsSharedStaticHelper(GenTree* tree)
35973597
helper == CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_DYNAMICCLASS ||
35983598
helper == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_DYNAMICCLASS ||
35993599
#ifdef FEATURE_READYTORUN
3600-
helper == CORINFO_HELP_READYTORUN_STATIC_BASE || helper == CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE ||
3600+
helper == CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE || helper == CORINFO_HELP_READYTORUN_GCSTATIC_BASE ||
3601+
helper == CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE || helper == CORINFO_HELP_READYTORUN_THREADSTATIC_BASE ||
3602+
helper == CORINFO_HELP_READYTORUN_NONGCTHREADSTATIC_BASE ||
36013603
#endif
36023604
helper == CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS;
36033605
#if 0

src/coreclr/jit/flowgraph.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,19 @@ GenTreeCall* Compiler::fgGetStaticsCCtorHelper(CORINFO_CLASS_HANDLE cls, CorInfo
885885
return result;
886886
}
887887

888+
//------------------------------------------------------------------------------
889+
// fgSetPreferredInitCctor: Set CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE as the
890+
// preferred call constructure if it is undefined.
891+
//
892+
void Compiler::fgSetPreferredInitCctor()
893+
{
894+
if (m_preferredInitCctor == CORINFO_HELP_UNDEF)
895+
{
896+
// This is the cheapest helper that triggers the constructor.
897+
m_preferredInitCctor = CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE;
898+
}
899+
}
900+
888901
GenTreeCall* Compiler::fgGetSharedCCtor(CORINFO_CLASS_HANDLE cls)
889902
{
890903
#ifdef FEATURE_READYTORUN
@@ -893,8 +906,8 @@ GenTreeCall* Compiler::fgGetSharedCCtor(CORINFO_CLASS_HANDLE cls)
893906
CORINFO_RESOLVED_TOKEN resolvedToken;
894907
memset(&resolvedToken, 0, sizeof(resolvedToken));
895908
resolvedToken.hClass = cls;
896-
897-
return impReadyToRunHelperToTree(&resolvedToken, CORINFO_HELP_READYTORUN_STATIC_BASE, TYP_BYREF);
909+
fgSetPreferredInitCctor();
910+
return impReadyToRunHelperToTree(&resolvedToken, m_preferredInitCctor, TYP_BYREF);
898911
}
899912
#endif
900913

src/coreclr/jit/importer.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4277,7 +4277,13 @@ GenTree* Compiler::impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolvedT
42774277
callFlags |= GTF_CALL_HOISTABLE;
42784278
}
42794279

4280-
op1 = gtNewHelperCallNode(CORINFO_HELP_READYTORUN_STATIC_BASE, TYP_BYREF);
4280+
op1 = gtNewHelperCallNode(pFieldInfo->helper, TYP_BYREF);
4281+
if (pResolvedToken->hClass == info.compClassHnd && m_preferredInitCctor == CORINFO_HELP_UNDEF &&
4282+
(pFieldInfo->helper == CORINFO_HELP_READYTORUN_GCSTATIC_BASE ||
4283+
pFieldInfo->helper == CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE))
4284+
{
4285+
m_preferredInitCctor = pFieldInfo->helper;
4286+
}
42814287
op1->gtFlags |= callFlags;
42824288

42834289
op1->AsCall()->setEntryPoint(pFieldInfo->fieldLookup);

src/coreclr/jit/morph.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8369,18 +8369,9 @@ GenTree* Compiler::fgMorphConst(GenTree* tree)
83698369
{
83708370
// For un-important blocks, we want to construct the string lazily
83718371

8372-
if (helper == CORINFO_HELP_STRCNS_CURRENT_MODULE)
8373-
{
8374-
tree = gtNewHelperCallNode(helper, TYP_REF,
8375-
gtNewIconNode(RidFromToken(tree->AsStrCon()->gtSconCPX), TYP_INT));
8376-
}
8377-
else
8378-
{
8379-
tree = gtNewHelperCallNode(helper, TYP_REF,
8380-
gtNewIconNode(RidFromToken(tree->AsStrCon()->gtSconCPX), TYP_INT),
8381-
gtNewIconEmbScpHndNode(tree->AsStrCon()->gtScpHnd));
8382-
}
8383-
8372+
tree =
8373+
gtNewHelperCallNode(helper, TYP_REF, gtNewIconNode(RidFromToken(tree->AsStrCon()->gtSconCPX), TYP_INT),
8374+
gtNewIconEmbScpHndNode(tree->AsStrCon()->gtScpHnd));
83848375
return fgMorphTree(tree);
83858376
}
83868377
}
@@ -14312,7 +14303,8 @@ GenTree* Compiler::fgInitThisClass()
1431214303
if (!(info.compClassAttr & CORINFO_FLG_SHAREDINST))
1431314304
{
1431414305
resolvedToken.hClass = info.compClassHnd;
14315-
return impReadyToRunHelperToTree(&resolvedToken, CORINFO_HELP_READYTORUN_STATIC_BASE, TYP_BYREF);
14306+
fgSetPreferredInitCctor();
14307+
return impReadyToRunHelperToTree(&resolvedToken, m_preferredInitCctor, TYP_BYREF);
1431614308
}
1431714309

1431814310
// We need a runtime lookup.

src/coreclr/jit/utils.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,10 @@ void HelperCallProperties::init()
13991399
case CORINFO_HELP_GETSTATICFIELDADDR_TLS:
14001400
case CORINFO_HELP_GETGENERICS_GCSTATIC_BASE:
14011401
case CORINFO_HELP_GETGENERICS_NONGCSTATIC_BASE:
1402-
case CORINFO_HELP_READYTORUN_STATIC_BASE:
1402+
case CORINFO_HELP_READYTORUN_GCSTATIC_BASE:
1403+
case CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE:
1404+
case CORINFO_HELP_READYTORUN_THREADSTATIC_BASE:
1405+
case CORINFO_HELP_READYTORUN_NONGCTHREADSTATIC_BASE:
14031406
case CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE:
14041407

14051408
// These may invoke static class constructors

src/coreclr/jit/valuenum.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10194,7 +10194,10 @@ void Compiler::fgValueNumberHelperCallFunc(GenTreeCall* call, VNFunc vnf, ValueN
1019410194
}
1019510195
break;
1019610196

10197-
case VNF_ReadyToRunStaticBase:
10197+
case VNF_ReadyToRunStaticBaseGC:
10198+
case VNF_ReadyToRunStaticBaseNonGC:
10199+
case VNF_ReadyToRunStaticBaseThread:
10200+
case VNF_ReadyToRunStaticBaseThreadNonGC:
1019810201
case VNF_ReadyToRunGenericStaticBase:
1019910202
case VNF_ReadyToRunIsInstanceOf:
1020010203
case VNF_ReadyToRunCastClass:
@@ -10555,8 +10558,17 @@ VNFunc Compiler::fgValueNumberJitHelperMethodVNFunc(CorInfoHelpFunc helpFunc)
1055510558
case CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE_NOCTOR:
1055610559
vnf = VNF_GetsharedNongcstaticBaseNoctor;
1055710560
break;
10558-
case CORINFO_HELP_READYTORUN_STATIC_BASE:
10559-
vnf = VNF_ReadyToRunStaticBase;
10561+
case CORINFO_HELP_READYTORUN_GCSTATIC_BASE:
10562+
vnf = VNF_ReadyToRunStaticBaseGC;
10563+
break;
10564+
case CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE:
10565+
vnf = VNF_ReadyToRunStaticBaseNonGC;
10566+
break;
10567+
case CORINFO_HELP_READYTORUN_THREADSTATIC_BASE:
10568+
vnf = VNF_ReadyToRunStaticBaseThread;
10569+
break;
10570+
case CORINFO_HELP_READYTORUN_NONGCTHREADSTATIC_BASE:
10571+
vnf = VNF_ReadyToRunStaticBaseThreadNonGC;
1056010572
break;
1056110573
case CORINFO_HELP_READYTORUN_GENERIC_STATIC_BASE:
1056210574
vnf = VNF_ReadyToRunGenericStaticBase;

src/coreclr/jit/valuenumfuncs.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ ValueNumFuncDef(GetsharedGcstaticBase, 2, false, true, true)
115115
ValueNumFuncDef(GetsharedNongcstaticBase, 2, false, true, true)
116116
ValueNumFuncDef(GetsharedGcstaticBaseNoctor, 1, false, true, true)
117117
ValueNumFuncDef(GetsharedNongcstaticBaseNoctor, 1, false, true, true)
118-
ValueNumFuncDef(ReadyToRunStaticBase, 1, false, true, true)
118+
ValueNumFuncDef(ReadyToRunStaticBaseGC, 1, false, true, true)
119+
ValueNumFuncDef(ReadyToRunStaticBaseNonGC, 1, false, true, true)
120+
ValueNumFuncDef(ReadyToRunStaticBaseThread, 1, false, true, true)
121+
ValueNumFuncDef(ReadyToRunStaticBaseThreadNonGC, 1, false, true, true)
119122
ValueNumFuncDef(ReadyToRunGenericStaticBase, 2, false, true, true)
120123
ValueNumFuncDef(GetsharedGcstaticBaseDynamicclass, 2, false, true, true)
121124
ValueNumFuncDef(GetsharedNongcstaticBaseDynamicclass, 2, false, true, true)

src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ which is the right helper to use to allocate an object of a given type. */
5959
CORINFO_HELP_NEWARR_1_ALIGN8, // like VC, but aligns the array start
6060

6161
CORINFO_HELP_STRCNS, // create a new string literal
62-
CORINFO_HELP_STRCNS_CURRENT_MODULE, // create a new string literal from the current module (used by NGen code)
6362
/* Object model */
6463

6564
CORINFO_HELP_INITCLASS, // Initialize class if not already initialized
@@ -233,7 +232,10 @@ which is the right helper to use to allocate an object of a given type. */
233232
CORINFO_HELP_READYTORUN_NEWARR_1,
234233
CORINFO_HELP_READYTORUN_ISINSTANCEOF,
235234
CORINFO_HELP_READYTORUN_CHKCAST,
236-
CORINFO_HELP_READYTORUN_STATIC_BASE,
235+
CORINFO_HELP_READYTORUN_GCSTATIC_BASE,
236+
CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE,
237+
CORINFO_HELP_READYTORUN_THREADSTATIC_BASE,
238+
CORINFO_HELP_READYTORUN_NONGCTHREADSTATIC_BASE,
237239
CORINFO_HELP_READYTORUN_VIRTUAL_FUNC_PTR,
238240
CORINFO_HELP_READYTORUN_GENERIC_HANDLE,
239241
CORINFO_HELP_READYTORUN_DELEGATE_CTOR,

src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3237,6 +3237,29 @@ private uint getThreadTLSIndex(ref void* ppIndirection)
32373237
}
32383238
}
32393239

3240+
public static ReadyToRunHelperId GetReadyToRunHelperFromStaticBaseHelper(CorInfoHelpFunc helper)
3241+
{
3242+
ReadyToRunHelperId res;
3243+
switch (helper)
3244+
{
3245+
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_GCSTATIC_BASE:
3246+
res = ReadyToRunHelperId.GetGCStaticBase;
3247+
break;
3248+
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE:
3249+
res = ReadyToRunHelperId.GetNonGCStaticBase;
3250+
break;
3251+
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_THREADSTATIC_BASE:
3252+
res = ReadyToRunHelperId.GetThreadStaticBase;
3253+
break;
3254+
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_NONGCTHREADSTATIC_BASE:
3255+
res = ReadyToRunHelperId.GetThreadNonGcStaticBase;
3256+
break;
3257+
default:
3258+
throw new NotImplementedException("ReadyToRun: " + helper.ToString());
3259+
}
3260+
return res;
3261+
}
3262+
32403263
private void getFunctionFixedEntryPoint(CORINFO_METHOD_STRUCT_* ftn, bool isUnsafeFunctionPointer, ref CORINFO_CONST_LOOKUP pResult)
32413264
{ throw new NotImplementedException("getFunctionFixedEntryPoint"); }
32423265

src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -726,13 +726,16 @@ private bool getReadyToRunHelper(ref CORINFO_RESOLVED_TOKEN pResolvedToken, ref
726726
pLookup = CreateConstLookupToSymbol(_compilation.SymbolNodeFactory.CreateReadyToRunHelper(ReadyToRunHelperId.CastClass, type));
727727
}
728728
break;
729-
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_STATIC_BASE:
729+
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_GCSTATIC_BASE:
730+
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE:
731+
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_THREADSTATIC_BASE:
732+
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_NONGCTHREADSTATIC_BASE:
730733
{
731734
var type = HandleToObject(pResolvedToken.hClass);
732735
if (type.IsCanonicalSubtype(CanonicalFormKind.Any))
733736
return false;
734-
735-
pLookup = CreateConstLookupToSymbol(_compilation.SymbolNodeFactory.CreateReadyToRunHelper(ReadyToRunHelperId.CctorTrigger, type));
737+
var helperId = GetReadyToRunHelperFromStaticBaseHelper(id);
738+
pLookup = CreateConstLookupToSymbol(_compilation.SymbolNodeFactory.CreateReadyToRunHelper(helperId, type));
736739
}
737740
break;
738741
case CorInfoHelpFunc.CORINFO_HELP_READYTORUN_GENERIC_HANDLE:
@@ -1536,7 +1539,7 @@ private void getFieldInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_MET
15361539
else
15371540
{
15381541
fieldAccessor = CORINFO_FIELD_ACCESSOR.CORINFO_FIELD_STATIC_SHARED_STATIC_HELPER;
1539-
pResult->helper = CorInfoHelpFunc.CORINFO_HELP_READYTORUN_STATIC_BASE;
1542+
pResult->helper = CorInfoHelpFunc.CORINFO_HELP_UNDEF;
15401543

15411544
ReadyToRunHelperId helperId = ReadyToRunHelperId.Invalid;
15421545
CORINFO_FIELD_ACCESSOR intrinsicAccessor;
@@ -1550,18 +1553,27 @@ private void getFieldInfo(ref CORINFO_RESOLVED_TOKEN pResolvedToken, CORINFO_MET
15501553
{
15511554
if (field.HasGCStaticBase)
15521555
{
1556+
pResult->helper = CorInfoHelpFunc.CORINFO_HELP_READYTORUN_THREADSTATIC_BASE;
15531557
helperId = ReadyToRunHelperId.GetThreadStaticBase;
15541558
}
15551559
else
15561560
{
1561+
pResult->helper = CorInfoHelpFunc.CORINFO_HELP_READYTORUN_NONGCTHREADSTATIC_BASE;
15571562
helperId = ReadyToRunHelperId.GetThreadNonGcStaticBase;
15581563
}
15591564
}
15601565
else
15611566
{
1562-
helperId = field.HasGCStaticBase ?
1563-
ReadyToRunHelperId.GetGCStaticBase :
1564-
ReadyToRunHelperId.GetNonGCStaticBase;
1567+
if (field.HasGCStaticBase)
1568+
{
1569+
pResult->helper = CorInfoHelpFunc.CORINFO_HELP_READYTORUN_GCSTATIC_BASE;
1570+
helperId = ReadyToRunHelperId.GetGCStaticBase;
1571+
}
1572+
else
1573+
{
1574+
pResult->helper = CorInfoHelpFunc.CORINFO_HELP_READYTORUN_NONGCSTATIC_BASE;
1575+
helperId = ReadyToRunHelperId.GetNonGCStaticBase;
1576+
}
15651577
}
15661578

15671579
if (!_compilation.NodeFactory.CompilationModuleGroup.VersionsWithType(field.OwningType) &&

0 commit comments

Comments
 (0)