@@ -433,6 +433,7 @@ void *native_functions; // opaque jl_native_code_desc_t blob used for fetching
433433
434434// table of struct field addresses to rewrite during saving
435435static htable_t field_replace ;
436+ static htable_t relocatable_ext_cis ;
436437
437438// array of definitions for the predefined function pointers
438439// (reverse of fptr_to_id)
@@ -656,7 +657,8 @@ static int needs_uniquing(jl_value_t *v) JL_NOTSAFEPOINT
656657
657658static void record_field_change (jl_value_t * * addr , jl_value_t * newval ) JL_NOTSAFEPOINT
658659{
659- ptrhash_put (& field_replace , (void * )addr , newval );
660+ if (* addr != newval )
661+ ptrhash_put (& field_replace , (void * )addr , newval );
660662}
661663
662664static jl_value_t * get_replaceable_field (jl_value_t * * addr , int mutabl ) JL_GC_DISABLED
@@ -797,6 +799,8 @@ static void jl_insert_into_serialization_queue(jl_serializer_state *s, jl_value_
797799 // TODO: if (ci in ci->defs->cache)
798800 record_field_change ((jl_value_t * * )& ci -> next , NULL );
799801 }
802+ if (jl_atomic_load_relaxed (& ci -> inferred ) && !is_relocatable_ci (& relocatable_ext_cis , ci ))
803+ record_field_change ((jl_value_t * * )& ci -> inferred , jl_nothing );
800804 }
801805
802806 if (immediate ) // must be things that can be recursively handled, and valid as type parameters
@@ -1505,6 +1509,7 @@ static void jl_write_values(jl_serializer_state *s) JL_GC_DISABLED
15051509 // will check on deserialize if this cache entry is still valid
15061510 }
15071511 }
1512+ newm -> relocatability = 0 ;
15081513 }
15091514
15101515 newm -> invoke = NULL ;
@@ -2384,7 +2389,7 @@ static void jl_prepare_serialization_data(jl_array_t *mod_array, jl_array_t *new
23842389 * edges = jl_alloc_vec_any (0 );
23852390 * method_roots_list = jl_alloc_vec_any (0 );
23862391 // Collect the new method roots
2387- jl_collect_new_roots (* method_roots_list , * new_specializations , worklist_key );
2392+ jl_collect_new_roots (& relocatable_ext_cis , * method_roots_list , * new_specializations , worklist_key );
23882393 jl_collect_edges (* edges , * ext_targets , * new_specializations , world );
23892394 }
23902395 assert (edges_map == NULL ); // jl_collect_edges clears this when done
@@ -2770,6 +2775,7 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
27702775 assert ((ct -> reentrant_timing & 0b1110 ) == 0 );
27712776 ct -> reentrant_timing |= 0b1000 ;
27722777 if (worklist ) {
2778+ htable_new (& relocatable_ext_cis , 0 );
27732779 jl_prepare_serialization_data (mod_array , newly_inferred , jl_worklist_key (worklist ),
27742780 & extext_methods , & new_specializations , & method_roots_list , & ext_targets , & edges );
27752781 if (!emit_split ) {
@@ -2786,6 +2792,8 @@ JL_DLLEXPORT void jl_create_system_image(void **_native_data, jl_array_t *workli
27862792 jl_save_system_image_to_stream (ff , mod_array , worklist , extext_methods , new_specializations , method_roots_list , ext_targets , edges );
27872793 if (_native_data != NULL )
27882794 native_functions = NULL ;
2795+ if (worklist )
2796+ htable_free (& relocatable_ext_cis );
27892797 // make sure we don't run any Julia code concurrently before this point
27902798 // Re-enable running julia code for postoutput hooks, atexit, etc.
27912799 jl_gc_enable_finalizers (ct , 1 );
0 commit comments