Uh oh!
There was an error while loading. Please reload this page.
Move TypeReference.ToObject to managed (CoreCLR) - #70055
Conversation
ghost
commented
May 31, 2022
Tagging subscribers to this area: @dotnet/area-system-reflection Issue Details
OverviewThis PR moves API additions (CoreCLR-only)namespaceSystem{publicunsafestructRuntimeTypeHandle{[MethodImpl(MethodImplOptions.InternalCall)]internalstaticexternunsafeMethodTable*GetElementTypeMethodTable(CorElementTypeelementType);}}namespaceSystem.Runtime.CompilerServices{internalunsafestructTypeHandle{publicboolIsNull{get;}publicTypeDesc*AsTypeDesc();publicMethodTable*GetMethodTable();}internalunsafestructTypeDesc{privatereadonlyuintTypeAndFlags;publicMethodTable*GetMethodTable();publicCorElementTypeGetInternalCorElementType();}internalunsafestructParamTypeDesc{publicreadonlyuintTypeAndFlags;publicreadonlyMethodTable*m_TemplateMT;publicreadonlyTypeHandlem_Arg;publicreadonlyvoid*m_hExposedClassObject;publicMethodTable*GetTemplateMethodTableInternal();}}Benchmarks
Benchmark code (click to expand):usingSystem.Reflection;usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Configs;usingBenchmarkDotNet.Running;BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()).Run(args);[DisassemblyDiagnoser][GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)]publicclassArrayGetValueBenchmark{privatestringtext="Hello world";privateintnumber=42;[Benchmark][BenchmarkCategory("REF_TYPE")]publicobject?ToObject_String(){returnTypedReference.ToObject(__makeref(text));}[Benchmark][BenchmarkCategory("VALUE_TYPE")]publicobject?ToObject_Int(){returnTypedReference.ToObject(__makeref(number));}}
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
871e46c to
2e8db94Comparejkotas
commented
Jun 1, 2022
The new tests are failing on Mono. Open an issue on it and disable the tests against it. |
Sergio0694
commented
Jun 1, 2022
Looks like the tests are not failing, but just can't even compile on Mono 🤔
So |
jkotas
commented
Jun 1, 2022
|
jkotas
commented
Jun 1, 2022
If it is causing the Mono AOT compiler the crash, we do not have a good way to deal with it today. I guess you can comment out the test for now. |
Sergio0694
commented
Jun 1, 2022
Ah, gotcha. Will do that, thank you! 🙂 |
Uh oh!
There was an error while loading. Please reload this page.
Overview
This PR moves
TypedReference.ToObjectto managed in CoreCLR.I've only added an FCall to handle a slow path that's only ever taken when
Tis a function pointer.This is to avoid having to port a whole lot of additional VM code to C# as well.
All other paths, both for reference types and value types (using the new
RuntimeHelpers.BoxAPI) are managed now.Benchmarks
Benchmark code (click to expand):