Skip to content

Commit c2fb863

Browse files
committed
Remove native runtime support for instant run
Context: #9292 With "Enhanced Fast Deployment" no longer part of .NET for Android, remove the native runtime side of its support.
1 parent 17e2e8e commit c2fb863

File tree

8 files changed

+24
-114
lines changed

8 files changed

+24
-114
lines changed

src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/EnvironmentHelper.cs

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public sealed class ApplicationConfig
4444
public bool aot_lazy_load;
4545
public bool uses_assembly_preload;
4646
public bool broken_exception_transitions;
47-
public bool instant_run_enabled;
4847
public bool jni_add_native_method_registration_attribute_present;
4948
public bool have_runtime_config_blob;
5049
public bool have_assemblies_blob;
@@ -68,7 +67,7 @@ public sealed class ApplicationConfig
6867
public string android_package_name = String.Empty;
6968
}
7069

71-
const uint ApplicationConfigFieldCount = 27;
70+
const uint ApplicationConfigFieldCount = 26;
7271

7372
const string ApplicationConfigSymbolName = "application_config";
7473
const string AppEnvironmentVariablesSymbolName = "app_environment_variables";
@@ -232,112 +231,107 @@ static ApplicationConfig ReadApplicationConfig (EnvironmentFile envFile)
232231
ret.broken_exception_transitions = ConvertFieldToBool ("broken_exception_transitions", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
233232
break;
234233

235-
case 5: // instant_run_enabled: bool / .byte
236-
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
237-
ret.instant_run_enabled = ConvertFieldToBool ("instant_run_enabled", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
238-
break;
239-
240-
case 6: // jni_add_native_method_registration_attribute_present: bool / .byte
234+
case 5: // jni_add_native_method_registration_attribute_present: bool / .byte
241235
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
242236
ret.jni_add_native_method_registration_attribute_present = ConvertFieldToBool ("jni_add_native_method_registration_attribute_present", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
243237
break;
244238

245-
case 7: // have_runtime_config_blob: bool / .byte
239+
case 6: // have_runtime_config_blob: bool / .byte
246240
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
247241
ret.have_runtime_config_blob = ConvertFieldToBool ("have_runtime_config_blob", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
248242
break;
249243

250-
case 8: // have_assemblies_blob: bool / .byte
244+
case 7: // have_assemblies_blob: bool / .byte
251245
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
252246
ret.have_assemblies_blob = ConvertFieldToBool ("have_assemblies_blob", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
253247
break;
254248

255-
case 9: // marshal_methods_enabled: bool / .byte
249+
case 8: // marshal_methods_enabled: bool / .byte
256250
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
257251
ret.marshal_methods_enabled = ConvertFieldToBool ("marshal_methods_enabled", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
258252
break;
259253

260-
case 10: // ignore_split_configs: bool / .byte
254+
case 9: // ignore_split_configs: bool / .byte
261255
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
262256
ret.ignore_split_configs = ConvertFieldToBool ("ignore_split_configs", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
263257
break;
264258

265-
case 11: // bound_stream_io_exception_type: byte / .byte
259+
case 10: // bound_stream_io_exception_type: byte / .byte
266260
AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber);
267261
ret.bound_stream_io_exception_type = ConvertFieldToByte ("bound_stream_io_exception_type", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
268262
break;
269263

270-
case 12: // package_naming_policy: uint32_t / .word | .long
264+
case 11: // package_naming_policy: uint32_t / .word | .long
271265
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
272266
ret.package_naming_policy = ConvertFieldToUInt32 ("package_naming_policy", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
273267
break;
274268

275-
case 13: // environment_variable_count: uint32_t / .word | .long
269+
case 12: // environment_variable_count: uint32_t / .word | .long
276270
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
277271
ret.environment_variable_count = ConvertFieldToUInt32 ("environment_variable_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
278272
break;
279273

280-
case 14: // system_property_count: uint32_t / .word | .long
274+
case 13: // system_property_count: uint32_t / .word | .long
281275
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
282276
ret.system_property_count = ConvertFieldToUInt32 ("system_property_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
283277
break;
284278

285-
case 15: // number_of_assemblies_in_apk: uint32_t / .word | .long
279+
case 14: // number_of_assemblies_in_apk: uint32_t / .word | .long
286280
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
287281
ret.number_of_assemblies_in_apk = ConvertFieldToUInt32 ("number_of_assemblies_in_apk", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
288282
break;
289283

290-
case 16: // bundled_assembly_name_width: uint32_t / .word | .long
284+
case 15: // bundled_assembly_name_width: uint32_t / .word | .long
291285
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
292286
ret.bundled_assembly_name_width = ConvertFieldToUInt32 ("bundled_assembly_name_width", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
293287
break;
294288

295-
case 17: // number_of_assembly_store_files: uint32_t / .word | .long
289+
case 16: // number_of_assembly_store_files: uint32_t / .word | .long
296290
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
297291
ret.number_of_assembly_store_files = ConvertFieldToUInt32 ("number_of_assembly_store_files", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
298292
break;
299293

300-
case 18: // number_of_dso_cache_entries: uint32_t / .word | .long
294+
case 17: // number_of_dso_cache_entries: uint32_t / .word | .long
301295
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
302296
ret.number_of_dso_cache_entries = ConvertFieldToUInt32 ("number_of_dso_cache_entries", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
303297
break;
304298

305-
case 19: // number_of_aot_cache_entries: uint32_t / .word | .long
299+
case 18: // number_of_aot_cache_entries: uint32_t / .word | .long
306300
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
307301
ret.number_of_aot_cache_entries = ConvertFieldToUInt32 ("number_of_aot_cache_entries", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
308302
break;
309303

310-
case 20: // android_runtime_jnienv_class_token: uint32_t / .word | .long
304+
case 19: // android_runtime_jnienv_class_token: uint32_t / .word | .long
311305
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
312306
ret.android_runtime_jnienv_class_token = ConvertFieldToUInt32 ("android_runtime_jnienv_class_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
313307
break;
314308

315-
case 21: // jnienv_initialize_method_token: uint32_t / .word | .long
309+
case 20: // jnienv_initialize_method_token: uint32_t / .word | .long
316310
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
317311
ret.jnienv_initialize_method_token = ConvertFieldToUInt32 ("jnienv_initialize_method_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
318312
break;
319313

320-
case 22: // jnienv_registerjninatives_method_token: uint32_t / .word | .long
314+
case 21: // jnienv_registerjninatives_method_token: uint32_t / .word | .long
321315
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
322316
ret.jnienv_registerjninatives_method_token = ConvertFieldToUInt32 ("jnienv_registerjninatives_method_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
323317
break;
324318

325-
case 23: // jni_remapping_replacement_type_count: uint32_t / .word | .long
319+
case 22: // jni_remapping_replacement_type_count: uint32_t / .word | .long
326320
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
327321
ret.jni_remapping_replacement_type_count = ConvertFieldToUInt32 ("jni_remapping_replacement_type_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
328322
break;
329323

330-
case 24: // jni_remapping_replacement_method_index_entry_count: uint32_t / .word | .long
324+
case 23: // jni_remapping_replacement_method_index_entry_count: uint32_t / .word | .long
331325
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
332326
ret.jni_remapping_replacement_method_index_entry_count = ConvertFieldToUInt32 ("jni_remapping_replacement_method_index_entry_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
333327
break;
334328

335-
case 25: // mono_components_mask: uint32_t / .word | .long
329+
case 24: // mono_components_mask: uint32_t / .word | .long
336330
Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
337331
ret.mono_components_mask = ConvertFieldToUInt32 ("mono_components_mask", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]);
338332
break;
339333

340-
case 26: // android_package_name: string / [pointer type]
334+
case 25: // android_package_name: string / [pointer type]
341335
Assert.IsTrue (expectedPointerTypes.Contains (field [0]), $"Unexpected pointer field type in '{envFile.Path}:{item.LineNumber}': {field [0]}");
342336
pointers.Add (field [1].Trim ());
343337
break;

src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfig.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ sealed class ApplicationConfig
2929
public bool aot_lazy_load;
3030
public bool uses_assembly_preload;
3131
public bool broken_exception_transitions;
32-
public bool instant_run_enabled ;
3332
public bool jni_add_native_method_registration_attribute_present;
3433
public bool have_runtime_config_blob;
3534
public bool have_assemblies_blob;

src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ protected override void Construct (LlvmIrModule module)
225225
aot_lazy_load = AotEnableLazyLoad,
226226
uses_assembly_preload = UsesAssemblyPreload,
227227
broken_exception_transitions = BrokenExceptionTransitions,
228-
instant_run_enabled = false,
229228
jni_add_native_method_registration_attribute_present = JniAddNativeMethodRegistrationAttributePresent,
230229
have_runtime_config_blob = HaveRuntimeConfigBlob,
231230
have_assemblies_blob = HaveAssemblyStore,

src/native/monodroid/embedded-assemblies.cc

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -569,17 +569,7 @@ EmbeddedAssemblies::typemap_java_to_managed ([[maybe_unused]] hash_t hash, const
569569
c_unique_ptr<char> java_type_name {mono_string_to_utf8 (const_cast<MonoString*>(java_type))};
570570
const TypeMapEntry *entry = nullptr;
571571

572-
if (application_config.instant_run_enabled) {
573-
TypeMap *module;
574-
for (size_t i = 0; i < type_map_count; i++) {
575-
module = &type_maps[i];
576-
entry = binary_search<const char, TypeMapEntry, compare_type_name, false> (java_type_name.get (), module->java_to_managed, module->entry_count);
577-
if (entry != nullptr)
578-
break;
579-
}
580-
} else {
581-
entry = binary_search<const char, TypeMapEntry, compare_type_name, false> (java_type_name.get (), type_map.java_to_managed, type_map.entry_count);
582-
}
572+
entry = binary_search<const char, TypeMapEntry, compare_type_name, false> (java_type_name.get (), type_map.java_to_managed, type_map.entry_count);
583573

584574
if (entry == nullptr) [[unlikely]] {
585575
log_info (LOG_ASSEMBLY, "typemap: unable to find mapping to a managed type from Java type '%s'", java_type_name.get ());
@@ -725,21 +715,7 @@ EmbeddedAssemblies::typemap_java_to_managed (MonoString *java_type) noexcept
725715
force_inline const TypeMapEntry*
726716
EmbeddedAssemblies::typemap_managed_to_java (const char *managed_type_name) noexcept
727717
{
728-
const TypeMapEntry *entry = nullptr;
729-
730-
if (application_config.instant_run_enabled) {
731-
TypeMap *module;
732-
for (size_t i = 0; i < type_map_count; i++) {
733-
module = &type_maps[i];
734-
entry = binary_search<const char, TypeMapEntry, compare_type_name, false> (managed_type_name, module->managed_to_java, module->entry_count);
735-
if (entry != nullptr)
736-
break;
737-
}
738-
} else {
739-
entry = binary_search<const char, TypeMapEntry, compare_type_name, false> (managed_type_name, type_map.managed_to_java, type_map.entry_count);
740-
}
741-
742-
return entry;
718+
return binary_search<const char, TypeMapEntry, compare_type_name, false> (managed_type_name, type_map.managed_to_java, type_map.entry_count);
743719
}
744720

745721
force_inline const char*
@@ -1119,43 +1095,6 @@ EmbeddedAssemblies::typemap_load_file (int dir_fd, const char *dir_path, const c
11191095

11201096
return ret;
11211097
}
1122-
1123-
void
1124-
EmbeddedAssemblies::try_load_typemaps_from_directory (const char *path)
1125-
{
1126-
if (!application_config.instant_run_enabled) {
1127-
log_info (LOG_ASSEMBLY, "typemap: instant run disabled, not loading type maps from storage");
1128-
return;
1129-
}
1130-
1131-
std::unique_ptr<char> dir_path {Util::path_combine (path, "typemaps")};
1132-
DIR *dir;
1133-
if ((dir = ::opendir (dir_path.get ())) == nullptr) {
1134-
log_warn (LOG_ASSEMBLY, "typemap: could not open directory: `%s`", dir_path.get ());
1135-
return;
1136-
}
1137-
1138-
int dir_fd = dirfd (dir);
1139-
1140-
constexpr char index_name[] = "typemap.index";
1141-
1142-
// The pointer must be stored here because, after index is loaded, module.assembly_name points into the index data
1143-
// and must be valid until after the actual module file is loaded.
1144-
std::unique_ptr<uint8_t[]> index_data = typemap_load_index (dir_fd, dir_path.get (), index_name);
1145-
if (!index_data) {
1146-
log_fatal (LOG_ASSEMBLY, "typemap: unable to load TypeMap data index from '%s/%s'", dir_path.get (), index_name);
1147-
Helpers::abort_application ();
1148-
}
1149-
1150-
for (size_t i = 0; i < type_map_count; i++) {
1151-
TypeMap *module = &type_maps[i];
1152-
if (!typemap_load_file (dir_fd, dir_path.get (), module->assembly_name, *module)) {
1153-
continue;
1154-
}
1155-
}
1156-
1157-
::closedir (dir);
1158-
}
11591098
#endif // def DEBUG
11601099

11611100
size_t

src/native/monodroid/embedded-assemblies.hh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ namespace xamarin::android::internal {
112112
{}
113113
#endif // def RELEASE
114114

115-
#if defined (DEBUG)
116-
void try_load_typemaps_from_directory (const char *path);
117-
#endif
118115
STATIC_IN_ANDROID_RELEASE const char* typemap_managed_to_java (MonoReflectionType *type, const uint8_t *mvid) noexcept;
119116

120117
void install_preload_hooks_for_appdomains ();

src/native/monodroid/monodroid-glue.cc

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -228,22 +228,6 @@ MonodroidRuntime::should_register_file ([[maybe_unused]] const char *filename)
228228
inline void
229229
MonodroidRuntime::gather_bundled_assemblies (jstring_array_wrapper &runtimeApks, size_t *out_user_assemblies_count, bool have_split_apks)
230230
{
231-
#if defined(DEBUG)
232-
if (application_config.instant_run_enabled) {
233-
for (const char *od : AndroidSystem::override_dirs) {
234-
if (od == nullptr || !Util::directory_exists (od)) {
235-
continue;
236-
}
237-
238-
// TODO: temporary hack for the location of typemaps, to be fixed
239-
dynamic_local_string<SENSIBLE_PATH_MAX> above { od };
240-
above.append ("/..");
241-
log_debug (LOG_ASSEMBLY, "Loading TypeMaps from %s", above.get());
242-
embeddedAssemblies.try_load_typemaps_from_directory (above.get());
243-
}
244-
}
245-
#endif
246-
247231
if (!AndroidSystem::is_embedded_dso_mode_enabled ()) {
248232
*out_user_assemblies_count = embeddedAssemblies.register_from_filesystem<should_register_file> ();
249233
return;

src/native/xamarin-app-stub/application_dso_stub.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ const ApplicationConfig application_config = {
4747
.aot_lazy_load = false,
4848
.uses_assembly_preload = false,
4949
.broken_exception_transitions = false,
50-
.instant_run_enabled = false,
5150
.jni_add_native_method_registration_attribute_present = false,
5251
.have_runtime_config_blob = false,
5352
.have_assembly_store = false,

src/native/xamarin-app-stub/xamarin-app.hh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ struct ApplicationConfig
237237
bool aot_lazy_load;
238238
bool uses_assembly_preload;
239239
bool broken_exception_transitions;
240-
bool instant_run_enabled;
241240
bool jni_add_native_method_registration_attribute_present;
242241
bool have_runtime_config_blob;
243242
bool have_assembly_store;

0 commit comments

Comments
 (0)