-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Move type check of MD array to managed #103414
Conversation
Tagging subscribers to this area: @mangod9 |
@@ -1169,6 +1165,9 @@ DEFINE_METHOD(CASTHELPERS, CHKCASTCLASSSPECIAL, ChkCastClassSpecial, SM_Ptr | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that we are ready to enable it for all platforms. Just separating to another PR.
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.
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. |
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.
LGTM otherwise. Thank you!
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.