Exemple #1
0
 public static ManagedJit GetOrCreate()
 {
     lock (JitLock)
     {
         return(ManagedJitInstance ?? (ManagedJitInstance = new ManagedJit()));
     }
 }
Exemple #2
0
 static void Main(string[] args)
 {
     using (var clrJit = ManagedJit.GetOrCreate())
     {
         // It will print `1 + 2 = 4!` instead of the expected 3
         var result = JitReplaceAdd(1, 2);
         Console.WriteLine($"{nameof(JitReplaceAdd)}: 1 + 2 = {result}!");
     }
 }
Exemple #3
0
        public void Dispose()
        {
            lock (JitLock)
            {
                if (_isDisposed)
                {
                    return;
                }

                if (_overrideCompileMethodPtr == IntPtr.Zero)
                {
                    return;
                }

                UninstallManagedJit();
                _overrideCompileMethodPtr = IntPtr.Zero;
                _overrideCompileMethod    = null;
                _isDisposed        = true;
                ManagedJitInstance = null;
                _isHookInstalled   = false;
            }
        }