Skip to content

Commit df07fea

Browse files
committed
rm CachedMethodTable
1 parent 344ffe1 commit df07fea

File tree

3 files changed

+2
-35
lines changed

3 files changed

+2
-35
lines changed

base/compiler/inferencestate.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ mutable struct InferenceState
6565
# The place to look up methods while working on this function.
6666
# In particular, we cache method lookup results for the same function to
6767
# fast path repeated queries.
68-
method_table::CachedMethodTable{InternalMethodTable}
68+
method_table::InternalMethodTable
6969

7070
# The interpreter that created this inference state. Not looked at by
7171
# NativeInterpreter. But other interpreters may use this to detect cycles
@@ -141,7 +141,7 @@ mutable struct InferenceState
141141
cache === :global, false, false,
142142
Effects(consistent, ALWAYS_TRUE, ALWAYS_TRUE, ALWAYS_TRUE,
143143
inbounds_taints_consistency),
144-
CachedMethodTable(get_method_lookup_cache(interp), method_table(interp)),
144+
method_table(interp),
145145
interp)
146146
result.result = frame
147147
cache !== :no && push!(get_inference_cache(interp), result)

base/compiler/methodtable.jl

-28
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,6 @@ struct OverlayMethodTable <: MethodTableView
2323
mt::Core.MethodTable
2424
end
2525

26-
"""
27-
struct CachedMethodTable <: MethodTableView
28-
29-
Overlays another method table view with an additional local fast path cache that
30-
can respond to repeated, identical queries faster than the original method table.
31-
"""
32-
struct CachedMethodTable{T} <: MethodTableView
33-
cache::MethodLookupCache
34-
table::T
35-
CachedMethodTable(cache::MethodLookupCache, table::T) where T = new{T}(cache, table)
36-
CachedMethodTable(::Nothing, table::T) where T = new{T}(MethodLookupCache(), table)
37-
end
38-
3926
"""
4027
findall(sig::Type, view::MethodTableView; limit=typemax(Int))
4128
@@ -74,17 +61,6 @@ function findall(@nospecialize(sig::Type), table::OverlayMethodTable; limit::Int
7461
return MethodLookupResult(ms::Vector{Any}, WorldRange(_min_val[], _max_val[]), _ambig[] != 0)
7562
end
7663

77-
function findall(@nospecialize(sig::Type), table::CachedMethodTable; limit::Int=typemax(Int))
78-
if isconcretetype(sig)
79-
# we have equivalent cache in this concrete DataType's hash table, so don't bother to cache it here
80-
return findall(sig, table.table; limit)
81-
end
82-
box = Core.Box(sig)
83-
return get!(table.cache, sig) do
84-
findall(box.contents, table.table; limit)
85-
end
86-
end
87-
8864
"""
8965
findsup(sig::Type, view::MethodTableView)::Union{Tuple{MethodMatch, WorldRange}, Nothing}
9066
@@ -108,10 +84,6 @@ function findsup(@nospecialize(sig::Type), table::InternalMethodTable)
10884
(result.method, WorldRange(min_valid[], max_valid[]))
10985
end
11086

111-
# This query is not cached
112-
findsup(@nospecialize(sig::Type), table::CachedMethodTable) = findsup(sig, table.table)
113-
11487
isoverlayed(::MethodTableView) = error("unsatisfied MethodTableView interface")
11588
isoverlayed(::InternalMethodTable) = false
11689
isoverlayed(::OverlayMethodTable) = true
117-
isoverlayed(mt::CachedMethodTable) = isoverlayed(mt.table)

base/compiler/types.jl

-5
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ It contains many parameters used by the compilation pipeline.
259259
struct NativeInterpreter <: AbstractInterpreter
260260
# Cache of inference results for this particular interpreter
261261
cache::Vector{InferenceResult}
262-
# cache of method lookup results
263-
method_lookup_cache::MethodLookupCache
264262
# The world age we're working inside of
265263
world::UInt
266264

@@ -285,7 +283,6 @@ struct NativeInterpreter <: AbstractInterpreter
285283
return new(
286284
# Initially empty caches
287285
Vector{InferenceResult}(),
288-
MethodLookupCache(),
289286

290287
# world age counter
291288
world,
@@ -335,8 +332,6 @@ may_discard_trees(::AbstractInterpreter) = true
335332
verbose_stmt_info(::AbstractInterpreter) = false
336333

337334
method_table(interp::AbstractInterpreter) = InternalMethodTable(get_world_counter(interp))
338-
get_method_lookup_cache(ni::NativeInterpreter) = ni.method_lookup_cache
339-
get_method_lookup_cache(::AbstractInterpreter) = nothing
340335

341336
"""
342337
By default `AbstractInterpreter` implements the following inference bail out logic:

0 commit comments

Comments
 (0)