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.
This PR is an alternative to #99. This is built on top of #116.
With this PR, the following test cases now pass correctly:
The basic approach is overloading
JuliaInterpreter.step_expr!
andLoweredCodeUtils.next_or_nothing!
for the newSelectiveEvalController
type, as described below, to perform correct selective execution.When
SelectiveEvalController
is passed as therecurse
argument ofselective_eval!
, the selective execution is adjusted as follows:Implicit return: In Julia's IR representation (
CodeInfo
), the final block does not necessarily return and maygoto
another block. And if thereturn
statement is not included in the slice in such cases, it is necessary to terminateselective_eval!
when execution reaches such implicit return statements.controller.implicit_returns
records the PCs of such return statements, andselective_eval!
will return when reaching those statements. This is the core part of the fix for the test cases in Add failing test for proper termination #99.CFG short-cut: When the successors of a conditional branch are inactive, and it is safe to move the program counter from the conditional branch to the nearest common post-dominator of those successors, this short-cut is taken. This short-cut is not merely an optimization but is actually essential for the correctness of the selective execution. This is because, in
CodeInfo
, even if we simply fall-through dead blocks (i.e., increment the program counter without executing the statements of those blocks), it does not necessarily lead to the nearest common post-dominator block.And now
lines_required
orlines_required!
will update theSelectiveEvalController
passed as their argument to be appropriate for the program slice generated.One thing to note is that currently, the
controller
is not be recursed. That said, in Revise, which is the main consumer of LCU, there is no need for recursive selective execution, and soselective_eval!
does not provide a system for inter-procedural selective evaluation. AccordinglySelectiveEvalController
does not recurse too, but this can be left as a future extension.