-
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
Fold "x ==/!= null" on NativeAOT for non-existent classes #111478
Conversation
I'm looking at the failure - the fix will be on the JitInterface side. Looks like |
65ff610
to
19cc5c9
Compare
9dafd2a
to
5d57eea
Compare
I think what's in #111493 is going to fix this, but I want to spend a little bit more time on it to come up with the right tests. There's a couple more angles to it that I'm not sure I'm handling correctly in that PR. It does fix the one issue we're seeing in the trimming tests right now. |
feel free to integrate this change in your PR if it's simpler for you 🙂 |
This reverts commit 0ce09bc.
/azp run runtime-nativeaot-outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
I've been meditating on this for a while. Looks like the savings are not huge (0.5% in the best case if we do extra work in analysis that this PR doesn't do yet) and I'm not completely sure we can track this correctly. We only had one failing test while there was a glaring hole in the tracking (that I did not anticipate before I investigated the failing test) and I'm not sure if I was able to patch up all the holes. The problem is that the compiler currently doesn't track types that are only used to type storage locations. So if there's code like: IFoo x = new Foo(); And one asks the whole program analysis "did you hear about But still, I'm not very convinced this would cover all the cases. It also complicates things quite a bit. Maybe this is not worth it. But thank you for entertaining the idea with me @EgorBo! |
No problem! Happy to try new ideas if you have any 🙂 |
Partially addresses #111256
This PR folds "obj ==/!= null" checks if VM tells JIT that obj is of type that has no real implementators (or they're trimmed out) so JIT can just fold such comparisons into true/false.
Codegen for
Foo
in Main:Codegen for
Foo
in PR:Unfortunately, I was not able to make it work for interfaces without implementators like was asked in #111256. It seems to be an issue or NativeAOT side where
getExactClasses
returns-1
for interface case, becauseScannedDevirtualizationManager.GetImplementingClasses
returns null.