Skip to content

Commit 72ee88a

Browse files
vtjnashclaude
andcommitted
Fix compatibility with Julia master after WorldView removal
Adapt InferenceBenchmarks to work with both older Julia versions that have Compiler.WorldView and newer versions that replaced it with OverlayCodeCache (JuliaLang/julia@998cb27). Uses isdefined checks to conditionally use the appropriate cache interface for each version. Fixes #337 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a03d447 commit 72ee88a

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/inference/InferenceBenchmarks.jl

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ using Core:
3232
MethodInstance, CodeInstance, MethodTable, SimpleVector
3333
using .CC:
3434
AbstractInterpreter, InferenceParams, InferenceResult, InferenceState,
35-
OptimizationParams, OptimizationState, WorldRange, WorldView,
35+
OptimizationParams, OptimizationState, WorldRange,
3636
specialize_method, unwrap_unionall, rewrap_unionall, copy
37+
@static if isdefined(CC, :WorldView)
38+
import .CC: WorldView
39+
end
3740
@static if VERSION v"1.11.0-DEV.1498"
3841
import .CC: get_inference_world
3942
else
@@ -84,11 +87,19 @@ CC.InferenceParams(interp::InferenceBenchmarker) = interp.inf_params
8487
CC.OptimizationParams(interp::InferenceBenchmarker) = interp.opt_params
8588
#=CC.=#get_inference_world(interp::InferenceBenchmarker) = interp.world
8689
CC.get_inference_cache(interp::InferenceBenchmarker) = interp.inf_cache
87-
CC.code_cache(interp::InferenceBenchmarker) = WorldView(interp.code_cache, WorldRange(get_inference_world(interp)))
88-
CC.get(wvc::WorldView{InferenceBenchmarkerCache}, mi::MethodInstance, default) = get(wvc.cache.dict, mi, default)
89-
CC.getindex(wvc::WorldView{InferenceBenchmarkerCache}, mi::MethodInstance) = getindex(wvc.cache.dict, mi)
90-
CC.haskey(wvc::WorldView{InferenceBenchmarkerCache}, mi::MethodInstance) = haskey(wvc.cache.dict, mi)
91-
CC.setindex!(wvc::WorldView{InferenceBenchmarkerCache}, ci::CodeInstance, mi::MethodInstance) = setindex!(wvc.cache.dict, ci, mi)
90+
@static if isdefined(CC, :WorldView)
91+
CC.code_cache(interp::InferenceBenchmarker) = WorldView(interp.code_cache, WorldRange(get_inference_world(interp)))
92+
CC.get(wvc::WorldView{InferenceBenchmarkerCache}, mi::MethodInstance, default) = get(wvc.cache.dict, mi, default)
93+
CC.getindex(wvc::WorldView{InferenceBenchmarkerCache}, mi::MethodInstance) = getindex(wvc.cache.dict, mi)
94+
CC.haskey(wvc::WorldView{InferenceBenchmarkerCache}, mi::MethodInstance) = haskey(wvc.cache.dict, mi)
95+
CC.setindex!(wvc::WorldView{InferenceBenchmarkerCache}, ci::CodeInstance, mi::MethodInstance) = setindex!(wvc.cache.dict, ci, mi)
96+
else
97+
CC.code_cache(interp::InferenceBenchmarker) = CC.OverlayCodeCache(interp.code_cache, interp.inf_cache)
98+
CC.get(cache::InferenceBenchmarkerCache, mi::MethodInstance, default) = get(cache.dict, mi, default)
99+
CC.getindex(cache::InferenceBenchmarkerCache, mi::MethodInstance) = getindex(cache.dict, mi)
100+
CC.haskey(cache::InferenceBenchmarkerCache, mi::MethodInstance) = haskey(cache.dict, mi)
101+
CC.setindex!(cache::InferenceBenchmarkerCache, ci::CodeInstance, mi::MethodInstance) = setindex!(cache.dict, ci, mi)
102+
end
92103
@static if isdefined(CC, :cache_owner)
93104
CC.cache_owner(wvc::InferenceBenchmarker) = wvc.code_cache
94105
end

0 commit comments

Comments
 (0)