Skip to content

Commit d360e4b

Browse files
authored
[tools] Clean up mtouch/mmp. (#24526)
* Make mtouch able to what mmp does (aka run the partial static registrar for macOS). * Simplify mtouch a bit, since it's only doing a single thing, and it's not a tool we publish, so we don't have to be user-friendly. * Remove mmp. * Remove dead code. * Simplify conditional compilation symbols (LEGACY_TOOLS is now used instead of MTOUCH/MMP).
1 parent c6fec41 commit d360e4b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+503
-3389
lines changed

runtime/monotouch-debug.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,6 @@ static ssize_t sdb_recv (void *buf, size_t len)
998998
use_fd = true;
999999
profiler_description = xamarin_strdup_printf ("%s,output=#%i", prof, fd);
10001000
#endif
1001-
xamarin_set_gc_pump_enabled (false);
10021001
} else {
10031002
LOG (PRODUCT ": Unknown profiler, expect unexpected behavior (%s)\n", prof);
10041003
profiler_description = strdup (prof);

runtime/monotouch-main.m

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,6 @@ - (void) memoryWarning: (NSNotification *) sender
283283
{
284284
/*
285285
* Command line arguments for mobile targets (iOS / tvOS / macOS / Mac Catalyst):
286-
* -debugtrack: [Simulator only]
287-
* If we should track zombie NSObjects and aggressively poke the GC to collect
288-
* every second.
289286
* -monodevelop-port=<port>
290287
* The port MonoDevelop is listening on (or we should listen on).
291288
* Overrides whatever any configuration file says.
@@ -350,9 +347,7 @@ - (void) memoryWarning: (NSNotification *) sender
350347
value = NULL;
351348

352349
#ifdef DEBUG
353-
if (!strcmp (name, "debugtrack")) {
354-
xamarin_gc_pump = true;
355-
} else if (!strcmp (name, "monodevelop-port")) {
350+
if (!strcmp (name, "monodevelop-port")) {
356351
if (!value && argc > i + 1)
357352
value = argv [++i];
358353
if (value) {

runtime/runtime.m

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
* the simlauncher binaries).
3737
*/
3838

39-
#if DEBUG
40-
bool xamarin_gc_pump = false;
41-
#endif
4239
#if MONOMAC
4340
// FIXME: implement release mode for monomac.
4441
bool xamarin_debug_mode = true;
@@ -1049,24 +1046,6 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
10491046
xamarin_handling_unhandled_exceptions = 0;
10501047
}
10511048

1052-
#if defined (DEBUG)
1053-
static void *
1054-
pump_gc (void *context)
1055-
{
1056-
#if !defined (CORECLR_RUNTIME)
1057-
mono_thread_attach (mono_get_root_domain ());
1058-
#endif
1059-
1060-
while (xamarin_gc_pump) {
1061-
GCHandle exception_gchandle = INVALID_GCHANDLE;
1062-
xamarin_gc_collect (&exception_gchandle);
1063-
xamarin_process_fatal_exception_gchandle (exception_gchandle, "An exception occurred while running the GC in a loop");
1064-
usleep (1000000);
1065-
}
1066-
return NULL;
1067-
}
1068-
#endif /* DEBUG */
1069-
10701049
#if !defined (CORECLR_RUNTIME)
10711050
static void
10721051
log_callback (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data)
@@ -1219,13 +1198,6 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
12191198

12201199
xamarin_install_nsautoreleasepool_hooks ();
12211200

1222-
#if defined (DEBUG)
1223-
if (xamarin_gc_pump) {
1224-
pthread_t gc_thread;
1225-
pthread_create (&gc_thread, NULL, pump_gc, NULL);
1226-
}
1227-
#endif
1228-
12291201
pthread_mutexattr_t attr;
12301202
pthread_mutexattr_init (&attr);
12311203
pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
@@ -2036,14 +2008,6 @@ -(struct NSObjectData*) xamarinGetNSObjectData;
20362008
return true;
20372009
}
20382010

