@@ -461,6 +461,7 @@ void *native_functions; // opaque jl_native_code_desc_t blob used for fetching
461461
462462// table of struct field addresses to rewrite during saving
463463static htable_t field_replace ;
464+ static htable_t relocatable_ext_cis ;
464465
465466// array of definitions for the predefined function pointers
466467// (reverse of fptr_to_id)
@@ -693,7 +694,8 @@ static int needs_uniquing(jl_value_t *v) JL_NOTSAFEPOINT
693694
694695static void record_field_change (jl_value_t * * addr , jl_value_t * newval ) JL_NOTSAFEPOINT
695696{
696- ptrhash_put (& field_replace , (void * )addr , newval );
697+ if (* addr != newval )
698+ ptrhash_put (& field_replace , (void * )addr , newval );
697699}
698700
699701static jl_value_t * get_replaceable_field (jl_value_t * * addr , int mutabl ) JL_GC_DISABLED
@@ -836,6 +838,8 @@ static void jl_insert_into_serialization_queue(jl_serializer_state *s, jl_value_
836838 // TODO: if (ci in ci->defs->cache)
837839 record_field_change ((jl_value_t * * )& ci -> next , NULL );
838840 }
841+ if (jl_atomic_load_relaxed (& ci -> inferred ) && !is_relocatable_ci (& relocatable_ext_cis , ci ))
842+ record_field_change ((jl_value_t * * )& ci -> inferred , jl_nothing );
839843 }
840844
841845 if (immediate ) // must be things that can be recursively handled, and valid as type parameters
@@ -1631,6 +1635,7 @@ static void jl_write_values(jl_serializer_state *s) JL_GC_DISABLED
16311635 jl_atomic_store_release (& newci -> min_world , 1 );
16321636 jl_atomic_store_release (& newci -> max_world , 0 );
16331637 }
1638+ newci -> relocatability = 0 ;
16341639 }
16351640 jl_atomic_store_relaxed (& newci -> invoke , NULL );
16361641 jl_atomic_store_relaxed (& newci -> specsigflags , 0 );
@@ -2573,7 +2578,7 @@ static void jl_prepare_serialization_data(jl_array_t *mod_array, jl_array_t *new
25732578 * edges = jl_alloc_vec_any (0 );
25742579 * method_roots_list = jl_alloc_vec_any (0 );
25752580 // Collect the new method roots for external specializations
2576- jl_collect_new_roots (* method_roots_list , * new_ext_cis , worklist_key );
2581+ jl_collect_new_roots (& relocatable_ext_cis , * method_roots_list , * new_ext_cis , worklist_key );
25772582 jl_collect_edges (* edges , * ext_targets , * new_ext_cis , world );
25782583 }
25792584 assert (edges_map == NULL ); // jl_collect_edges clears this when done
@@ -2974,6 +2979,7 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
29742979 assert ((ct -> reentrant_timing & 0b1110 ) == 0 );
29752980 ct -> reentrant_timing |= 0b1000 ;
29762981 if (worklist ) {
2982+ htable_new (& relocatable_ext_cis , 0 );
29772983 jl_prepare_serialization_data (mod_array , newly_inferred , jl_worklist_key (worklist ),
29782984 & extext_methods , & new_ext_cis , & method_roots_list , & ext_targets , & edges );
29792985 if (!emit_split ) {
@@ -2990,6 +2996,8 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
29902996 jl_save_system_image_to_stream (ff , mod_array , worklist , extext_methods , new_ext_cis , method_roots_list , ext_targets , edges );
29912997 if (_native_data != NULL )
29922998 native_functions = NULL ;
2999+ if (worklist )
3000+ htable_free (& relocatable_ext_cis );
29933001 // make sure we don't run any Julia code concurrently before this point
29943002 // Re-enable running julia code for postoutput hooks, atexit, etc.
29953003 jl_gc_enable_finalizers (ct , 1 );
0 commit comments