@@ -63,8 +63,8 @@ mutable struct InstanceNode
6363 end
6464 InstanceNode (mi:: MethodInstance , children:: Vector{InstanceNode} ) = return new (mi, 0 , children)
6565 # Create child with a given `parent`. Checks that the depths are consistent.
66- function InstanceNode (mi:: MethodInstance , parent:: InstanceNode , depth)
67- @assert parent. depth + Int32 (1 ) == depth
66+ function InstanceNode (mi:: MethodInstance , parent:: InstanceNode , depth= parent . depth + Int32 ( 1 ) )
67+ depth != = nothing && @assert parent. depth + Int32 (1 ) == depth
6868 child = new (mi, depth, InstanceNode[], parent)
6969 push! (parent. children, child)
7070 return child
@@ -249,6 +249,12 @@ function showlist(io::IO, treelist, indent::Int=0)
249249 end
250250end
251251
252+ if Base. VERSION >= v " 1.9.0-DEV.1512"
253+ new_backedge_table () = Dict{Union{Int32,MethodInstance},Union{Tuple{Any,Vector{Any}},InstanceNode}}()
254+ else
255+ new_backedge_table () = Dict {Tuple{Int32,UInt64},Tuple{Any,Vector{Any}}} ()
256+ end
257+
252258"""
253259 trees = invalidation_trees(list)
254260
@@ -288,6 +294,11 @@ See the documentation for further details.
288294function invalidation_trees (list; exclude_corecompiler:: Bool = true )
289295
290296 function handle_insert_backedges (list, i, callee)
297+ if Base. VERSION >= v " 1.9.0-DEV.1512"
298+ key, causes = list[i+= 1 ], list[i+= 1 ]
299+ backedge_table[key] = (callee, causes)
300+ return i
301+ end
291302 if Base. VERSION >= v " 1.9.0-DEV.1432"
292303 key = (list[i+= 1 ], list[i+= 1 ])
293304 backedge_table[key] = (callee, list[i+= 1 ])
@@ -316,7 +327,7 @@ function invalidation_trees(list; exclude_corecompiler::Bool=true)
316327 leaf = nothing
317328 mt_backedges, backedges, mt_cache, mt_disable = methinv_storage ()
318329 reason = nothing
319- backedge_table = Dict {Tuple{Int32,UInt64},Tuple{Any,Vector{Any}}} ()
330+ backedge_table = new_backedge_table ()
320331 i = 0
321332 while i < length (list)
322333 item = list[i+= 1 ]
@@ -337,6 +348,9 @@ function invalidation_trees(list; exclude_corecompiler::Bool=true)
337348 end
338349 elseif isa (item, String)
339350 loctag = item
351+ if Base. VERSION >= v " 1.9.0-DEV.1512" && loctag ∉ (" insert_backedges_callee" , " verify_methods" )
352+ empty! (backedge_table)
353+ end
340354 if loctag == " invalidate_mt_cache"
341355 push! (mt_cache, mi)
342356 leaf = nothing
@@ -371,6 +385,36 @@ function invalidation_trees(list; exclude_corecompiler::Bool=true)
371385 end
372386 elseif loctag == " insert_backedges_callee"
373387 i = handle_insert_backedges (list, i, mi)
388+ elseif loctag == " verify_methods"
389+ next = list[i+= 1 ]
390+ if isa (next, Integer)
391+ trig, causes = backedge_table[next]
392+ newnode = InstanceNode (mi, 1 )
393+ push! (mt_backedges, trig => newnode)
394+ backedge_table[mi] = newnode
395+ for cause in causes
396+ add_method_trigger! (methodinvs, cause, :inserting , mt_backedges, backedges, mt_cache, mt_disable)
397+ end
398+ mt_backedges, backedges, mt_cache, mt_disable = methinv_storage ()
399+ leaf = nothing
400+ reason = nothing
401+ else
402+ @assert isa (next, MethodInstance) " unexpected logging format"
403+ parent = backedge_table[next]
404+ found = false
405+ for child in parent. children
406+ if child. mi == mi
407+ found = true
408+ break
409+ end
410+ end
411+ if ! found
412+ newnode = InstanceNode (mi, parent)
413+ if ! haskey (backedge_table, mi)
414+ backedge_table[mi] = newnode
415+ end
416+ end
417+ end
374418 elseif loctag == " insert_backedges"
375419 if Base. VERSION >= v " 1.9.0-DEV.1432"
376420 key = (list[i+= 1 ], list[i+= 1 ])
0 commit comments