Skip to content

Commit

Permalink
Ensure invalidated target gets logged (#49048)
Browse files Browse the repository at this point in the history
To interpret causes of invalidation, it's helpful to understand what
signature got invalidated. #48954 inadvertently dropped this info
from the logging stream; this commit restores it.
  • Loading branch information
timholy authored Mar 20, 2023
1 parent 6337cf6 commit 99fce41
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,11 @@ JL_DLLEXPORT void jl_method_table_insert(jl_methtable_t *mt, jl_method_t *method
}
jl_array_ptr_1d_push(oldmi, (jl_value_t*)mi);
invalidate_external(mi, max_world);
if (_jl_debug_method_invalidation) {
jl_array_ptr_1d_push(_jl_debug_method_invalidation, (jl_value_t*)mi);
loctag = jl_cstr_to_string("jl_method_table_insert");
jl_array_ptr_1d_push(_jl_debug_method_invalidation, loctag);
}
}
}
}
Expand Down
24 changes: 24 additions & 0 deletions test/worlds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,27 @@ wc_aiw2 = get_world_counter()
@test Base.invoke_in_world(wc_aiw2, f_inworld, 2) == "world two; x=2"
@test Base.invoke_in_world(wc_aiw1, g_inworld, 2, y=3) == "world one; x=2, y=3"
@test Base.invoke_in_world(wc_aiw2, g_inworld, 2, y=3) == "world two; x=2, y=3"

# logging
mc48954(x, y) = false
mc48954(x::Int, y::Int) = x == y
mc48954(x::Symbol, y::Symbol) = x == y
function mcc48954(container, y)
x = container[1]
return mc48954(x, y)
end

mcc48954(Any[1], 1)
mc48954i = method_instance(mc48954, (Any, Int))
mcc48954i = method_instance(mcc48954, (Vector{Any}, Int))
list48954 = ccall(:jl_debug_method_invalidation, Any, (Cint,), 1)
mc48954(x::AbstractFloat, y::Int) = x == y
ccall(:jl_debug_method_invalidation, Any, (Cint,), 0)
@test list48954 == [
mcc48954i,
1,
mc48954i,
"jl_method_table_insert",
which(mc48954, (AbstractFloat, Int)),
"jl_method_table_insert"
]

0 comments on commit 99fce41

Please sign in to comment.