Skip to content

Commit 02f1270

Browse files
committed
Allow for generic MethodTableView
1 parent 772a78c commit 02f1270

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

src/interface.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ get_interpreter(@nospecialize(job::CompilerJob)) =
236236
opt_params=optimization_params(job))
237237
else
238238
get_interpreter(@nospecialize(job::CompilerJob)) =
239-
GPUInterpreter(job.world; method_table=method_table(job),
239+
GPUInterpreter(job.world; method_table_view=maybe_cached(method_table_view(job)),
240240
code_cache=ci_cache(job), inf_params=inference_params(job),
241241
opt_params=optimization_params(job))
242242
end
@@ -299,6 +299,7 @@ end
299299

300300
# the method table to use
301301
method_table(@nospecialize(job::CompilerJob)) = GLOBAL_METHOD_TABLE
302+
method_table_view(@nospecialize(job::CompilerJob)) = get_method_table_view(job.world, method_table(job))
302303

303304
# the inference parameters to use when constructing the GPUInterpreter
304305
function inference_params(@nospecialize(job::CompilerJob))

src/jlgen.jl

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -307,21 +307,18 @@ else
307307
import Core.Compiler: get_world_counter, get_world_counter as get_inference_world
308308
end
309309

310-
using Core.Compiler: OverlayMethodTable
311-
const MTType = Core.MethodTable
312310
if isdefined(Core.Compiler, :CachedMethodTable)
313311
using Core.Compiler: CachedMethodTable
314-
const GPUMethodTableView = CachedMethodTable{OverlayMethodTable}
315-
get_method_table_view(world::UInt, mt::MTType) =
316-
CachedMethodTable(OverlayMethodTable(world, mt))
312+
maybe_cached(mtv::CC.MethodTableView) = CachedMethodTable(mtv)
317313
else
318-
const GPUMethodTableView = OverlayMethodTable
319-
get_method_table_view(world::UInt, mt::MTType) = OverlayMethodTable(world, mt)
314+
maybe_cached(mtv::CC.MethodTableView) = mtv
320315
end
321316

322-
struct GPUInterpreter <: CC.AbstractInterpreter
317+
get_method_table_view(world::UInt, mt::CC.MethodTable) = CC.OverlayMethodTable(world, mt)
318+
319+
struct GPUInterpreter{MTV<:CC.MethodTableView} <: CC.AbstractInterpreter
323320
world::UInt
324-
method_table::GPUMethodTableView
321+
method_table_view::MTV
325322

326323
@static if HAS_INTEGRATED_CACHE
327324
token::Any
@@ -365,28 +362,27 @@ end
365362
else
366363

367364
function GPUInterpreter(world::UInt=Base.get_world_counter();
368-
method_table::MTType,
365+
method_table_view::CC.MethodTableView,
369366
code_cache::CodeCache,
370367
inf_params::CC.InferenceParams,
371368
opt_params::CC.OptimizationParams)
372369
@assert world <= Base.get_world_counter()
373370

374-
method_table = get_method_table_view(world, method_table)
375371
inf_cache = Vector{CC.InferenceResult}()
376372

377-
return GPUInterpreter(world, method_table,
373+
return GPUInterpreter(world, method_table_view,
378374
code_cache, inf_cache,
379375
inf_params, opt_params)
380376
end
381377

382378
function GPUInterpreter(interp::GPUInterpreter;
383379
world::UInt=interp.world,
384-
method_table::GPUMethodTableView=interp.method_table,
380+
method_table_view::CC.MethodTableView=interp.method_table_view,
385381
code_cache::CodeCache=interp.code_cache,
386382
inf_cache::Vector{CC.InferenceResult}=interp.inf_cache,
387383
inf_params::CC.InferenceParams=interp.inf_params,
388384
opt_params::CC.OptimizationParams=interp.opt_params)
389-
return GPUInterpreter(world, method_table,
385+
return GPUInterpreter(world, method_table_view,
390386
code_cache, inf_cache,
391387
inf_params, opt_params)
392388
end
@@ -416,7 +412,7 @@ CC.may_discard_trees(interp::GPUInterpreter) = true
416412
@static if VERSION <= v"1.12.0-DEV.1531"
417413
CC.verbose_stmt_info(interp::GPUInterpreter) = false
418414
end
419-
CC.method_table(interp::GPUInterpreter) = interp.method_table
415+
CC.method_table(interp::GPUInterpreter) = interp.method_table_view
420416

421417
# semi-concrete interepretation is broken with overlays (JuliaLang/julia#47349)
422418
function CC.concrete_eval_eligible(interp::GPUInterpreter,

0 commit comments

Comments
 (0)