-
Notifications
You must be signed in to change notification settings - Fork 5k
Convert JIT_Box* to C# #115134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert JIT_Box* to C# #115134
Conversation
Tagging subscribers to this area: @mangod9 |
543d2ae
to
ad38529
Compare
@EgorBot -amd -arm using System.Reflection;
using BenchmarkDotNet.Attributes;
public class Bench
{
public readonly int AReadonlyIntField = 42;
[Benchmark]
public int ReflectionFieldBoxing()
{
FieldInfo fieldInfo = typeof(Bench).GetTypeInfo().GetDeclaredField(nameof(AReadonlyIntField));
Bench myInstance = new();
object current = fieldInfo.GetValue(myInstance);
fieldInfo.SetValue(myInstance, int.MinValue);
return (int)current + (int)fieldInfo.GetValue(myInstance);
}
} |
aaadc26
to
bf23c6d
Compare
@EgorBot -windows_intel -amd -arm using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
public class Bench
{
[Benchmark] public object Box8() => Box(new Buffer8());
[Benchmark] public object Box16() => Box(new Buffer16());
[Benchmark] public object Box32() => Box(new Buffer32());
[Benchmark] public object Box256() => Box(new Buffer256());
[MethodImpl(MethodImplOptions.NoInlining |
MethodImplOptions.NoOptimization)]
static object Box<T>(T value) => (object)value;
}
[InlineArray(1)] public struct Buffer8 {
long _element0;
}
[InlineArray(2)] public struct Buffer16 {
long _element0;
}
[InlineArray(4)] public struct Buffer32 {
long _element0;
}
[InlineArray(32)] public struct Buffer256 {
long _element0;
} |
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastHelpers.cs
Show resolved
Hide resolved
@EgorBot -windows_intel -amd -arm using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
public class Bench
{
[Benchmark] public object Box8() => Box(new Buffer8());
[Benchmark] public object Box16() => Box(new Buffer16());
[Benchmark] public object Box32() => Box(new Buffer32());
[Benchmark] public object Box256() => Box(new Buffer256());
[MethodImpl(MethodImplOptions.NoInlining |
MethodImplOptions.NoOptimization)]
static object Box<T>(T value) => (object)value;
}
[InlineArray(1)] public struct Buffer8 {
long _element0;
}
[InlineArray(2)] public struct Buffer16 {
long _element0;
}
[InlineArray(4)] public struct Buffer32 {
long _element0;
}
[InlineArray(32)] public struct Buffer256 {
long _element0;
} |
arm32 doesn't seem to be happy with the TLV commit despite |
arm32 had the special alignment code path (RequiresAlign8) |
10ef59b
to
841c89e
Compare
...coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastHelpers.cs
Show resolved
Hide resolved
0b8d8f9
to
0f4cd04
Compare
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastHelpers.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastHelpers.cs
Outdated
Show resolved
Hide resolved
0f4cd04
to
7468c56
Compare
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastHelpers.cs
Outdated
Show resolved
Hide resolved
NativeAOT's AllocFast mechanism is much efficient, maybe coreclr can reuse it via asm sharing being introduced in #114982? Alternatively, JIT can optimize/inline |
Agreed. I tried to reuse |
src/coreclr/System.Private.CoreLib/src/System/MulticastDelegate.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastHelpers.cs
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastHelpers.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs
Outdated
Show resolved
Hide resolved
100647b
to
9dbafa3
Compare
9d00363
to
113056f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Thanks @jkotas, @EgorBo and @filipnavara for the help! Do you think we can bring the rest of these to the same plan: runtime/src/coreclr/vm/jitinterfacegen.cpp Lines 84 to 87 in 9e490ef
|
I'd think that they are good candidate for implementing in assembly and sharing with NativeAOT (as per #115134 (comment)). For some of them it looks like a quite straightforward mapping but perhaps I was just lucky to look at the ones that match up closely... |
Sounds good. Then we can follow @davidwrighton's footsteps once #114982 is completed. :) |
JFYI I have a prototype on top of #114982 that moves AllocFast.S/asm to the shared code base and replaces most of the helpers. Still needs a bit of love but wanted to let you know to avoid working on the same thing... |
Thanks! Can't wait to see |
No description provided.