@@ -5,16 +5,16 @@ import Core: _apply, svec, apply_type, Builtin, IntrinsicFunction
5
5
# ### parameters limiting potentially-infinite types ####
6
6
const MAX_TYPEUNION_LEN = 3
7
7
const MAX_TYPE_DEPTH = 7
8
- const MAX_TUPLETYPE_LEN = 15
9
8
10
- const MAX_TUPLE_SPLAT = 16
11
- const MAX_UNION_SPLITTING = 4
12
9
const UNION_SPLIT_MISMATCH_ERROR = false
13
10
14
11
immutable InferenceParams
12
+ MAX_TUPLETYPE_LEN
13
+ MAX_TUPLE_SPLAT
14
+ MAX_UNION_SPLITTING
15
15
MAX_TUPLE_DEPTH
16
16
end
17
- const DEFAULT_PARAMS = InferenceParams (4 )
17
+ const DEFAULT_PARAMS = InferenceParams (15 , 16 , 4 , 4 )
18
18
19
19
# alloc_elim_pass! relies on `Slot_AssignedOnce | Slot_UsedUndef` being
20
20
# SSA. This should be true now but can break if we start to track conditional
@@ -637,7 +637,7 @@ function invoke_tfunc(f::ANY, types::ANY, argtype::ANY, sv::InferenceState)
637
637
if ! isleaftype (Type{types})
638
638
return Any
639
639
end
640
- argtype = typeintersect (types,limit_tuple_type (argtype))
640
+ argtype = typeintersect (types,limit_tuple_type (argtype, sv ))
641
641
if is (argtype,Bottom)
642
642
return Bottom
643
643
end
@@ -752,9 +752,9 @@ function limit_tuple_depth_(params::InferenceParams, t::ANY, d::Int)
752
752
Tuple{p... }
753
753
end
754
754
755
- limit_tuple_type = (t:: ANY ) -> limit_tuple_type_n (t, MAX_TUPLETYPE_LEN)
755
+ limit_tuple_type = (t:: ANY , sv :: InferenceState ) -> limit_tuple_type_n (t, sv . params . MAX_TUPLETYPE_LEN, sv )
756
756
757
- function limit_tuple_type_n (t:: ANY , lim:: Int )
757
+ function limit_tuple_type_n (t:: ANY , lim:: Int , sv :: InferenceState )
758
758
p = t. parameters
759
759
n = length (p)
760
760
if n > lim
@@ -776,7 +776,7 @@ function abstract_call_gf_by_type(f::ANY, argtype::ANY, sv::InferenceState)
776
776
# It is important for N to be >= the number of methods in the error()
777
777
# function, so we can still know that error() is always Bottom.
778
778
# here I picked 4.
779
- argtype = limit_tuple_type (argtype)
779
+ argtype = limit_tuple_type (argtype, sv )
780
780
argtypes = argtype. parameters
781
781
applicable = _methods_by_ftype (argtype, 4 )
782
782
rettype = Bottom
@@ -874,7 +874,7 @@ function abstract_call_gf_by_type(f::ANY, argtype::ANY, sv::InferenceState)
874
874
end
875
875
end
876
876
if ! allsame
877
- sig = limit_tuple_type_n (sig, lsig+ 1 )
877
+ sig = limit_tuple_type_n (sig, lsig+ 1 , sv )
878
878
end
879
879
end
880
880
end
@@ -949,9 +949,9 @@ function abstract_apply(af::ANY, fargs, aargtypes::Vector{Any}, vtypes::VarTable
949
949
# can be collapsed to a call to the applied func
950
950
at = append_any (Any[type_typeof (af)], ctypes... )
951
951
n = length (at)
952
- if n- 1 > MAX_TUPLETYPE_LEN
953
- tail = foldl ((a,b)-> tmerge (a,unwrapva (b)), Bottom, at[MAX_TUPLETYPE_LEN+ 1 : n])
954
- at = vcat (at[1 : MAX_TUPLETYPE_LEN], Any[Vararg{tail}])
952
+ if n- 1 > sv . params . MAX_TUPLETYPE_LEN
953
+ tail = foldl ((a,b)-> tmerge (a,unwrapva (b)), Bottom, at[sv . params . MAX_TUPLETYPE_LEN+ 1 : n])
954
+ at = vcat (at[1 : sv . params . MAX_TUPLETYPE_LEN], Any[Vararg{tail}])
955
955
end
956
956
return abstract_call (af, (), at, vtypes, sv)
957
957
end
@@ -2415,7 +2415,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
2415
2415
function invoke_NF ()
2416
2416
# converts a :call to :invoke
2417
2417
local nu = countunionsplit (atypes)
2418
- nu > MAX_UNION_SPLITTING && return NF
2418
+ nu > sv . params . MAX_UNION_SPLITTING && return NF
2419
2419
2420
2420
if nu > 1
2421
2421
local spec_hit = nothing
@@ -2519,8 +2519,8 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
2519
2519
return invoke_NF ()
2520
2520
end
2521
2521
2522
- if length (atype_unlimited. parameters) - 1 > MAX_TUPLETYPE_LEN
2523
- atype = limit_tuple_type (atype_unlimited)
2522
+ if length (atype_unlimited. parameters) - 1 > sv . params . MAX_TUPLETYPE_LEN
2523
+ atype = limit_tuple_type (atype_unlimited, sv )
2524
2524
else
2525
2525
atype = atype_unlimited
2526
2526
end
@@ -3055,7 +3055,7 @@ function inlining_pass(e::Expr, sv, linfo)
3055
3055
elseif isa (aarg, Tuple)
3056
3056
newargs[i- 2 ] = Any[ QuoteNode (x) for x in aarg ]
3057
3057
elseif isa (t, DataType) && t. name === Tuple. name && ! isvatuple (t) &&
3058
- effect_free (aarg, linfo, true ) && length (t. parameters) <= MAX_TUPLE_SPLAT
3058
+ effect_free (aarg, linfo, true ) && length (t. parameters) <= sv . params . MAX_TUPLE_SPLAT
3059
3059
# apply(f,t::(x,y)) => f(t[1],t[2])
3060
3060
tp = t. parameters
3061
3061
newargs[i- 2 ] = Any[ mk_getfield (aarg,j,tp[j]) for j= 1 : length (tp) ]
0 commit comments