xamarin-macios/runtime
Rolf Bjarne Kvinge f557936e9c
[runtime] Use the correct underlying types for our own nfloat/n(u)int types. (#12714)
Defining xm_nint_t to be 32-bit sized only on i386 is not the right thing to do for armv7.

Strangely enough this caused just a single test failure:

    MonoTouchFixtures.Foundation.CalendarTest
        [FAIL] TestFindNextDateAfterDateMatching :   Expected: <Foundation.MonoTouchException>
            But was:  null
            at MonoTouchFixtures.Foundation.CalendarTest.TestFindNextDateAfterDateMatching()

and that happened because:

1. We use a wrapper function around objc_msgSend:

    void *
    xamarin_IntPtr_objc_msgSend_IntPtr_IntPtr_nuint_exception (id self, SEL sel, void * p0, void * p1, xm_nuint_t p2, GCHandle *exception_gchandle)
    {
    	@try {
    		return ((func_xamarin_IntPtr_objc_msgSend_IntPtr_IntPtr_nuint_exception) objc_msgSend) (self, sel, p0, p1, p2);
    	} @catch (NSException *e) {
    		xamarin_process_nsexception_using_mode (e, true, exception_gchandle);
    		return NULL;
    	}
    }

2. Note that the second to last argument is an 'xm_nuint_t'. We told the
   native compiler this was a 64-bit value, when the managed P/Invoke would
   give it a 32-bit value. This had no effect on the 'p2' parameter, but it
   meant that clang would thing the next argument, 'exception_gchandle', would
   be somewhere it wasn't (the managed function would pass two 32-bit values,
   'p2' and 'exception_gchandle', which clang would merge into a single 64-bit
   'p2' argument, and then read random stuff for 'exception_gchandle').

3. Finally things would go sideways when we caught the exception and passed
   'exception_gchandle' to xamarin_process_nsexception_using_mode. In effect
   we'd ask xamarin_process_nsexception_using_mode to store the resulting
   gchandle in random memory. Amazingly it only resulted in a test failure
   (because upon return the managed location for the 'exception_gchandle'
   wasn't touched, and would have its initial value of 0, thus managed code
   would think no exception occurred).

So fix this to use the correct underlying types, instead of trying to figure
out the correct #if condition.

