@@ -47,25 +47,23 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
47
47
# function has not seen any side effects, we would like to make sure there
48
48
# aren't any in the throw block either to enable other optimizations.
49
49
add_remark! (interp, sv, " Skipped call in throw block" )
50
- overlayed = true
51
- if isoverlayed (method_table (interp))
52
- if ! sv. ipo_effects. overlayed
53
- # as we may want to concrete-evaluate this frame in cases when there are
54
- # no overlayed calls, try an additional effort now to check if this call
55
- # isn't overlayed rather than just handling it conservatively
56
- matches = find_matching_methods (arginfo. argtypes, atype, method_table (interp),
57
- InferenceParams (interp). MAX_UNION_SPLITTING, max_methods)
58
- if ! isa (matches, FailedMethodMatch)
59
- overlayed = matches. overlayed
60
- end
50
+ nonoverlayed = false
51
+ if isoverlayed (method_table (interp)) && sv. ipo_effects. nonoverlayed
52
+ # as we may want to concrete-evaluate this frame in cases when there are
53
+ # no overlayed calls, try an additional effort now to check if this call
54
+ # isn't overlayed rather than just handling it conservatively
55
+ matches = find_matching_methods (arginfo. argtypes, atype, method_table (interp),
56
+ InferenceParams (interp). MAX_UNION_SPLITTING, max_methods)
57
+ if ! isa (matches, FailedMethodMatch)
58
+ nonoverlayed = matches. nonoverlayed
61
59
end
62
60
else
63
- overlayed = false
61
+ nonoverlayed = true
64
62
end
65
63
# At this point we are guaranteed to end up throwing on this path,
66
64
# which is all that's required for :consistent-cy. Of course, we don't
67
65
# know anything else about this statement.
68
- tristate_merge! (sv, Effects (; consistent= ALWAYS_TRUE, overlayed ))
66
+ tristate_merge! (sv, Effects (; consistent= ALWAYS_TRUE, nonoverlayed ))
69
67
return CallMeta (Any, false )
70
68
end
71
69
@@ -88,11 +86,11 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
88
86
any_const_result = false
89
87
const_results = Union{InferenceResult,Nothing,ConstResult}[]
90
88
multiple_matches = napplicable > 1
91
- if matches. overlayed
89
+ if ! matches. nonoverlayed
92
90
# currently we don't have a good way to execute the overlayed method definition,
93
91
# so we should give up pure/concrete eval when any of the matched methods is overlayed
94
92
f = nothing
95
- tristate_merge! (sv, Effects (EFFECTS_TOTAL; overlayed = true ))
93
+ tristate_merge! (sv, Effects (EFFECTS_TOTAL; nonoverlayed = false ))
96
94
end
97
95
98
96
val = pure_eval_call (interp, f, applicable, arginfo, sv)
@@ -212,7 +210,9 @@ function abstract_call_gf_by_type(interp::AbstractInterpreter, @nospecialize(f),
212
210
end
213
211
214
212
if seen != napplicable
215
- tristate_merge! (sv, Effects (; overlayed= false )) # already accounted for method overlay above
213
+ # there may be unanalyzed effects within unseen dispatch candidate,
214
+ # but we can still ignore nonoverlayed effect here since we already accounted for it
215
+ tristate_merge! (sv, EFFECTS_UNKNOWN)
216
216
elseif isa (matches, MethodMatches) ? (! matches. fullmatch || any_ambig (matches)) :
217
217
(! _all (b-> b, matches. fullmatches) || any_ambig (matches))
218
218
# Account for the fact that we may encounter a MethodError with a non-covered or ambiguous signature.
@@ -251,7 +251,7 @@ struct MethodMatches
251
251
valid_worlds:: WorldRange
252
252
mt:: Core.MethodTable
253
253
fullmatch:: Bool
254
- overlayed :: Bool
254
+ nonoverlayed :: Bool
255
255
end
256
256
any_ambig (info:: MethodMatchInfo ) = info. results. ambig
257
257
any_ambig (m:: MethodMatches ) = any_ambig (m. info)
@@ -263,7 +263,7 @@ struct UnionSplitMethodMatches
263
263
valid_worlds:: WorldRange
264
264
mts:: Vector{Core.MethodTable}
265
265
fullmatches:: Vector{Bool}
266
- overlayed :: Bool
266
+ nonoverlayed :: Bool
267
267
end
268
268
any_ambig (m:: UnionSplitMethodMatches ) = _any (any_ambig, m. info. matches)
269
269
@@ -278,7 +278,7 @@ function find_matching_methods(argtypes::Vector{Any}, @nospecialize(atype), meth
278
278
valid_worlds = WorldRange ()
279
279
mts = Core. MethodTable[]
280
280
fullmatches = Bool[]
281
- overlayed = false
281
+ nonoverlayed = true
282
282
for i in 1 : length (split_argtypes)
283
283
arg_n = split_argtypes[i]:: Vector{Any}
284
284
sig_n = argtypes_to_type (arg_n)
@@ -289,8 +289,8 @@ function find_matching_methods(argtypes::Vector{Any}, @nospecialize(atype), meth
289
289
if result === missing
290
290
return FailedMethodMatch (" For one of the union split cases, too many methods matched" )
291
291
end
292
- matches, overlayedᵢ = result
293
- overlayed |= overlayedᵢ
292
+ matches, overlayed = result
293
+ nonoverlayed &= ! overlayed
294
294
push! (infos, MethodMatchInfo (matches))
295
295
for m in matches
296
296
push! (applicable, m)
@@ -317,7 +317,7 @@ function find_matching_methods(argtypes::Vector{Any}, @nospecialize(atype), meth
317
317
valid_worlds,
318
318
mts,
319
319
fullmatches,
320
- overlayed )
320
+ nonoverlayed )
321
321
else
322
322
mt = ccall (:jl_method_table_for , Any, (Any,), atype)
323
323
if mt === nothing
@@ -337,7 +337,7 @@ function find_matching_methods(argtypes::Vector{Any}, @nospecialize(atype), meth
337
337
matches. valid_worlds,
338
338
mt,
339
339
fullmatch,
340
- overlayed)
340
+ ! overlayed)
341
341
end
342
342
end
343
343
@@ -712,7 +712,7 @@ function concrete_eval_eligible(interp::AbstractInterpreter,
712
712
@nospecialize (f), result:: MethodCallResult , arginfo:: ArgInfo , sv:: InferenceState )
713
713
# disable concrete-evaluation since this function call is tainted by some overlayed
714
714
# method and currently there is no direct way to execute overlayed methods
715
- isoverlayed (method_table (interp)) && result. edge_effects. overlayed && return false
715
+ isoverlayed (method_table (interp)) && ! result. edge_effects. nonoverlayed && return false
716
716
return f != = nothing &&
717
717
result. edge != = nothing &&
718
718
is_total_or_error (result. edge_effects) &&
@@ -1500,13 +1500,13 @@ end
1500
1500
function abstract_invoke (interp:: AbstractInterpreter , (; fargs, argtypes):: ArgInfo , sv:: InferenceState )
1501
1501
ft′ = argtype_by_index (argtypes, 2 )
1502
1502
ft = widenconst (ft′)
1503
- ft === Bottom && return CallMeta (Bottom, false ), EFFECTS_THROWN
1503
+ ft === Bottom && return CallMeta (Bottom, false ), EFFECTS_THROWS
1504
1504
(types, isexact, isconcrete, istype) = instanceof_tfunc (argtype_by_index (argtypes, 3 ))
1505
- types === Bottom && return CallMeta (Bottom, false ), EFFECTS_THROWN
1505
+ types === Bottom && return CallMeta (Bottom, false ), EFFECTS_THROWS
1506
1506
isexact || return CallMeta (Any, false ), Effects ()
1507
1507
argtype = argtypes_to_type (argtype_tail (argtypes, 4 ))
1508
1508
nargtype = typeintersect (types, argtype)
1509
- nargtype === Bottom && return CallMeta (Bottom, false ), EFFECTS_THROWN
1509
+ nargtype === Bottom && return CallMeta (Bottom, false ), EFFECTS_THROWS
1510
1510
nargtype isa DataType || return CallMeta (Any, false ), Effects () # other cases are not implemented below
1511
1511
isdispatchelem (ft) || return CallMeta (Any, false ), Effects () # check that we might not have a subtype of `ft` at runtime, before doing supertype lookup below
1512
1512
ft = ft:: DataType
@@ -1540,6 +1540,7 @@ function abstract_invoke(interp::AbstractInterpreter, (; fargs, argtypes)::ArgIn
1540
1540
(; rt, effects, const_result) = const_call_result
1541
1541
end
1542
1542
end
1543
+ effects = Effects (effects; nonoverlayed= ! overlayed)
1543
1544
return CallMeta (from_interprocedural! (rt, sv, arginfo, sig), InvokeCallInfo (match, const_result)), effects
1544
1545
end
1545
1546
@@ -1585,12 +1586,12 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
1585
1586
end
1586
1587
end
1587
1588
end
1588
- tristate_merge! (sv, Effects (; overlayed = false ) ) # TODO
1589
+ tristate_merge! (sv, EFFECTS_UNKNOWN ) # TODO
1589
1590
return CallMeta (Any, false )
1590
1591
elseif f === TypeVar
1591
1592
# Manually look through the definition of TypeVar to
1592
1593
# make sure to be able to get `PartialTypeVar`s out.
1593
- tristate_merge! (sv, Effects (; overlayed = false ) ) # TODO
1594
+ tristate_merge! (sv, EFFECTS_UNKNOWN ) # TODO
1594
1595
(la < 2 || la > 4 ) && return CallMeta (Union{}, false )
1595
1596
n = argtypes[2 ]
1596
1597
ub_var = Const (Any)
@@ -1603,17 +1604,17 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
1603
1604
end
1604
1605
return CallMeta (typevar_tfunc (n, lb_var, ub_var), false )
1605
1606
elseif f === UnionAll
1606
- tristate_merge! (sv, Effects (; overlayed = false ) ) # TODO
1607
+ tristate_merge! (sv, EFFECTS_UNKNOWN ) # TODO
1607
1608
return CallMeta (abstract_call_unionall (argtypes), false )
1608
1609
elseif f === Tuple && la == 2
1609
- tristate_merge! (sv, Effects (; overlayed = false ) ) # TODO
1610
+ tristate_merge! (sv, EFFECTS_UNKNOWN ) # TODO
1610
1611
aty = argtypes[2 ]
1611
1612
ty = isvarargtype (aty) ? unwrapva (aty) : widenconst (aty)
1612
1613
if ! isconcretetype (ty)
1613
1614
return CallMeta (Tuple, false )
1614
1615
end
1615
1616
elseif is_return_type (f)
1616
- tristate_merge! (sv, Effects (; overlayed = false ) ) # TODO
1617
+ tristate_merge! (sv, EFFECTS_UNKNOWN ) # TODO
1617
1618
return return_type_tfunc (interp, argtypes, sv)
1618
1619
elseif la == 2 && istopfunction (f, :! )
1619
1620
# handle Conditional propagation through !Bool
@@ -1956,21 +1957,21 @@ function abstract_eval_statement(interp::AbstractInterpreter, @nospecialize(e),
1956
1957
effects. effect_free ? ALWAYS_TRUE : TRISTATE_UNKNOWN,
1957
1958
effects. nothrow ? ALWAYS_TRUE : TRISTATE_UNKNOWN,
1958
1959
effects. terminates_globally ? ALWAYS_TRUE : TRISTATE_UNKNOWN,
1959
- #= overlayed =# false
1960
+ #= nonoverlayed =# true
1960
1961
))
1961
1962
else
1962
- tristate_merge! (sv, Effects (; overlayed = false ) )
1963
+ tristate_merge! (sv, EFFECTS_UNKNOWN )
1963
1964
end
1964
1965
elseif ehead === :cfunction
1965
- tristate_merge! (sv, Effects (; overlayed = false ) )
1966
+ tristate_merge! (sv, EFFECTS_UNKNOWN )
1966
1967
t = e. args[1 ]
1967
1968
isa (t, Type) || (t = Any)
1968
1969
abstract_eval_cfunction (interp, e, vtypes, sv)
1969
1970
elseif ehead === :method
1970
- tristate_merge! (sv, Effects (; overlayed = false ) )
1971
+ tristate_merge! (sv, EFFECTS_UNKNOWN )
1971
1972
t = (length (e. args) == 1 ) ? Any : Nothing
1972
1973
elseif ehead === :copyast
1973
- tristate_merge! (sv, Effects (; overlayed = false ) )
1974
+ tristate_merge! (sv, EFFECTS_UNKNOWN )
1974
1975
t = abstract_eval_value (interp, e. args[1 ], vtypes, sv)
1975
1976
if t isa Const && t. val isa Expr
1976
1977
# `copyast` makes copies of Exprs
@@ -2283,7 +2284,7 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
2283
2284
effect_free= ALWAYS_FALSE,
2284
2285
nothrow= TRISTATE_UNKNOWN))
2285
2286
elseif ! isa (lhs, SSAValue)
2286
- tristate_merge! (frame, Effects (; overlayed = false ) )
2287
+ tristate_merge! (frame, EFFECTS_UNKNOWN )
2287
2288
end
2288
2289
elseif hd === :method
2289
2290
stmt = stmt:: Expr
0 commit comments