Skip to content
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

add IsOSPlatformOrLater and IsOSPlatformEarlierThan methods #39005

Merged
merged 5 commits into from
Jul 10, 2020

Conversation

adamsitnik
Copy link
Member

Contributes to #33331

@Dotnet-GitSync-Bot
Copy link
Collaborator

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost
Copy link

ghost commented Jul 9, 2020

Tagging subscribers to this area: @tommcdon
Notify danmosemsft if you want to be subscribed.

@adamsitnik
Copy link
Member Author

The spec mentions that:

The IsPlatformXXx methods should be recognized by the JIT to be constant

@tannergooding @jkotas could you please point me to some doc|PR that explains|shows how to make JIT recognize given method as a constant?

@tannergooding
Copy link
Member

I'm not sure the JIT treating them as a constant is necessarily a .NET 5 goal, but rather an eventual goal.

I don't think getting the JIT to support ISOSPlatform is going to necessarily be trivial as I believe IsOSPlatform would need to be intrinsic, as would the OSPlatform.Windows and related properties.

Jan or someone else may know better or have a different opinion here, of course 😄

@jkotas
Copy link
Member

jkotas commented Jul 9, 2020

I agree with @tannergooding that the design of these APIs is unfriendly to optimizations, and recognizing the complex pattern as constant would be non-trivial. I do not think we should be building one-off optimizations like that.

If somebody needs to call this on a hot path, they should cache the result in a static readonly bool.

Copy link
Member

@buyaa-n buyaa-n left a comment

Choose a reason for hiding this comment

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

I think we should add other new OS versions with this PR EDIT: there is another PR for this. LGTM, thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants