@@ -421,11 +421,23 @@ end
421
421
# # interpreter
422
422
423
423
using Core. Compiler:
424
- AbstractInterpreter, InferenceResult, InferenceParams, InferenceState, OptimizationParams
424
+ AbstractInterpreter, InferenceResult, InferenceParams, InferenceState,
425
+ OptimizationParams, MethodTableView, CachedMethodTable
426
+
427
+ if isdefined (Base. Experimental, Symbol (" @overlay" ))
428
+ using Core. Compiler: OverlayMethodTable
429
+ const GPUMethodTableView = CachedMethodTable{OverlayMethodTable}
430
+ const MTType = Core. MethodTable
431
+ get_method_table_view (world:: UInt , mt:: MTType ) = CachedMethodTable (OverlayMethodTable (world, mt))
432
+ else
433
+ const GPUMethodTableView = CachedMethodTable{WorldOverlayMethodTable}
434
+ const MTType = Nothing
435
+ get_method_table_view (world:: UInt , mt:: MTType ) = CachedMethodTable (WorldOverlayMethodTable (world))
436
+ end
425
437
426
438
struct GPUInterpreter <: AbstractInterpreter
427
439
global_cache:: CodeCache
428
- method_table:: Union{Nothing,Core.MethodTable}
440
+ method_table:: GPUMethodTableView
429
441
430
442
# Cache of inference results for this particular interpreter
431
443
local_cache:: Vector{InferenceResult}
@@ -436,13 +448,14 @@ struct GPUInterpreter <: AbstractInterpreter
436
448
inf_params:: InferenceParams
437
449
opt_params:: OptimizationParams
438
450
439
-
440
- function GPUInterpreter (cache:: CodeCache , mt:: Union{Nothing,Core.MethodTable} , world:: UInt , ip:: InferenceParams , op:: OptimizationParams )
451
+ function GPUInterpreter (cache:: CodeCache , mt:: MTType , world:: UInt , ip:: InferenceParams , op:: OptimizationParams )
441
452
@assert world <= Base. get_world_counter ()
442
453
454
+ method_table = get_method_table_view (world, mt)
455
+
443
456
return new (
444
457
cache,
445
- mt ,
458
+ method_table ,
446
459
447
460
# Initially empty cache
448
461
Vector {InferenceResult} (),
@@ -478,18 +491,10 @@ if VERSION >= v"1.7.0-DEV.577"
478
491
Core. Compiler. verbose_stmt_info (interp:: GPUInterpreter ) = false
479
492
end
480
493
481
- if isdefined (Base. Experimental, Symbol (" @overlay" ))
482
- using Core. Compiler: OverlayMethodTable
483
494
if v " 1.8-beta2" <= VERSION < v " 1.9-" || VERSION >= v " 1.9.0-DEV.120"
484
- Core. Compiler. method_table (interp:: GPUInterpreter ) =
485
- OverlayMethodTable (interp. world, interp. method_table)
486
- else
487
- Core. Compiler. method_table (interp:: GPUInterpreter , sv:: InferenceState ) =
488
- OverlayMethodTable (interp. world, interp. method_table)
489
- end
495
+ Core. Compiler. method_table (interp:: GPUInterpreter ) = interp. method_table
490
496
else
491
- Core. Compiler. method_table (interp:: GPUInterpreter , sv:: InferenceState ) =
492
- WorldOverlayMethodTable (interp. world)
497
+ Core. Compiler. method_table (interp:: GPUInterpreter , sv:: InferenceState ) = interp. method_table
493
498
end
494
499
495
500
# semi-concrete interepretation is broken with overlays (JuliaLang/julia#47349)
0 commit comments