Skip to content

Commit

Permalink
[WIP] Some code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
grendello committed Mar 1, 2021
1 parent 5c29bca commit 6b663c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 43 deletions.
10 changes: 2 additions & 8 deletions src/java-runtime/java/mono/android/MonoPackageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,8 @@ public static void LoadApplication (Context context, ApplicationInfo runtimePack
System.loadLibrary("xamarin-app");

if (!BuildConfig.DotNetRuntime) {
// .net5+ APKs don't contain `libmono-native.so` but we can't just perform a file existence check
// because we might be running with embedded DSOs enabled in which case the check would fail and we
// would have to catch the exception anyway in this case.
try {
System.loadLibrary("mono-native");
} catch (java.lang.UnsatisfiedLinkError ex) {
Log.i ("monodroid", "Failed to preload libmono-native.so (may not exist), ignoring", ex);
}
// .net5+ APKs don't contain `libmono-native.so`
System.loadLibrary("mono-native");
}

System.loadLibrary("monodroid");
Expand Down
37 changes: 2 additions & 35 deletions src/monodroid/jni/pinvoke-override-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,6 @@ MonodroidRuntime::pinvoke_api_map MonodroidRuntime::xa_pinvoke_map = {

MonodroidRuntime::pinvoke_library_map MonodroidRuntime::other_pinvoke_map (MonodroidRuntime::LIBRARY_MAP_INITIAL_BUCKET_COUNT);

//static bool first_call = true;

// `pinvoke_map_write_lock` MUST be held when calling this method
force_inline void*
MonodroidRuntime::load_library_entry (std::string const& library_name, std::string const& entrypoint_name, pinvoke_api_map_ptr api_map)
Expand Down Expand Up @@ -687,22 +685,15 @@ MonodroidRuntime::monodroid_pinvoke_override (const char *library_name, const ch
return handle;
}

// if (first_call) {
// log_warn (LOG_DEFAULT, "First call. Internal p/invoke map:");
// for (auto const& kv : xa_pinvoke_map) {
// log_warn (LOG_DEFAULT, " { \"%s\", %p }", kv.first.c_str (), kv.second);
// }
// first_call = false;
// }

timing_period lookup_time;
if (XA_UNLIKELY (utils.should_log (LOG_TIMING))) {
lookup_time.mark_start ();
}
auto iter = xa_pinvoke_map.find (entrypoint_name);
if (iter == xa_pinvoke_map.end ()) {
// TODO: perhaps it should be fatal?
log_warn (LOG_ASSEMBLY, "Internal p/invoke symbol %s@%s not found in compile-time map. Falling back to slow search.", library_name, entrypoint_name);
log_fatal (LOG_ASSEMBLY, "Internal p/invoke symbol '%s @ %s' not found in compile-time map.", library_name, entrypoint_name);
abort ();
return nullptr;
}

Expand All @@ -715,28 +706,4 @@ MonodroidRuntime::monodroid_pinvoke_override (const char *library_name, const ch
}
log_warn (LOG_DEFAULT, "Found %s@%s in internal p/invoke map (%p)", library_name, entrypoint_name, iter->second);
return iter->second;

// constexpr char UNKNOWN_ERROR[] = "Unknown error";

// char *err = nullptr;

// // "java-interop" is an alias for __Internal, which we handle as if it was "xa-internal-api", both of which can
// // be represented by a null name passed to monodroid_dlopen
// void *dso_handle = monodroid_dlopen (nullptr, 0, &err, nullptr);
// if (dso_handle == nullptr) {
// log_warn (LOG_DEFAULT, "Failed to load internal API shared library. %s", err != nullptr ? err : UNKNOWN_ERROR);
// }

// if (dso_handle == nullptr) {
// delete[] err;
// return nullptr;
// }

// void *func_ptr = monodroid_dlsym (dso_handle, entrypoint_name, &err, nullptr);
// if (func_ptr == nullptr) {
// log_warn (LOG_DEFAULT, "Failed to look up symbol '%s' in '%s'. %s", entrypoint_name, library_name, err != nullptr ? err : UNKNOWN_ERROR);
// delete[] err;
// }

// return func_ptr;
}

0 comments on commit 6b663c2

Please sign in to comment.