@@ -242,6 +242,11 @@ cmp_tfunc = (x,y)->Bool
242
242
243
243
isType (t:: ANY ) = isa (t,DataType) && is ((t:: DataType ). name,Type. name)
244
244
245
+ # true if Type is inlineable as constant
246
+ isconstType (t:: ANY ,b:: Bool ) =
247
+ isType (t) && ! has_typevars (t. parameters[1 ],b) &&
248
+ ! issubtype (Tuple{Vararg}, t. parameters[1 ]) # work around inference bug #18450
249
+
245
250
const IInf = typemax (Int) # integer infinity
246
251
const n_ifunc = reinterpret (Int32,arraylen)+ 1
247
252
const t_ifunc = Array {Tuple{Int,Int,Any},1} (n_ifunc)
990
995
991
996
function pure_eval_call (f:: ANY , argtypes:: ANY , atype, vtypes, sv)
992
997
for a in drop (argtypes,1 )
993
- if ! (isa (a,Const) || ( isType (a) && ! has_typevars (a . parameters[ 1 ]) ))
998
+ if ! (isa (a,Const) || isconstType (a, false ))
994
999
return false
995
1000
end
996
1001
end
@@ -1965,7 +1970,7 @@ function finish(me::InferenceState)
1965
1970
# need to add coverage support to the `jl_call_method_internal` fast path
1966
1971
if ! do_coverage &&
1967
1972
((isa (me. bestguess,Const) && me. bestguess. val != = nothing ) ||
1968
- ( isType ( me. bestguess) && ! has_typevars (me . bestguess . parameters[ 1 ] ,true ) ))
1973
+ isconstType ( me. bestguess,true ))
1969
1974
if ! ispure && length (me. src. code) < 10
1970
1975
ispure = true
1971
1976
for stmt in me. src. code
@@ -2388,7 +2393,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
2388
2393
topmod = _topmod (sv)
2389
2394
# special-case inliners for known pure functions that compute types
2390
2395
if sv. inlining
2391
- if isType (e. typ) && ! has_typevars (e . typ . parameters[ 1 ] ,true )
2396
+ if isconstType (e. typ,true )
2392
2397
if (is (f, apply_type) || is (f, fieldtype) || is (f, typeof) ||
2393
2398
istopfunction (topmod, f, :typejoin ) ||
2394
2399
istopfunction (topmod, f, :promote_type ))
@@ -2539,14 +2544,10 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
2539
2544
methsp = meth[2 ]
2540
2545
method = meth[3 ]:: Method
2541
2546
# check whether call can be inlined to just a quoted constant value
2542
- if isa (f, widenconst (ft)) && ! method. isstaged && (method. source. pure || f === return_type) &&
2543
- (isType (e. typ) || isa (e. typ,Const))
2544
- if isType (e. typ)
2545
- if ! has_typevars (e. typ. parameters[1 ])
2546
- return inline_as_constant (e. typ. parameters[1 ], argexprs, sv)
2547
- end
2548
- else
2549
- assert (isa (e. typ,Const))
2547
+ if isa (f, widenconst (ft)) && ! method. isstaged && (method. source. pure || f === return_type)
2548
+ if isconstType (e. typ,false )
2549
+ return inline_as_constant (e. typ. parameters[1 ], argexprs, sv)
2550
+ elseif isa (e. typ,Const)
2550
2551
return inline_as_constant (e. typ. val, argexprs, sv)
2551
2552
end
2552
2553
end
2 commit comments
yuyichao commentedon Sep 19, 2016
@nanosoldier
runbenchmarks(ALL, vs="@e781d08180a96519e84793e872c96e095df95c79")
e781d08
nanosoldier commentedon Sep 19, 2016
Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels