Move type check of MD array to managed - #103414
Conversation
|
Tagging subscribers to this area: @mangod9 |
| DEFINE_METHOD(CASTHELPERS, UNBOX, Unbox, SM_PtrVoid_Obj_RetRefByte) | ||
| DEFINE_METHOD(CASTHELPERS, STELEMREF, StelemRef, SM_ArrObject_IntPtr_Obj_RetVoid) | ||
| DEFINE_METHOD(CASTHELPERS, LDELEMAREF, LdelemaRef, SM_ArrObject_IntPtr_PtrVoid_RetRefObj) | ||
| #ifdef FEATURE_ARRAYSTUB_AS_IL |
There was a problem hiding this comment.
It seems that we are ready to enable it for all platforms. Just separating to another PR.
There was a problem hiding this comment.
I agree it would be nice to enable this on all platforms and delete the #define.
Could you please share the source for the benchmark? It is a bit suspicious that the difference between the baseline and the PR is in the noise range. I would expect it to be a small measurable improvement. |
|
Updated test: private Base[,] baseArray = new Base[10, 1];
private Base[,] covariantArray = new Derived[10, 1];
private Derived[,] derivedArray = new Derived[10, 1];
private Derived derivedObj = new Derived();
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);Result:
Yes it is measuable improvement when |
Removes a HELPER_METHOD_FRAME.
Generally there are more of MD array can be moved to managed, but not completely now.
Not over optimizing, just ensuring no regression.