ILMarshaler Refactor (#21227)
authorJeremy Koritzinsky <jekoritz@microsoft.com>
Wed, 19 Jun 2019 00:26:10 +0000 (17:26 -0700)
committerGitHub <noreply@github.com>
Wed, 19 Jun 2019 00:26:10 +0000 (17:26 -0700)
commit70febbad4bbe23326c26480b2848cdfe9fc8450c
treec7984d7d348f459d378885bba4943cb162d36f57
parenteafa8648ebee92de1380278b15cd5c2b6ef11218
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.
src/System.Private.CoreLib/src/System/StubHelpers.cs
src/vm/fieldmarshaler.cpp
src/vm/ilmarshalers.cpp
src/vm/ilmarshalers.h
src/vm/metasig.h
src/vm/mlinfo.cpp
src/vm/mscorlib.h