diff options
author | Fei Peng <fei.peng@intel.com> | 2017-12-06 20:01:18 -0800 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2017-12-06 23:01:18 -0500 |
commit | ee743a7bd51a327b692a557759c37553ac4760e2 (patch) | |
tree | 9d82762d7fcc57110ca856a8ca98e55a4bfefdf3 /src/vm | |
parent | 688b75c143aa0e080f386a04c74b13b3fc9877bf (diff) | |
download | coreclr-ee743a7bd51a327b692a557759c37553ac4760e2.tar.gz coreclr-ee743a7bd51a327b692a557759c37553ac4760e2.tar.bz2 coreclr-ee743a7bd51a327b692a557759c37553ac4760e2.zip |
new intrinsic type support (#15340)
Diffstat (limited to 'src/vm')
-rw-r--r-- | src/vm/jitinterface.cpp | 58 | ||||
-rw-r--r-- | src/vm/jitinterface.h | 2 | ||||
-rw-r--r-- | src/vm/methodtable.h | 14 | ||||
-rw-r--r-- | src/vm/methodtablebuilder.cpp | 17 |
4 files changed, 89 insertions, 2 deletions
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 |