@@ -503,25 +503,42 @@ end # HAS_INTEGRATED_CACHE
503
503
# # codegen/inference integration
504
504
505
505
function ci_cache_populate (interp, cache, mi, min_world, max_world)
506
- src = CC. typeinf_ext_toplevel (interp, mi)
507
-
508
- # inference populates the cache, so we don't need to jl_get_method_inferred
509
- wvc = WorldView (cache, min_world, max_world)
510
- @assert CC. haskey (wvc, mi)
511
-
512
- # if src is rettyp_const, the codeinfo won't cache ci.inferred
513
- # (because it is normally not supposed to be used ever again).
514
- # to avoid the need to re-infer, set that field here.
515
- ci = CC. getindex (wvc, mi)
516
- if ci != = nothing && ci. inferred === nothing
517
- @static if VERSION >= v " 1.9.0-DEV.1115"
518
- @atomic ci. inferred = src
519
- else
520
- ci. inferred = src
506
+ if VERSION >= v " 1.12.0-DEV.15"
507
+ inferred_ci = CC. typeinf_ext_toplevel (interp, mi, CC. SOURCE_MODE_FORCE_SOURCE) # or SOURCE_MODE_FORCE_SOURCE_UNCACHED?
508
+
509
+ # inference should have populated our cache
510
+ wvc = WorldView (cache, min_world, max_world)
511
+ @assert CC. haskey (wvc, mi)
512
+ ci = CC. getindex (wvc, mi)
513
+
514
+ # if ci is rettype_const, the inference result won't have been cached
515
+ # (because it is normally not supposed to be used ever again).
516
+ # to avoid the need to re-infer, set that field here.
517
+ if ci. inferred === nothing
518
+ CC. setindex! (wvc, inferred_ci, mi)
519
+ ci = CC. getindex (wvc, mi)
520
+ end
521
+ else
522
+ src = CC. typeinf_ext_toplevel (interp, mi)
523
+
524
+ # inference should have populated our cache
525
+ wvc = WorldView (cache, min_world, max_world)
526
+ @assert CC. haskey (wvc, mi)
527
+ ci = CC. getindex (wvc, mi)
528
+
529
+ # if ci is rettype_const, the inference result won't have been cached
530
+ # (because it is normally not supposed to be used ever again).
531
+ # to avoid the need to re-infer, set that field here.
532
+ if ci. inferred === nothing
533
+ @static if VERSION >= v " 1.9.0-DEV.1115"
534
+ @atomic ci. inferred = src
535
+ else
536
+ ci. inferred = src
537
+ end
521
538
end
522
539
end
523
540
524
- return ci
541
+ return ci:: CodeInstance
525
542
end
526
543
527
544
function ci_cache_lookup (cache, mi, min_world, max_world)
0 commit comments