Skip to content

Commit

Permalink
Add missing entry to invalidation log (#49449)
Browse files Browse the repository at this point in the history
* Add missing entry to invalidation log

Addresses timholy/SnoopCompile.jl#357 (comment)
using the observation in the following comment.

Co-authored-by: Jameson Nash <vtjnash@gmail.com>

* Fix indentation

---------

Co-authored-by: Jameson Nash <vtjnash@gmail.com>
  • Loading branch information
timholy and vtjnash authored Apr 21, 2023
1 parent bb83df1 commit 23a5b04
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
20 changes: 10 additions & 10 deletions src/staticdata_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1022,18 +1022,18 @@ static int jl_verify_graph_edge(size_t *maxvalids2_data, jl_array_t *edges, size
if (idx != childidx) {
if (max_valid < maxvalids2_data[childidx])
maxvalids2_data[childidx] = max_valid;
if (_jl_debug_method_invalidation && max_valid != ~(size_t)0) {
jl_method_instance_t *mi = (jl_method_instance_t*)jl_array_ptr_ref(edges, childidx * 2);
jl_value_t *loctag = NULL;
JL_GC_PUSH1(&loctag);
jl_array_ptr_1d_push(_jl_debug_method_invalidation, (jl_value_t*)mi);
loctag = jl_cstr_to_string("verify_methods");
jl_array_ptr_1d_push(_jl_debug_method_invalidation, loctag);
jl_array_ptr_1d_push(_jl_debug_method_invalidation, (jl_value_t*)cause);
JL_GC_POP();
}
}
visited->items[childidx] = (void*)1;
if (_jl_debug_method_invalidation && max_valid != ~(size_t)0) {
jl_method_instance_t *mi = (jl_method_instance_t*)jl_array_ptr_ref(edges, childidx * 2);
jl_value_t *loctag = NULL;
JL_GC_PUSH1(&loctag);
jl_array_ptr_1d_push(_jl_debug_method_invalidation, (jl_value_t*)mi);
loctag = jl_cstr_to_string("verify_methods");
jl_array_ptr_1d_push(_jl_debug_method_invalidation, loctag);
jl_array_ptr_1d_push(_jl_debug_method_invalidation, (jl_value_t*)cause);
JL_GC_POP();
}
}
return 0;
}
Expand Down
10 changes: 9 additions & 1 deletion test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -857,9 +857,13 @@ precompile_test_harness("code caching") do dir
# This will be invalidated if StaleC is loaded
useA() = $StaleA.stale("hello")
useA2() = useA()
# force precompilation
useA()
begin
Base.Experimental.@force_compile
useA2()
end
## Reporting tests
call_nbits(x::Integer) = $StaleA.nbits(x)
Expand Down Expand Up @@ -940,6 +944,10 @@ precompile_test_harness("code caching") do dir
@test invalidations[j-1] == "insert_backedges_callee"
@test isa(invalidations[j-2], Type)
@test isa(invalidations[j+1], Vector{Any}) # [nbits(::UInt8)]
m = only(methods(MB.useA2))
mi = only(Base.specializations(m))
@test !hasvalid(mi, world)
@test mi invalidations

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

0 comments on commit 23a5b04

Please sign in to comment.