-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Use a proper check rather than an assert #103995
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The need to do this seems like a bug in NAOT,
Vector512DebugViewis not marked as intrinsic and correspondingly neither should the synthesizedBoxed_Vector512DebugViewthat's being created for NAOT.The fact that something in NAOT is marking it as such means that its going down the
impIntrinsicpath when it shouldn't be and that correspondingly is failing the assert here. It could potentially lead to other undesirable downstream behavior if arbitrary types are being marked as[Intrinsic]when they shouldn'tCC. @MichalStrehovsky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that jit is asking questions about the unboxing entrypoint here. We prefix them with Boxed_. We can probably drop the prefix, it will only make debugging the compiler a bit more confusing.
CoreCLR VM is probably reporting these still as intrinsic with the original name, but they are all sorts of weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coreclr vm should only report types marked as intrinsic as intrinsic, it’s fairly explicit about that handling today to ensure that not anything named Vector128 is treated as such
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s not clear what would be causing it to go down this path in naot otherwise, this path is only accessible from lookupId which is only done for impIntrinsic, which should only be invoked for methods marked as Intrinsic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is Vector128, but we got to it though something like a devirtualization. It's an entrypoint of the valuetype method that accepts a boxed
thisinstead of the typical ref to this. The JIT typically converts these to a non-unboxing/normal entrypoint if it was able to elide the box.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍, not sure what would be triggering this then given how the VM marks methods as intrinsic
I might try to debug it further later tonight
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so this is flowing down through:
Which determines
isIntrinsicviaisIntrinsic = eeIsIntrinsic(methodHnd);, which in turn ends up querying the information fromValueTypeInstanceMethodWithHiddenParameter.IsIntrinsicwhich unconditionally setsIsIntrinsictotrue: https://github.com/dotnet/runtime/blob/main/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.BoxedTypes.cs#L606So this is indeed the AOT VM setting things as
Intrinsic, CC. @MichalStrehovskyIs that expected or should this rather be
falsesince it is aNoInlining+InternalCalland doesn't appear to have any JIT side handling that would necessitate it being intrinsic?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- It looks like
DefaultInterfaceMethodImplementationWithHiddenParameter.IsINtrinsicis doing the same thing: https://github.com/dotnet/runtime/blob/main/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.InterfaceThunks.cs#L290There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We rely on this being intrinsic elsewhere in the compiler.
I looked at how unboxing MethodDesc are constructed in the CoreCLR VM and I believe they inherit everything from the non-unboxing flavor, from token (that decides the name), to
IsIntrinsicbit (seeCreateMethodDesc). PR to do the equivalent at #104008.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsIntrinsic tells the JIT to check the type and method name to see whether it is something the JIT is interested in handling, but it does not say that the JIT must handle it.
The JIT is expected to handle every potential CoreLib method being reported as intrinsic. It will be slow because it will have to check the name every time, but it should work.