Skip to content

Commit

Permalink
disable one of my changes that turns out not to be necessary to fix #…
Browse files Browse the repository at this point in the history
…4374,

erring on the side of caution
  • Loading branch information
JeffBezanson committed Oct 7, 2013
1 parent 0d02489 commit 9f20276
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
49 changes: 28 additions & 21 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,9 @@ function inlineable(f, e::Expr, sv, enclosing_ast)
end
argexprs = e.args[2:]
atypes = tuple(map(exprtype, argexprs)...)
if length(atypes) > MAX_TUPLETYPE_LEN
atypes = limit_tuple_type(atypes)
end

if is(f, convert_default) && length(atypes)==3
# builtin case of convert. convert(T,x::S) => x, when S<:T
Expand Down Expand Up @@ -1739,27 +1742,31 @@ function inlineable(f, e::Expr, sv, enclosing_ast)
meth = meth[1]::Tuple
linfo = meth[3].func.code

if length(atypes) > MAX_TUPLETYPE_LEN
# check call stack to see if this argument list is growing
st = inference_stack
while !isa(st, EmptyCallStack)
if st.ast === linfo.def.ast && length(atypes) > length(st.types)
atypes = limit_tuple_type(atypes)
meth = _methods(f, atypes, 1)
if meth === false || length(meth) != 1
return NF
end
meth = meth[1]::Tuple
linfo2 = meth[3].func.code
if linfo2 !== linfo
return NF
end
linfo = linfo2
break
end
st = st.prev
end
end
## This code tries to limit the argument list length only when it is
## growing due to recursion.
## It might be helpful for some things, but turns out not to be
## necessary to get max performance from recursive varargs functions.
# if length(atypes) > MAX_TUPLETYPE_LEN
# # check call stack to see if this argument list is growing
# st = inference_stack
# while !isa(st, EmptyCallStack)
# if st.ast === linfo.def.ast && length(atypes) > length(st.types)
# atypes = limit_tuple_type(atypes)
# meth = _methods(f, atypes, 1)
# if meth === false || length(meth) != 1
# return NF
# end
# meth = meth[1]::Tuple
# linfo2 = meth[3].func.code
# if linfo2 !== linfo
# return NF
# end
# linfo = linfo2
# break
# end
# st = st.prev
# end
# end

# when 1 method matches the inferred types, there is still a chance
# of a no-method error at run time, unless the inferred types are a
Expand Down
3 changes: 3 additions & 0 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ for op = (:+, :*, :&, :|, :$, :min, :max)
# that defining +(a,b) is sufficient for full functionality.
($op)(a, b, c) = ($op)(($op)(a,b),c)
($op)(a, b, c, xs...) = ($op)(($op)(($op)(a,b),c), xs...)
# a further concern is that it's easy for a type like (Int,Int...)
# to match many definitions, so we need to keep the number of
# definitions down to avoid losing type information.
end
end

Expand Down

0 comments on commit 9f20276

Please sign in to comment.