-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Debugging and edit-and-continue for pattern-matching: action items #25547
Comments
Let's have a separate discussion re switch expression. It might be possible to avoid the need for sequence points in that case. I believe sequence points are not strictly necessary for the debugger to be able to place and stop at a breakpoint. We would need to handle such breakpoints differently than breakpoints at sequence points throughout the system (especially in edit and continue). We have an issue tracking breakpoints on expressions in general: #22016. Switch expression should just be part of that work. |
Just as some editing of a containing |
That's gonna be a bit tricky. We would need to spill and track the spill temps. We do something like that for |
- [X] There should be a hidden sequence point at the start of the code to handle the decision dag. This is necessary so that jumps back from a `when` clause into the decision dag do not appear to jump back up to the switch statement. - [X] After an evaluation that calls out to user code, the decision dag already saves it to a temp. We should add a hidden sequence point there when the stack is empty. - [X] Temps that are used in lowering the decision dag and that need to survive across calls out to user code (i.e. pretty much all of them) should be classified as long-lived. (Done previously) - [X] Those temps need to be associated with the switch statement's syntax node. (Done previously) We also add hidden sequence points before the code that assigns the pattern variables in a switch section and after evaluating a *when-clause*. Part of dotnet#25547 Note that we do not introduce sequence points (hidden or otherwise)... - following calls out to language-supported operations (such as equality of language-supported types including decimal and string), some of which are produced during code gen rather than lowering. - for the *is-pattern-expression*. It is treated like any other expression, as it does not have the subtleties caused by the switch's *when-clause*.
…t. (#26138) - [X] There should be a hidden sequence point at the start of the code to handle the decision dag. This is necessary so that jumps back from a `when` clause into the decision dag do not appear to jump back up to the switch statement. - [X] After an evaluation that calls out to user code, the decision dag already saves it to a temp. We should add a hidden sequence point there when the stack is empty. - [X] Temps that are used in lowering the decision dag and that need to survive across calls out to user code (i.e. pretty much all of them) should be classified as long-lived. (Done previously) - [X] Those temps need to be associated with the switch statement's syntax node. (Done previously) We also add hidden sequence points before the code that assigns the pattern variables in a switch section and after evaluating a *when-clause*. Part of #25547 Note that we do not introduce sequence points (hidden or otherwise)... - following calls out to language-supported operations (such as equality of language-supported types including decimal and string), some of which are produced during code gen rather than lowering. - for the *is-pattern-expression*. It is treated like any other expression, as it does not have the subtleties caused by the switch's *when-clause*.
@tmat @ivanbasov What do you think we need to do for the remaining action items (unchecked bullets) above? Are they must-do for 16.3, or can some of them be deferred to later? |
I believe all issues have been resolved now. |
Based on discussion with @tmat we came up with the following set of work items that we expect will provide reasonable debugging and edit-and-continue support for pattern-matching constructs.
Generally speaking, these action items result from the following understanding of the way things work:
Deconstruct
, orstring.operator==
. This becomes an opportunity for the edit-and-continue infrastructure to move the PC from the old method's frame to the new method's frame, mapping variables from one to the other in the process.Based on this, we have the following action items:
when
clause is on the execution stack, changing any case clause is a rude edit. That's because changing a case clause could potentially invalidate the shape of the lowered decision dag, making it infeasible to map the old code to the new code. This applies to thewhen
clause as well (it is part of the case clause), because a general expression in thewhen
clause it treated differently than a constanttrue
or a constantfalse
expression. We could relax this by not permitting changes to or from a constant-valuedwhen
clause.Deconstruct
method), changing any case clause is a rude edit.when
clause into the decision dag do not appear to jump back up to the switch statement. (Fixed in recursive-patterns(21) Add hidden sequence points for switch statement. #26138)string.operator ==
), the result should be saved, leaving the stack empty, then there should be a sequence point, then the result should be loaded again. Thisbool
temp can be shared for all the places this needs to be done.Given that we need to implement spilling for the switch expression for debug, we might elect to use spilling to simplify the compiler pipeline in release as well.
/cc @tmat @dotnet/roslyn-compiler
The text was updated successfully, but these errors were encountered: