Skip to content

Commit

Permalink
Mark methods specially handled in JitInterface Intrinsic (dotnet#26209)
Browse files Browse the repository at this point in the history
* Mark methods specially handled in JitInterface Intrinsic

For CPAOT compiler's sake.
  • Loading branch information
MichalStrehovsky authored and jkotas committed Aug 22, 2019
1 parent 47a1558 commit 2173d92
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public static partial class Activator
return o != null ? new ObjectHandle(o) : null;
}

[System.Runtime.CompilerServices.Intrinsic]
public static T CreateInstance<T>()
{
return (T)((RuntimeType)typeof(T)).CreateInstanceDefaultCtor(publicOnly: true, skipCheckThis: true, fillCache: true, wrapExceptions: true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ internal static void ExecuteBackoutCodeHelper(object backoutCode, object? userDa
}

/// <returns>true if given type is reference type or value type that contains references</returns>
[Intrinsic]
public static bool IsReferenceOrContainsReferences<T>()
{
// The body of this function will be replaced by the EE with unsafe code!!!
Expand All @@ -157,6 +158,7 @@ public static bool IsReferenceOrContainsReferences<T>()
/// <remarks>
/// Only use the result of this for Equals() comparison, not for CompareTo() comparison.
/// </remarks>
[Intrinsic]
internal static bool IsBitwiseEquatable<T>()
{
// The body of this function will be replaced by the EE with unsafe code!!!
Expand All @@ -167,6 +169,7 @@ internal static bool IsBitwiseEquatable<T>()
internal static ref byte GetRawData(this object obj) =>
ref Unsafe.As<RawData>(obj).Data;

[Intrinsic]
internal static ref byte GetRawSzArrayData(this Array array) =>
ref Unsafe.As<RawSzArrayData>(array).Data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,15 @@ internal static StackCrawlMarkHandle GetStackCrawlMarkHandle(ref StackCrawlMark
return new StackCrawlMarkHandle((IntPtr)Unsafe.AsPointer(ref stackMark));
}

[Intrinsic]
internal static bool EnumEquals<T>(T x, T y) where T : struct, Enum
{
// The body of this function will be replaced by the EE with unsafe code
// See getILIntrinsicImplementation for how this happens.
return x.Equals(y);
}

[Intrinsic]
internal static int EnumCompareTo<T>(T x, T y) where T : struct, Enum
{
// The body of this function will be replaced by the EE with unsafe code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public static T Exchange<T>([NotNullIfNotNull("value")] ref T location1, T value
// The workaround is no longer strictly necessary now that we have Unsafe.As but it does
// have the advantage of being less sensitive to JIT's inliner decisions.
[return: NotNullIfNotNull("location1")]
[Intrinsic]
public static T CompareExchange<T>(ref T location1, T value, T comparand) where T : class?
{
return Unsafe.As<T>(CompareExchange(ref Unsafe.As<T, object?>(ref location1), value, comparand));
Expand Down
2 changes: 1 addition & 1 deletion src/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7638,7 +7638,7 @@ getMethodInfoHelper(

MethodTable * pMT = ftn->GetMethodTable();

if (pMT->GetModule()->IsSystem())
if (ftn->IsJitIntrinsic())
{
if (MscorlibBinder::IsClass(pMT, CLASS__JIT_HELPERS))
{
Expand Down

0 comments on commit 2173d92

Please sign in to comment.