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

[release/8.0] [mono][interp] Fix type of args when inlining method #102801

Merged
merged 1 commit into from
Jun 10, 2024

Conversation

BrzVlad
Copy link
Member

@BrzVlad BrzVlad commented May 29, 2024

Backport of #102570 to release/8.0-staging. Fix for #102046

Customer Impact

When using interpreter, inlining a method that has its argument the result of a ternary conditional operator, could lead to an assumption that the argument is of the wrong type. This is a regression from NET7 because in this release we started to devirtualize calls based on the type of objects and when inlining we attempt to get the real type of arguments from the parent method. This issue was reported by customer in BlazorWasm with a simple repro consisting of a list of items so it looks like it can be easily hit. Since reproduction of this issue relies on inlining to happen, it was probably noticed this late in the release cycle since it needs for the problematic method to be tiered up.

Testing

Tested the fix locally on top of 8.0 release branch with the customer provided sample. CI PR testing without issues.

Risk

Low. There are other more conservative fixes like obtaining the type of the arg from the inlined method signature (like it was done in .NET7) or completely disabling devirtualization. In my opinion the fix in this PR is simple enough that reverting behavior is not necessary.

The vars allocated from pushing values on the execution stack might not reflect exactly the actual type of the var. Consider this pattern:

	condbr	BB0
	newobj	Derived // push var0 of type Derived
	br	BB1
BB0:
	newobj	Base	// push var1 of type Base
	// here we will end up inserting a `mov var1 -> var0`
BB1:
	// top of stack will be seen as being var0
	call

Because we first reach BB1 with the stack contents of var0, BB1 will end up accessing top of the stack as var0. However the type of var0 at this point is not Derived, since it can also be a Base object. We currently don't update the type of var0, but just update the type information of the top of stack entry when entering BB1. When inlining, after this commit, we use the type information from the stack, rather than the type of the var present on the stack.
Copy link
Contributor

Tagging subscribers to this area: @BrzVlad, @kotlarmilos
See info in area-owners.md if you want to be subscribed.

@BrzVlad BrzVlad added this to the 8.0.x milestone May 29, 2024
@BrzVlad BrzVlad added the Servicing-consider Issue for next servicing release review label Jun 6, 2024
@lewing lewing added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Jun 6, 2024
@carlossanlop
Copy link
Member

@lewing @BrzVlad is this good to merge? Today's code complete for the July Release.

@lewing lewing merged commit a04bc0c into dotnet:release/8.0-staging Jun 10, 2024
109 of 115 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants