diff --git a/src/Java.Interop/Java.Interop/JniEnvironment.cs b/src/Java.Interop/Java.Interop/JniEnvironment.cs index ac9f8397c..88b9c6b18 100644 --- a/src/Java.Interop/Java.Interop/JniEnvironment.cs +++ b/src/Java.Interop/Java.Interop/JniEnvironment.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Threading; @@ -12,6 +13,7 @@ public static partial class JniEnvironment { internal static readonly ThreadLocal Info = new ThreadLocal (() => new JniEnvironmentInfo (), trackAllValues: true); internal static JniEnvironmentInfo CurrentInfo { + [MethodImpl (MethodImplOptions.AggressiveInlining)] get { var e = Info.Value; if (!e.IsValid) @@ -21,22 +23,27 @@ internal static JniEnvironmentInfo CurrentInfo { } public static JniRuntime Runtime { + [MethodImpl (MethodImplOptions.AggressiveInlining)] get {return CurrentInfo.Runtime;} } public static IntPtr EnvironmentPointer { + [MethodImpl (MethodImplOptions.AggressiveInlining)] get {return CurrentInfo.EnvironmentPointer;} } public static JniVersion JniVersion { + [MethodImpl (MethodImplOptions.AggressiveInlining)] get {return (JniVersion) Versions.GetVersion ();} } public static int LocalReferenceCount { + [MethodImpl (MethodImplOptions.AggressiveInlining)] get {return CurrentInfo.LocalReferenceCount;} } public static bool WithinNewObjectScope { + [MethodImpl (MethodImplOptions.AggressiveInlining)] get {return CurrentInfo.WithinNewObjectScope;} internal set {CurrentInfo.WithinNewObjectScope = value;} } diff --git a/src/Java.Interop/Java.Interop/JniObjectReference.cs b/src/Java.Interop/Java.Interop/JniObjectReference.cs index faf7fccd6..e72659371 100644 --- a/src/Java.Interop/Java.Interop/JniObjectReference.cs +++ b/src/Java.Interop/Java.Interop/JniObjectReference.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; #if FEATURE_JNIOBJECTREFERENCE_SAFEHANDLES && FEATURE_JNIOBJECTREFERENCE_INTPTRS @@ -24,6 +25,7 @@ internal JniReferenceSafeHandle SafeHandle { get {return gcHandle.IsAllocated ? ((JniReferenceSafeHandle) gcHandle.Target) : JniReferenceSafeHandle.Null;} } public IntPtr Handle { + [MethodImpl (MethodImplOptions.AggressiveInlining)] get { var h = SafeHandle; return h == null @@ -32,7 +34,11 @@ public IntPtr Handle { } } #elif FEATURE_JNIOBJECTREFERENCE_INTPTRS - public IntPtr Handle {get; private set;} + public IntPtr Handle { + [MethodImpl (MethodImplOptions.AggressiveInlining)] + get; + private set; + } #endif uint referenceInfo; @@ -47,6 +53,7 @@ internal JniObjectReferenceFlags Flags { } public bool IsValid { + [MethodImpl (MethodImplOptions.AggressiveInlining)] get { #if FEATURE_JNIOBJECTREFERENCE_SAFEHANDLES return SafeHandle != null && !SafeHandle.IsInvalid && !SafeHandle.IsClosed; diff --git a/src/Java.Interop/Java.Interop/JniType.cs b/src/Java.Interop/Java.Interop/JniType.cs index 83837d10f..18c8afc51 100644 --- a/src/Java.Interop/Java.Interop/JniType.cs +++ b/src/Java.Interop/Java.Interop/JniType.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; +using System.Runtime.CompilerServices; using System.Threading; using Java.Interop; @@ -78,6 +79,7 @@ void RegisterWithRuntime () registered = true; } + [MethodImpl (MethodImplOptions.AggressiveInlining)] void AssertValid () { if (!PeerReference.IsValid)