Skip to content

Commit 9ca9cd5

Browse files
committed
[new] support prejit interpreter class and method
1 parent 37dafd7 commit 9ca9cd5

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Runtime/RuntimeApi.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Runtime.InteropServices;
77
using System.Text;
88
using System.Threading.Tasks;
9+
using UnityEditor;
910
using UnityEngine.Scripting;
1011

1112
namespace HybridCLR
@@ -29,6 +30,37 @@ public static unsafe LoadImageErrorCode LoadMetadataForAOTAssembly(byte[] dllByt
2930
public static extern LoadImageErrorCode LoadMetadataForAOTAssembly(byte[] dllBytes, HomologousImageMode mode);
3031
#endif
3132

33+
/// <summary>
34+
/// prejit method to avoid the jit cost of first time running
35+
/// </summary>
36+
/// <param name="method"></param>
37+
/// <returns>return true if method is jited, return false if method can't be jited </returns>
38+
///
39+
#if UNITY_EDITOR
40+
public static bool PreJitMethod(MethodInfo method)
41+
{
42+
return false;
43+
}
44+
#else
45+
[MethodImpl(MethodImplOptions.InternalCall)]
46+
public static extern bool PreJitMethod(MethodInfo method);
47+
#endif
48+
49+
/// <summary>
50+
/// prejit all methods of class to avoid the jit cost of first time running
51+
/// </summary>
52+
/// <param name="type"></param>
53+
/// <returns>return true if class is jited, return false if class can't be jited </returns>
54+
#if UNITY_EDITOR
55+
public static bool PreJitClass(Type type)
56+
{
57+
return false;
58+
}
59+
#else
60+
[MethodImpl(MethodImplOptions.InternalCall)]
61+
public static extern bool PreJitClass(Type type);
62+
#endif
63+
3264
/// <summary>
3365
/// get the maximum number of StackObjects in the interpreter thread stack (size*8 represents the final memory size occupied
3466
/// </summary>

0 commit comments

Comments
 (0)