Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Move parts of delegate to shared partition#23552

Merged
jkotas merged 2 commits intodotnet:masterfrom
marek-safar:shared
Apr 4, 2019
Merged

Move parts of delegate to shared partition#23552
jkotas merged 2 commits intodotnet:masterfrom
marek-safar:shared

Conversation

@marek-safar
Copy link
Copy Markdown

No description provided.

@marek-safar marek-safar requested a review from jkotas March 29, 2019 11:23
{
public abstract partial class Delegate : ICloneable, ISerializable
{
internal Delegate()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this file appears to be using tabs in many places... can you change it to use spaces instead?

@@ -0,0 +1,107 @@
using System.Reflection;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing license header.

{
public abstract partial class Delegate : ICloneable, ISerializable
{
internal Delegate()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this ctor change from private to internal?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the version from corert, it's private now


public static Delegate Combine(params Delegate[] delegates)
{
if (delegates == null || delegates.Length == 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it'd be good to be consistent, at least within the same file or least overloads of the same method, about how we do null checks. You changed the above to be a is null... can you change this one to be delegates is null, too?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return newDelegate;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove all of the comments in these operators? They were added very recently, in #21765.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worked with several copied and forgot to align this one, should be now identical to coreclr

public static bool operator ==(Delegate d1, Delegate d2)
{
if (d2 is null)
return d1 is null;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you validated that the workaround that was employed previously is no longer necessary for performance? The return (d1 is null) ? true : false; was there due to https://github.com/dotnet/coreclr/issues/914, which is still an open issue. Same goes for the changes you made to the return statement below.

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Delegate d1, Delegate d2)
{
return !(d1 == d2);
Copy link
Copy Markdown
Member

@stephentoub stephentoub Mar 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you validate that this doesn't impact perf?
cc: @benaadams

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used coreclr version but it's missing AggressiveInlining so not sure if it's intentional

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benaadams Was it intentional to mark operator== with AggressiveInlining, but not operator!= ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was intentional to mark operator== with AggressiveInlining.

It would make sense to mirror it and mark operator!= with AggressiveInlining.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did such small methods not get inlined without the attribute?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a small method after incorporating the other CR feedback.

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Delegate d1, Delegate d2)
{
if (d2 is null)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing micro-optimizations and related comments from the original version.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Delegate d1, Delegate d2)
{
return !(d1 == d2);
Copy link
Copy Markdown
Member

@jkotas jkotas Mar 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@marek-safar
Copy link
Copy Markdown
Author

@jkotas anything else to be done here?

Copy link
Copy Markdown
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. This just dropped from my radar.

@jkotas jkotas merged commit 991817d into dotnet:master Apr 4, 2019
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request Apr 4, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/mono that referenced this pull request Apr 4, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Dotnet-GitSync-Bot pushed a commit to Dotnet-GitSync-Bot/corefx that referenced this pull request Apr 4, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
stephentoub pushed a commit to dotnet/corefx that referenced this pull request Apr 4, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
jkotas pushed a commit to Dotnet-GitSync-Bot/corert that referenced this pull request Apr 5, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
MichalStrehovsky pushed a commit to dotnet/corert that referenced this pull request Apr 5, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
marek-safar added a commit to mono/mono that referenced this pull request Apr 6, 2019
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants