ILMarshaler Refactor (#21227)
* Add support for fields to ILStubMarshalHome objects.
* Make the specific code streams in the ILMarshaler private members.
* Make home members private.
* Move the IL code stream members back to being protected for the marshalers that override EmitMarshalArgumentCLRToNative instead of EmitMarshalArgumentContents/Space.
* Convert virtual specifiers in overrides to override specifiers.
* Remove unused and undefined member.
* Cleanup a few missed virtual/override specifiers.
* Refactor setup methods. Refactor some of the overrides to duplicate less code.
* Refactor the setup stream and add some comments around how the ArgumentOverride/ReturnOverride marshalling system works.
* Use the cleanup work list in SafeHandle marshalling since the work list is now implemented entirely in managed code.
* Generalize DelegateCleanupWorkListElement -> KeepAliveCleanupWorkListElement and rename the managed entry point to match.
* Refactor direct usage of the cleanup code stream in non-overridden marshalers to use the cleanup work list instead.
* Refactor AsAny marshalling to fit into the regular ILMarshaler code-paths.
* Move ILArgIteratorMarshaler over to the full ILMarshaler infrastructure.
* Port ILBlittablePtrMarshaler over to not directly reference m_pcsMarshal.
* Make the specific code streams private and have ILNativeArrayMarshaler fetch the one it needs from the NDirectStubLinker.
* Devirtualize a method on ILMarshaler.
* Fix broken metasig
* Revert "Use the cleanup work list in SafeHandle marshalling since the work list is now implemented entirely in managed code."
This reverts commit
aedcdfb4830475ff8f4d582147cdc0eb497dd681.
* Fix ILArgIteratorMarshaler.
* Take 2 on using the cleanup work list for SafeHandles
* Remove unused field
* SafeHandleMarshaler doesn't need to have extra cleanup code when using the CleanupWorkList.
* Move the rest of the SafeHandle marshalling into ArgumentOverride.
* Moved Pinned Native Array special case into an ArgumentOverride.
* Devirtualize
* Remove invalid field hometype.
* Make ILMarshaler::m_pslNDirect private.
* Native Array marshalling fixes.
* Fix STLOC->LDLOC mistakes.
* Add override hook to allow a marshaler to request that byval contents are always converted to native even when not marked as In (i.e. explicitly marked only as Out). Used in AsAny for byval arrays.
* PR Feedback.
* Add explicit pinning path to ilmarshalers.
* Move implementation of ILNativeArrayMarshaler::CanMarshalViaPinning to ilmarshalers.cpp.
* Add missing override specifier.
* Don't create a managed marshaler if we are able to marshal via pinning. Remove extraneous checks against pinning.
* Convert ILWSTRMarshaler to use the MarshalViaPinning functions for its pinning fast-path.
* Enable LPWSTR marshalling to fall back to allocating on the heap for large strings when stack-allocating for native space (byref in-only semantics).
* PR Feedback.