Skip to content

Commit d3b0136

Browse files
committed
Make the length of VectorT accessible to the DAC
The length of VectorT is now a constant that is set on VM initialization, and the DAC needs to be able to replicate this state without access to the original SVE VL value.
1 parent 79ba8ba commit d3b0136

File tree

6 files changed

+45
-24
lines changed

6 files changed

+45
-24
lines changed

src/coreclr/inc/dacvars.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ DEFINE_DACVAR(PTR_JITNotification, dac__g_pNotificationTable, ::g_pNotificationT
134134
DEFINE_DACVAR(ULONG32, dac__g_dacNotificationFlags, ::g_dacNotificationFlags)
135135

136136
DEFINE_DACVAR(DWORD, dac__g_gcNotificationFlags, g_gcNotificationFlags)
137+
DEFINE_DACVAR(DWORD, dac__g_vectorTByteLength, ::g_vectorTByteLength)
138+
DEFINE_DACVAR(BOOL, dac__g_vectorTIsScalable, ::g_vectorTIsScalable)
137139

138140
DEFINE_DACVAR(PTR_EEConfig, dac__g_pConfig, ::g_pConfig)
139141

src/coreclr/vm/codeman.cpp

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,8 @@ EECodeGenManager::EECodeGenManager()
11391139
EEJitManager::EEJitManager()
11401140
: m_CPUCompileFlags()
11411141
, m_JitLoadLock( CrstSingleUseLock )
1142+
, m_vectorTByteLength(0)
1143+
, m_useScalableVectorT(false)
11421144
{
11431145
CONTRACTL {
11441146
THROWS;
@@ -1546,35 +1548,49 @@ void EEJitManager::SetCpuInfo()
15461548
#endif // TARGET_X86 || TARGET_AMD64
15471549

15481550
m_CPUCompileFlags = CPUCompileFlags;
1549-
}
15501551

1551-
uint32_t EEJitManager::GetSizeOfVectorT()
1552-
{
1553-
LIMITED_METHOD_CONTRACT;
1554-
1555-
uint32_t size = 0;
1552+
m_useScalableVectorT = false;
1553+
m_vectorTByteLength = 0;
15561554

15571555
#if defined(TARGET_X86) || defined(TARGET_AMD64)
15581556
if (m_CPUCompileFlags.IsSet(InstructionSet_VectorT512))
15591557
{
1560-
length = 64;
1558+
m_vectorTByteLength = 64;
15611559
}
1562-
else if (CPUCompileFlags.IsSet(InstructionSet_VectorT256))
1560+
else if (m_CPUCompileFlags.IsSet(InstructionSet_VectorT256))
15631561
{
1564-
length = 32;
1562+
m_vectorTByteLength = 32;
1563+
}
1564+
else if (m_CPUCompileFlags.IsSet(InstructionSet_VectorT128))
1565+
{
1566+
m_vectorTByteLength = 16;
15651567
}
15661568
#elif defined(TARGET_ARM64)
1567-
if (UseScalableVectorT())
1569+
if (m_CPUCompileFlags.IsSet(InstructionSet_VectorT128))
15681570
{
1569-
size = (uint32_t) GetSveLengthFromOS();
1571+
m_vectorTByteLength = 16;
15701572
}
1571-
else if (m_CPUCompileFlags.IsSet(InstructionSet_VectorT128))
1573+
1574+
if (CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_JitUseScalableVectorT)
1575+
&& m_CPUCompileFlags.IsSet(InstructionSet_Sve_Arm64))
15721576
{
1573-
size = 16;
1577+
uint64_t sveLengthFromOS = GetSveLengthFromOS();
1578+
if (sveLengthFromOS != 0)
1579+
{
1580+
m_useScalableVectorT = true;
1581+
m_vectorTByteLength = static_cast<uint32_t>(sveLengthFromOS);
1582+
}
15741583
}
15751584
#endif
15761585

1577-
return size;
1586+
g_vectorTByteLength = m_vectorTByteLength;
1587+
g_vectorTIsScalable = m_useScalableVectorT ? 1 : 0;
1588+
}
1589+
1590+
uint32_t EEJitManager::GetSizeOfVectorT() const
1591+
{
1592+
LIMITED_METHOD_DAC_CONTRACT;
1593+
return m_vectorTByteLength;
15781594
}
15791595

15801596
// Define some data that we can use to get a better idea of what happened when we get a Watson dump that indicates the JIT failed to load.

src/coreclr/vm/codeman.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,19 +2188,13 @@ class EEJitManager final : public EECodeGenManager
21882188
return m_CPUCompileFlags;
21892189
}
21902190

