Skip to content

Commit f4a2148

Browse files
What if everything was managed-only?
1 parent 0ae638d commit f4a2148

File tree

6 files changed

+5
-43
lines changed

6 files changed

+5
-43
lines changed

src/Mono.Android.Runtime/Mono.Android.Runtime.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,5 @@
6464
<ProjectReference Include="..\..\external\Java.Interop\src\Java.Interop\Java.Interop.csproj" />
6565
</ItemGroup>
6666

67-
<Import Project="..\..\build-tools\scripts\custom-runtime.targets" />
6867
<Import Project="Mono.Android.Runtime.targets" />
6968
</Project>

src/Mono.Android/Android.Runtime/RuntimeNativeMethods.cs

+1-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System;
33
using System.Runtime.CompilerServices;
44
using System.Runtime.InteropServices;
5-
using System.Runtime.InteropServices.Java;
65
using System.Text;
76

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

22-
internal unsafe static class RuntimeNativeMethods
21+
internal static class RuntimeNativeMethods
2322
{
2423
[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
2524
internal extern static void monodroid_log (LogLevel level, LogCategories category, string message);
@@ -93,17 +92,6 @@ internal unsafe static class RuntimeNativeMethods
9392
[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
9493
internal static extern bool clr_typemap_java_to_managed (string java_type_name, out IntPtr managed_assembly_name, out uint managed_type_token_id);
9594

96-
/// <summary>
97-
/// TODO: implement this in the native side.
98-
/// Initializes the "GC Bridge" implementation for the CoreCLR runtime.
99-
/// </summary>
100-
/// <param name="bridge_processing_finished_callback">A function pointer to a C# callback that will be invoked when bridge processing has completed.</param>
101-
/// <returns>A function pointer that should be passed to JavaMarshal.Initialize() on startup.</returns>
102-
[DllImport (RuntimeConstants.InternalDllName, CallingConvention = CallingConvention.Cdecl)]
103-
internal static extern delegate* unmanaged<nint, StronglyConnectedComponent*, nint, ComponentCrossReference*, void> clr_initialize_gc_bridge (
104-
delegate* unmanaged<nint, StronglyConnectedComponent*, nint, ComponentCrossReference*, void> bridge_processing_finished_callback
105-
);
106-
10795
[MethodImplAttribute(MethodImplOptions.InternalCall)]
10896
internal static extern void monodroid_unhandled_exception (Exception javaException);
10997

src/Mono.Android/Microsoft.Android.Runtime/ManagedValueManager.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ class ManagedValueManager : JniRuntime.JniValueManager
2525

2626
internal unsafe ManagedValueManager ()
2727
{
28-
var mark_cross_references_ftn = RuntimeNativeMethods.clr_initialize_gc_bridge (&BridgeProcessingFinished);
29-
JavaMarshal.Initialize (mark_cross_references_ftn);
28+
JavaMarshal.Initialize (&FinishBridgeProcessing);
3029
}
3130

3231
public override void WaitForGCBridgeProcessing ()
@@ -277,8 +276,10 @@ static unsafe void FreeHandle (GCHandle handle)
277276
}
278277

279278
[UnmanagedCallersOnly]
280-
internal static unsafe void BridgeProcessingFinished (nint sccsLen, StronglyConnectedComponent* sccs, nint ccrsLen, ComponentCrossReference* ccrs)
279+
internal static unsafe void FinishBridgeProcessing (nint sccsLen, StronglyConnectedComponent* sccs, nint ccrsLen, ComponentCrossReference* ccrs)
281280
{
281+
Java.Lang.JavaSystem.Gc ();
282+
282283
JavaMarshal.ReleaseMarkCrossReferenceResources (
283284
new Span<StronglyConnectedComponent> (sccs, (int) sccsLen),
284285
new Span<ComponentCrossReference> (ccrs, (int) ccrsLen));

src/native/clr/host/generate-pinvoke-tables.cc

-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ const std::vector<std::string> internal_pinvoke_names = {
7272
"monodroid_TypeManager_get_java_class_name",
7373
"clr_typemap_managed_to_java",
7474
"clr_typemap_java_to_managed",
75-
"clr_initialize_gc_bridge",
7675
"_monodroid_weak_gref_delete",
7776
"_monodroid_weak_gref_get",
7877
"_monodroid_weak_gref_new",

src/native/clr/host/internal-pinvokes.cc

-10
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,6 @@ bool clr_typemap_java_to_managed (const char *java_type_name, char const** assem
3636
return TypeMapper::typemap_java_to_managed (java_type_name, assembly_name, managed_type_token_id);
3737
}
3838

39-
static void clr_mark_cross_references (size_t sccsLen, StronglyConnectedComponent* sccs, size_t ccrsLen, ComponentCrossReference* ccrs)
40-
{
41-
// TODO: implement this
42-
}
43-
44-
MarkCrossReferencesFtn clr_initialize_gc_bridge (MarkCrossReferencesFtn callback) noexcept
45-
{
46-
return clr_mark_cross_references;
47-
}
48-
4939
void monodroid_log (LogLevel level, LogCategories category, const char *message) noexcept
5040
{
5141
switch (level) {

src/native/clr/include/runtime-base/internal-pinvokes.hh

-15
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,13 @@
77
#include "logger.hh"
88
#include <runtime-base/timing.hh>
99

10-
struct StronglyConnectedComponent
11-
{
12-
size_t Count;
13-
void** ContextMemory;
14-
};
15-
16-
struct ComponentCrossReference
17-
{
18-
size_t SourceGroupIndex;
19-
size_t DestinationGroupIndex;
20-
};
21-
22-
typedef void (*MarkCrossReferencesFtn)(size_t, StronglyConnectedComponent*, size_t, ComponentCrossReference*);
23-
2410
extern "C" {
2511
int _monodroid_gref_get () noexcept;
2612
void _monodroid_gref_log (const char *message) noexcept;
2713
int _monodroid_gref_log_new (jobject curHandle, char curType, jobject newHandle, char newType, const char *threadName, int threadId, const char *from, int from_writable) noexcept;
2814
void _monodroid_gref_log_delete (jobject handle, char type, const char *threadName, int threadId, const char *from, int from_writable) noexcept;
2915
const char* clr_typemap_managed_to_java (const char *typeName, const uint8_t *mvid) noexcept;
3016
bool clr_typemap_java_to_managed (const char *java_type_name, char const** assembly_name, uint32_t *managed_type_token_id) noexcept;
31-
MarkCrossReferencesFtn clr_initialize_gc_bridge (MarkCrossReferencesFtn callback) noexcept;
3217
void monodroid_log (xamarin::android::LogLevel level, LogCategories category, const char *message) noexcept;
3318
char* monodroid_TypeManager_get_java_class_name (jclass klass) noexcept;
3419
void monodroid_free (void *ptr) noexcept;

0 commit comments

Comments
 (0)