-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Convert Valuetype.FastEqualsCheck and GetHashCodeOfPtr to managed #69723
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
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
Inspired by #69723 `SpanHelpers` didn't exist when this part of NativeAOT was written (dotnet/corert#5436 (comment)).
Additionally, do we need |
Inspired by #69723 `SpanHelpers` didn't exist when this part of NativeAOT was written (dotnet/corert#5436 (comment)).
|
||
internal static int GetHashCodeOfPtr(IntPtr ptr) | ||
{ | ||
int hashCode = (int)ptr; |
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.
This is dropping the upper bits of a 64 bit pointer. Is this wise? All pointers offset by 4GB will result in the same hash code.
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.
This method is for runtime handles which are pointers to unmanaged tables. I don't expect they would span across 4GB.
Tagging subscribers to this area: @dotnet/area-system-runtime Issue DetailsI'm not sure whether such conversions is desired. Opening a PR for comment.
|
src/coreclr/vm/comutilnative.h
Outdated
@@ -218,9 +218,8 @@ extern "C" void QCALLTYPE Interlocked_MemoryBarrierProcessWide(); | |||
class ValueTypeHelper { | |||
public: | |||
static FCDECL1(FC_BOOL_RET, CanCompareBits, Object* obj); | |||
static FCDECL2(FC_BOOL_RET, FastEqualsCheck, Object* obj1, Object* obj2); | |||
static FCDECL1(UINT32, GetNumInstanceFieldBytes, MethodTable* mt); |
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.
Nit: It would be nice to put it into a separate type. I expect we are going to have more MethodTable methods like this over time.
class MethodTableNative {
public:
static FCDECL1(UINT32, GetNumInstanceFieldBytes, MethodTable* mt);
}
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!
Could you please resolve the conflict? |
I'm not sure whether such conversions is desired. Opening a PR for comment.
Can't find corresponding benchmark in performance repo.