Skip to content

Commit

Permalink
Finish aborted tests in Compiled mode. Fixes #30.
Browse files Browse the repository at this point in the history
Also fixes a bug when trying to run a :thunk expr in Compiled mode.
  • Loading branch information
timholy committed Feb 18, 2019
1 parent e66a3f7 commit 01e7f2a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,14 @@ function _step_expr!(stack, frame, @nospecialize(node), pc::JuliaProgramCounter,
elseif node.head == :thunk
newframe = prepare_thunk(moduleof(frame), node)
frame.pc[] = pc
push!(stack, frame)
finish!(stack, newframe, true)
pop!(stack)
push!(junk, newframe) # rather than going through GC, just re-use it
if isa(stack, Compiled)
finish!(stack, newframe, true)
else
push!(stack, frame)
finish!(stack, newframe, true)
pop!(stack)
push!(junk, newframe) # rather than going through GC, just re-use it
end
elseif node.head == :global
# error("fixme")
elseif node.head == :toplevel
Expand Down
17 changes: 16 additions & 1 deletion test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,22 @@ function run_test_by_eval(test, fullpath, nstmts)
while true
ret, nstmtsleft = evaluate_limited!(stack, frame, nstmtsleft)
isa(ret, Some{Any}) && break
isa(ret, Aborted) && (push!(aborts, ret); break)
if isa(ret, Aborted)
push!(aborts, ret)
# run the remaining statements in Compiled mode, thus allowing later tests
# to work. Largely fixes #30. Of course this is not perfect, because it
# may repeat some work done previously, but it's a decent start.
# TODO: recurse over stack. The key problem is that the inner-most frame is lost.
frame = frame[3]
pc = frame.pc[]
while true # This is finish!, except we need to run it at top level
new_pc = _step_expr!(Compiled(), frame, pc, true)
new_pc == nothing && break
pc = new_pc
end
frame.pc[] = pc
break
end
end
end
println("Finished ", $test)
Expand Down

0 comments on commit 01e7f2a

Please sign in to comment.