Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/invalidations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -616,14 +616,14 @@ function invalidation_trees(list::InvalidationLists; consolidate::Bool=true, kwa
if etree.reason === :deleting
@assert isempty(etree.backedges) # should not have any backedges
# Determine whether any of the deleted methods cover this
covered = false
for (edge, node) in etree.mt_backedges
covered = false
for mtree in mtrees
mtree.reason === :deleting || continue
isnothing(mtree.method) && continue
mtree.method.sig <: edge || continue
# This edge is covered by the deleted method
join_invalidations!(mtree.mt_backedges, edge => node)
join_invalidations!(mtree.mt_backedges, BackedgeMT[edge => node])
covered = true
end
covered && continue
Expand Down Expand Up @@ -785,8 +785,9 @@ function join_invalidations!(list::AbstractVector{<:Pair}, items::AbstractVector
key2 == key || continue
mi2 = root2.mi
if mi2 == mi
# Find the first branch that isn't shared
join_branches!(node, root2)
# Merge into the node already in `list`, which is the one that is kept
# (issue #364)
join_branches!(root2, node)
found = true
break
end
Expand Down
21 changes: 21 additions & 0 deletions test/snoop_invalidations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,27 @@ end
Pkg.activate(cproj)
end

@testset "Merging mt_backedges" begin
# issue #364: when two invalidation trees share a signature and root
# MethodInstance, the merged tree must retain the callers of both.
c = Any[1]
SnooprTests.callapplyf(c)
SnooprTests.mccc1(c, 1)
root = methodinstance(SnooprTests.applyf, (Vector{Any},))
childa = methodinstance(SnooprTests.callapplyf, (Vector{Any},))
childb = methodinstance(SnooprTests.mccc1, (Vector{Any}, Int))
sig = Tuple{typeof(SnooprTests.f), Any}
function mt_backedge(childmi)
rootnode = SnoopCompile.InstanceNode(root, 0)
SnoopCompile.InstanceNode(childmi, rootnode)
return SnoopCompile.BackedgeMT[sig => rootnode]
end
list = mt_backedge(childa)
SnoopCompile.join_invalidations!(list, mt_backedge(childb))
_, merged = only(list)
@test Set(child.mi for child in merged.children) == Set((childa, childb))
end

@testset "Unknown-tree attribution via logmeths cross-reference" begin
# When a package is loaded and its precompiled CIs are already C-level invalid
# (max_world=0), verify_method returns early without emitting an
Expand Down
Loading