Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/Mono.Android/Android.Runtime/JNIEnvInit.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -80,6 +81,13 @@ static unsafe void RegisterJniNatives (IntPtr typeName_ptr, int typeName_len, In
#endif
internal static unsafe void Initialize (JnienvInitializeArgs* args)
{
// var report = new System.Text.StringBuilder ();
// var total = new Stopwatch ();
// total.Start ();

// var watch = new Stopwatch ();
// watch.Start ();

IntPtr total_timing_sequence = IntPtr.Zero;
IntPtr partial_timing_sequence = IntPtr.Zero;

Expand All @@ -97,13 +105,31 @@ internal static unsafe void Initialize (JnienvInitializeArgs* args)

LocalRefsAreIndirect = args->localRefsAreIndirect == 1;

// watch.Stop ();
// report.Append ("Initialize: initialize fields:: ");
// report.Append (watch.ElapsedTicks);
// report.AppendLine ();

// watch.Restart ();
#if MONOANDROID1_0
Mono.SystemDependencyProvider.Initialize ();
#endif
// watch.Stop ();
// report.Append ("Initialize: system deps init:: ");
// report.Append (watch.ElapsedTicks);
// report.AppendLine ();

// watch.Restart ();
bool androidNewerThan10 = args->androidSdkVersion > 10;
BoundExceptionType = (BoundExceptionType)args->ioExceptionType;

androidRuntime = new AndroidRuntime (args->env, args->javaVm, androidNewerThan10, args->grefLoader, args->Loader_loadClass, args->jniAddNativeMethodRegistrationAttributePresent != 0);
// watch.Stop ();
// report.Append ("Initialize: AndroidRuntime.ctor:: ");
// report.Append (watch.ElapsedTicks);
// report.AppendLine ();

// watch.Restart ();
AndroidValueManager = (AndroidValueManager) androidRuntime.ValueManager;

AllocObjectSupported = androidNewerThan10;
Expand All @@ -124,6 +150,17 @@ internal static unsafe void Initialize (JnienvInitializeArgs* args)
#if !MONOANDROID1_0
SetSynchronizationContext ();
#endif
// watch.Stop ();
// report.Append ("Initialize: the rest:: ");
// report.Append (watch.ElapsedTicks);
// report.AppendLine ();

// total.Stop ();
// report.Append ("Initialize: total time:: ");
// report.Append (total.ElapsedTicks);
// report.AppendLine ();

// Console.WriteLine ($"Initialize: {report.ToString ()}");
}

#if !MONOANDROID1_0
Expand Down
2 changes: 2 additions & 0 deletions src/Mono.Android/Android.Runtime/RuntimeNativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ internal static class RuntimeNativeMethods
[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
internal extern static void monodroid_log (LogLevel level, LogCategories category, string message);

[SuppressGCTransition]
[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
internal extern static IntPtr monodroid_timing_start (string? message);

[SuppressGCTransition]
[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
internal extern static void monodroid_timing_stop (IntPtr sequence, string? message);

Expand Down
1 change: 1 addition & 0 deletions src/monodroid/jni/monodroid-glue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ MonodroidRuntime::init_android_runtime (
"Failed to obtain unmanaged-callers-only pointer to the Android.Runtime.JNIEnvInit.Initialize method. %s",
mono_error_get_message (&error)
);
log_info (LOG_DEFAULT, "Before INITIALIZE");
initialize (&init);
#else // def NET && def ANDROID
void *args [] = {
Expand Down