summaryrefslogtreecommitdiff
path: root/src/vm/typehashingalgorithms.h
diff options
context:
space:
mode:
authorJohn Chen (CLR) <jochen@microsoft.com>2016-05-12 10:02:33 -0700
committerJohn Chen (CLR) <jochen@microsoft.com>2016-05-12 13:03:49 -0700
commite732c0a3fe1649995e62d577a067d4f066c79b22 (patch)
treee32e1927ca57199f4ff58b33d5da3037e494db28 /src/vm/typehashingalgorithms.h
parent4678ac883a8eafa45246fff978a4756483e0f067 (diff)
downloadcoreclr-e732c0a3fe1649995e62d577a067d4f066c79b22.tar.gz
coreclr-e732c0a3fe1649995e62d577a067d4f066c79b22.tar.bz2
coreclr-e732c0a3fe1649995e62d577a067d4f066c79b22.zip
Fix contract violations in Ready to Run code
Diffstat (limited to 'src/vm/typehashingalgorithms.h')
-rw-r--r--src/vm/typehashingalgorithms.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/vm/typehashingalgorithms.h b/src/vm/typehashingalgorithms.h
index 9f3f3cd37a..c661451eff 100644
--- a/src/vm/typehashingalgorithms.h
+++ b/src/vm/typehashingalgorithms.h
@@ -14,6 +14,8 @@
//
inline static int ComputeNameHashCode(LPCUTF8 src)
{
+ LIMITED_METHOD_CONTRACT;
+
if (src == NULL || *src == '\0')
return 0;
@@ -39,6 +41,8 @@ inline static int ComputeNameHashCode(LPCUTF8 src)
inline static int ComputeNameHashCode(LPCUTF8 pszNamespace, LPCUTF8 pszName)
{
+ LIMITED_METHOD_CONTRACT;
+
// DIFFERENT FROM CORERT: CoreRT hashes the full name as one string ("namespace.name"),
// as the full name is already available. In CoreCLR we normally only have separate
// strings for namespace and name, thus we hash them separately.
@@ -47,6 +51,8 @@ inline static int ComputeNameHashCode(LPCUTF8 pszNamespace, LPCUTF8 pszName)
inline static int ComputeArrayTypeHashCode(int elementTypeHashcode, int rank)
{
+ LIMITED_METHOD_CONTRACT;
+
// DIFFERENT FROM CORERT: This is much simplified compared to CoreRT, to avoid converting.rank to string.
// For single-dimensinal array, the result is identical to CoreRT.
int hashCode = 0xd5313556 + rank;
@@ -59,22 +65,30 @@ inline static int ComputeArrayTypeHashCode(int elementTypeHashcode, int rank)
inline static int ComputePointerTypeHashCode(int pointeeTypeHashcode)
{
+ LIMITED_METHOD_CONTRACT;
+
return (pointeeTypeHashcode + _rotl(pointeeTypeHashcode, 5)) ^ 0x12D0;
}
inline static int ComputeByrefTypeHashCode(int parameterTypeHashcode)
{
+ LIMITED_METHOD_CONTRACT;
+
return (parameterTypeHashcode + _rotl(parameterTypeHashcode, 7)) ^ 0x4C85;
}
inline static int ComputeNestedTypeHashCode(int enclosingTypeHashcode, int nestedTypeNameHash)
{
+ LIMITED_METHOD_CONTRACT;
+
return (enclosingTypeHashcode + _rotl(enclosingTypeHashcode, 11)) ^ nestedTypeNameHash;
}
template <typename TA, typename TB>
inline static int ComputeGenericInstanceHashCode(int definitionHashcode, int arity, const TA& genericTypeArguments, int (*getHashCode)(TB))
{
+ LIMITED_METHOD_CONTRACT;
+
int hashcode = definitionHashcode;
for (int i = 0; i < arity; i++)
{