Skip to content

Commit

Permalink
fix #390, adjust to the latest Julia compiler (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored Sep 20, 2022
1 parent df7014b commit f1f8c18
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions src/abstractinterpret/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,16 @@ function CC.abstract_call_method(analyzer::AbstractAnalyzer,
return ret
end

let
@static if hasmethod(CC.abstract_call_method_with_const_args, (AbstractInterpreter,
let # overload `abstract_call_method_with_const_args`
@static if isdefined(CC, :InvokeCall)
# https://github.com/JuliaLang/julia/pull/46743
sigs_ex = :(analyzer::AbstractAnalyzer,
result::MethodCallResult, @nospecialize(f), arginfo::ArgInfo, match::MethodMatch,
sv::InferenceState, $(Expr(:kw, :(invokecall::Union{Nothing,CC.InvokeCall}), :nothing)))
args_ex = :(analyzer::AbstractInterpreter,
result::MethodCallResult, f::Any, arginfo::ArgInfo, match::MethodMatch,
sv::InferenceState, invokecall::Union{Nothing,CC.InvokeCall})
elseif hasmethod(CC.abstract_call_method_with_const_args, (AbstractInterpreter,
MethodCallResult, Any, ArgInfo, MethodMatch,
InferenceState, Any))
sigs_ex = :(analyzer::AbstractAnalyzer,
Expand Down Expand Up @@ -232,19 +240,33 @@ let
end
end

@static if IS_V18
function CC.concrete_eval_call(analyzer::AbstractAnalyzer,
@nospecialize(f), result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState)
ret = @invoke CC.concrete_eval_call(analyzer::AbstractInterpreter,
f::Any, result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState)
if @static isdefined(CC, :ConstCallResults) ? (ret isa CC.ConstCallResults) : (ret !== nothing)
# this frame has been happily concretized, now we throw away reports collected
# during the previous abstract interpretation
filter_lineages!(analyzer, sv.result, result.edge::MethodInstance)
let # overload `concrete_eval_call`
@static if isdefined(CC, :InvokeCall)
# https://github.com/JuliaLang/julia/pull/46743
sigs_ex = :(analyzer::AbstractAnalyzer,
@nospecialize(f), result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState,
$(Expr(:kw, :(invokecall::Union{Nothing,CC.InvokeCall}), :nothing)))
args_ex = :(analyzer::AbstractInterpreter,
f::Any, result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState,
invokecall::Union{Nothing,CC.InvokeCall})
elseif IS_V18
sigs_ex = :(analyzer::AbstractAnalyzer,
@nospecialize(f), result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState)
args_ex = :(analyzer::AbstractInterpreter,
f::Any, result::MethodCallResult, arginfo::ArgInfo, sv::InferenceState)
else
return # `concrete_eval_call` isn't defined for this case
end
@eval function CC.concrete_eval_call($(sigs_ex.args...))
ret = @invoke CC.concrete_eval_call($(args_ex.args...))
if @static isdefined(CC, :ConstCallResults) ? (ret isa CC.ConstCallResults) : (ret !== nothing)
# this frame has been happily concretized, now we throw away reports collected
# during the previous abstract-interpretation based analysis
filter_lineages!(analyzer, sv.result, result.edge::MethodInstance)
end
return ret
end
return ret
end
end # @static if IS_V18

@static if IS_AFTER_42529
function CC.abstract_call(analyzer::AbstractAnalyzer,
Expand Down

0 comments on commit f1f8c18

Please sign in to comment.