Skip to content

Commit 890cae3

Browse files
authored
Fix & improve test/limits.jl (#672)
1 parent b552e60 commit 890cae3

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

test/limits.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ module EvalLimited end
8585
insert!(ex.args, 1, LineNumberNode(1, Symbol("fake.jl")))
8686
end
8787
modexs = collect(ExprSplitter(EvalLimited, ex))
88+
# See "uncomment the following..." in test/utils.jl for how to calibrate `nstmts` below
89+
# Adjust α so that the recursive mode ends up back in "fake.jl"
8890
@static if VERSION >= v"1.12-"
89-
nstmts = 10*21 + 27 # 10 * 21 statements per iteration + α
91+
nstmts = 10*24 + 50 # 10 * 24 statements per iteration + α in compiled mode
9092
elseif VERSION >= v"1.11-"
9193
nstmts = 10*17 + 20 # 10 * 17 statements per iteration + α
9294
else

test/utils.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ end
4040
struct Aborted # for signaling that some statement or test blocks were interrupted
4141
at::Base.IRShow.LineInfoNode
4242
end
43+
const dummylin = length(fieldnames(Base.IRShow.LineInfoNode)) == 5 ? Base.IRShow.LineInfoNode(Main, nothing, :none, Int32(0), Int32(0)) : # dummy lineinfo for fallback
44+
Base.IRShow.LineInfoNode(nothing, :none, Int32(0))
4345

4446
function Aborted(frame::Frame, pc)
4547
lineidx = JuliaInterpreter.codelocs(frame, pc)
48+
lineidx == 0 && return Aborted(dummylin) # fallback to a dummy lineinfo if no location found
4649
lineinfo = JuliaInterpreter.linetable(frame, lineidx; macro_caller=true)
4750
return Aborted(lineinfo)
4851
end
@@ -64,6 +67,9 @@ function evaluate_limited!(@nospecialize(recurse), frame::Frame, nstmts::Int, is
6467
while nstmts > 0
6568
shouldbreak(frame, pc) && return BreakpointRef(frame.framecode, pc), refnstmts[]
6669
stmt = pc_expr(frame, pc)
70+
# uncomment the following to calibrate `nstmts` in test/limits.jl
71+
# _lnn_ = Aborted(frame, pc).at
72+
# _lnn_.file == Symbol("fake.jl") && _lnn_.line == 5 && isa(stmt, Core.GotoIfNot) && @show nstmts
6773
if isa(stmt, Expr)
6874
if stmt.head === :call && !isa(recurse, Compiled)
6975
refnstmts[] = nstmts

0 commit comments

Comments
 (0)