Skip to content

Commit 6cc243c

Browse files
committed
Native portion of the changes
1 parent 63c42a5 commit 6cc243c

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

src/native/clr/host/typemap.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,22 +228,22 @@ auto TypeMapper::managed_to_java_release (const char *typeName, const uint8_t *m
228228
log_debug (LOG_ASSEMBLY, "typemap: found module matching MVID [{}]"sv, MonoGuidString (mvid).c_str ());
229229
hash_t name_hash = xxhash::hash (typeName, strlen (typeName));
230230

231-
const TypeMapModuleEntry *entry = find_managed_to_java_map_entry (name_hash, match->map, match->entry_count);
231+
// We implicitly trust the build process that the indexes are correct. This is by design, the libxamarin-app.so built
232+
// with the application is immutable and the build process made sure that the data in it matches the application.
233+
const TypeMapModuleEntry *const map = &modules_map_data[match->map_index];
234+
const TypeMapModuleEntry *entry = find_managed_to_java_map_entry (name_hash, map, match->entry_count);
232235
if (entry == nullptr) [[unlikely]] {
233-
if (match->map == nullptr) [[unlikely]] {
234-
log_warn (LOG_ASSEMBLY, "typemap: module with MVID [{}] has no associated type map."sv, MonoGuidString (mvid).c_str ());
235-
return nullptr;
236-
}
237-
238-
if (match->duplicate_count > 0 && match->duplicate_map != nullptr) {
236+
if (match->duplicate_count > 0 && match->duplicate_map_index < std::numeric_limits<decltype (match->duplicate_map_index)>::max ()) {
239237
log_debug (
240238
LOG_ASSEMBLY,
241239
"typemap: searching module [{}] duplicate map for type '{}' (hash {:x})"sv,
242240
MonoGuidString (mvid).c_str (),
243241
optional_string (typeName),
244242
name_hash
245243
);
246-
entry = find_managed_to_java_map_entry (name_hash, match->duplicate_map, match->duplicate_count);
244+
245+
const TypeMapModuleEntry *const duplicate_map = &modules_duplicates_data[match->duplicate_map_index];
246+
entry = find_managed_to_java_map_entry (name_hash, duplicate_map, match->duplicate_count);
247247
}
248248

249249
if (entry == nullptr) {

src/native/clr/include/xamarin-app.hh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ struct TypeMapModule
105105
uint32_t duplicate_count;
106106
uint32_t assembly_name_index;
107107
uint32_t assembly_name_length;
108-
TypeMapModuleEntry const *map;
109-
TypeMapModuleEntry const *duplicate_map;
108+
uint32_t map_index;
109+
uint32_t duplicate_map_index;
110110
};
111111

112112
struct TypeMapJava
@@ -349,7 +349,9 @@ extern "C" {
349349
[[gnu::visibility("default")]] extern const uint64_t java_type_names_size;
350350
[[gnu::visibility("default")]] extern const char managed_type_names[];
351351
[[gnu::visibility("default")]] extern const char managed_assembly_names[];
352-
[[gnu::visibility("default")]] extern TypeMapModule managed_to_java_map[];
352+
[[gnu::visibility("default")]] extern const TypeMapModule managed_to_java_map[];
353+
[[gnu::visibility("default")]] extern const TypeMapModuleEntry modules_map_data[];
354+
[[gnu::visibility("default")]] extern const TypeMapModuleEntry modules_duplicates_data[];
353355
[[gnu::visibility("default")]] extern const TypeMapJava java_to_managed_map[];
354356
[[gnu::visibility("default")]] extern const xamarin::android::hash_t java_to_managed_hashes[];
355357
#endif

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ const char java_type_names[] = {};
3333
const uint64_t java_type_names_size = 0;
3434
const char managed_type_names[] = {};
3535
const char managed_assembly_names[] = {};
36-
TypeMapModule managed_to_java_map[] = {};
36+
const TypeMapModule managed_to_java_map[] = {};
37+
const TypeMapModuleEntry modules_map_data[] = {};
38+
const TypeMapModuleEntry modules_duplicates_data[] = {};
3739
const TypeMapJava java_to_managed_map[] = {};
3840
const xamarin::android::hash_t java_to_managed_hashes[] = {};
3941
#endif

0 commit comments

Comments
 (0)