Skip to content

Commit 8e50608

Browse files
committed
[net6] use MONO_AOT_MODE_INTERP_ONLY
This depends on a fix to mono/mono#18893 (make interp only mode distinct from MONO_AOT_MODE_LAST) which was done in mono/mono#20159 but only for .NET 6, not previous Mono releases. Fixes #5633
1 parent 1270c68 commit 8e50608

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/monodroid/jni/android-system.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,8 +657,12 @@ AndroidSystem::setup_environment ()
657657
break;
658658

659659
case 'i':
660+
#if !defined (NET6)
660661
aotMode = MonoAotMode::MONO_AOT_MODE_LAST;
661662
aot_mode_last_is_interpreter = true;
663+
#else
664+
aotMode = MonoAotMode::MONO_AOT_MODE_INTERP_ONLY;
665+
#endif
662666
break;
663667

664668
default:

src/monodroid/jni/android-system.hh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,22 @@ namespace xamarin::android::internal
101101

102102
bool is_interpreter_enabled () const
103103
{
104+
#if !defined (NET6)
104105
// HACK! See below
105106
return get_mono_aot_mode () == MonoAotMode::MONO_AOT_MODE_LAST && is_aot_mode_last_really_interpreter_mode ();
107+
#else
108+
return get_mono_aot_mode () == MonoAotMode::MONO_AOT_MODE_INTERP_ONLY;
109+
#endif
106110
}
107111

108112
// Hack, see comment for `aot_mode_last_is_interpreter` at the bottom of the class declaration
109113
bool is_aot_mode_last_really_interpreter_mode () const
110114
{
115+
#if !defined(NET6)
111116
return aot_mode_last_is_interpreter;
117+
#else
118+
return false;
119+
#endif
112120
}
113121

114122
void set_running_in_emulator (bool yesno)
@@ -151,6 +159,7 @@ namespace xamarin::android::internal
151159
MonoAotMode aotMode = MonoAotMode::MONO_AOT_MODE_NONE;
152160
bool running_in_emulator = false;
153161

162+
#if !defined (NET6)
154163
// This is a hack because of the way Mono currently switches the full interpreter (no JIT) mode. In Mono
155164
// **internal** headers there's an AOT mode macro, `MONO_EE_MODE_INTERP`, whose value is exactly the same as
156165
// MonoAotMode::MONO_AOT_MODE_LAST. However, we use `MonoAotMode::MONO_AOT_MODE_LAST` as a sentinel to indicate
@@ -161,6 +170,7 @@ namespace xamarin::android::internal
161170
// See also: https://github.com/mono/mono/issues/18893
162171
//
163172
bool aot_mode_last_is_interpreter = false;
173+
#endif
164174
};
165175
}
166176
#endif // !__ANDROID_SYSTEM_H

src/monodroid/jni/monodroid-glue.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,7 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl
18181818
MonoAotMode mode = MonoAotMode::MONO_AOT_MODE_NONE;
18191819
if (androidSystem.is_mono_aot_enabled ()) {
18201820
mode = androidSystem.get_mono_aot_mode ();
1821+
#if !defined (NET6)
18211822
if (mode == MonoAotMode::MONO_AOT_MODE_LAST) {
18221823
// Hack. See comments in android-system.hh
18231824
if (!androidSystem.is_interpreter_enabled ()) {
@@ -1832,6 +1833,13 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl
18321833
log_info (LOG_DEFAULT, "Enabling Mono Interpreter");
18331834
}
18341835
}
1836+
#else
1837+
if (mode != MonoAotMode::MONO_AOT_MODE_INTERP_ONLY) {
1838+
log_info (LOG_DEFAULT, "Enabling AOT mode in Mono");
1839+
} else {
1840+
log_info (LOG_DEFAULT, "Enabling Mono Interpreter");
1841+
}
1842+
#endif
18351843
}
18361844
mono_jit_set_aot_mode (mode);
18371845

0 commit comments

Comments
 (0)