2191-
inline bool UseScalableVectorT()
2191+
inline bool UseScalableVectorT() const
21922192
{
2193-
LIMITED_METHOD_CONTRACT;
2194-
#ifdef TARGET_ARM64
2195-
// Vector length discovery is currently dependent on running directly on Arm64.
2196-
return CLRConfig::GetConfigValue(CLRConfig::EXTERNAL_JitUseScalableVectorT)
2197-
&& m_CPUCompileFlags.IsSet(InstructionSet_Sve_Arm64);
2198-
#else
2199-
return false;
2200-
#endif
2193+
LIMITED_METHOD_DAC_CONTRACT;
2194+
return m_useScalableVectorT;
22012195
}
22022196

2203-
uint32_t GetSizeOfVectorT();
2197+
uint32_t GetSizeOfVectorT() const;
22042198

22052199
private :
22062200
Crst m_JitLoadLock;
@@ -2239,6 +2233,9 @@ private :
22392233
bool m_AltJITRequired;
22402234
#endif //ALLOW_SXS_JIT
22412235

2236+
uint32_t m_vectorTByteLength;
2237+
bool m_useScalableVectorT;
2238+
22422239
friend struct ::cdac_data<EEJitManager>;
22432240
};
22442241

src/coreclr/vm/datadescriptor/datadescriptor.inc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,8 @@ CDAC_GLOBAL(PtrArrayOffsetToDataArray, uintptr_t, offsetof(PtrArray, m_Array))
10281028
CDAC_GLOBAL(NumberOfTlsOffsetsNotUsedInNoncollectibleArray, uint8, NUMBER_OF_TLSOFFSETS_NOT_USED_IN_NONCOLLECTIBLE_ARRAY)
10291029
CDAC_GLOBAL(MaxClrNotificationArgs, uint32, MAX_CLR_NOTIFICATION_ARGS)
10301030
CDAC_GLOBAL(FieldOffsetBigRVA, uint32, FIELD_OFFSET_BIG_RVA)
1031+
CDAC_GLOBAL_POINTER(VectorTByteLength, &::g_vectorTByteLength)
1032+
CDAC_GLOBAL_POINTER(VectorTIsScalable, &::g_vectorTIsScalable)
10311033
CDAC_GLOBAL_POINTER(ClrNotificationArguments, &::g_clrNotificationArguments)
10321034
CDAC_GLOBAL_POINTER(ArrayBoundsZero, cdac_data<ArrayBase>::ArrayBoundsZero)
10331035
CDAC_GLOBAL_POINTER(ExceptionMethodTable, &::g_pExceptionClass)

src/coreclr/vm/vars.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ GVAL_IMPL_INIT(DWORD, g_debuggerWordTLSIndex, TLS_OUT_OF_INDEXES);
101101
GVAL_IMPL_INIT(DWORD, g_TlsIndex, TLS_OUT_OF_INDEXES);
102102
GVAL_IMPL_INIT(DWORD, g_offsetOfCurrentThreadInfo, 0);
103103
GVAL_IMPL_INIT(DWORD, g_gcNotificationFlags, 0);
104+
GVAL_IMPL_INIT(DWORD, g_vectorTByteLength, 0);
105+
GVAL_IMPL_INIT(BOOL, g_vectorTIsScalable, 0);
104106

105107

106108
MethodTable* g_pCastHelpers;

src/coreclr/vm/vars.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ GVAL_DECL(DWORD, g_debuggerWordTLSIndex);
364364
GVAL_DECL(DWORD, g_TlsIndex);
365365
GVAL_DECL(DWORD, g_offsetOfCurrentThreadInfo);
366366
GVAL_DECL(DWORD, g_gcNotificationFlags);
367+
GVAL_DECL(DWORD, g_vectorTByteLength);
368+
GVAL_DECL(BOOL, g_vectorTIsScalable);
367369

368370
#ifdef FEATURE_EH_FUNCLETS
369371
GPTR_DECL(MethodTable, g_pEHClass);

0 commit comments

Comments
 (0)