@@ -187,7 +187,7 @@ function Base.show(io::IO, methinvs::MethodInvalidations)
187
187
sig = root. first
188
188
if isa (sig, MethodInstance)
189
189
# "insert_backedges_callee"/"insert_backedges" (delayed) invalidations
190
- printstyled (io, which (sig. specTypes), color = :light_cyan )
190
+ printstyled (io, try which (sig. specTypes) catch _ " (unavailable) " end , color = :light_cyan )
191
191
print (io, " (formerly " , sig. def, ' )' )
192
192
else
193
193
# `sig` (immediate) invalidations
@@ -290,27 +290,24 @@ function invalidation_trees(list; exclude_corecompiler::Bool=true)
290
290
291
291
function handle_insert_backedges (list, i, callee)
292
292
ncovered = 0
293
+ callees = Any[callee]
293
294
while length (list) >= i+ 2 && list[i+ 2 ] == " insert_backedges_callee"
294
- if isa (callee, Type)
295
- newcallee = list[i+ 1 ]
296
- if isa (newcallee, MethodInstance)
297
- callee = newcallee
298
- end
299
- end
295
+ push! (callees, list[i+ 1 ])
300
296
i += 2
301
297
end
298
+ callers = MethodInstance[]
302
299
while length (list) >= i+ 2 && list[i+ 2 ] == " insert_backedges"
303
- caller = list[i+= 1 ]
304
- i += 1
305
- push! (delayed, callee => caller)
300
+ push! (callers, list[i+ 1 ])
301
+ i += 2
306
302
ncovered += 1
307
303
end
304
+ push! (delayed, callees => callers)
308
305
@assert ncovered > 0
309
306
return i
310
307
end
311
308
312
309
methodinvs = MethodInvalidations[]
313
- delayed = Pair{Any, MethodInstance}[] # from "insert_backedges" invalidations
310
+ delayed = Pair{Vector{ Any},Vector{ MethodInstance} }[] # from "insert_backedges" invalidations
314
311
leaf = nothing
315
312
mt_backedges, backedges, mt_cache, mt_disable = methinv_storage ()
316
313
reason = nothing
@@ -418,20 +415,31 @@ function invalidation_trees(list; exclude_corecompiler::Bool=true)
418
415
end
419
416
end
420
417
end
421
- trouble = similar (delayed, 0 )
422
- for (callee, caller) in delayed
423
- if isa (callee, MethodInstance)
424
- idx = get (callee2idx, callee. def, nothing )
425
- if idx != = nothing
426
- push! (methodinvs[idx]. mt_backedges, callee => caller)
427
- continue
418
+ solved = Int[]
419
+ for (i, (callees, callers)) in enumerate (delayed)
420
+ for callee in callees
421
+ if isa (callee, MethodInstance)
422
+ idx = get (callee2idx, callee. def, nothing )
423
+ if idx != = nothing
424
+ for caller in callers
425
+ push! (methodinvs[idx]. mt_backedges, callee => caller)
426
+ end
427
+ push! (solved, i)
428
+ break
429
+ end
428
430
end
429
431
end
430
- push! (trouble, callee => caller)
431
432
end
432
- if ! isempty (trouble)
433
+ deleteat! (delayed, solved)
434
+ if ! isempty (delayed)
433
435
@warn " Could not attribute the following delayed invalidations:"
434
- display (trouble)
436
+ for (callees, callers) in delayed
437
+ @assert ! isempty (callees) # this shouldn't ever happen
438
+ printstyled (length (callees) == 1 ? callees[1 ] : callees; color = :light_cyan )
439
+ print (" invalidated " )
440
+ printstyled (length (callers) == 1 ? callers[1 ] : callers; color = :light_yellow )
441
+ println ()
442
+ end
435
443
end
436
444
return sort! (methodinvs; by= countchildren)
437
445
end
0 commit comments