Skip to content

Commit

Permalink
Ensure accurate invalidation logging data
Browse files Browse the repository at this point in the history
This modifies #48841 to restore the required logging data.  When
logging is on, it recalculates the method-match as needed, casting a
wider net to ensure that we identify the trigger of the invalidation.
  • Loading branch information
timholy committed Mar 12, 2023
1 parent 441c570 commit 09ac725
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/staticdata_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,7 @@ static jl_array_t *jl_verify_edges(jl_array_t *targets, size_t minworld)
jl_value_t *expected = jl_array_ptr_ref(targets, i * 3 + 2);
size_t min_valid = 0;
size_t max_valid = ~(size_t)0;
jl_value_t *sig = NULL;
if (invokesig) {
assert(callee && "unsupported edge");
jl_methtable_t *mt = jl_method_get_table(((jl_method_instance_t*)callee)->def.method);
Expand All @@ -861,7 +862,6 @@ static jl_array_t *jl_verify_edges(jl_array_t *targets, size_t minworld)
}
}
else {
jl_value_t *sig;
if (jl_is_method_instance(callee))
sig = ((jl_method_instance_t*)callee)->specTypes;
else
Expand Down Expand Up @@ -907,6 +907,12 @@ static jl_array_t *jl_verify_edges(jl_array_t *targets, size_t minworld)
jl_array_ptr_1d_push(_jl_debug_method_invalidation, loctag);
loctag = jl_box_int32((int32_t)i);
jl_array_ptr_1d_push(_jl_debug_method_invalidation, loctag);
if (matches == jl_nothing) {
assert(sig);
int ambig = 0;
matches = jl_matching_methods((jl_tupletype_t*)sig, jl_nothing,
-1, 0, minworld, &min_valid, &max_valid, &ambig);
}
jl_array_ptr_1d_push(_jl_debug_method_invalidation, matches);
}
//jl_static_show((JL_STREAM*)ios_stderr, (jl_value_t*)invokesig);
Expand Down
4 changes: 2 additions & 2 deletions test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ precompile_test_harness("code caching") do dir
mi = m.specializations[1]
@test hasvalid(mi, world) # was compiled with the new method

# Reporting test
# Reporting test (ensure SnoopCompile works)
@test all(i -> isassigned(invalidations, i), eachindex(invalidations))
m = only(methods(MB.call_nbits))
for mi in m.specializations
Expand All @@ -936,7 +936,7 @@ precompile_test_harness("code caching") do dir
j = findfirst(==(tagbad), invalidations)
@test invalidations[j-1] == "insert_backedges_callee"
@test isa(invalidations[j-2], Type)
@test invalidations[j+1] === nothing || isa(invalidations[j+1], Vector{Any}) # [nbits(::UInt8)]
@test isa(invalidations[j+1], Vector{Any}) # [nbits(::UInt8)]

m = only(methods(MB.map_nbits))
@test !hasvalid(m.specializations[1], world+1) # insert_backedges invalidations also trigger their backedges
Expand Down

0 comments on commit 09ac725

Please sign in to comment.