summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFei Peng <fei.peng@intel.com>2017-12-06 20:01:18 -0800
committerJan Kotas <jkotas@microsoft.com>2017-12-06 23:01:18 -0500
commitee743a7bd51a327b692a557759c37553ac4760e2 (patch)
tree9d82762d7fcc57110ca856a8ca98e55a4bfefdf3
parent688b75c143aa0e080f386a04c74b13b3fc9877bf (diff)
downloadcoreclr-ee743a7bd51a327b692a557759c37553ac4760e2.tar.gz
coreclr-ee743a7bd51a327b692a557759c37553ac4760e2.tar.bz2
coreclr-ee743a7bd51a327b692a557759c37553ac4760e2.zip
new intrinsic type support (#15340)
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h4
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/lwmlist.h2
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp107
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/methodcontext.h14
-rw-r--r--src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp16
-rw-r--r--src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp12
-rw-r--r--src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp10
-rw-r--r--src/ToolBox/superpmi/superpmi/icorjitinfo.cpp14
-rw-r--r--src/debug/daccess/nidump.cpp1
-rw-r--r--src/inc/corinfo.h27
-rw-r--r--src/jit/ICorJitInfo_API_names.h2
-rw-r--r--src/jit/ICorJitInfo_API_wrapper.hpp16
-rw-r--r--src/jit/compiler.h15
-rw-r--r--src/jit/simd.cpp8
-rw-r--r--src/mscorlib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs3
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/Vector128.cs2
-rw-r--r--src/mscorlib/src/System/Runtime/Intrinsics/Vector256.cs2
-rw-r--r--src/vm/jitinterface.cpp58
-rw-r--r--src/vm/jitinterface.h2
-rw-r--r--src/vm/methodtable.h14
-rw-r--r--src/vm/methodtablebuilder.cpp17
-rw-r--r--src/zap/zapinfo.cpp10
-rw-r--r--src/zap/zapinfo.h2
23 files changed, 348 insertions, 10 deletions
diff --git a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
index 5c6dc4fc04..e0a5886e76 100644
--- a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
+++ b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h
@@ -271,6 +271,10 @@ CorInfoType asCorInfoType(CORINFO_CLASS_HANDLE cls);
// for completeness
const char* getClassName(CORINFO_CLASS_HANDLE cls);
+const char* getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName);
+
+CORINFO_CLASS_HANDLE getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index);
+
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
// If fNamespace=TRUE, include the namespace/enclosing classes
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters
diff --git a/src/ToolBox/superpmi/superpmi-shared/lwmlist.h b/src/ToolBox/superpmi/superpmi-shared/lwmlist.h
index b0cb7ad3c8..467d28ac55 100644
--- a/src/ToolBox/superpmi/superpmi-shared/lwmlist.h
+++ b/src/ToolBox/superpmi/superpmi-shared/lwmlist.h
@@ -68,6 +68,8 @@ LWM(GetClassDomainID, DWORDLONG, DLD)
LWM(GetClassGClayout, DWORDLONG, Agnostic_GetClassGClayout)
LWM(GetClassModuleIdForStatics, DWORDLONG, Agnostic_GetClassModuleIdForStatics)
LWM(GetClassName, DWORDLONG, DWORD)
+LWM(GetClassNameFromMetadata, DLD, DD)
+LWM(GetTypeInstantiationArgument, DWORDLONG, DWORDLONG)
LWM(GetClassNumInstanceFields, DWORDLONG, DWORD)
LWM(GetClassSize, DWORDLONG, DWORD)
LWM(GetCookieForPInvokeCalliSig, GetCookieForPInvokeCalliSigValue, DLDL)
diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
index 3a9f48feea..581b2286d8 100644
--- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
+++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp
@@ -5683,6 +5683,113 @@ const char* MethodContext::repGetClassName(CORINFO_CLASS_HANDLE cls)
return name;
}
+void MethodContext::recGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls,
+ char* className,
+ const char** namespaceName)
+{
+ if (GetClassNameFromMetadata == nullptr)
+ GetClassNameFromMetadata = new LightWeightMap<DLD, DD>();
+ DD value;
+ DLD key;
+ key.A = (DWORDLONG)cls;
+ key.B = (namespaceName != nullptr);
+
+ if (className != nullptr)
+ value.A =
+ GetClassNameFromMetadata->AddBuffer((unsigned char*)className, (DWORD)strlen(className) + 1);
+ else
+ value.A = (DWORD)-1;
+
+ if ((namespaceName != nullptr) && (*namespaceName != nullptr))
+ value.B =
+ GetClassNameFromMetadata->AddBuffer((unsigned char*)*namespaceName, (DWORD)strlen(*namespaceName) + 1);
+ else
+ value.B = (DWORD)-1;
+
+ GetClassNameFromMetadata->Add(key, value);
+ DEBUG_REC(dmpGetClassNameFromMetadata(key, value));
+}
+
+void MethodContext::dmpGetClassNameFromMetadata(DLD key, DD value)
+{
+ unsigned char* className = (unsigned char*)GetClassNameFromMetadata->GetBuffer(value.A);
+ unsigned char* namespaceName = (unsigned char*)GetClassNameFromMetadata->GetBuffer(value.B);
+ printf("GetClassNameFromMetadata key - classNonNull-%u namespaceNonNull-%u, value "
+ "class-'%s', namespace-'%s'",
+ key.A, key.B, className, namespaceName);
+ GetClassNameFromMetadata->Unlock();
+}
+
+const char* MethodContext::repGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
+{
+ const char* result = nullptr;
+ DD value;
+ DLD key;
+ key.A = (DWORDLONG)cls;
+ key.B = (namespaceName != nullptr);
+
+ int itemIndex = -1;
+ if (GetClassNameFromMetadata != nullptr)
+ itemIndex = GetClassNameFromMetadata->GetIndex(key);
+ if (itemIndex < 0)
+ {
+ if (namespaceName != nullptr)
+ {
+ *namespaceName = nullptr;
+ }
+ }
+ else
+ {
+ value = GetClassNameFromMetadata->Get(key);
+ result = (const char*)GetClassNameFromMetadata->GetBuffer(value.A);
+
+ if (namespaceName != nullptr)
+ {
+ *namespaceName = (const char*)GetClassNameFromMetadata->GetBuffer(value.B);
+ }
+ }
+ DEBUG_REP(dmpGetClassNameFromMetadata(key, value));
+ return result;
+}
+
+void MethodContext::recGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result, unsigned index)
+{
+ if (GetTypeInstantiationArgument == nullptr)
+ GetTypeInstantiationArgument = new LightWeightMap<DWORDLONG, DWORDLONG>();
+
+ DWORDLONG key = (DWORDLONG)cls;
+
+ GetTypeInstantiationArgument->Add(key, (DWORDLONG)result);
+ DEBUG_REC(dmpGetTypeInstantiationArgument(key, (DWORDLONG)result));
+}
+
+void MethodContext::dmpGetTypeInstantiationArgument(DWORDLONG key, DWORDLONG value)
+{
+ printf("GetTypeInstantiationArgument key - classNonNull-%u, value NonNull-%u", key, value);
+ GetTypeInstantiationArgument->Unlock();
+}
+
+
+CORINFO_CLASS_HANDLE MethodContext::repGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
+{
+ CORINFO_CLASS_HANDLE result = nullptr;
+ DWORDLONG value;
+ DWORDLONG key;
+ key = (DWORDLONG)cls;
+
+ int itemIndex = -1;
+ if (GetTypeInstantiationArgument != nullptr)
+ itemIndex = GetTypeInstantiationArgument->GetIndex(key);
+ if (itemIndex >= 0)
+ {
+ value = GetTypeInstantiationArgument->Get(key);
+ result = (CORINFO_CLASS_HANDLE)value;
+ }
+
+ DEBUG_REP(dmpGetTypeInstantiationArgument(key, value));
+ return result;
+}
+
void MethodContext::recAppendClassName(
CORINFO_CLASS_HANDLE cls, BOOL fNamespace, BOOL fFullInst, BOOL fAssembly, const WCHAR* result)
{
diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h
index 582a26ff70..1174f070c7 100644
--- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h
+++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h
@@ -1222,6 +1222,16 @@ public:
void dmpGetClassName(DWORDLONG key, DWORD value);
const char* repGetClassName(CORINFO_CLASS_HANDLE cls);
+ void recGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls,
+ char* className,
+ const char** namespaceName);
+ void dmpGetClassNameFromMetadata(DLD key, DD value);
+ const char* repGetClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName);
+
+ void recGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, CORINFO_CLASS_HANDLE result, unsigned index);
+ void dmpGetTypeInstantiationArgument(DWORDLONG key, DWORDLONG value);
+ CORINFO_CLASS_HANDLE repGetTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index);
+
void recAppendClassName(
CORINFO_CLASS_HANDLE cls, BOOL fNamespace, BOOL fFullInst, BOOL fAssembly, const WCHAR* result);
void dmpAppendClassName(const Agnostic_AppendClassName& key, DWORD value);
@@ -1273,7 +1283,7 @@ private:
};
// ********************* Please keep this up-to-date to ease adding more ***************
-// Highest packet number: 165
+// Highest packet number: 167
// *************************************************************************************
enum mcPackets
{
@@ -1337,6 +1347,8 @@ enum mcPackets
Packet_GetClassGClayout = 43,
Packet_GetClassModuleIdForStatics = 44,
Packet_GetClassName = 45,
+ Packet_GetClassNameFromMetadata = 166, // Added 12/4/17
+ Packet_GetTypeInstantiationArgument = 167, // Added 12/4/17
Packet_GetClassNumInstanceFields = 46,
Packet_GetClassSize = 47,
Packet_GetIntConfigValue = 151, // Added 2/12/2015
diff --git a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
index fe5f5572fb..b6bc4fa8fb 100644
--- a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
+++ b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp
@@ -550,6 +550,22 @@ const char* interceptor_ICJI::getClassName(CORINFO_CLASS_HANDLE cls)
return result;
}
+const char* interceptor_ICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
+{
+ mc->cr->AddCall("getClassNameFromMetadata");
+ const char* temp = original_ICorJitInfo->getClassNameFromMetadata(cls, namespaceName);
+ mc->recGetClassNameFromMetadata(cls, (char*)temp, namespaceName);
+ return temp;
+}
+
+CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
+{
+ mc->cr->AddCall("getTypeInstantiationArgument");
+ CORINFO_CLASS_HANDLE temp = original_ICorJitInfo->getTypeInstantiationArgument(cls, index);
+ mc->recGetTypeInstantiationArgument(cls, temp, index);
+ return temp;
+}
+
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
// If fNamespace=TRUE, include the namespace/enclosing classes
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters
diff --git a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
index a9e5761c34..91d6b3388d 100644
--- a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
+++ b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp
@@ -405,6 +405,18 @@ const char* interceptor_ICJI::getClassName(CORINFO_CLASS_HANDLE cls)
return original_ICorJitInfo->getClassName(cls);
}
+const char* interceptor_ICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
+{
+ mcs->AddCall("getClassNameFromMetadata");
+ return original_ICorJitInfo->getClassNameFromMetadata(cls, namespaceName);
+}
+
+CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
+{
+ mcs->AddCall("getTypeInstantiationArgument");
+ return original_ICorJitInfo->getTypeInstantiationArgument(cls, index);
+}
+
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
// If fNamespace=TRUE, include the namespace/enclosing classes
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters
diff --git a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
index d7ca029fae..d23f727fd9 100644
--- a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
+++ b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp
@@ -364,6 +364,16 @@ const char* interceptor_ICJI::getClassName(CORINFO_CLASS_HANDLE cls)
return original_ICorJitInfo->getClassName(cls);
}
+const char* interceptor_ICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
+{
+ return original_ICorJitInfo->getClassNameFromMetadata(cls, namespaceName);
+}
+
+CORINFO_CLASS_HANDLE interceptor_ICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
+{
+ return original_ICorJitInfo->getTypeInstantiationArgument(cls, index);
+}
+
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
// If fNamespace=TRUE, include the namespace/enclosing classes
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters
diff --git a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
index fc5677cea2..81ff74db71 100644
--- a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
+++ b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp
@@ -436,6 +436,20 @@ const char* MyICJI::getClassName(CORINFO_CLASS_HANDLE cls)
return result;
}
+const char* MyICJI::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
+{
+ jitInstance->mc->cr->AddCall("getClassNameFromMetadata");
+ const char* result = jitInstance->mc->repGetClassNameFromMetadata(cls, namespaceName);
+ return result;
+}
+
+CORINFO_CLASS_HANDLE MyICJI::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
+{
+ jitInstance->mc->cr->AddCall("getTypeInstantiationArgument");
+ CORINFO_CLASS_HANDLE result = jitInstance->mc->repGetTypeInstantiationArgument(cls, index);
+ return result;
+}
+
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
// If fNamespace=TRUE, include the namespace/enclosing classes
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters
diff --git a/src/debug/daccess/nidump.cpp b/src/debug/daccess/nidump.cpp
index f1ee6f151e..b780405474 100644
--- a/src/debug/daccess/nidump.cpp
+++ b/src/debug/daccess/nidump.cpp
@@ -5608,6 +5608,7 @@ NativeImageDumper::EnumMnemonics s_MTFlags2[] =
MTFLAG2_ENTRY(IsZapped),
MTFLAG2_ENTRY(IsPreRestored),
MTFLAG2_ENTRY(HasModuleDependencies),
+ MTFLAG2_ENTRY(IsIntrinsicType),
MTFLAG2_ENTRY(RequiresDispatchTokenFat),
MTFLAG2_ENTRY(HasCctor),
MTFLAG2_ENTRY(HasCCWTemplate),
diff --git a/src/inc/corinfo.h b/src/inc/corinfo.h
index cd48999cd0..264cde69b9 100644
--- a/src/inc/corinfo.h
+++ b/src/inc/corinfo.h
@@ -213,11 +213,11 @@ TODO: Talk about initializing strutures before use
#define SELECTANY extern __declspec(selectany)
#endif
-SELECTANY const GUID JITEEVersionIdentifier = { /* b6af83a1-ca48-46c6-b7b0-5d7d6a79a5c5 */
- 0xb6af83a1,
- 0xca48,
- 0x46c6,
- {0xb7, 0xb0, 0x5d, 0x7d, 0x6a, 0x79, 0xa5, 0xc5}
+SELECTANY const GUID JITEEVersionIdentifier = { /* EBEE9A84-63C3-4610-9E4F-05491D335D67 */
+ 0xebee9a84,
+ 0x63c3,
+ 0x4610,
+ { 0x9e, 0x4f, 0x5, 0x49, 0x1d, 0x33, 0x5d, 0x67 }
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -809,7 +809,7 @@ enum CorInfoFlag
CORINFO_FLG_VIRTUAL = 0x00000040,
// CORINFO_FLG_UNUSED = 0x00000080,
CORINFO_FLG_NATIVE = 0x00000100,
-// CORINFO_FLG_UNUSED = 0x00000200,
+ CORINFO_FLG_INTRINSIC_TYPE = 0x00000200, // This type is marked by [Intrinsic]
CORINFO_FLG_ABSTRACT = 0x00000400,
CORINFO_FLG_EnC = 0x00000800, // member was added by Edit'n'Continue
@@ -2281,6 +2281,21 @@ public:
CORINFO_CLASS_HANDLE cls
) = 0;
+ // Return class name as in metadata, or nullptr if there is none.
+ // Suitable for non-debugging use.
+ virtual const char* getClassNameFromMetadata (
+ CORINFO_CLASS_HANDLE cls,
+ const char **namespaceName /* OUT */
+ ) = 0;
+
+ // Return the type argument of the instantiated generic class,
+ // which is specified by the index
+ virtual CORINFO_CLASS_HANDLE getTypeInstantiationArgument(
+ CORINFO_CLASS_HANDLE cls,
+ unsigned index
+ ) = 0;
+
+
// Append a (possibly truncated) representation of the type cls to the preallocated buffer ppBuf of length pnBufLen
// If fNamespace=TRUE, include the namespace/enclosing classes
// If fFullInst=TRUE (regardless of fNamespace and fAssembly), include namespace and assembly for any type parameters
diff --git a/src/jit/ICorJitInfo_API_names.h b/src/jit/ICorJitInfo_API_names.h
index 620e0dcfb8..0a8117da59 100644
--- a/src/jit/ICorJitInfo_API_names.h
+++ b/src/jit/ICorJitInfo_API_names.h
@@ -37,6 +37,8 @@ DEF_CLR_API(isValidStringRef)
DEF_CLR_API(shouldEnforceCallvirtRestriction)
DEF_CLR_API(asCorInfoType)
DEF_CLR_API(getClassName)
+DEF_CLR_API(getClassNameFromMetadata)
+DEF_CLR_API(getTypeInstantiationArgument)
DEF_CLR_API(appendClassName)
DEF_CLR_API(isValueClass)
DEF_CLR_API(canInlineTypeCheckWithObjectVTable)
diff --git a/src/jit/ICorJitInfo_API_wrapper.hpp b/src/jit/ICorJitInfo_API_wrapper.hpp
index 3ab72b9994..f298ea9173 100644
--- a/src/jit/ICorJitInfo_API_wrapper.hpp
+++ b/src/jit/ICorJitInfo_API_wrapper.hpp
@@ -356,6 +356,22 @@ const char* WrapICorJitInfo::getClassName(CORINFO_CLASS_HANDLE cls)
return result;
}
+const char* WrapICorJitInfo::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
+{
+ API_ENTER(getClassNameFromMetadata);
+ const char* result = wrapHnd->getClassNameFromMetadata(cls, namespaceName);
+ API_LEAVE(getClassNameFromMetadata);
+ return result;
+}
+
+CORINFO_CLASS_HANDLE WrapICorJitInfo::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
+{
+ API_ENTER(getTypeInstantiationArgument);
+ CORINFO_CLASS_HANDLE result = wrapHnd->getTypeInstantiationArgument(cls, index);
+ API_LEAVE(getTypeInstantiationArgument);
+ return result;
+}
+
int WrapICorJitInfo::appendClassName(
__deref_inout_ecount(*pnBufLen) WCHAR** ppBuf,
int* pnBufLen,
diff --git a/src/jit/compiler.h b/src/jit/compiler.h
index c4eaeb0a9f..fbc52fac98 100644
--- a/src/jit/compiler.h
+++ b/src/jit/compiler.h
@@ -7503,6 +7503,21 @@ private:
return info.compCompHnd->isInSIMDModule(clsHnd);
}
+ bool isIntrinsicType(CORINFO_CLASS_HANDLE clsHnd)
+ {
+ return (info.compCompHnd->getClassAttribs(clsHnd) & CORINFO_FLG_INTRINSIC_TYPE) != 0;
+ }
+
+ const char* getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
+ {
+ return info.compCompHnd->getClassNameFromMetadata(cls, namespaceName);
+ }
+
+ CORINFO_CLASS_HANDLE getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
+ {
+ return info.compCompHnd->getTypeInstantiationArgument(cls, index);
+ }
+
bool isSIMDClass(typeInfo* pTypeInfo)
{
return pTypeInfo->IsStruct() && isSIMDClass(pTypeInfo->GetClassHandleForValueClass());
diff --git a/src/jit/simd.cpp b/src/jit/simd.cpp
index 3b11043012..312355567a 100644
--- a/src/jit/simd.cpp
+++ b/src/jit/simd.cpp
@@ -129,6 +129,14 @@ var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, u
return TYP_UNKNOWN;
}
+#if FEATURE_HW_INTRINSICS && DEBUG
+ if (isIntrinsicType(typeHnd))
+ {
+ JITDUMP("\nFound Vector Type: %s with base type %s\n", getClassNameFromMetadata(typeHnd, nullptr),
+ getClassNameFromMetadata(getTypeInstantiationArgument(typeHnd, 0), nullptr));
+ }
+#endif
+
// fast path search using cached type handles of important types
var_types simdBaseType = TYP_UNKNOWN;
unsigned size = 0;
diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs
index dd01bacc49..381b4c63f7 100644
--- a/src/mscorlib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs
+++ b/src/mscorlib/shared/System/Runtime/CompilerServices/IntrinsicAttribute.cs
@@ -6,7 +6,8 @@ namespace System.Runtime.CompilerServices
{
// Calls to methods or references to fields marked with this attribute may be replaced at
// some call sites with jit intrinsic expansions.
- [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field, Inherited = false)]
+ // Types marked with this attribute may be specially treated by the rumtime/compiler.
+ [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Field, Inherited = false)]
internal sealed class IntrinsicAttribute : Attribute
{
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/Vector128.cs b/src/mscorlib/src/System/Runtime/Intrinsics/Vector128.cs
index 8e32f1a9dd..bfc1a2c2be 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/Vector128.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/Vector128.cs
@@ -2,10 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.Runtime.Intrinsics
{
+ [Intrinsic]
[StructLayout(LayoutKind.Sequential, Size = 16)]
public struct Vector128<T> where T : struct {}
}
diff --git a/src/mscorlib/src/System/Runtime/Intrinsics/Vector256.cs b/src/mscorlib/src/System/Runtime/Intrinsics/Vector256.cs
index ba1e11d003..f7015bd7ea 100644
--- a/src/mscorlib/src/System/Runtime/Intrinsics/Vector256.cs
+++ b/src/mscorlib/src/System/Runtime/Intrinsics/Vector256.cs
@@ -2,10 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.Runtime.Intrinsics
{
+ [Intrinsic]
[StructLayout(LayoutKind.Sequential, Size = 32)]
public struct Vector256<T> where T : struct {}
}
diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp
index 94abe3aaa8..349700ad72 100644
--- a/src/vm/jitinterface.cpp
+++ b/src/vm/jitinterface.cpp
@@ -4029,6 +4029,9 @@ DWORD CEEInfo::getClassAttribsInternal (CORINFO_CLASS_HANDLE clsHnd)
if (pClass->IsSealed())
ret |= CORINFO_FLG_FINAL;
+
+ if (pMT->IsIntrinsicType())
+ ret |= CORINFO_FLG_INTRINSIC_TYPE;
}
return ret;
@@ -6641,6 +6644,61 @@ const char* CEEInfo::getMethodNameFromMetadata(CORINFO_METHOD_HANDLE ftnHnd, con
}
/*********************************************************************/
+const char* CEEInfo::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
+{
+ CONTRACTL {
+ SO_TOLERANT;
+ THROWS;
+ GC_TRIGGERS;
+ MODE_PREEMPTIVE;
+ } CONTRACTL_END;
+
+ const char* result = NULL;
+ const char* namespaceResult = NULL;
+
+ JIT_TO_EE_TRANSITION();
+ TypeHandle VMClsHnd(cls);
+
+ if (!VMClsHnd.IsTypeDesc())
+ {
+ result = VMClsHnd.AsMethodTable()->GetFullyQualifiedNameInfo(&namespaceResult);
+ }
+
+ if (namespaceName != NULL)
+ {
+ *namespaceName = namespaceResult;
+ }
+
+ EE_TO_JIT_TRANSITION();
+
+ return result;
+}
+
+/*********************************************************************/
+CORINFO_CLASS_HANDLE CEEInfo::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
+{
+ CONTRACTL {
+ SO_TOLERANT;
+ THROWS;
+ GC_TRIGGERS;
+ MODE_PREEMPTIVE;
+ } CONTRACTL_END;
+
+ CORINFO_CLASS_HANDLE result = NULL;
+
+ JIT_TO_EE_TRANSITION_LEAF();
+
+ TypeHandle VMClsHnd(cls);
+ Instantiation inst = VMClsHnd.GetInstantiation();
+ TypeHandle typeArg = index < inst.GetNumArgs() ? inst[index] : NULL;
+ result = CORINFO_CLASS_HANDLE(typeArg.AsPtr());
+
+ EE_TO_JIT_TRANSITION_LEAF();
+
+ return result;
+}
+
+/*********************************************************************/
DWORD CEEInfo::getMethodAttribs (CORINFO_METHOD_HANDLE ftn)
{
CONTRACTL {
diff --git a/src/vm/jitinterface.h b/src/vm/jitinterface.h
index 4b52d9851a..71872d31e9 100644
--- a/src/vm/jitinterface.h
+++ b/src/vm/jitinterface.h
@@ -464,6 +464,8 @@ public:
void LongLifetimeFree(void* obj);
size_t getClassModuleIdForStatics(CORINFO_CLASS_HANDLE clsHnd, CORINFO_MODULE_HANDLE *pModuleHandle, void **ppIndirection);
const char* getClassName (CORINFO_CLASS_HANDLE cls);
+ const char* getClassNameFromMetadata (CORINFO_CLASS_HANDLE cls, const char** namespaceName);
+ CORINFO_CLASS_HANDLE getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index);
const char* getHelperName(CorInfoHelpFunc ftnNum);
int appendClassName(__deref_inout_ecount(*pnBufLen) WCHAR** ppBuf,
int* pnBufLen,
diff --git a/src/vm/methodtable.h b/src/vm/methodtable.h
index e5fd7fad07..c23117335b 100644
--- a/src/vm/methodtable.h
+++ b/src/vm/methodtable.h
@@ -1398,6 +1398,18 @@ public:
SetFlag(enum_flag_HasModuleDependencies);
}
+ inline BOOL IsIntrinsicType()
+ {
+ LIMITED_METHOD_DAC_CONTRACT;;
+ return GetFlag(enum_flag_IsIntrinsicType);
+ }
+
+ inline void SetIsIntrinsicType()
+ {
+ LIMITED_METHOD_DAC_CONTRACT;;
+ SetFlag(enum_flag_IsIntrinsicType);
+ }
+
// See the comment in code:MethodTable.DoFullyLoad for detailed description.
inline BOOL DependsOnEquivalentOrForwardedStructs()
{
@@ -4003,7 +4015,7 @@ private:
enum_flag_HasModuleDependencies = 0x0080,
- // enum_Unused = 0x0100,
+ enum_flag_IsIntrinsicType = 0x0100,
enum_flag_RequiresDispatchTokenFat = 0x0200,
diff --git a/src/vm/methodtablebuilder.cpp b/src/vm/methodtablebuilder.cpp
index adcf7bbc79..f34f8f4846 100644
--- a/src/vm/methodtablebuilder.cpp
+++ b/src/vm/methodtablebuilder.cpp
@@ -2006,7 +2006,22 @@ MethodTableBuilder::BuildMethodTableThrowing(
{
pMT->SetICastable();
}
-#endif // FEATURE_ICASTABLE
+#endif // FEATURE_ICASTABLE
+
+ // If this type is marked by [Intrinsic] attribute, it may be specially treated by the runtime/compiler
+ // Currently, only SIMD types have [Intrinsic] attribute
+ if ((GetModule()->IsSystem() || GetAssembly()->IsSIMDVectorAssembly()) && IsValueClass() && bmtGenerics->HasInstantiation())
+ {
+ HRESULT hr = GetMDImport()->GetCustomAttributeByName(bmtInternal->pType->GetTypeDefToken(),
+ g_CompilerServicesIntrinsicAttribute,
+ NULL,
+ NULL);
+
+ if (hr == S_OK)
+ {
+ pMT->SetIsIntrinsicType();
+ }
+ }
// Grow the typedef ridmap in advance as we can't afford to
// fail once we set the resolve bit
diff --git a/src/zap/zapinfo.cpp b/src/zap/zapinfo.cpp
index f0e9d9e8c4..215f4a7360 100644
--- a/src/zap/zapinfo.cpp
+++ b/src/zap/zapinfo.cpp
@@ -3024,6 +3024,16 @@ const char* ZapInfo::getClassName(CORINFO_CLASS_HANDLE cls)
return m_pEEJitInfo->getClassName(cls);
}
+const char* ZapInfo::getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName)
+{
+ return m_pEEJitInfo->getClassNameFromMetadata(cls, namespaceName);
+}
+
+CORINFO_CLASS_HANDLE ZapInfo::getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index)
+{
+ return m_pEEJitInfo->getTypeInstantiationArgument(cls, index);
+}
+
const char* ZapInfo::getHelperName(CorInfoHelpFunc func)
{
return m_pEEJitInfo->getHelperName(func);
diff --git a/src/zap/zapinfo.h b/src/zap/zapinfo.h
index 1c73d4a0f5..621ffbdc30 100644
--- a/src/zap/zapinfo.h
+++ b/src/zap/zapinfo.h
@@ -505,6 +505,8 @@ public:
CorInfoType asCorInfoType(CORINFO_CLASS_HANDLE cls);
const char* getClassName(CORINFO_CLASS_HANDLE cls);
+ const char* getClassNameFromMetadata(CORINFO_CLASS_HANDLE cls, const char** namespaceName);
+ CORINFO_CLASS_HANDLE getTypeInstantiationArgument(CORINFO_CLASS_HANDLE cls, unsigned index);
const char* getHelperName(CorInfoHelpFunc ftnNum);
int appendClassName(__deref_inout_ecount(*pnBufLen) WCHAR** ppBuf, int* pnBufLen,
CORINFO_CLASS_HANDLE cls,