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.
|
|
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.
|
|
* 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
|
|
|
|
|
|
|
|
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.
|
|
|
|
[tfs-changeset: 1407945]
|