-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Partial expand of casts to non-sealed classes #55884
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dotnet-issue-labeler
bot
added
the
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
label
Jul 18, 2021
The diff is quite big so I guess I can enable this opt only for really hot methods (with PGO data). aspnet.run.windows.x64.checked.mch:
Detail diffs
benchmarks.run.windows.x64.checked.mch:
Detail diffs
coreclr_tests.pmi.windows.x64.checked.mch:
Detail diffs
libraries.pmi.windows.x64.checked.mch:
Detail diffs
libraries_tests.pmi.windows.x64.checked.mch:
Detail diffs
|
EgorBo
requested review from
eiriktsarpalis,
jozkee,
layomia and
steveharter
as code owners
July 18, 2021 15:20
EgorBo
commented
Jul 18, 2021
...libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializer.Read.Helpers.cs
Outdated
Show resolved
Hide resolved
EgorBo
force-pushed
the
jit-partial-expand-casts
branch
from
July 18, 2021 15:53
7f6ebc5
to
e0dfe3a
Compare
EgorBo
force-pushed
the
jit-partial-expand-casts
branch
from
July 18, 2021 16:01
e0dfe3a
to
3421ec3
Compare
Closing in favor of a proper fix for #55325 |
ghost
locked as resolved and limited conversation to collaborators
Aug 18, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, we don't expand casts/isinst to non-sealed classes, e.g.
Here is the codegen for
Test
andTest2
:As you can see, we just call
CORINFO_HELP_ISINSTANCEOFCLASS
.I propose we also expand cases like this but with that call as a fallback.
Basically, optimize
if (CORINFO_HELP_ISINSTANCEOFCLASS(obj, MyNonSealedType)
toif ((obj != null && obj->pMT == MyNonSealedType) || CORINFO_HELP_ISINSTANCEOFCLASS(obj, MyNonSealedType))
Here is the new codegen:
diffchecker.
Benchmarks
I wrote a simple benchmark to check benefits or overhead (in case of subclasses): https://gist.github.com/EgorBo/a3ac2b1f5c6e182acdd5f5d43c8335ec
Here are the results:
A 10% (+0.2ns) overhead for a case when
Subclass
is passed (and we expectedBaseClass
), but a significant win for cases wherenull
orBaseClass
are passed.PS: we'll avoid the overhead at all with PGO, see #55325
PS2: the new codegen is not super-efficient and will be improved, see #55841 (comment))