Age | Commit message (Collapse) | Author | Files | Lines |
|
Rework use of marshalling for RuntimeTypeHandle, RuntimeModule, RuntimeAssembly, and IRuntimeMethodInfo as used by QCalls
- Remove special QCall only used marshallers for RuntimeAssembly, RuntimeModule and IRuntimeMethodInfo
- Following the pattern of ObjectHandleOnStack, implement QCall handle types for RuntimeAssembly/Module/TypeHandle. Use these in all QCalls that once passed the types directly.
- For uses of IRuntimeMethodInfo, follow the existing RuntimeMethodHandleInternal pattern
Also perform some replacement of bool marshalling with use of Interop.BOOL, and a few cases of using pointers instead of byref arguments.
Fix delivers a relatively small win on startup, and small throughput gains around reflection as IL stubs are no longer necessary for many functions in reflection that once needed them.
Reduces methods jitted on powershell startup from 422 to 399, (About 5%) but performance win is only about 5ms on ~400ms as the methods removed are simple.
|
|
* Opt COM methods out of the new Windows instance-method handling.
* Add test for an HResult "struct" returned from a COM method.
* Update ErrorMarshalTesting.cs
* Update "is member function" check on the ilmarshalers.h side to only consider thiscall.
|
|
(#23625)
* Enable return buffers on Windows ARM64 for struct-returning member functions. Fixes #23577.
* Update comment to match new condition.
* Enable byref return on all Windows (excluding arm64 HFA. Add more test cases for ThisCall.
* On x86, if we have a normalized return value in an instance method, get back the actual type so that we correctly marshal it via a return buffer.
* Fix param ordering.
* Clean up based on PR feedback.
* Fix accidental variable shadowing.
|
|
Win-x86 (#23145)
* In Windows-x64, if we have a native member function signature with a struct return type, we need to do a by-ref return.
* Implement support for marshalling structure return values via a return buffer argument correctly in instance signatures on AMD64-Windows.
* Change field initialization ordering to satisfy warning.
* Try to narrow down the conditions that trigger these changes to just COM methods.
* Don't bash the return type on AMD64 Windows. Only treat it as a byref return buffer.
* PR feedback.
* Enable returning structs from COM methods via a return buffer on x86 for structs <= 8 bytes.
* Add test for struct returns with ThisCall. Extend the "struct return buffer" fix to functions marked as unmanaged thiscall since they all must be instance methods
* Don't include the return-type-bashing switch on AMD64 platforms.
* Don't do the signature swapping/copy on non-instance functions with struct returns.
* Cast the return type of GetStubTargetCallingConv to the right calling convention enum type.
* If we're doing a thiscall, marshal the "this" parameter before the return buffer (if the return buffer exists) on all platforms.
* Remove temporary logging code I added in for debugging.
* Clean up class naming.
* Try using a vtable instead of a pointer-to-member-function.
* Remove delete of class with non-virtual destructor
|
|
Fixes #22219.
I decided to try simplifying the code when bringing this feature over from .NET Framework. The .NETFX x86 implementation of this marshaler adds a lot of extra code-paths, and intercepts the calling stub to enable it to exactly replicate the behavior of what would be the native code by copy-constructing an object in-place where it goes on the stack for the native call.
Instead of adding all of that extra goo, I decided to keep the implementation much more similar to the non-x86 implementation from .NETFX. Instead of intercepting the call and adding bookkeeping helper stubs, the marshaler just copies to a local in the IL stub, just like non-x86. When calling the native function, it just loads the local onto the IL stack and calls the native function as a normal function. There is a difference there, but I cannot think of a way that the difference is observable to the user.
The non-x86 implementation is identical to the .NETFX implementation.
|
|
* Replace Win32Native.cs with Interop files
- Replace Win32Native usage with existing Interop.* calls where they already existed
- Moved Win32Native.* to their own files otherwise, and changed call sites
- Left a stub Win32Native in place to handle some emitted IL from the runtime. The current infrastructure doesn't support targeting nested types, like Interop.Kernel32, and fixing that would be more involved.
* Remove Win32Native.cs
Replace emitted calls with ones to Marshal.
* Fix incorrectly changed field
* Fix Kernel32 -> Ole32
|
|
* Throw an exception when passing strings by-value as out parameters.
* Fix encoding
* Don't use override in this PR.
* Clean up Marshal_In
Marshal_In was copied back into existence from Marshal_InOut. Clean it up a bit.
* Remove extraneous whitespace.
* Fix failing test.
* Remove out attribute in COM string tests.
* Add back attribute and check for exception thow in COM tests.
* Add block comment to explain the implementation of Reverse_LPWStr_OutAttr in the NETServer.
* Only throw in a CLR->Native marshalling situation.
* Fix asserts from changed code-paths used in ILWSTRMarshaler.
* Add comment and explicitly load in a null value (instead of leaving it uninitialized).
* Apply suggestions from code review
Co-Authored-By: jkoritzinsky <jkoritzinsky@gmail.com>
Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
|
|
from crossing ALCs (#21606)
* Create repro for dotnet/coreclr#19654
* Update ICustomMarshaler.csproj
* Update ICustomMarshaler.csproj
* Clean up repro per feedback.
* Add test case for different assemblies with the same CustomMarshaler name.
* Move EEMarshalingData cache from AppDomain to LoaderAllocator. This fixes the custom-marshaler conflict when using unloadable assembly contexts.
* Internalize the LoaderHeap* parameter.
* Add the pointer to the requesting assembly to the hashtable key.
* Fix linux-musl build break.
* Move Crst out of FEATURE_COMINTEROP block.
* Make sure to copy over the assembly pointer to the key that's actually stored in the hash table.
* Add comment for m_invokingAssembly.
* Move all usages of EEMarshallingData to hang off the correct loader allocator instead of always the global one.
* Change to m_InteropDataCrst since this EEMarshallingData can be used in preemptive GC mode.
* Always init m_InteropDataCrst (since it's used by EEMarshallingData as well as COM).
* PR Feedback.
* Remove extraneous inlines.
|
|
* Cleanup changes from #21793.
* Emit the data pointer offset directly into the IL stream (and calculate it as needed instead of passing it through)
* Fix broken assumption that OverrideProcArgs::na::m_pMT is the array type instead of the element type (which it was).
|
|
* Add tests for ANSI BSTRs
* Fix signed/unsigned mismatch in comparisons. Add xplatform include
* Use regular memcpy
* Enable ANSI BSTR off-windows.
* Also enable UnmanagedType.TBStr off-Windows since both BStr variants are available off-Windows.
* Make sure the AnsiBSTR marshaller is hooked up off-Windows.
* Remove a few more ifdefs I missed.
* remove ifdefs around binder definitions and the C# stub helpers.
* PR Feedback.
* Add xplat ARRAYSIZE macro
* Move xplat ARRAYSIZE to platformdefines.h
|
|
|
|
* [x86/Linux] Fix IL_STUB_PInvoke with RetBuf
Fix calling convention and IL_STUB_PInvoke for native functions
which was problematic for native functions that has
a RetBuf argument(struct size <= 8) on x86/Linux.
Fix #10027
|
|
|
|
|
|
instruction
|
|
* Revises compMethodReturnsMultiRegRetType for ARM
For ARM, the current implementation of 'compMethodReturnsMultiRegRetType'
always returns false.
Unfortunately, this behavior is inconsistent with JIT importer. JIT impoter
attempts to merge various return statements as one statement via inserting
an assignment statement just before each return statement if there are more
than 4 returns.
If the method of interest has a return value, then JIT importer
introduces a local temporary variable, and use it to return value.
Due to the above implementation, JIT importer never generates a return
variable, which results in assertion violation insider JIT morph, which
is discussed in #5009.
This commit attempts to fix #5009 via implementing 'compMethodReturnsMultiRegRetType'
for ARM.
* Uses compRetNativeType instead of compRetType
* Fix typo '_TARGET_ARM' as '_TARGET_ARM_'
|
|
Usage: [MarshalAs(UnmanagedType.LPUTF8Str)] applied to string
and stringbuilder.
Implementation mostly use Encoding.UTF8 API to do the byte buffer
to string roundtripping. Introducing two new marshalers,
UTF8StringMarshaler and UTF8BufferMarshaler which handle string
and StringBuilder respectively. [Out] StringBuilder marshaling use
builder capacity as the buffer size ie (builder. Capacity + 1) *3
which is enough for any UTF8 char in BMP plane, infact Encoding.UTF8
mscorlib APIs use the same length.All marshaling flags(ThrowOnUnmapable,
defaultchar) are ignored since they do not make sense in UTF16 to UTD8
context.
The public contracts are not yet updated, the public contracts and
public marshaling API (Marshal.PtrToStringUtf8 and StringToHGlobalUtf8)
will be added once the implementation is in. The marshal api are anyway
going to be a wrapper around Encoding.GetBytes and GetChars.
|
|
|
|
This PR adds support for System V x86_64 ABI classification and calling
convention to the VM and the Jit, including, but not limited to Ubuntu
Linux and Mac OS X.
The general rules outlined in the System V x86_64 ABI (described at
http://www.x86-64.org/documentation/abi.pdf) are followed with a few
little exceptions, described below:
1. The hidden argument for by-value passed structs is always after
the ÎéÎíthisÎéÎí parameter (if there is one.). This is a difference with
the Sysetem V ABI and affects only the internal jit calling conventions.
For PInvoke calls the hidden argument is always the first parameter since
there is no ÎéÎíthisÎéÎí parameter in this case.
2. Managed structs that have no fields are always passed by-value on
the stack.
3. The jit proactively generates frame register frames (with RBP as a
frame register) in order to aid the native OS tooling for stack unwinding
and the like.
|
|
|
|
After adding virtual destructors to some classes, the contract scanning
tool started to complain about missing contracts in some of the
constructors that were not touched.
This change adds contracts to those.
|
|
This change adds missing contract annotation to several destructors that
were missing it.
|
|
This change changes destructors to be virtual or adds virtual ones where they were
missing based on the clang warnings.
|
|
[tfs-changeset: 1407945]
|