Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit ee743a7

Browse files
FeiPengInteljkotas
authored andcommitted
new intrinsic type support (#15340)
1 parent 688b75c commit ee743a7

File tree

23 files changed

+348
-10
lines changed

23 files changed

+348
-10
lines changed

src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ CorInfoType asCorInfoType(CORINFO_CLASS_HANDLE cls);
271271
// for completeness
272272
const char* getClassName(CORINFO_CLASS_HANDLE cls);
273273

274+
const char* getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName);
275+
276+
CORINFO_CLASS_HANDLE getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index);
277+
274278
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
275279
// If fNamespace=TRUE, include the namespace/enclosing classes
276280
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters

src/ToolBox/superpmi/superpmi-shared/lwmlist.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ LWM(GetClassDomainID, DWORDLONG, DLD)
6868
LWM(GetClassGClayout, DWORDLONG, Agnostic_GetClassGClayout)
6969
LWM(GetClassModuleIdForStatics, DWORDLONG, Agnostic_GetClassModuleIdForStatics)
7070
LWM(GetClassName, DWORDLONG, DWORD)
71+
LWM(GetClassNameFromMetadata, DLD, DD)
72+
LWM(GetTypeInstantiationArgument, DWORDLONG, DWORDLONG)
7173
LWM(GetClassNumInstanceFields, DWORDLONG, DWORD)
7274
LWM(GetClassSize, DWORDLONG, DWORD)
7375
LWM(GetCookieForPInvokeCalliSig, GetCookieForPInvokeCalliSigValue, DLDL)

src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5683,6 +5683,113 @@ const char* MethodContext::repGetClassName(CORINFO_CLASS_HANDLE cls)
56835683
return name;
56845684
}
56855685

5686+
void MethodContext::recGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls,
5687+
char* className,
5688+
const char** namespaceName)
5689+
{
5690+
if (GetClassNameFromMetadata == nullptr)
5691+
GetClassNameFromMetadata = new LightWeightMap<DLD, DD>();
5692+
DD value;
5693+
DLD key;
5694+
key.A = (DWORDLONG)cls;
5695+
key.B = (namespaceName != nullptr);
5696+
5697+
if (className != nullptr)
5698+
value.A =
5699+
GetClassNameFromMetadata->AddBuffer((unsigned char*)className, (DWORD)strlen(className) + 1);
5700+
else
5701+
value.A = (DWORD)-1;
5702+
5703+
if ((namespaceName != nullptr) && (*namespaceName != nullptr))
5704+
value.B =
5705+
GetClassNameFromMetadata->AddBuffer((unsigned char*)*namespaceName, (DWORD)strlen(*namespaceName) + 1);
5706+
else
5707+
value.B = (DWORD)-1;
5708+
5709+
GetClassNameFromMetadata->Add(key, value);
5710+
DEBUG_REC(dmpGetClassNameFromMetadata(key, value));
5711+
}
5712+
5713+
void MethodContext::dmpGetClassNameFromMetadata(DLD key, DD value)
5714+
{
5715+
unsigned char* className = (unsigned char*)GetClassNameFromMetadata->GetBuffer(value.A);
5716+
unsigned char* namespaceName = (unsigned char*)GetClassNameFromMetadata->GetBuffer(value.B);
5717+
printf("GetClassNameFromMetadata key - classNonNull-%u namespaceNonNull-%u, value "
5718+
"class-'%s', namespace-'%s'",
5719+
key.A, key.B, className, namespaceName);
5720+
GetClassNameFromMetadata->Unlock();
5721+
}
5722+
5723+
const char* MethodContext::repGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
5724+
{
5725+
const char* result = nullptr;
5726+
DD value;
5727+
DLD key;
5728+
key.A = (DWORDLONG)cls;
5729+
key.B = (namespaceName != nullptr);
5730+
5731+
int itemIndex = -1;
5732+
if (GetClassNameFromMetadata != nullptr)
5733+
itemIndex = GetClassNameFromMetadata->GetIndex(key);
5734+
if (itemIndex < 0)
5735+
{
5736+
if (namespaceName != nullptr)
5737+
{
5738+
*namespaceName = nullptr;
5739+
}
5740+
}
5741+
else
5742+
{
5743+
value = GetClassNameFromMetadata->Get(key);
5744+
result = (const char*)GetClassNameFromMetadata->GetBuffer(value.A);
5745+
5746+
if (namespaceName != nullptr)
5747+
{
5748+
*namespaceName = (const char*)GetClassNameFromMetadata->GetBuffer(value.B);
5749+
}
5750+
}
5751+
DEBUG_REP(dmpGetClassNameFromMetadata(key, value));
5752+
return result;
5753+
}
5754+
5755+
void MethodContext::recGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result, unsigned index)
5756+
{
5757+
if (GetTypeInstantiationArgument == nullptr)
5758+
GetTypeInstantiationArgument = new LightWeightMap<DWORDLONG, DWORDLONG>();
5759+
5760+
DWORDLONG key = (DWORDLONG)cls;
5761+
5762+
GetTypeInstantiationArgument->Add(key, (DWORDLONG)result);
5763+
DEBUG_REC(dmpGetTypeInstantiationArgument(key, (DWORDLONG)result));
5764+
}
5765+
5766+
void MethodContext::dmpGetTypeInstantiationArgument(DWORDLONG key, DWORDLONG value)
5767+
{
5768+
printf("GetTypeInstantiationArgument key - classNonNull-%u, value NonNull-%u", key, value);
5769+
GetTypeInstantiationArgument->Unlock();
5770+
}
5771+
5772+
5773+
CORINFO_CLASS_HANDLE MethodContext::repGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
5774+
{
5775+
CORINFO_CLASS_HANDLE result = nullptr;
5776+
DWORDLONG value;
5777+
DWORDLONG key;
5778+
key = (DWORDLONG)cls;
5779+
5780+
int itemIndex = -1;
5781+
if (GetTypeInstantiationArgument != nullptr)
5782+
itemIndex = GetTypeInstantiationArgument->GetIndex(key);
5783+
if (itemIndex >= 0)
5784+
{
5785+
value = GetTypeInstantiationArgument->Get(key);
5786+
result = (CORINFO_CLASS_HANDLE)value;
5787+
}
5788+
5789+
DEBUG_REP(dmpGetTypeInstantiationArgument(key, value));
5790+
return result;
5791+
}
5792+
56865793
void MethodContext::recAppendClassName(
56875794
CORINFO_CLASS_HANDLE cls, BOOL fNamespace, BOOL fFullInst, BOOL fAssembly, const WCHAR* result)
56885795
{

src/ToolBox/superpmi/superpmi-shared/methodcontext.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,16 @@ class MethodContext
12221222
void dmpGetClassName(DWORDLONG key, DWORD value);
12231223
const char* repGetClassName(CORINFO_CLASS_HANDLE cls);
12241224

1225+
void recGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls,
1226+
char* className,
1227+
const char** namespaceName);
1228+
void dmpGetClassNameFromMetadata(DLD key, DD value);
1229+
const char* repGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName);
1230+
1231+
void recGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result, unsigned index);
1232+
void dmpGetTypeInstantiationArgument(DWORDLONG key, DWORDLONG value);
1233+
CORINFO_CLASS_HANDLE repGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index);
1234+
12251235
void recAppendClassName(
12261236
CORINFO_CLASS_HANDLE cls, BOOL fNamespace, BOOL fFullInst, BOOL fAssembly, const WCHAR* result);
12271237
void dmpAppendClassName(const Agnostic_AppendClassName& key, DWORD value);
@@ -1273,7 +1283,7 @@ class MethodContext
12731283
};
12741284

