Typesafe coop handles for all platforms. (#11012)
This is an alternative or precursor to https://github.com/mono/mono/pull/10212.
- Removes the dependency of some ABIs passing a pointer and a pointer in a struct the same.
- Therefore gives all platforms the same type safety.
- *If* we move to C++, allows us to have member functions in coop handles.
- Having the coop signatures available in C can provide benefits, though we should
probably generate them from reading metadata -- though they won't match w/o more changes,
since we mixup types in several places, like IntPtr vs. pointers.
JIT now traffics in old type-unsafe handles, and wrappers are generated with C preprocessor to trivially convert.
This way the JIT doesn't have to pass structs by value here, which was tried/failed.
The C preprocessor machinery can/should be extended for additional gains.
In particular driving managed/native coop icall transitions from 3+ per call to 1 (like https://github.com/mono/mono/pull/10212).
That will require better verification of the signatures in icall-def.h, either automated and en masses or gradually manually. Embedders will likely do something else, or at least have to independently invent similar.
Whereever a native function was exposed via multiple managed names, wrappers are reused.
16 files changed: