Skip to content

Commit 9d454dc

Browse files
timholyKristofferC
authored andcommitted
Ensure completion of invalidation log (#58137)
(cherry picked from commit caa97c9)
1 parent d3a569d commit 9d454dc

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/gf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,13 +2445,14 @@ void jl_method_table_activate(jl_methtable_t *mt, jl_typemap_entry_t *newentry)
24452445
// found that this specialization dispatch got replaced by m
24462446
// call invalidate_backedges(mi, max_world, "jl_method_table_insert");
24472447
// but ignore invoke-type edges
2448-
invalidated = _invalidate_dispatch_backedges(mi, type, m, d, n, replaced_dispatch, ambig, max_world, morespec);
2448+
int invalidatedmi = _invalidate_dispatch_backedges(mi, type, m, d, n, replaced_dispatch, ambig, max_world, morespec);
24492449
jl_array_ptr_1d_push(oldmi, (jl_value_t*)mi);
2450-
if (_jl_debug_method_invalidation && invalidated) {
2450+
if (_jl_debug_method_invalidation && invalidatedmi) {
24512451
jl_array_ptr_1d_push(_jl_debug_method_invalidation, (jl_value_t*)mi);
24522452
loctag = jl_cstr_to_string("jl_method_table_insert");
24532453
jl_array_ptr_1d_push(_jl_debug_method_invalidation, loctag);
24542454
}
2455+
invalidated |= invalidatedmi;
24552456
}
24562457
}
24572458
}

test/worlds.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,27 @@ ccall(:jl_debug_method_invalidation, Any, (Cint,), 0)
420420
"jl_method_table_insert"
421421
]
422422

423+
# logging issue #58080
424+
f58080(::Integer) = 1
425+
callsf58080rts(x) = f58080(Base.inferencebarrier(x)::Signed)
426+
invokesf58080s(x) = invoke(f58080, Tuple{Signed}, x)
427+
# compilation
428+
invokesf58080s(1) # invoked callee
429+
callsf58080rts(1) # runtime-dispatched callee
430+
# invalidation
431+
logmeths = ccall(:jl_debug_method_invalidation, Any, (Cint,), 1);
432+
f58080(::Int) = 2
433+
f58080(::Signed) = 4
434+
ccall(:jl_debug_method_invalidation, Any, (Cint,), 0);
435+
@test logmeths[1].def.name === :callsf58080rts
436+
m58080i = which(f58080, (Int,))
437+
m58080s = which(f58080, (Signed,))
438+
idxi = findfirst(==(m58080i), logmeths)
439+
@test logmeths[idxi+1] == "jl_method_table_insert"
440+
@test logmeths[idxi+2].def.name === :invokesf58080s
441+
@test logmeths[end-1] == m58080s
442+
@test logmeths[end] == "jl_method_table_insert"
443+
423444
# issue #50091 -- missing invoke edge affecting nospecialized dispatch
424445
module ExceptionUnwrapping
425446
@nospecialize

0 commit comments

Comments
 (0)