-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Enable FEATURE_ARRAYSTUB_AS_IL on all platforms #103533
Conversation
Tagging subscribers to this area: @mangod9 |
Benchmarks: public class Base { }
public class Derived : Base { }
public struct GCStruct
{
public object a, b, c, d, e, f, g, h;
}
private Base[,] baseArray = new Base[10, 1];
private Base[,] covariantArray = new Derived[10, 1];
private Derived[,] derivedArray = new Derived[10, 1];
private int[,] intArray = new int[10, 1];
private Guid[,] guidArray = new Guid[10, 1];
private GCStruct[,] gcStructArray = new GCStruct[10, 1];
private double[,] doubleArray = new double[10, 1];
private Derived derivedObj = new Derived();
private Guid guid = Guid.NewGuid();
private GCStruct gcStruct = new GCStruct
{
a = new object(),
g = new object(),
};
private void GenericSet<T>(T[,] array, T value)
{
for (int i = 0; i < 10; i++)
{
array[i, 0] = value;
}
}
[Benchmark]
public void ReferenceTypeBase() => GenericSet(baseArray, derivedObj);
[Benchmark]
public void ReferenceTypeExactMatch() => GenericSet(derivedArray, derivedObj);
[Benchmark]
public void ReferenceTypeCovariant() => GenericSet(covariantArray, derivedObj);
[Benchmark]
public void PrimitiveInt() => GenericSet(intArray, 42);
[Benchmark]
public void NonGCStruct() => GenericSet(guidArray, guid);
[Benchmark]
public void GCStruct() => GenericSet(gcStructArray, gcStruct);
[Benchmark]
public void FPUType() => GenericSet(doubleArray, 123.456);
JIT generates much better code for large structs. |
Test failure at |
The test failure seems to unveil another bug: In runtime/src/coreclr/vm/ilstubcache.cpp Lines 319 to 326 in eb455ec
Thus for SVM dispatch stubs, the stub type is set as the fallback runtime/src/coreclr/vm/method.hpp Lines 2500 to 2504 in eb455ec
So the stub type will actually be set as |
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.
Nice! Thank you
Since the initial publish commit of coreclr, FEATURE_ARRAYSTUB_AS_IL was not enabled for win-x86. Now it's 10 years later and our JIT compiler is able to produce better code than hand written assemblies. It's also much easier to maintain the logic in IL.
A little portion of dead code accessing ESP+offset is not removed in stublinkerx86.