Skip to content

Commit 34cf432

Browse files
authored
remove the new finish_nested_frame! interface (#686)
The additional logic implemented for `RecursiveInterpreter` seems to be no longer necessary. I think we can simply call `finish!` instead, since there is no strong reason to add `caller->callee` relation to the nested `CodeInfo` frame within `:thunk` expression. Confirmed LoweredCodeUtils/Revise/Debugger still pass their test suites with this change.
1 parent a3ed4cc commit 34cf432

File tree

3 files changed

+3
-33
lines changed

3 files changed

+3
-33
lines changed

docs/src/dev_reference.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ JuliaInterpreter.step_expr!
4444
JuliaInterpreter.finish!
4545
JuliaInterpreter.finish_and_return!
4646
JuliaInterpreter.finish_stack!
47-
JuliaInterpreter.finish_nested_frame!
4847
JuliaInterpreter.get_return
4948
JuliaInterpreter.next_until!
5049
JuliaInterpreter.maybe_next_until!

src/interpret.jl

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ function step_expr!(interp::Interpreter, frame::Frame, @nospecialize(node), isto
520520
end
521521
elseif node.head === :thunk
522522
newframe = Frame(moduleof(frame), node.args[1]::CodeInfo)
523-
finish_nested_frame!(interp, newframe, frame)
523+
finish!(interp, newframe, true)
524524
return_from(newframe)
525525
elseif node.head === :global
526526
Core.eval(moduleof(frame), node)
@@ -613,28 +613,6 @@ step_expr!(interp::Interpreter, frame::Frame, istoplevel::Bool=false) =
613613
step_expr!(interp, frame, pc_expr(frame), istoplevel)
614614
step_expr!(frame::Frame, istoplevel::Bool=false) = step_expr!(RecursiveInterpreter(), frame, istoplevel)
615615

616-
# TODO Is this interface really needed?
617-
618-
"""
619-
finish_nested_frame!(interp::Interpreter, newframe::Frame, frame::Frame)
620-
621-
Finish evaluating `newframe` and return to `frame`.
622-
623-
This function is used when `newframe` is a nested frame embedded within `frame`.
624-
Specifically, it applies when `frame` contains a top‐level `Expr(:thunk)` and needs to
625-
interpret the `CodeInfo` embedded in that thunk. Consequently, within this function
626-
`newframe` is also treated as a top‐level frame during interpretation.
627-
"""
628-
function finish_nested_frame!(interp::Interpreter, newframe::Frame, frame::Frame)
629-
newframe.caller = frame
630-
frame.callee = newframe
631-
finish!(interp, newframe, true)
632-
frame.callee = nothing
633-
end
634-
function finish_nested_frame!(interp::NonRecursiveInterpreter, newframe::Frame, ::Frame)
635-
finish!(interp, newframe, true)
636-
end
637-
638616
"""
639617
loc = handle_err(interp, frame, err)
640618

test/utils.jl

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,8 @@ function evaluate_limited!(interp::Interpreter, frame::Frame, nstmts::Int, istop
105105
else
106106
limited_interp.nstmts = nstmts
107107
newframe = Frame(moduleof(frame), stmt)
108-
if isa(interp, NonRecursiveInterpreter)
109-
finish!(interp, newframe, true)
110-
else
111-
newframe.caller = frame
112-
frame.callee = newframe
113-
ret = finish_and_return!(limited_interp, newframe, true)
114-
isa(ret, Aborted) && return ret, limited_interp.nstmts
115-
frame.callee = nothing
116-
end
108+
ret = finish_and_return!(limited_interp, newframe, true)
109+
isa(ret, Aborted) && return ret, limited_interp.nstmts
117110
JuliaInterpreter.recycle(newframe)
118111
# Because thunks may define new methods, return to toplevel
119112
frame.pc = pc + 1

0 commit comments

Comments
 (0)