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

Commit aa70c0a

Browse files
MichalStrehovskyjkotas
authored andcommitted
Restrict HW intrinsic name check to intrinsic types (#22116)
Avoids having to compare names of all types in CoreLib to see if they're HW intrinsics.
1 parent 1923d37 commit aa70c0a

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/vm/methodtablebuilder.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,8 +1489,25 @@ MethodTableBuilder::BuildMethodTableThrowing(
14891489
}
14901490
}
14911491

1492+
// If this type is marked by [Intrinsic] attribute, it may be specially treated by the runtime/compiler
1493+
// SIMD types have [Intrinsic] attribute, for example
1494+
//
1495+
// We check this here fairly early to ensure other downstream checks on these types can be slightly more efficient.
1496+
if (GetModule()->IsSystem() || GetAssembly()->IsSIMDVectorAssembly())
1497+
{
1498+
HRESULT hr = GetMDImport()->GetCustomAttributeByName(bmtInternal->pType->GetTypeDefToken(),
1499+
g_CompilerServicesIntrinsicAttribute,
1500+
NULL,
1501+
NULL);
1502+
1503+
if (hr == S_OK)
1504+
{
1505+
bmtProp->fIsIntrinsicType = true;
1506+
}
1507+
}
1508+
14921509
#if defined(_TARGET_X86_) || defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_)
1493-
if (GetModule()->IsSystem() && !bmtGenerics->HasInstantiation())
1510+
if (bmtProp->fIsIntrinsicType && !bmtGenerics->HasInstantiation())
14941511
{
14951512
LPCUTF8 className;
14961513
LPCUTF8 nameSpace;
@@ -1520,23 +1537,6 @@ MethodTableBuilder::BuildMethodTableThrowing(
15201537
}
15211538
#endif
15221539

1523-
// If this type is marked by [Intrinsic] attribute, it may be specially treated by the runtime/compiler
1524-
// Currently, only SIMD types have [Intrinsic] attribute
1525-
//
1526-
// We check this here fairly early to ensure other downstream checks on these types can be slightly more efficient.
1527-
if (GetModule()->IsSystem() || GetAssembly()->IsSIMDVectorAssembly())
1528-
{
1529-
HRESULT hr = GetMDImport()->GetCustomAttributeByName(bmtInternal->pType->GetTypeDefToken(),
1530-
g_CompilerServicesIntrinsicAttribute,
1531-
NULL,
1532-
NULL);
1533-
1534-
if (hr == S_OK)
1535-
{
1536-
bmtProp->fIsIntrinsicType = true;
1537-
}
1538-
}
1539-
15401540
// Com Import classes are special. These types must derive from System.Object,
15411541
// and we then substitute the parent with System._ComObject.
15421542
if (IsComImport() && !IsEnum() && !IsInterface() && !IsValueClass() && !IsDelegate())

0 commit comments

Comments
 (0)