12751285
// ********************* Please keep this up-to-date to ease adding more ***************
1276-
// Highest packet number: 165
1286+
// Highest packet number: 167
12771287
// *************************************************************************************
12781288
enum mcPackets
12791289
{
@@ -1337,6 +1347,8 @@ enum mcPackets
13371347
Packet_GetClassGClayout = 43,
13381348
Packet_GetClassModuleIdForStatics = 44,
13391349
Packet_GetClassName = 45,
1350+
Packet_GetClassNameFromMetadata = 166, // Added 12/4/17
1351+
Packet_GetTypeInstantiationArgument = 167, // Added 12/4/17
13401352
Packet_GetClassNumInstanceFields = 46,
13411353
Packet_GetClassSize = 47,
13421354
Packet_GetIntConfigValue = 151, // Added 2/12/2015

src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,22 @@ const char* interceptor_ICJI::getClassName(CORINFO_CLASS_HANDLE cls)
550550
return result;
551551
}
552552

553+
const char* interceptor_ICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
554+
{
555+
mc->cr->AddCall("getClassNameFromMetadata");
556+
const char* temp = original_ICorJitInfo->getClassNameFromMetadata(cls, namespaceName);
557+
mc->recGetClassNameFromMetadata(cls, (char*)temp, namespaceName);
558+
return temp;
559+
}
560+
561+
CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
562+
{
563+
mc->cr->AddCall("getTypeInstantiationArgument");
564+
CORINFO_CLASS_HANDLE temp = original_ICorJitInfo->getTypeInstantiationArgument(cls, index);
565+
mc->recGetTypeInstantiationArgument(cls, temp, index);
566+
return temp;
567+
}
568+
553569
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
554570
// If fNamespace=TRUE, include the namespace/enclosing classes
555571
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters

src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,18 @@ const char* interceptor_ICJI::getClassName(CORINFO_CLASS_HANDLE cls)
405405
return original_ICorJitInfo->getClassName(cls);
406406
}
407407