2039-
void
2040-
xamarin_set_gc_pump_enabled (bool value)
2041-
{
2042-
#if DEBUG
2043-
xamarin_gc_pump = value;
2044-
#endif
2045-
}
2046-
20472011
const char *
20482012
xamarin_skip_encoding_flags (const char *encoding)
20492013
{

runtime/xamarin/main.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ extern bool mono_use_llvm; // this is defined inside mono
105105
#define SUPPORTS_DYNAMIC_REGISTRATION 1
106106
#endif
107107

108-
#if DEBUG
109-
extern bool xamarin_gc_pump;
110-
#endif
111108
extern bool xamarin_debug_mode;
112109
extern bool xamarin_disable_lldb_attach;
113110
extern bool xamarin_disable_omit_fp;

runtime/xamarin/runtime.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ void xamarin_verify_parameter (MonoObject *obj, SEL sel, id self, id arg, unsi
256256
void xamarin_check_objc_type (id obj, Class expected_class, SEL sel, id self, int index, MonoMethod *method);
257257
#endif
258258

259-
void xamarin_set_gc_pump_enabled (bool value);
260259
void xamarin_set_is_managed_static_registrar (bool value);
261260

262261
void xamarin_process_nsexception (NSException *exc);

src/ObjCRuntime/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if MTOUCH || MMP || BUNDLER
1+
#if LEGACY_TOOLS || BUNDLER
22
namespace Xamarin.Bundler {
33
#else
44
namespace ObjCRuntime {

src/ObjCRuntime/ErrorHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#nullable enable
44

5-
#if MTOUCH || MMP || MMP_TEST || MTOUCH_TESTS
5+
#if LEGACY_TOOLS
66
#define BUNDLER
77
#endif
88

src/ObjCRuntime/NFloat.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
#if !(MTOUCH || MMP || BUNDLER)
21
global using nfloat = System.Runtime.InteropServices.NFloat;
3-
#endif

src/ObjCRuntime/Registrar.cs

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
using Xamarin.Bundler;
1818

19-
#if MTOUCH || MMP || BUNDLER
19+
#if LEGACY_TOOLS || BUNDLER
2020
using Xamarin.Utils;
2121
using TAssembly = Mono.Cecil.AssemblyDefinition;
2222
using TType = Mono.Cecil.TypeReference;
@@ -33,11 +33,11 @@
3333
using R = ObjCRuntime.Runtime;
3434
#endif
3535

36-
#if !(MTOUCH || MMP || BUNDLER)
36+
#if !(LEGACY_TOOLS || BUNDLER)
3737
using ProductException = ObjCRuntime.RuntimeException;
3838
#endif
3939

40-
#if !MTOUCH && !MMP && !BUNDLER
40+
#if !LEGACY_TOOLS && !BUNDLER
4141
// static registrar needs them but they might not be marked (e.g. if System.Console is not used)
4242
[assembly: Preserve (typeof (System.Action))]
4343
[assembly: Preserve (typeof (System.Action<string>))]
@@ -89,15 +89,11 @@ public static List<ProductException> GetMT4127 (TMethod impl, List<TMethod> ifac
8989
}
9090

9191
abstract partial class Registrar {
92-
#if MTOUCH || MMP || BUNDLER
92+
#if LEGACY_TOOLS || BUNDLER
9393
public Application App { get; protected set; }
9494
#endif
9595

96-
#if MMP || MTOUCH || BUNDLER
97-
static string NFloatTypeName { get => Driver.IsDotNet ? "System.Runtime.InteropServices.NFloat" : "System.nfloat"; }
98-
#else
9996
const string NFloatTypeName = "System.Runtime.InteropServices.NFloat";
100-
#endif
10197

10298
Dictionary<TAssembly, object> assemblies = new Dictionary<TAssembly, object> (); // Use Dictionary instead of HashSet to avoid pulling in System.Core.dll.
10399
// locking: all accesses must lock 'types'.
@@ -135,7 +131,7 @@ internal class ObjCType {
135131
public bool IsInformalProtocol;
136132
public bool IsWrapper;
137133
public bool IsGeneric;
138-
#if !MTOUCH && !MMP && !BUNDLER
134+
#if !LEGACY_TOOLS && !BUNDLER
139135
public IntPtr Handle;
140136
#else
141137
public TType ProtocolWrapperType;
@@ -152,7 +148,7 @@ internal class ObjCType {
152148

153149
public bool IsCategory { get { return CategoryAttribute is not null; } }
154150

155-
#if MTOUCH || MMP || BUNDLER
151+
#if LEGACY_TOOLS || BUNDLER
156152
HashSet<ObjCType> all_protocols;
157153
// This contains all protocols in the type hierarchy.
158154
// Given a type T that implements a protocol with super protocols:
@@ -630,7 +626,7 @@ public bool IsConstructor {
630626
}
631627
}
632628

633-
#if !MMP && !MTOUCH && !BUNDLER
629+
#if !LEGACY_TOOLS && !BUNDLER
634630
// The ArgumentSemantic enum is public, and
635631
// I don't want to add another enum value there which
636632
// is just an internal implementation detail, so just
@@ -881,7 +877,7 @@ public Trampoline Trampoline {
881877
if (trampoline != Trampoline.None)
882878
return trampoline;
883879

884-
#if MTOUCH || MMP || BUNDLER
880+
#if LEGACY_TOOLS || BUNDLER
885881
throw ErrorHelper.CreateError (8018, Errors.MT8018);
886882
#else
887883
var mi = (System.Reflection.MethodInfo) Method;
@@ -1045,7 +1041,7 @@ public override string FullName {
10451041
}
10461042

10471043
internal class ObjCField : ObjCMember {
1048-
#if !MTOUCH && !MMP && !BUNDLER
1044+
#if !LEGACY_TOOLS && !BUNDLER
10491045
public int Size;
10501046
public byte Alignment;
10511047
#else
@@ -1328,18 +1324,18 @@ internal static string AppKit {
13281324
}
13291325
#endif
13301326

1331-
#if MTOUCH || MMP || BUNDLER
1327+
#if LEGACY_TOOLS || BUNDLER
13321328
internal string AssemblyName {
13331329
get {
13341330
switch (App.Platform) {
13351331
case ApplePlatform.iOS:
1336-
return Driver.IsDotNet ? "Microsoft.iOS" : "Xamarin.iOS";
1332+
return "Microsoft.iOS";
13371333
case ApplePlatform.TVOS:
1338-
return Driver.IsDotNet ? "Microsoft.tvOS" : "Xamarin.TVOS";
1334+
return "Microsoft.tvOS";
13391335
case ApplePlatform.MacOSX:
1340-
return Driver.IsDotNet ? "Microsoft.macOS" : "Xamarin.Mac";
1336+
return "Microsoft.macOS";
13411337
case ApplePlatform.MacCatalyst:
1342-
return Driver.IsDotNet ? "Microsoft.MacCatalyst" : "Xamarin.MacCatalyst";
1338+
return "Microsoft.MacCatalyst";
13431339
default:
13441340
throw ErrorHelper.CreateError (71, Errors.MX0071, App.Platform, App.ProductName);
13451341
}
@@ -1376,7 +1372,7 @@ public string PlatformAssembly {
13761372
}
13771373
}
13781374

1379-
#if MTOUCH || MMP || BUNDLER
1375+
#if LEGACY_TOOLS || BUNDLER
13801376
// "#if MTOUCH" code does not need locking when accessing 'types', because mtouch is single-threaded.
13811377
public Dictionary<TType, ObjCType> Types {
13821378
get { return types; }
@@ -1821,7 +1817,7 @@ ObjCType [] GetProtocols (ObjCType type, ref List<Exception> exceptions)
18211817
Type = iface,
18221818
IsProtocol = true,
18231819
};
1824-
#if MMP || MTOUCH || BUNDLER
1820+
#if LEGACY_TOOLS || BUNDLER
18251821
objcType.ProtocolWrapperType = GetProtocolAttributeWrapperType (objcType.Type);
18261822
objcType.IsWrapper = objcType.ProtocolWrapperType is not null;
18271823
#endif
@@ -1985,7 +1981,7 @@ ObjCType RegisterTypeUnsafe (TType type, ref List<Exception> exceptions)
19851981
isInformalProtocol = pAttr.IsInformal;
19861982
isProtocol = true;
19871983

1988-
#if MMP || MTOUCH || BUNDLER
1984+
#if LEGACY_TOOLS || BUNDLER
19891985
if (pAttr.FormalSinceVersion is not null && pAttr.FormalSinceVersion > App.SdkVersion)
19901986
isInformalProtocol = !isInformalProtocol;
19911987
#endif
@@ -2019,7 +2015,7 @@ ObjCType RegisterTypeUnsafe (TType type, ref List<Exception> exceptions)
20192015
objcType.VerifyAdoptedProtocolsNames (ref exceptions);
20202016
objcType.BaseType = isProtocol ? null : (baseObjCType ?? objcType);
20212017
objcType.Protocols = GetProtocols (objcType, ref exceptions);
2022-
#if MMP || MTOUCH || BUNDLER
2018+
#if LEGACY_TOOLS || BUNDLER
20232019
objcType.ProtocolWrapperType = (isProtocol && !isInformalProtocol) ? GetProtocolAttributeWrapperType (objcType.Type) : null;
20242020
#endif
20252021
objcType.IsWrapper = (isProtocol && !isInformalProtocol) ? (GetProtocolAttributeWrapperType (objcType.Type) is not null) : (objcType.RegisterAttribute is not null && objcType.RegisterAttribute.IsWrapper);
@@ -2142,7 +2138,7 @@ ObjCType RegisterTypeUnsafe (TType type, ref List<Exception> exceptions)
21422138
}
21432139
}
21442140

2145-
#if MMP || MTOUCH || BUNDLER
2141+
#if LEGACY_TOOLS || BUNDLER
21462142
// Special fields
21472143
if (is_first_nonWrapper) {
21482144
// static registrar
@@ -2209,7 +2205,7 @@ ObjCType RegisterTypeUnsafe (TType type, ref List<Exception> exceptions)
22092205
}
22102206
} else {
22112207
TMethod method = null;
2212-
#if MTOUCH || MMP || BUNDLER
2208+
#if LEGACY_TOOLS || BUNDLER
22132209
method = attrib.Method;
22142210
#endif
22152211
var objcMethod = new ObjCMethod (this, objcType, method) {
@@ -2258,14 +2254,14 @@ ObjCType RegisterTypeUnsafe (TType type, ref List<Exception> exceptions)
22582254
objcType.Add (new ObjCField () {
22592255
DeclaringType = objcType,
22602256
Name = ca.Name ?? GetPropertyName (property),
2261-
#if !MTOUCH && !MMP && !BUNDLER
2257+
#if !LEGACY_TOOLS && !BUNDLER
22622258
Size = 8,
22632259
Alignment = (byte) 3,
22642260
#endif
22652261
FieldType = "@",
22662262
IsProperty = true,
22672263
IsStatic = IsStatic (property),
2268-
#if MTOUCH || MMP || BUNDLER
2264+
#if LEGACY_TOOLS || BUNDLER
22692265
Property = property,
22702266
#endif
22712267
}, ref exceptions);
@@ -2546,7 +2542,7 @@ public void RegisterAssembly (TAssembly assembly)
25462542

25472543
if (exceptions.Count > 0) {
25482544
Exception ae = exceptions.Count == 1 ? exceptions [0] : new AggregateException (exceptions);
2549-
#if !MTOUCH && !MMP && !BUNDLER
2545+
#if !LEGACY_TOOLS && !BUNDLER
25502546
Runtime.NSLog (ae.ToString ());
25512547
#endif
25522548
throw ae;
@@ -2661,7 +2657,7 @@ protected string GetExportedTypeName (TType type)
26612657
string GetBoolEncoding ()
26622658
{
26632659
// map managed 'bool' to ObjC BOOL = 'unsigned char' in OSX and 32bit iOS architectures and 'bool' in 64bit iOS architectures
2664-
#if MTOUCH || MMP || BUNDLER
2660+
#if LEGACY_TOOLS || BUNDLER
26652661
switch (App.Platform) {
26662662
case ApplePlatform.iOS:
26672663
case ApplePlatform.TVOS:
@@ -2786,7 +2782,7 @@ protected void UnlockRegistrar ()
27862782
System.Threading.Monitor.Exit (types);
27872783
}
27882784

2789-
#if MTOUCH || MMP || BUNDLER
2785+
#if LEGACY_TOOLS || BUNDLER
27902786
internal static void NSLog (string format, params object [] args)
27912787
{
27922788
Console.WriteLine (format, args);

tools/Makefile

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,7 @@ include $(TOP)/Make.config
44

55
SUBDIRS += devops
66

7-
ifdef INCLUDE_MAC
8-
SUBDIRS+=mmp
9-
endif
10-
11-
ifdef INCLUDE_IOS
12-
INCLUDE_MTOUCH=1
13-
endif
14-
ifdef INCLUDE_TVOS
15-
INCLUDE_MTOUCH=1
16-
endif
17-
ifdef INCLUDE_MACCATALYST
18-
INCLUDE_MTOUCH=1
19-
endif
20-
21-
ifdef INCLUDE_MTOUCH
227
SUBDIRS += mtouch
23-
endif
248

259
SUBDIRS+=mlaunch
2610

0 commit comments

Comments
 (0)