Skip to content

[CoreCLR] Implement GC bridge #10198

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

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion src/Mono.Android/Android.Runtime/AndroidRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,9 @@ class AndroidValueManager : JniRuntime.JniValueManager {

public override void WaitForGCBridgeProcessing ()
{
AndroidRuntimeInternal.WaitForBridgeProcessing ();
if (!AndroidRuntimeInternal.BridgeProcessing)
return;
RuntimeNativeMethods._monodroid_gc_wait_for_bridge_processing ();
}

public override IJavaPeerable? CreatePeer (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ static void MonoUnhandledException (Exception ex)

public static void WaitForBridgeProcessing ()
{
if (!BridgeProcessing)
return;
RuntimeNativeMethods._monodroid_gc_wait_for_bridge_processing ();
Java.Interop.JniEnvironment.Runtime.ValueManager.WaitForGCBridgeProcessing ();
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/Mono.Android/Android.Runtime/RuntimeNativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Java;
using System.Text;

namespace Android.Runtime
Expand All @@ -18,7 +19,7 @@ enum TraceKind : uint
All = Java | Managed | Native | Signals,
}

internal static class RuntimeNativeMethods
internal unsafe static class RuntimeNativeMethods
{
[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
internal extern static void monodroid_log (LogLevel level, LogCategories category, string message);
Expand Down Expand Up @@ -92,6 +93,11 @@ internal static class RuntimeNativeMethods
[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
internal static extern bool clr_typemap_java_to_managed (string java_type_name, out IntPtr managed_assembly_name, out uint managed_type_token_id);

[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
internal static extern delegate* unmanaged<MarkCrossReferencesArgs*, void> clr_initialize_gc_bridge (
delegate* unmanaged<void> bridge_processing_started_callback,
delegate* unmanaged<MarkCrossReferencesArgs*, void> bridge_processing_finished_callback);

[MethodImplAttribute(MethodImplOptions.InternalCall)]
internal static extern void monodroid_unhandled_exception (Exception javaException);

Expand Down
Loading
Loading