Skip to content
Merged
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
4 changes: 4 additions & 0 deletions src/monodroid/jni/android-system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,12 @@ AndroidSystem::setup_environment ()
break;

case 'i':
#if !defined (NET6)
aotMode = MonoAotMode::MONO_AOT_MODE_LAST;
aot_mode_last_is_interpreter = true;
#else // defined (NET6)
aotMode = MonoAotMode::MONO_AOT_MODE_INTERP_ONLY;
#endif // !defined (NET6)
break;

default:
Expand Down
10 changes: 10 additions & 0 deletions src/monodroid/jni/android-system.hh
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,22 @@ namespace xamarin::android::internal

bool is_interpreter_enabled () const
{
#if !defined (NET6)
// HACK! See below
return get_mono_aot_mode () == MonoAotMode::MONO_AOT_MODE_LAST && is_aot_mode_last_really_interpreter_mode ();
#else // defined (NET6)
return get_mono_aot_mode () == MonoAotMode::MONO_AOT_MODE_INTERP_ONLY;
#endif // !defined (NET6)
}

// Hack, see comment for `aot_mode_last_is_interpreter` at the bottom of the class declaration
bool is_aot_mode_last_really_interpreter_mode () const
{
#if !defined(NET6)
return aot_mode_last_is_interpreter;
#else // defined (NET6)
return false;
#endif // !defined (NET6)
}

void set_running_in_emulator (bool yesno)
Expand Down Expand Up @@ -151,6 +159,7 @@ namespace xamarin::android::internal
MonoAotMode aotMode = MonoAotMode::MONO_AOT_MODE_NONE;
bool running_in_emulator = false;

#if !defined (NET6)
// This is a hack because of the way Mono currently switches the full interpreter (no JIT) mode. In Mono
// **internal** headers there's an AOT mode macro, `MONO_EE_MODE_INTERP`, whose value is exactly the same as
// MonoAotMode::MONO_AOT_MODE_LAST. However, we use `MonoAotMode::MONO_AOT_MODE_LAST` as a sentinel to indicate
Expand All @@ -161,6 +170,7 @@ namespace xamarin::android::internal
// See also: https://github.com/mono/mono/issues/18893
//
bool aot_mode_last_is_interpreter = false;
#endif // !defined (NET6)
};
}
#endif // !__ANDROID_SYSTEM_H
8 changes: 8 additions & 0 deletions src/monodroid/jni/monodroid-glue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1807,6 +1807,7 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl
MonoAotMode mode = MonoAotMode::MONO_AOT_MODE_NONE;
if (androidSystem.is_mono_aot_enabled ()) {
mode = androidSystem.get_mono_aot_mode ();
#if !defined (NET6)
if (mode == MonoAotMode::MONO_AOT_MODE_LAST) {
// Hack. See comments in android-system.hh
if (!androidSystem.is_interpreter_enabled ()) {
Expand All @@ -1821,6 +1822,13 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl
log_info (LOG_DEFAULT, "Enabling Mono Interpreter");
}
}
#else // defined (NET6)
if (mode != MonoAotMode::MONO_AOT_MODE_INTERP_ONLY) {
log_info (LOG_DEFAULT, "Enabling AOT mode in Mono");
} else {
log_info (LOG_DEFAULT, "Enabling Mono Interpreter");
}
#endif // !defined (NET6)
}
mono_jit_set_aot_mode (mode);

Expand Down