Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[monodroid] treat LocalRefsAreIndirect as always true #9138

Merged
merged 1 commit into from
Jul 25, 2024
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
2 changes: 1 addition & 1 deletion src/Mono.Android/Android.Runtime/JNIEnv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static Type MakeArrayType (Type type) =>

internal static IntPtr IdentityHash (IntPtr v)
{
return JNIEnvInit.LocalRefsAreIndirect ? RuntimeNativeMethods._monodroid_get_identity_hash_code (Handle, v) : v;
return RuntimeNativeMethods._monodroid_get_identity_hash_code (Handle, v);
}

public static void CheckHandle (IntPtr jnienv)
Expand Down
4 changes: 0 additions & 4 deletions src/Mono.Android/Android.Runtime/JNIEnvInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ internal struct JnienvInitializeArgs {
public uint logCategories;
public int version; // TODO: remove, not needed anymore
public int androidSdkVersion;
public int localRefsAreIndirect;
public int grefGcThreshold;
public IntPtr grefIGCUserPeer;
public int isRunningOnDesktop;
Expand All @@ -40,7 +39,6 @@ internal struct JnienvInitializeArgs {
internal static bool AllocObjectSupported;
internal static bool IsRunningOnDesktop;
internal static bool jniRemappingInUse;
internal static bool LocalRefsAreIndirect;
internal static bool LogAssemblyCategory;
internal static bool MarshalMethodsEnabled;
internal static bool PropagateExceptions;
Expand Down Expand Up @@ -96,8 +94,6 @@ internal static unsafe void Initialize (JnienvInitializeArgs* args)

mid_Class_forName = new JniMethodInfo (args->Class_forName, isStatic: true);

LocalRefsAreIndirect = args->localRefsAreIndirect == 1;

bool androidNewerThan10 = args->androidSdkVersion > 10;
BoundExceptionType = (BoundExceptionType)args->ioExceptionType;
androidRuntime = new AndroidRuntime (args->env, args->javaVm, androidNewerThan10, args->grefLoader, args->Loader_loadClass, args->jniAddNativeMethodRegistrationAttributePresent != 0);
Expand Down
2 changes: 0 additions & 2 deletions src/native/monodroid/monodroid-glue-internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ namespace xamarin::android::internal
unsigned int logCategories;
int version;
int androidSdkVersion;
int localRefsAreIndirect;
int grefGcThreshold;
jobject grefIGCUserPeer;
int isRunningOnDesktop;
Expand Down Expand Up @@ -180,7 +179,6 @@ namespace xamarin::android::internal
fnptr = reinterpret_cast<TFunc*>(symptr);
}

int LocalRefsAreIndirect (JNIEnv *env, jclass runtimeClass, int version);
void create_xdg_directory (jstring_wrapper& home, size_t home_len, std::string_view const& relative_path, std::string_view const& environment_variable_name) noexcept;
void create_xdg_directories_and_environment (jstring_wrapper &homeDir);
void lookup_bridge_info (MonoClass *klass, const OSBridge::MonoJavaGCBridgeType *type, OSBridge::MonoJavaGCBridgeInfo *info);
Expand Down
19 changes: 3 additions & 16 deletions src/native/monodroid/monodroid-glue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -772,21 +772,6 @@ MonodroidRuntime::create_domain (JNIEnv *env, jstring_array_wrapper &runtimeApks
return domain;
}

inline int
MonodroidRuntime::LocalRefsAreIndirect (JNIEnv *env, jclass runtimeClass, int version)
{
if (version < 14) {
java_System = nullptr;
java_System_identityHashCode = 0;
return 0;
}

java_System = RuntimeUtil::get_class_from_runtime_field (env, runtimeClass, "java_lang_System", true);
java_System_identityHashCode = env->GetStaticMethodID (java_System, "identityHashCode", "(Ljava/lang/Object;)I");

return 1;
}

force_inline void
MonodroidRuntime::lookup_bridge_info (MonoClass *klass, const OSBridge::MonoJavaGCBridgeType *type, OSBridge::MonoJavaGCBridgeInfo *info)
{
Expand Down Expand Up @@ -851,7 +836,6 @@ MonodroidRuntime::init_android_runtime (JNIEnv *env, jclass runtimeClass, jobjec
init.logCategories = log_categories;
init.version = env->GetVersion ();
init.androidSdkVersion = android_api_level;
init.localRefsAreIndirect = LocalRefsAreIndirect (env, runtimeClass, init.androidSdkVersion);
init.isRunningOnDesktop = is_running_on_desktop ? 1 : 0;
init.brokenExceptionTransitions = application_config.broken_exception_transitions ? 1 : 0;
init.packageNamingPolicy = static_cast<int>(application_config.package_naming_policy);
Expand All @@ -860,6 +844,9 @@ MonodroidRuntime::init_android_runtime (JNIEnv *env, jclass runtimeClass, jobjec
init.jniRemappingInUse = application_config.jni_remapping_replacement_type_count > 0 || application_config.jni_remapping_replacement_method_index_entry_count > 0;
init.marshalMethodsEnabled = application_config.marshal_methods_enabled;

java_System = RuntimeUtil::get_class_from_runtime_field (env, runtimeClass, "java_lang_System", true);
java_System_identityHashCode = env->GetStaticMethodID (java_System, "identityHashCode", "(Ljava/lang/Object;)I");

// GC threshold is 90% of the max GREF count
init.grefGcThreshold = static_cast<int>(AndroidSystem::get_gref_gc_threshold ());

Expand Down
Loading