Skip to content

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

Merged
merged 7 commits into from
May 29, 2022

Conversation

huoyaoyuan
Copy link
Member

I'm not sure whether such conversions is desired. Opening a PR for comment.
Can't find corresponding benchmark in performance repo.

@ghost
Copy link

ghost commented May 24, 2022

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.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label May 24, 2022
MichalStrehovsky added a commit that referenced this pull request May 25, 2022
Inspired by #69723 

`SpanHelpers` didn't exist when this part of NativeAOT was written (dotnet/corert#5436 (comment)).
@huoyaoyuan
Copy link
Member Author

Additionally, do we need AgressiveInlining here? Inlining looks probably beneficial.

MichalStrehovsky added a commit that referenced this pull request May 25, 2022
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;
Copy link

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.

Copy link
Member Author

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.

@ghost
Copy link

ghost commented May 27, 2022

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

Issue Details

I'm not sure whether such conversions is desired. Opening a PR for comment.
Can't find corresponding benchmark in performance repo.

Author: huoyaoyuan
Assignees: -
Labels:

area-System.Runtime, community-contribution

Milestone: -

@@ -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);
Copy link
Member

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);
}

Copy link
Member

@jkotas jkotas left a 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!

@jkotas
Copy link
Member

jkotas commented May 28, 2022

Could you please resolve the conflict?

@jkotas jkotas merged commit 1466e40 into dotnet:main May 29, 2022
@huoyaoyuan huoyaoyuan deleted the valuetype-managed branch May 29, 2022 13:46
@ghost ghost locked as resolved and limited conversation to collaborators Jun 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Runtime community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants