@@ -2085,19 +2085,28 @@ function abstract_call_method_with_const_args(@nospecialize(f), argtypes::Vector
2085
2085
return result
2086
2086
end
2087
2087
2088
- function method_for_inference_heuristics (infstate:: InferenceState )
2089
- m = infstate. src. method_for_inference_heuristics
2090
- return isa (m, Method) ? m : infstate. linfo. def
2088
+ function method_for_inference_heuristics (cinfo, default:: Method ):: Method
2089
+ if isa (cinfo, CodeInfo)
2090
+ # appropriate format for `sig` is svec(ftype, argtypes, world)
2091
+ sig = cinfo. signature_for_inference_heuristics
2092
+ if isa (sig, SimpleVector) && length (sig) == 3
2093
+ methods = _methods (sig[1 ], sig[2 ], - 1 , sig[3 ])
2094
+ if length (methods) == 1
2095
+ _, _, m = methods[]
2096
+ if isa (m, Method)
2097
+ return m
2098
+ end
2099
+ end
2100
+ end
2101
+ end
2102
+ return default
2091
2103
end
2092
2104
2093
- function method_for_inference_heuristics (method:: Method , @nospecialize (sig), sparams, world)
2105
+ function method_for_inference_heuristics (method:: Method , @nospecialize (sig), sparams, world):: Method
2094
2106
if isdefined (method, :generator ) && method. generator. expand_early
2095
2107
method_instance = code_for_method (method, sig, sparams, world, false )
2096
2108
if isa (method_instance, MethodInstance)
2097
- cinfo = get_staged (method_instance)
2098
- if isa (cinfo, CodeInfo) && isa (cinfo. method_for_inference_heuristics, Method)
2099
- return cinfo. method_for_inference_heuristics
2100
- end
2109
+ return method_for_inference_heuristics (get_staged (method_instance), method)
2101
2110
end
2102
2111
end
2103
2112
return method
@@ -2122,7 +2131,7 @@ function abstract_call_method(method::Method, @nospecialize(sig), sparams::Simpl
2122
2131
edgecycle = true
2123
2132
break
2124
2133
end
2125
- working_method = method_for_inference_heuristics (infstate)
2134
+ working_method = method_for_inference_heuristics (infstate. src, infstate . linfo . def )
2126
2135
if checked_method === working_method
2127
2136
if topmost === nothing
2128
2137
# inspect the parent of this edge,
@@ -2142,7 +2151,7 @@ function abstract_call_method(method::Method, @nospecialize(sig), sparams::Simpl
2142
2151
# then check the parent link
2143
2152
if topmost === nothing && parent != = nothing
2144
2153
parent = parent:: InferenceState
2145
- parent_method = method_for_inference_heuristics (parent)
2154
+ parent_method = method_for_inference_heuristics (parent. src, parent . linfo . def )
2146
2155
if parent. cached && parent_method === working_method
2147
2156
topmost = infstate
2148
2157
edgecycle = true
@@ -3404,7 +3413,7 @@ function typeinf_code(linfo::MethodInstance, optimize::Bool, cached::Bool,
3404
3413
method = linfo. def:: Method
3405
3414
tree = ccall (:jl_new_code_info_uninit , Ref{CodeInfo}, ())
3406
3415
tree. code = Any[ Expr (:return , quoted (linfo. inferred_const)) ]
3407
- tree. method_for_inference_heuristics = nothing
3416
+ tree. signature_for_inference_heuristics = nothing
3408
3417
tree. slotnames = Any[ compiler_temp_sym for i = 1 : method. nargs ]
3409
3418
tree. slotflags = UInt8[ 0 for i = 1 : method. nargs ]
3410
3419
tree. slottypes = nothing
0 commit comments