Skip to content

Commit

Permalink
rm CachedMethodTable
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Feb 21, 2022
1 parent 344ffe1 commit df07fea
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 35 deletions.
4 changes: 2 additions & 2 deletions base/compiler/inferencestate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mutable struct InferenceState
# The place to look up methods while working on this function.
# In particular, we cache method lookup results for the same function to
# fast path repeated queries.
method_table::CachedMethodTable{InternalMethodTable}
method_table::InternalMethodTable

# The interpreter that created this inference state. Not looked at by
# NativeInterpreter. But other interpreters may use this to detect cycles
Expand Down Expand Up @@ -141,7 +141,7 @@ mutable struct InferenceState
cache === :global, false, false,
Effects(consistent, ALWAYS_TRUE, ALWAYS_TRUE, ALWAYS_TRUE,
inbounds_taints_consistency),
CachedMethodTable(get_method_lookup_cache(interp), method_table(interp)),
method_table(interp),
interp)
result.result = frame
cache !== :no && push!(get_inference_cache(interp), result)
Expand Down
28 changes: 0 additions & 28 deletions base/compiler/methodtable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@ struct OverlayMethodTable <: MethodTableView
mt::Core.MethodTable
end

"""
struct CachedMethodTable <: MethodTableView
Overlays another method table view with an additional local fast path cache that
can respond to repeated, identical queries faster than the original method table.
"""
struct CachedMethodTable{T} <: MethodTableView
cache::MethodLookupCache
table::T
CachedMethodTable(cache::MethodLookupCache, table::T) where T = new{T}(cache, table)
CachedMethodTable(::Nothing, table::T) where T = new{T}(MethodLookupCache(), table)
end

"""
findall(sig::Type, view::MethodTableView; limit=typemax(Int))
Expand Down Expand Up @@ -74,17 +61,6 @@ function findall(@nospecialize(sig::Type), table::OverlayMethodTable; limit::Int
return MethodLookupResult(ms::Vector{Any}, WorldRange(_min_val[], _max_val[]), _ambig[] != 0)
end

function findall(@nospecialize(sig::Type), table::CachedMethodTable; limit::Int=typemax(Int))
if isconcretetype(sig)
# we have equivalent cache in this concrete DataType's hash table, so don't bother to cache it here
return findall(sig, table.table; limit)
end
box = Core.Box(sig)
return get!(table.cache, sig) do
findall(box.contents, table.table; limit)
end
end

"""
findsup(sig::Type, view::MethodTableView)::Union{Tuple{MethodMatch, WorldRange}, Nothing}
Expand All @@ -108,10 +84,6 @@ function findsup(@nospecialize(sig::Type), table::InternalMethodTable)
(result.method, WorldRange(min_valid[], max_valid[]))
end

# This query is not cached
findsup(@nospecialize(sig::Type), table::CachedMethodTable) = findsup(sig, table.table)

isoverlayed(::MethodTableView) = error("unsatisfied MethodTableView interface")
isoverlayed(::InternalMethodTable) = false
isoverlayed(::OverlayMethodTable) = true
isoverlayed(mt::CachedMethodTable) = isoverlayed(mt.table)
5 changes: 0 additions & 5 deletions base/compiler/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@ It contains many parameters used by the compilation pipeline.
struct NativeInterpreter <: AbstractInterpreter
# Cache of inference results for this particular interpreter
cache::Vector{InferenceResult}
# cache of method lookup results
method_lookup_cache::MethodLookupCache
# The world age we're working inside of
world::UInt

Expand All @@ -285,7 +283,6 @@ struct NativeInterpreter <: AbstractInterpreter
return new(
# Initially empty caches
Vector{InferenceResult}(),
MethodLookupCache(),

# world age counter
world,
Expand Down Expand Up @@ -335,8 +332,6 @@ may_discard_trees(::AbstractInterpreter) = true
verbose_stmt_info(::AbstractInterpreter) = false

method_table(interp::AbstractInterpreter) = InternalMethodTable(get_world_counter(interp))
get_method_lookup_cache(ni::NativeInterpreter) = ni.method_lookup_cache
get_method_lookup_cache(::AbstractInterpreter) = nothing

"""
By default `AbstractInterpreter` implements the following inference bail out logic:
Expand Down

0 comments on commit df07fea

Please sign in to comment.