408+
const char* interceptor_ICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
409+
{
410+
mcs->AddCall("getClassNameFromMetadata");
411+
return original_ICorJitInfo->getClassNameFromMetadata(cls, namespaceName);
412+
}
413+
414+
CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
415+
{
416+
mcs->AddCall("getTypeInstantiationArgument");
417+
return original_ICorJitInfo->getTypeInstantiationArgument(cls, index);
418+
}
419+
408420
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
409421
// If fNamespace=TRUE, include the namespace/enclosing classes
410422
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters

src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,16 @@ const char* interceptor_ICJI::getClassName(CORINFO_CLASS_HANDLE cls)
364364
return original_ICorJitInfo->getClassName(cls);
365365
}
366366

367+
const char* interceptor_ICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
368+
{
369+
return original_ICorJitInfo->getClassNameFromMetadata(cls, namespaceName);
370+
}
371+
372+
CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
373+
{
374+
return original_ICorJitInfo->getTypeInstantiationArgument(cls, index);
375+
}
376+
367377
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
368378
// If fNamespace=TRUE, include the namespace/enclosing classes
369379
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters

src/ToolBox/superpmi/superpmi/icorjitinfo.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,20 @@ const char* MyICJI::getClassName(CORINFO_CLASS_HANDLE cls)
436436
return result;
437437
}
438438

439+
const char* MyICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
440+
{
441+
jitInstance->mc->cr->AddCall("getClassNameFromMetadata");
442+
const char* result = jitInstance->mc->repGetClassNameFromMetadata(cls, namespaceName);
443+
return result;
444+
}
445+
446+
CORINFO_CLASS_HANDLE MyICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
447+
{
448+
jitInstance->mc->cr->AddCall("getTypeInstantiationArgument");
449+
CORINFO_CLASS_HANDLE result = jitInstance->mc->repGetTypeInstantiationArgument(cls, index);
450+
return result;
451+
}
452+
439453
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
440454
// If fNamespace=TRUE, include the namespace/enclosing classes
441455
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters

src/debug/daccess/nidump.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5608,6 +5608,7 @@ NativeImageDumper::EnumMnemonics s_MTFlags2[] =
56085608
MTFLAG2_ENTRY(IsZapped),
56095609
MTFLAG2_ENTRY(IsPreRestored),
56105610
MTFLAG2_ENTRY(HasModuleDependencies),
5611+
MTFLAG2_ENTRY(IsIntrinsicType),
56115612
MTFLAG2_ENTRY(RequiresDispatchTokenFat),
56125613
MTFLAG2_ENTRY(HasCctor),
56135614
MTFLAG2_ENTRY(HasCCWTemplate),

src/inc/corinfo.h

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@ TODO: Talk about initializing strutures before use
213213
#define SELECTANY extern __declspec(selectany)
214214
#endif
215215

216-
SELECTANY const GUID JITEEVersionIdentifier = { /* b6af83a1-ca48-46c6-b7b0-5d7d6a79a5c5 */
217-
0xb6af83a1,
218-
0xca48,
219-
0x46c6,
220-
{0xb7, 0xb0, 0x5d, 0x7d, 0x6a, 0x79, 0xa5, 0xc5}
216+
SELECTANY const GUID JITEEVersionIdentifier = { /* EBEE9A84-63C3-4610-9E4F-05491D335D67 */
217+
0xebee9a84,
218+
0x63c3,
219+
0x4610,
220+
{ 0x9e, 0x4f, 0x5, 0x49, 0x1d, 0x33, 0x5d, 0x67 }
221221
};
222222

223223
//////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -809,7 +809,7 @@ enum CorInfoFlag
809809
CORINFO_FLG_VIRTUAL = 0x00000040,
810810
// CORINFO_FLG_UNUSED = 0x00000080,
811811
CORINFO_FLG_NATIVE = 0x00000100,
812-
// CORINFO_FLG_UNUSED = 0x00000200,
812+
CORINFO_FLG_INTRINSIC_TYPE = 0x00000200, // This type is marked by [Intrinsic]
813813
CORINFO_FLG_ABSTRACT = 0x00000400,
814814

815815
CORINFO_FLG_EnC = 0x00000800, // member was added by Edit'n'Continue
@@ -2281,6 +2281,21 @@ class ICorStaticInfo
22812281
CORINFO_CLASS_HANDLE cls
22822282
) = 0;
22832283

2284+
// Return class name as in metadata, or nullptr if there is none.
2285+
// Suitable for non-debugging use.
2286+
virtual const char* getClassNameFromMetadata (
2287+
CORINFO_CLASS_HANDLE cls,
2288+
const char **namespaceName /* OUT */
2289+
) = 0;
2290+
2291+
// Return the type argument of the instantiated generic class,
2292+
// which is specified by the index
2293+
virtual CORINFO_CLASS_HANDLE getTypeInstantiationArgument(
2294+
CORINFO_CLASS_HANDLE cls,
2295+
unsigned index
2296+
) = 0;
2297+
2298+
22842299
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
22852300
// If fNamespace=TRUE, include the namespace/enclosing classes
22862301
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters

0 commit comments

Comments
 (0)