Skip to content

Commit 4c32381

Browse files
authored
generalize insert-backedges to insert in any world (#48785)
Rather than a binary valid/not-valid, we track the exact later world that deleted it, relative to when we first assumed it may be valid.
1 parent eb8bb4e commit 4c32381

File tree

2 files changed

+133
-123
lines changed

2 files changed

+133
-123
lines changed

src/staticdata.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,7 @@ static void jl_prepare_serialization_data(jl_array_t *mod_array, jl_array_t *new
22442244
}
22452245

22462246
if (edges) {
2247+
size_t world = jl_atomic_load_acquire(&jl_world_counter);
22472248
jl_collect_missing_backedges(jl_type_type_mt);
22482249
jl_collect_missing_backedges(jl_nonfunction_mt);
22492250
// jl_collect_extext_methods_from_mod and jl_collect_missing_backedges also accumulate data in callers_with_edges.
@@ -2253,7 +2254,7 @@ static void jl_prepare_serialization_data(jl_array_t *mod_array, jl_array_t *new
22532254
*method_roots_list = jl_alloc_vec_any(0);
22542255
// Collect the new method roots
22552256
jl_collect_new_roots(*method_roots_list, *new_specializations, worklist_key);
2256-
jl_collect_edges(*edges, *ext_targets, *new_specializations);
2257+
jl_collect_edges(*edges, *ext_targets, *new_specializations, world);
22572258
}
22582259
assert(edges_map == NULL); // jl_collect_edges clears this when done
22592260

@@ -3271,7 +3272,8 @@ static jl_value_t *jl_restore_package_image_from_stream(ios_t *f, jl_image_t *im
32713272
// Add roots to methods
32723273
jl_copy_roots(method_roots_list, jl_worklist_key((jl_array_t*)restored));
32733274
// Handle edges
3274-
jl_insert_backedges((jl_array_t*)edges, (jl_array_t*)ext_targets, (jl_array_t*)new_specializations); // restore external backedges (needs to be last)
3275+
size_t world = jl_atomic_load_acquire(&jl_world_counter);
3276+
jl_insert_backedges((jl_array_t*)edges, (jl_array_t*)ext_targets, (jl_array_t*)new_specializations, world); // restore external backedges (needs to be last)
32753277
// reinit ccallables
32763278
jl_reinit_ccallable(&ccallable_list, base, NULL);
32773279
arraylist_free(&ccallable_list);

0 commit comments

Comments
 (0)