Skip to content

Commit

Permalink
only limit argument lists that are growing by recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Mar 5, 2015
1 parent 7e3a8ec commit 0e5f09f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,17 @@ function abstract_call_gf(f, fargs, argtypes, e)
# limit argument type tuple based on size of definition signature.
# for example, given function f(T, Any...), limit to 3 arguments
# instead of the default (MAX_TUPLETYPE_LEN)
sp = inference_stack
limit = false
# look at the stack to detect recursive calls with growing argument lists
while sp !== EmptyCallStack()
if linfo.ast === sp.ast && length(argtypes) > length(sp.types)
limit = true; break
end
sp = sp.prev
end
ls = length(sig)
if ls > lsig+1 && !(isdefined(Main.Base,:promote_typeof) && f === Main.Base.promote_typeof)
if limit && ls > lsig+1 && !(isdefined(Main.Base,:promote_typeof) && f === Main.Base.promote_typeof)
fst = sig[lsig+1]
allsame = true
# allow specializing on longer arglists if all the trailing
Expand Down

2 comments on commit 0e5f09f

@StefanKarpinski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever.

@timholy
Copy link
Member

@timholy timholy commented on 0e5f09f Mar 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that A[...9 indexes...] will be fast now? If so, #9622 can presumably be closed.

Please sign in to comment.