Skip to content

Commit 25c3659

Browse files
committed
bail out of type inference on too many exception handlers
this significantly speeds up the test suite on jb/functions
1 parent 2dca1f8 commit 25c3659

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

base/inference.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,7 @@ function typeinf_uncached(linfo::LambdaStaticData, atypes::ANY, sparams::SimpleV
16821682
# exception handlers
16831683
cur_hand = ()
16841684
handler_at = Any[ () for i=1:n ]
1685+
n_handlers = 0
16851686

16861687
push!(W,1) #initial pc to visit
16871688

@@ -1802,6 +1803,16 @@ function typeinf_uncached(linfo::LambdaStaticData, atypes::ANY, sparams::SimpleV
18021803
elseif is(hd,:enter)
18031804
l = findlabel(labels,stmt.args[1]::Int)
18041805
cur_hand = (l,cur_hand)
1806+
if handler_at[l] === ()
1807+
n_handlers += 1
1808+
if n_handlers > 25
1809+
# too many exception handlers slows down inference a lot.
1810+
# for an example see test/libgit2.jl on 0.5-pre master
1811+
# around e.g. commit c072d1ce73345e153e4fddf656cda544013b1219
1812+
inference_stack = (inference_stack::CallStack).prev
1813+
return (ast0, Any, false)
1814+
end
1815+
end
18051816
handler_at[l] = cur_hand
18061817
elseif is(hd,:leave)
18071818
for i=1:((stmt.args[1])::Int)

0 commit comments

Comments
 (0)