Skip to content

Commit

Permalink
adjust to the latest JuliaLang/julia#master
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Nov 6, 2023
1 parent 5ab1079 commit b0582e6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
23 changes: 11 additions & 12 deletions src/JET.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,7 @@ get_linfo(sv::State) = sv.linfo
get_linfo(result::InferenceResult) = result.linfo
get_linfo(linfo::MethodInstance) = linfo

function is_constant_propagated(frame::InferenceState)
@static if VERSION v"1.11.0-DEV.737"
return frame.cache_mode === :local &&
is_constant_propagated(frame.result)
else
return !frame.cached && # const-prop'ed frame is never cached globally
is_constant_propagated(frame.result)
end
end
is_constant_propagated(frame::InferenceState) = is_constant_propagated(frame.result)
is_constant_propagated(result::InferenceResult) = CC.any(result.overridden_by_const)

# lattice
Expand Down Expand Up @@ -755,16 +747,23 @@ end
function analyze_method_instance!(analyzer::AbstractAnalyzer, mi::MethodInstance)
result = InferenceResult(mi)

frame = InferenceState(result, #=cache=# :global, analyzer)
frame = InferenceState(result, #=cache_mode=#:global, analyzer)

isnothing(frame) && return analyzer, result

return analyze_frame!(analyzer, frame)
end

function InferenceState(result::InferenceResult, cache::Symbol, analyzer::AbstractAnalyzer)
@static if VERSION v"1.11.0-DEV.843"
function InferenceState(result::InferenceResult, cache_mode::UInt8, analyzer::AbstractAnalyzer)
init_result!(analyzer, result)
return @invoke InferenceState(result::InferenceResult, cache::Symbol, analyzer::AbstractInterpreter)
return @invoke InferenceState(result::InferenceResult, cache_mode::UInt8, analyzer::AbstractInterpreter)
end
else
function InferenceState(result::InferenceResult, cache_mode::Symbol, analyzer::AbstractAnalyzer)
init_result!(analyzer, result)
return @invoke InferenceState(result::InferenceResult, cache_mode::Symbol, analyzer::AbstractInterpreter)
end
end

function analyze_frame!(analyzer::AbstractAnalyzer, frame::InferenceState)
Expand Down
4 changes: 4 additions & 0 deletions src/abstractinterpret/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,11 @@ function CC.abstract_eval_special_value(analyzer::AbstractAnalyzer, @nospecializ
# in this call graph, but it's highly possible this is a toplevel callsite
# and we take a risk here since we can't enter the analysis otherwise
val = getglobal(mod, name)
@static if VERSION v"1.11.0-DEV.797"
ret = CC.RTEffects(isa(val, AbstractGlobal) ? val.t : Const(val), ret.effects)
else
ret = isa(val, AbstractGlobal) ? val.t : Const(val)
end
end
end
end
Expand Down
14 changes: 12 additions & 2 deletions src/analyzers/jetanalyzer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,23 @@ end # @static if VERSION < v"1.10.0-DEV.286"
# overloads
# =========

function CC.InferenceState(result::InferenceResult, cache::Symbol, analyzer::JETAnalyzer)
frame = @invoke CC.InferenceState(result::InferenceResult, cache::Symbol, analyzer::AbstractAnalyzer)
@static if VERSION v"1.11.0-DEV.843"
function CC.InferenceState(result::InferenceResult, cache_mode::UInt8, analyzer::JETAnalyzer)
frame = @invoke CC.InferenceState(result::InferenceResult, cache_mode::UInt8, analyzer::AbstractAnalyzer)
if isnothing(frame) # indicates something bad happened within `retrieve_code_info`
ReportPass(analyzer)(GeneratorErrorReport, analyzer, result)
end
return frame
end
else
function CC.InferenceState(result::InferenceResult, cache_mode::Symbol, analyzer::JETAnalyzer)
frame = @invoke CC.InferenceState(result::InferenceResult, cache_mode::Symbol, analyzer::AbstractAnalyzer)
if isnothing(frame) # indicates something bad happened within `retrieve_code_info`
ReportPass(analyzer)(GeneratorErrorReport, analyzer, result)
end
return frame
end
end

function CC.finish!(analyzer::JETAnalyzer, caller::InferenceState)
src = caller.result.src
Expand Down
2 changes: 1 addition & 1 deletion src/toplevel/virtualprocess.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ function analyze_toplevel!(analyzer::AbstractAnalyzer, src::CodeInfo)
# NOTE toplevel frames don't really need to be cached, but still better to be optimized
# in order to get reasonable `UncaughtExceptionReport`, and also, otherwise
# `typeinf_edge` won't add "toplevel-to-callee" edges
frame = InferenceState(result, src, #=cache=# :global, analyzer)::InferenceState
frame = InferenceState(result, src, #=cache_mode=#:global, analyzer)::InferenceState

return analyze_frame!(analyzer, frame)
end
Expand Down

0 comments on commit b0582e6

Please sign in to comment.