Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use CC.add_invalidation_callback! if available #573

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/abstractinterpret/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,22 @@ function CC.setindex!(wvc::WorldView{<:AbstractAnalyzerView}, ci::CodeInstance,
analysis_cache[mi] = ci
end

struct JETCallback
analysis_cache::AnalysisCache
end

@static if VERSION ≥ v"1.11.0-DEV.798"

function add_jet_callback!(mi::MethodInstance, analysis_cache::AnalysisCache)
callback = JETCallback(analysis_cache)
CC.add_invalidation_callback!(callback, mi)
end
function (callback::JETCallback)(replaced::MethodInstance, max_world::UInt32)
delete!(callback.analysis_cache, replaced)
end

else

function add_jet_callback!(mi::MethodInstance, analysis_cache::AnalysisCache)
callback = JETCallback(analysis_cache)
if !isdefined(mi, :callbacks)
Expand All @@ -293,10 +309,7 @@ function add_jet_callback!(mi::MethodInstance, analysis_cache::AnalysisCache)
return nothing
end

struct JETCallback
analysis_cache::AnalysisCache
end
function (callback::JETCallback)(replaced::MethodInstance, max_world,
function (callback::JETCallback)(replaced::MethodInstance, max_world::UInt32,
seen::IdSet{MethodInstance} = IdSet{MethodInstance}())
push!(seen, replaced)
delete!(callback.analysis_cache, replaced)
Expand All @@ -311,6 +324,8 @@ function (callback::JETCallback)(replaced::MethodInstance, max_world,
return nothing
end

end

# local
# -----

Expand Down
Loading