I'm not sure why we're using our own types here anyways, but this fix is the
smallest.
2021-09-15 09:17:43 +02:00
..
xamarin [runtime] Add support for logging exceptions that go through exception marshalling using an environment variable. Fixes #12343. (#12344) 2021-08-05 08:17:20 +02:00
.gitignore [runtime] Move MonoVM-specific initialization to MonoVM-specific code. (#10899) 2021-03-18 07:23:39 +01:00
COOP.md [src] Remove ObjectWrapper. 2020-05-04 11:31:19 +02:00
Delegates.cs.t4 [dotnet][linker] Eliminate code that is only required for CoreCLR on iOS and tvOS (#11577) 2021-05-18 09:33:41 -04:00
EXCEPTIONS.md [runtime] Improve documentation about exceptions a little bit. 2016-06-08 20:11:07 +02:00
Makefile [runtime] Implement xamarin_dyn_objc_msgSend for ARM64. 2021-05-11 15:54:39 +02:00
README.md Initial review pass for COOP for watchOS. 2016-05-26 17:47:10 +02:00
Xamarin.framework-iphoneos.Info.plist [runtime] Split the build differently: build libraries for simulator and device separately. (#7143) 2019-10-03 16:38:44 +02:00
Xamarin.framework-iphonesimulator.Info.plist [runtime] Split the build differently: build libraries for simulator and device separately. (#7143) 2019-10-03 16:38:44 +02:00
Xamarin.framework-tvos.Info.plist Rename bundle identifier for the frameworks we ship. Fixes #6920. (#6926) 2019-09-06 09:30:49 -07:00
Xamarin.framework-tvsimulator.Info.plist [runtime] Split the build differently: build libraries for simulator and device separately. (#7143) 2019-10-03 16:38:44 +02:00
Xamarin.framework-watchos.Info.plist Rename bundle identifier for the frameworks we ship. Fixes #6920. (#6926) 2019-09-06 09:30:49 -07:00
Xamarin.framework-watchsimulator.Info.plist [runtime] Split the build differently: build libraries for simulator and device separately. (#7143) 2019-10-03 16:38:44 +02:00
bindings-generator.cs [generator] Simplify native enums logic. (#12473) 2021-08-19 16:59:07 +02:00
bindings-generator.csproj Fix some whitespace issues in various files. (#12399) 2021-08-11 10:06:46 +02:00
bindings.h [runtime] Use the correct underlying types for our own nfloat/n(u)int types. (#12714) 2021-09-15 09:17:43 +02:00
bindings.m [runtime] Return the exception from wrapper methods for exception marshalling. (#11382) 2021-05-04 08:25:38 +02:00
coreclr-bridge.m [runtime] Fix the arguments to the managed main function when using CoreCLR. Fixes #12219. (#12239) 2021-07-28 17:12:29 +02:00
delegates.h.t4 [runtime] Support automatic GCHandle -> MonoObject* conversion for parameters and return values when calling managed delegates. 2020-05-04 11:22:26 +02:00
delegates.inc.t4 [runtime] Implement functions for getting and setting array elements for CoreCLR. (#11519) 2021-05-13 07:11:49 +02:00
delegates.t4 [runtime] Set the current directory to the root directory of the app bundle for all platforms in .NET. (#12104) 2021-07-14 17:42:49 +02:00
exports.t4 [dotnet] Add support for generating a binary version of runtimeconfig.json. Fixes #11745. (#11887) 2021-06-16 15:22:02 +02:00
extension-main.m [xcode12] Bump for beta 1 (#8935) 2020-06-26 14:02:44 -04:00
frameworks.h [runtime] MapKit is available on macOS/arm64. (#11363) 2021-04-29 14:45:58 +02:00
launcher.h Build our runtime. 2016-04-24 14:47:24 -04:00
launcher.m [CoreCLR] Add support for mono_assembly_open. 2021-03-25 07:32:32 +01:00
libmonotouch.csproj Fix some whitespace issues in various files. (#12399) 2021-08-11 10:06:46 +02:00
libxammac.csproj Fix some whitespace issues in various files. (#12399) 2021-08-11 10:06:46 +02:00
main-internal.h [xcode12] Bump for beta 1 (#8935) 2020-06-26 14:02:44 -04:00
mono-runtime.h.t4 [dotnet] Add support for generating a binary version of runtimeconfig.json. Fixes #11745. (#11887) 2021-06-16 15:22:02 +02:00
mono-runtime.m.t4 [runtime] Deal with the rest of the Mono Embedding API for CoreCLR. (#11642) 2021-05-21 07:53:41 +02:00
monotouch-debug.h [runtime] Move a few mono function declaration to the generated logic for mono function declarations instead of doing it manually. (#10849) 2021-03-12 07:37:27 +01:00
monotouch-debug.m [runtime] Deal with the rest of the Mono Embedding API for CoreCLR. (#11642) 2021-05-21 07:53:41 +02:00
monotouch-main.m [runtime] AOT is no longer limited to device builds. 2021-07-22 10:36:21 +02:00
monotouch-support.h [Runtime] Move some of the changes back to int. (#7529) (#7606) 2019-12-16 22:06:51 -05:00
monovm-bridge.m [runtime] AOT is no longer limited to device builds. 2021-07-22 10:36:21 +02:00
nsstring-localization.m Build our runtime. 2016-04-24 14:47:24 -04:00
product.h [runtime] Add support for finding assemblies in an RID-specific subdirectory. 2021-06-18 10:24:28 +02:00
runtime-generated.h.t4 [runtime] Add support for generating managed delegates only for CoreCLR. 2021-03-25 07:32:32 +01:00
runtime-internal.h [runtime] Add support for tracking created and destroyed MonoObject* instances for CoreCLR. (#11657) 2021-05-25 08:19:27 +02:00
runtime.m [runtime] Set the RUNTIME_IDENTIFER and APP_CONTEXT_BASE_DIRECTORY app context values. Fixes #12444. (#12446) 2021-08-17 15:30:27 +02:00
shared.h [runtime] Move the code to wrap every managed thread with an NSAutoreleasePool to the MonoVM bridge. (#11257) 2021-04-21 16:21:09 +02:00
shared.m [CoreCLR] Implement xamarin_gchandle_get_target. (#11333) 2021-04-27 14:59:03 +02:00
slinked-list.h Build our runtime. 2016-04-24 14:47:24 -04:00
trampolines-arm64-asm.s [runtime] Add correct prologue/epilogue to xamarin_arm64_common_trampoline 2021-05-11 15:54:39 +02:00
trampolines-arm64-objc_msgSend.inc.s [runtime] Be a bit defensive after handling Objective-C exceptions and return a consistent value. (#11601) 2021-05-19 07:35:46 +02:00
trampolines-arm64-objc_msgSend.s [runtime] Implement xamarin_dyn_objc_msgSend for ARM64. 2021-05-11 15:54:39 +02:00
trampolines-arm64-objc_msgSendSuper.s [runtime] Implement xamarin_dyn_objc_msgSend for ARM64. 2021-05-11 15:54:39 +02:00
trampolines-arm64.h Xamarin.Mac native Apple Silicon targetting support (#10115) 2021-03-17 21:48:02 -04:00
trampolines-arm64.m Use pointer-sized GCHandles everywhere. (#10597) 2021-02-11 08:18:38 +01:00
trampolines-i386-asm.s [runtime] Rename CallState to XamarinCallState to keep the public namespace cleaner. (#5940) 2019-04-23 16:53:35 +01:00
trampolines-i386-objc_msgSend-copyframe.inc [runtime] Don't store xmm registers where we store other registers. 2016-05-17 11:24:02 +02:00
trampolines-i386-objc_msgSend-post.inc [runtime] Make sure the stack is correctly aligned to 16 bytes. 2016-05-17 11:24:03 +02:00
trampolines-i386-objc_msgSend-pre.inc [runtime] Make sure the stack is correctly aligned to 16 bytes. 2016-05-17 11:24:03 +02:00
trampolines-i386-objc_msgSend.s Implement support for exception marshalling. 2016-05-17 11:23:48 +02:00
trampolines-i386-objc_msgSendSuper.s Implement support for exception marshalling. 2016-05-17 11:23:48 +02:00
trampolines-i386-objc_msgSendSuper_stret.s Implement support for exception marshalling. 2016-05-17 11:23:48 +02:00
trampolines-i386-objc_msgSend_stret.s Implement support for exception marshalling. 2016-05-17 11:23:48 +02:00
trampolines-i386.h [runtime] Rename CallState to XamarinCallState to keep the public namespace cleaner. (#5940) 2019-04-23 16:53:35 +01:00
trampolines-i386.m Use pointer-sized GCHandles everywhere. (#10597) 2021-02-11 08:18:38 +01:00
trampolines-internal.h Use pointer-sized GCHandles everywhere. (#10597) 2021-02-11 08:18:38 +01:00
trampolines-invoke.m [dynamic registrar] Free the return value from mono_signature_get_params and mono_signature_get_return_type. (#11730) 2021-05-31 08:02:45 +02:00
trampolines-varargs.h [runtime] Rename CallState to XamarinCallState to keep the public namespace cleaner. (#5940) 2019-04-23 16:53:35 +01:00
trampolines-varargs.m Use pointer-sized GCHandles everywhere. (#10597) 2021-02-11 08:18:38 +01:00
trampolines-x86_64-asm.s [runtime] Fix crash in the x86_64 dynamic registrar. (#5989) 2019-05-06 07:25:49 +02:00
trampolines-x86_64-objc_msgSend-copyframe.inc Implement support for exception marshalling. 2016-05-17 11:23:48 +02:00
trampolines-x86_64-objc_msgSend-post.inc Implement support for exception marshalling. 2016-05-17 11:23:48 +02:00
trampolines-x86_64-objc_msgSend-pre.inc Implement support for exception marshalling. 2016-05-17 11:23:48 +02:00
trampolines-x86_64-objc_msgSend.s Implement support for exception marshalling. 2016-05-17 11:23:48 +02:00
trampolines-x86_64-objc_msgSendSuper.s Implement support for exception marshalling. 2016-05-17 11:23:48 +02:00
trampolines-x86_64-objc_msgSendSuper_stret.s Implement support for exception marshalling. 2016-05-17 11:23:48 +02:00
trampolines-x86_64-objc_msgSend_stret.s Implement support for exception marshalling. 2016-05-17 11:23:48 +02:00
trampolines-x86_64.h [runtime] Fix crash in the x86_64 dynamic registrar. (#5989) 2019-05-06 07:25:49 +02:00
trampolines-x86_64.m Use pointer-sized GCHandles everywhere. (#10597) 2021-02-11 08:18:38 +01:00
trampolines.m [runtime] Add missing release for call to mono_reflection_type_get_type. (#11756) 2021-06-01 22:19:20 +02:00
xamarin-support.m [dotnet] Build macOS/.NET for ARM64 as well. (#10959) 2021-03-25 07:26:48 +01:00

README.md

Native runtime

This directory contains the native runtime for Xamarin.iOS and Xamarin.Mac.

Cooperative GC

See COOP.md

Generated code

A few files are generated automatically:

delegates.h|inc, Delegates.cs

These files contain the code required to glue the native runtime and the managed runtime.

mono-runtime.m, xamarin/mono-runtime.h

These files contain code that makes other code, consumers of the mono runtime, oblivious to whether the mono runtime is linked statically, dynamically, or using dlopen at runtime.

If you need to use a new function from the Mono headers, add it to exports.t4.

If you need a new enum / constant / typedef / etc, add it to mono-runtime.h.t4.

Shipped headers

These are the headers shipped with XI/XM (they're not for public consumption, but we need them to build generated code on customers machine, in particular main.m and registrar.m)

xamarin/runtime.h xamarin/trampolines.h xamarin/main.h xamarin/xamarin.h